diff --git a/README.md b/README.md index b1862ab2905fb038479705924665891601ad6c34..7ef85618861d9420c2b04bb53d812f7c9b3d1374 100755 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ export default { console.info("Succeeded in triggering vibration."); }); // Step 3 Stop vibration that is triggered with a specific duration. - vibrate.stop(vibrate.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function(error) { + vibrate.stop("time", function(error) { if (error) { console.error("Failed to stop vibration. Error code: " + error.code + "; message: " + error.message); return; @@ -147,7 +147,7 @@ export default { console.info("Succeeded in stopping vibration."); }); // Step 4 Trigger vibration based on with a specific effect. - vibrate.vibrate(vibrate.EffectId.EFFECT_CLOCK_TIMER, function(error) { + vibrate.vibrate("haptic.clock.timer", function(error) { if (error) { console.error("Failed to trigger vibration. Error code: " + error.code + "; message: " + error.message); return; @@ -155,7 +155,7 @@ export default { console.info("Succeeded in triggering vibration."); }); // Step 54 Stop vibration that is triggered with a specific effect. - vibrate.stop(vibrate.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error) { + vibrate.stop("preset", function(error) { if (error) { console.error("Failed to stop vibration. Error code: " + error.code + "; message: " + error.message); return; diff --git a/README_zh.md b/README_zh.md index a8d172d3fd4f9ac96d3b6e3cb4fa537fdb6bac67..9053661e4c37a99737666fafc37fd5686d801d07 100755 --- a/README_zh.md +++ b/README_zh.md @@ -139,7 +139,7 @@ export default { console.info("Succeeded in triggering vibration."); }); //步骤3 停止马达按照指定持续的时间振动 - vibrate.stop(vibrate.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function(error) { + vibrate.stop("time", function(error) { if (error) { console.error("Failed to stop vibration. Error code: " + error.code + "; message: " + error.message); return; @@ -147,7 +147,7 @@ export default { console.info("Succeeded in stopping vibration."); }); //步骤4 触发马达按照指定的字符串效果振动 - vibrate.vibrate(vibrate.EffectId.EFFECT_CLOCK_TIMER, function(error) { + vibrate.vibrate("haptic.clock.timer", function(error) { if (error) { console.error("Failed to trigger vibration. Error code: " + error.code + "; message: " + error.message); return; @@ -155,7 +155,7 @@ export default { console.info("Succeeded in triggering vibration."); }); //步骤5 停止马达按照指定的字符串效果振动 - vibrate.stop(vibrate.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error) { + vibrate.stop("preset", function(error) { if (error) { console.error("Failed to stop vibration. Error code: " + error.code + "; message: " + error.message); return; diff --git a/interfaces/plugin/vibrate/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/vibrate/test/unittest/ExampleJsunit.test.js index 3234acad887758e8a1150015933141245bfce9e2..0b05cda392d898806776ee1141e108fade4d6e07 100755 --- a/interfaces/plugin/vibrate/test/unittest/ExampleJsunit.test.js +++ b/interfaces/plugin/vibrate/test/unittest/ExampleJsunit.test.js @@ -60,7 +60,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest001 vibrator success'); expect(true).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate(10, vibrateCallback); }) @@ -80,7 +82,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest002 vibrator error'); expect(false).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate(-1, vibrateCallback); }) @@ -100,9 +104,11 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest003 vibrator error'); expect(false).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } - vibrator.vibrate(1000000000000, vibrateCallback); + vibrator.vibrate(1800000 + 1, vibrateCallback); }) /* @@ -120,7 +126,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest004 vibrator success'); expect(true).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate(1800000, vibrateCallback); }) @@ -140,7 +148,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest005 vibrator error'); expect(false).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate("", vibrateCallback); }) @@ -160,7 +170,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest006 vibrator error'); expect(false).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate("xxx", vibrateCallback); }) @@ -180,7 +192,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest007 vibrator success'); expect(true).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.vibrate("haptic.clock.timer", vibrateCallback); }) @@ -200,7 +214,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest008 stop success'); expect(true).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.stop("preset", vibrateCallback); }) @@ -219,11 +235,15 @@ describe("VibratorJsTest", function () { if (error) { console.info('VibratorJsTest009 stop error'); expect(false).assertTrue(); - reject(); + setTimeout(()=>{ + reject(); + }, 500); } else { console.info('VibratorJsTest009 stop success'); expect(true).assertTrue(); - resolve(); + setTimeout(()=>{ + resolve(); + }, 500); } }); }) @@ -234,11 +254,15 @@ describe("VibratorJsTest", function () { if (error) { console.info('VibratorJsTest009 vibrate error'); expect(false).assertTrue(); - reject(); + setTimeout(()=>{ + reject(); + }, 500); } else { console.info('VibratorJsTest009 vibrate success'); expect(true).assertTrue(); - resolve(); + setTimeout(()=>{ + resolve(); + }, 500); } }); }) @@ -266,7 +290,9 @@ describe("VibratorJsTest", function () { console.info('VibratorJsTest010 stop off'); expect(false).assertTrue(); } - done(); + setTimeout(()=>{ + done(); + }, 500); } vibrator.stop("", vibrateCallback); }) @@ -281,11 +307,15 @@ describe("VibratorJsTest", function () { vibrator.vibrate(1000).then(() => { console.log("VibratorJsTest011 vibrate success"); expect(true).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(false).assertTrue(); console.log("VibratorJsTest011 vibrate error"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -299,11 +329,15 @@ describe("VibratorJsTest", function () { vibrator.vibrate(-1).then(() => { console.log("VibratorJsTest012 vibrate error"); expect(false).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(true).assertTrue(); console.log("VibratorJsTest012 vibrate success"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -314,14 +348,18 @@ describe("VibratorJsTest", function () { * @tc.require: Issue Number */ it("VibratorJsTest013", 0, async function (done) { - vibrator.vibrate(1000000000000000).then(() => { + vibrator.vibrate(1800000 + 1).then(() => { console.log("VibratorJsTest013 vibrate error"); expect(false).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(true).assertTrue(); console.log("VibratorJsTest013 vibrate success"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -335,11 +373,15 @@ describe("VibratorJsTest", function () { vibrator.vibrate("haptic.clock.timer").then(() => { console.log("VibratorJsTest014 vibrate success"); expect(true).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(false).assertTrue(); console.log("VibratorJsTest014 vibrate error"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -353,11 +395,15 @@ describe("VibratorJsTest", function () { vibrator.vibrate("").then(() => { console.log("VibratorJsTest015 vibrate error"); expect(false).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(true).assertTrue(); console.log("VibratorJsTest015 vibrate success"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -371,11 +417,15 @@ describe("VibratorJsTest", function () { vibrator.stop("").then(() => { console.log("VibratorJsTest016 stop error"); expect(false).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(true).assertTrue(); console.log("VibratorJsTest016 stop success"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -389,11 +439,15 @@ describe("VibratorJsTest", function () { vibrator.stop("preset").then(() => { console.log("VibratorJsTest017 off success"); expect(true).assertTrue(); - done(); + setTimeout(()=>{ + done(); + }, 500); }, (error)=>{ expect(false).assertTrue(); console.log("VibratorJsTest017 off error"); - done(); + setTimeout(()=>{ + done(); + }, 500); }); }) @@ -409,11 +463,15 @@ describe("VibratorJsTest", function () { vibrator.stop("time").then(() => { console.log("VibratorJsTest018 stop success"); expect(true).assertTrue(); - resolve(); + setTimeout(()=>{ + resolve(); + }, 500); }, (error)=>{ expect(false).assertTrue(); console.log("VibratorJsTest018 stop error"); - reject(); + setTimeout(()=>{ + reject(); + }, 500); }); }) } @@ -422,11 +480,15 @@ describe("VibratorJsTest", function () { vibrator.vibrate(180000).then(() => { console.log("VibratorJsTest018 vibrate success"); expect(true).assertTrue(); - resolve(); + setTimeout(()=>{ + resolve(); + }, 500); }, (error)=>{ expect(false).assertTrue(); console.log("VibratorJsTest018 vibrate error"); - reject(); + setTimeout(()=>{ + reject(); + }, 500); }); })