diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_new.test.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_new.test.js index a6610c3b19b63a2794b72126c9cec5ef1ac5015e..703dc8b9e08649419f4b90602079f9406cc64c3f 100644 --- a/sensors/miscdevice_standard/src/main/js/test/Vibrator_new.test.js +++ b/sensors/miscdevice_standard/src/main/js/test/Vibrator_new.test.js @@ -48,6 +48,9 @@ describe("VibratorJsTest_misc_4", function () { * @tc.teardown: teardown invoked after each testcases */ console.info('afterEach caled') + vibrator.stop("preset"); + vibrator.stop("time"); + console.info('afterEach called') }) const OPERATION_FAIL_CODE = 14600101; @@ -214,10 +217,10 @@ describe("VibratorJsTest_misc_4", function () { function vibrateCallback(error) { if (error) { console.info('VibratorJsTest008 stop error'); - expect(false).assertTrue(); + expect(true).assertTrue(); } else { console.info('VibratorJsTest008 stop success'); - expect(true).assertTrue(); + expect(false).assertTrue(); } setTimeout(() => { done(); @@ -399,12 +402,12 @@ describe("VibratorJsTest_misc_4", function () { it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { vibrator.stop("preset").then(() => { console.log("VibratorJsTest015 off success"); - expect(true).assertTrue(); + expect(false).assertTrue(); setTimeout(() => { done(); }, 500); }, (error) => { - expect(false).assertTrue(); + expect(true).assertTrue(); console.log("VibratorJsTest015 off error"); setTimeout(() => { done(); diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement.test.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement.test.js index ccf060ceb9795c5e302b7ec3eb6303b39e20f22b..c7b4d7523c6d95050902a62831b30bb269afcc52 100644 --- a/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement.test.js +++ b/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement.test.js @@ -67,7 +67,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0290 */ it("VibratorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 1000 }, { @@ -93,7 +93,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "", duration: 1000 }, { @@ -122,7 +122,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0310 */ it("VibratorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -149,7 +149,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, @@ -181,7 +181,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -213,7 +213,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate(null, null); + vibrator.startVibration(null, null); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -227,7 +227,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0350 */ it("VibratorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - await vibrator.vibrate({ + await vibrator.startVibration({ type: "time", duration: 1000, }, { @@ -247,7 +247,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - await vibrator.vibrate({ + await vibrator.startVibration({ type: "", duration: 1000 }, { @@ -272,7 +272,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0370 */ it("VibratorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - await vibrator.vibrate({ + await vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -293,7 +293,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, @@ -321,7 +321,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -349,7 +349,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: 1, count: 3, }, { @@ -370,7 +370,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 100 }, { @@ -389,7 +389,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 100 }, { @@ -421,7 +421,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -441,7 +441,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 100 }, { @@ -473,7 +473,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest033", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -494,7 +494,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 10000 }, { @@ -525,7 +525,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest034", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -545,7 +545,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -578,7 +578,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest035", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 3000, }, { @@ -597,7 +597,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -630,7 +630,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest036", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 3000, }, { @@ -649,7 +649,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -682,7 +682,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest037", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -702,7 +702,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 3, @@ -735,7 +735,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest038", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -755,7 +755,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -788,7 +788,7 @@ describe("VibratorJsTest_misc_5", function () { it("VibratorJsTest039", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -808,7 +808,7 @@ describe("VibratorJsTest_misc_5", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -838,7 +838,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0500 */ it("VibratorJsTest040", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 1000 }, { @@ -865,7 +865,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest041", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "", duration: 1000 }, { @@ -895,7 +895,7 @@ describe("VibratorJsTest_misc_5", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0520 */ it("VibratorJsTest042", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "haptic.clock.timer", count: 1, @@ -923,7 +923,7 @@ describe("VibratorJsTest_misc_5", function () { */ it("VibratorJsTest043", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement_common.test.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement_common.test.js index d803ff4c872807ea6d1a1cac0ea0d6947da518f4..e059cd199e77bbedd2462954ffba1a2cb337e142 100644 --- a/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement_common.test.js +++ b/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupplement_common.test.js @@ -67,7 +67,7 @@ describe("VibratorJsTest_misc_3", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0290 */ it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 1000 }, { @@ -93,7 +93,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "", duration: 1000 }, { @@ -123,7 +123,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, @@ -155,7 +155,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate(null, null); + vibrator.startVibration(null, null); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -169,7 +169,7 @@ describe("VibratorJsTest_misc_3", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0350 */ it("VibratorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - await vibrator.vibrate({ + await vibrator.startVibration({ type: "time", duration: 1000, }, { @@ -189,7 +189,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - await vibrator.vibrate({ + await vibrator.startVibration({ type: "", duration: 1000 }, { @@ -215,7 +215,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, @@ -243,7 +243,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: 1, count: 3, }, { @@ -264,7 +264,7 @@ describe("VibratorJsTest_misc_3", function () { it("VibratorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function vibratePromise() { return new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 100 }, { @@ -283,7 +283,7 @@ describe("VibratorJsTest_misc_3", function () { } let promise = new Promise((resolve, reject) => { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 100 }, { @@ -313,7 +313,7 @@ describe("VibratorJsTest_misc_3", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0500 */ it("VibratorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - vibrator.vibrate({ + vibrator.startVibration({ type: "time", duration: 1000 }, { @@ -340,7 +340,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "", duration: 1000 }, { @@ -371,7 +371,7 @@ describe("VibratorJsTest_misc_3", function () { */ it("VibratorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { - vibrator.vibrate({ + vibrator.startVibration({ type: "preset", effectId: "", count: 3, diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_old.test.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_old.test.js index 5b9ccedda00cc2d945f3f01c43ee5384ad8f7190..78c2e38cd9958fe485f065eeb360a3b9eafa0b82 100644 --- a/sensors/miscdevice_standard/src/main/js/test/Vibrator_old.test.js +++ b/sensors/miscdevice_standard/src/main/js/test/Vibrator_old.test.js @@ -187,21 +187,13 @@ describe("VibratorJsTest_misc_1", function () { */ it("SubVibratorJsTest0007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------SubVibratorJsTest0007---------------------------'); - try { - vibrator.vibrate({ - mode: 'short', - success: function () { - console.info("SubVibratorJsTest0007 success"); - expect(false).assertTrue(); - done(); - }, - }, 25); - } catch (error) { - console.info('SubVibratorJsTest0007 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + vibrator.vibrate({ + mode: 'short', + success: function () { + console.info("SubVibratorJsTest0007 success"); + done(); + }, + }, 25); }) /* @@ -243,14 +235,10 @@ describe("VibratorJsTest_misc_1", function () { */ it("SubVibratorJsTest0009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------SubVibratorJsTest0009---------------------------'); - try { - vibrator.vibrate(); - } catch (error) { - console.info('SubVibratorJsTest0009 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + vibrator.vibrate(); + setTimeout(() => { done(); - } + }, 500); }) /* @@ -260,23 +248,13 @@ describe("VibratorJsTest_misc_1", function () { */ it("SubVibratorJsTest0010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------SubVibratorJsTest0010---------------------------'); - try { - vibrator.vibrate({ - mode: 'short', - success: function () { - console.info("SubVibratorJsTest0010 success"); - expect(false).assertTrue(); - done(); - }, - }, function () { - }, 25); - } catch (error) { - console.info('SubVibratorJsTest0010 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + vibrator.vibrate({ + mode: 'short', + success: function () { + console.info("SubVibratorJsTest0010 success"); + done(); + }, + }, 25); }) }) - - } +} diff --git a/sensors/sensor_standard/src/main/js/test/List.test.js b/sensors/sensor_standard/src/main/js/test/List.test.js index 59a1a305b0b3343e3eb42d3285e7d97be2637060..98e165f20b9492781da82df4cc5aa218ed80cdc3 100644 --- a/sensors/sensor_standard/src/main/js/test/List.test.js +++ b/sensors/sensor_standard/src/main/js/test/List.test.js @@ -41,6 +41,8 @@ import SensorJsTest_sensor_27 from './Subscribe_subscribeDeviceOrientation.test. import SensorJsTest_sensor_53 from './SensorOnOffTest.test_newBarometer.test.js' import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.test.js' import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.test.js' +import SensorJsTest_sensor_57 from './SensorOnOffTest.test_newPedometer_Detection.test.js' +import SensorJsTest_sensor_17 from './SensorOnOffTest.test_oldPedometer_Detection.test.js' export default function testsuite() { SystemParameterTest() @@ -72,4 +74,6 @@ export default function testsuite() { SensorJsTest_sensor_53() SensorJsTest_sensor_8() SensorJsTest_sensor_26() + SensorJsTest_sensor_57() + SensorJsTest_sensor_17() } diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js index fdd66dd374d69c892e8f68c47b689ed33fffec89..361e6331f35b4ca137d9664032447c9d669eec4f 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js @@ -298,14 +298,12 @@ describe("SensorJsTest_sensor_39", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newAccelerometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { + console.info('---------newAccelerometer_SensorJsTest025--------------'); + sensor.on(sensor.SensorId.ACCELEROMETER, callback); + setTimeout(()=>{ sensor.off(sensor.SensorId.ACCELEROMETER, 5); - } catch (error) { - console.info('newAccelerometer_SensorJsTest025 error:'+error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); - } + }, 1000); }) /* diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js index 3fbffffbf86d88a160b840a7187b6d82d4706aaf..4f0d861fe71c58353a2af44d0889673520169a4c 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js @@ -370,13 +370,25 @@ describe("SensorJsTest_sensor_41", function () { * @tc.name: newAmbient_Light_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.AMBIENT_LIGHT, 5); - } catch (error) { + it("newAmbient_Light_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.AMBIENT_LIGHT, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newAmbient_Light_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js index 98ce6b4ceb1f63d928c814657ed0053963079e8e..a261094fb1b798b89141e565bfbdd590aaa72ef2 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js @@ -371,13 +371,25 @@ describe("SensorJsTest_sensor_53", function () { * @tc.name: newBarometer_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.BAROMETER, 5); - } catch (error) { + it("newBarometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newBarometer_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.BAROMETER, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newBarometer_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js index f8d6bbe1c5a0839c537438dcdd18589c1910ccc6..9ad0178968129438fc4ca2cc2cefee63516f8ea7 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js @@ -100,33 +100,41 @@ describe("SensorJsTest_sensor_35", function () { * @tc.name: getSensorLists_SensorJsTest003 * @tc.desc: Verification results of the incorrect parameters of the test interface. */ - it("getSensorLists_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest003----------------------------------"); - try { - sensor.getSensorList(null) - } catch (error) { - console.info('getSensorLists_SensorJsTest003 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } -}) + it("getSensorLists_SensorJsTest003", 0, async function (done) { + console.info("---------------------------getSensorLists_SensorJsTest003----------------------------------"); + sensor.getSensorList(null).then(data => { + console.info("---------------------------getSensorLists_SensorJsTest003 callback in-----------" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest003 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('getSensorLists_SensorJsTest003 failed'); + expect(false).assertTrue(); + done(); + }); + }) /** * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0040 * @tc.name: getSensorLists_SensorJsTest004 * @tc.desc: Verification results of the incorrect parameters of the test interface. */ - it('getSensorLists_SensorJsTest004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info("------------------getSensorLists_SensorJsTest004-------------------------"); - try { - sensor.getSensorList(errMessage) - } catch (error) { - console.info('getSensorLists_SensorJsTest004 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); +it("getSensorLists_SensorJsTest004", 0, async function (done) { + console.info("---------------------------getSensorLists_SensorJsTest004----------------------------------"); + sensor.getSensorList(errMessage).then(data => { + console.info("---------------------------getSensorLists_SensorJsTest004 callback in-----------" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest004 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); done(); - } + }, (error) => { + console.info('getSensorLists_SensorJsTest004 failed'); + expect(false).assertTrue(); + done(); + }); }) /** @@ -134,16 +142,20 @@ describe("SensorJsTest_sensor_35", function () { * @tc.name: getSensorLists_SensorJsTest005 * @tc.desc: Verification results of the incorrect parameters of the test interface. */ - it('getSensorLists_SensorJsTest005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info("------------------getSensorLists_SensorJsTest005-------------------------"); - try { - sensor.getSensorList('xxx') - } catch (error) { - console.info('getSensorLists_SensorJsTest005 error:' + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); +it("getSensorLists_SensorJsTest005", 0, async function (done) { + console.info("---------------------------getSensorLists_SensorJsTest005----------------------------------"); + sensor.getSensorList('xxx').then(data => { + console.info("---------------------------getSensorLists_SensorJsTest005 callback in-----------" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest005 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); done(); - } + }, (error) => { + console.info('getSensorLists_SensorJsTest005 failed'); + expect(false).assertTrue(); + done(); + }); }) /** @@ -151,16 +163,20 @@ describe("SensorJsTest_sensor_35", function () { * @tc.name: getSensorLists_SensorJsTest006 * @tc.desc: Verification results of the incorrect parameters of the test interface. */ - it("getSensorLists_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("getSensorLists_SensorJsTest006", 0, async function (done) { console.info("---------------------------getSensorLists_SensorJsTest006----------------------------------"); - try { - sensor.getSensorList(invild); - } catch(error) { - console.info("getSensorLists_SensorJsTest006 error:" +error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + sensor.getSensorList(invild).then(data => { + console.info("---------------------------getSensorLists_SensorJsTest006 callback in-----------" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); done(); - } + }, (error) => { + console.info('getSensorLists_SensorJsTest006 failed'); + expect(false).assertTrue(); + done(); + }); }) /** diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js index 4b5638960d9824753cae514c577a99d761940581..8d83e9cf59a041c3e0a2fef0702a3552dc32a825 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js @@ -405,13 +405,20 @@ describe("SensorJsTest_sensor_42", function () { * @tc.name: newGravity_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGravity_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.GRAVITY, 5); - } catch (error) { + it("newGravity_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + sensor.on(sensor.SensorId.GRAVITY, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.GRAVITY, 5); + done(); + }, 500); + }) + } catch (error) { console.info('newGravity_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js index eeb09c4e7f9a52f91e26a99d5a1c7488336c7fc8..c202749dd70cb174b5c18de28a6120ede38e6c18 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js @@ -382,13 +382,25 @@ describe("SensorJsTest_sensor_43", function () { * @tc.name: newGyroScope_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.GYROSCOPE, 5); - } catch (error) { + it("newGyroScope_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGyroScope_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.GYROSCOPE, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newGyroScope_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js index 213d563019da41057a8bd5d057748a41965c172c..ae8dfd171e53a54197a397be3c7da66a68501b82 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js @@ -370,13 +370,25 @@ describe("SensorJsTest_sensor_45", function () { * @tc.name: newHall_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.HALL, 5); - } catch (error) { + it("newHall_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newHall_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.HALL, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newHall_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js index 80aec4b82f3541503783aab144605eff1ba9cf38..d2ad21c5b9c3713511ae2eddaad069d6365c15f6 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js @@ -405,13 +405,20 @@ describe("SensorJsTest_sensor_37", function () { * @tc.name: newMagneticField_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.MAGNETIC_FIELD, 5); - } catch (error) { + it("newMagneticField_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newMagneticField_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.MAGNETIC_FIELD, 5); + done(); + }, 500); + }) + } catch (error) { console.info('newMagneticField_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js index b690ff69603953860cba7ef34e6f48f0d14af8f8..f686ad9776d1daa3ae8e6ab94418470db4db5670 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js @@ -382,13 +382,25 @@ describe("SensorJsTest_sensor_48", function () { * @tc.name: newOrientating_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.ORIENTATION, 5); - } catch (error) { + it("newOrientating_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newOrientating_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.ORIENTATION, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newOrientating_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js index cbd314248d5360effb72b9be645ef406487122b9..6edc37d95a6b590ed62a8951f52ddf9f6ca26cfa 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js @@ -696,8 +696,8 @@ describe("SensorJsTest_sensor_57", function () { * @tc.name: newPedometerDetection_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newPedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometerDetection_SensorJsTest015--------'); + it("newPedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------newPedometerDetection_SensorJsTest015---------------------------'); let atManager = abilityAccessCtrl.createAtManager(); await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_SYSTEM_FIXED) @@ -710,16 +710,19 @@ describe("SensorJsTest_sensor_57", function () { done(); } try { - sensor.off(sensor.SensorId.PEDOMETER_DETECTION,5); + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION, 5); + done(); + }, 4000); } catch (error) { - console.error('newPedometerDetection_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error)); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) - done(); + console.error('newPedometerDetection_SensorJsTest015 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); } }); } catch (error) { - console.error('newPedometerDetection_SensorJsTest015 Sensor is not support'+error); + console.error('newPedometerDetection_SensorJsTest015 Sensor is not support'); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -729,7 +732,7 @@ describe("SensorJsTest_sensor_57", function () { console.error('newPedometerDetection_SensorJsTest015 error:' + JSON.stringify(error)); done(); }) - }) + }) /* * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0160 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js index 146445206eccbb9b203db7c1414e7c72049b5977..8cefbe09be82be2c91ddd9f1e5f1b56d800d688b 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js @@ -387,13 +387,25 @@ describe("SensorJsTest_sensor_49", function () { * @tc.name: newRotatingVector_SensorJsTest025 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - try { - sensor.off(sensor.SensorId.ROTATION_VECTOR, 5); - } catch (error) { + it("newRotatingVector_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newRotatingVector_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.ROTATION_VECTOR, 5); + done(); + }, 500); + } + }) + } catch (error) { console.info('newRotatingVector_SensorJsTest025 Device does not support! '); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js index 51b54434e3421d34f6a50037bde061ce55069d32..0099205d2f98e9882b58334b6777d7b540195b8f 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js @@ -1394,6 +1394,12 @@ describe("SensorJsTest_sensor_60", function () { [30, 25, 41], [3, 2, 4], [-123, -456, -564], [3.40282e+38, 3.40282e+38, 3.40282e+38], [NaN, NaN, NaN] ] + let createRotationMatrixResult = [ + [0.6724675297737122,-0.10471208393573761,0.7326819896697998,0.06531608104705811,0.9944750070571899, + 0.08217836916446686,-0.7372390031814575,-0.007406365126371384,0.6755914688110352], + [1,0,0,0,1,0,0,0,1] + ] + /* * @tc.name:Sensor_CreateRotationMatrix_001 * @tc.desc:Verification results of the incorrect parameters of the test interface. @@ -1522,15 +1528,17 @@ describe("SensorJsTest_sensor_60", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_1160 */ - it('Sensor_CreateRotationMatrix_008', 0, async function (done) { - try { - sensor.getRotationMatrix(gravity[2], -1) - } catch (err) { - console.info("Sensor_CreateRotationMatrix_008 catch error " + err); - expect(err.code).assertEqual(PARAMETER_ERROR_CODE) - expect(err.message).assertEqual(PARAMETER_ERROR_MSG) + it('Sensor_CreateRotationMatrix_008', 0, async function (done) { + sensor.getRotationMatrix([-0.0245, 0.402, 0.0465], -1).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_CreateRotationMatrix_008 [" + i + "] : " + data[i]); + expect(data[i]).assertEqual(createRotationMatrixResult[0][i]) + } done() - } + }, (error) => { + expect(false).assertTrue(); + done() + }) }) /* @@ -1582,28 +1590,18 @@ describe("SensorJsTest_sensor_60", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_1190 */ - it('Sensor_CreateRotationMatrix_011', 0, async function (done) { - try { - sensor.getRotationMatrix(gravity[2], -1).then((data) => { - expect(true).assertfalse() - done() - }, (error) =>{ - expect(true).assertfalse() - done() - }) - } catch (err) { - console.info("Sensor_CreateRotationMatrix_011 catch error " + err); - expect(err.code).assertEqual(PARAMETER_ERROR_CODE) - expect(err.message).assertEqual(PARAMETER_ERROR_MSG) + it('Sensor_CreateRotationMatrix_011', 0, async function (done) { + sensor.getRotationMatrix([-0.0245, 0.402, 0.0465], -1).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_CreateRotationMatrix_011 [" + i + "] : " + data[i]); + expect(data[i]).assertEqual(createRotationMatrixResult[0][i]) + } done() - } + }, (error) => { + expect(false).assertTrue(); + done() + }) }) - - let createRotationMatrixResult = [ - [0.6724675297737122,-0.10471208393573761,0.7326819896697998,0.06531608104705811,0.9944750070571899, - 0.08217836916446686,-0.7372390031814575,-0.007406365126371384,0.6755914688110352], - [1,0,0,0,1,0,0,0,1] - ] /* * @tc.name:Sensor_CreateRotationMatrix_012 @@ -2518,17 +2516,21 @@ describe("SensorJsTest_sensor_60", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_1620 */ - it('Sensor_CreateQuaterniont_013', 0, async function (done) { - try { - sensor.createQuaternion([0.52, -0.336, -0.251], -1) - } catch (error) { - console.info("Sensor_CreateQuaterniont_013 catch error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + it('Sensor_CreateQuaterniont_013', 0, async function (done) { + sensor.createQuaternion([0.52, -0.336, -0.251], -1).then((data) => { + console.info('Sensor_CreateQuaterniont_013'); + for (let i = 0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + expect(data[i]).assertEqual(result[0][i]) + } done() - } + }, (error) => { + expect(false).assertTrue(); + done() + }) }) + /* * @tc.name:Sensor_CreateQuaterniont_014 * @tc.desc:Verification results of the incorrect parameters of the test interface. @@ -2578,21 +2580,18 @@ describe("SensorJsTest_sensor_60", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_1650 */ - it('Sensor_CreateQuaterniont_016', 0, async function (done) { - try { - sensor.createQuaternion([0.52, -0.336, -0.251], -1).then((data) => { - expect(true).assertfalse() - done() - }, (error) =>{ - expect(false).assertfalse() - done() - }) - } catch (error) { - console.info("Sensor_CreateQuaterniont_016 catch error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + it('Sensor_CreateQuaterniont_016', 0, async function (done) { + sensor.createQuaternion([0.52, -0.336, -0.251], -1).then((data) => { + console.info('Sensor_CreateQuaterniont_016'); + for (let i = 0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + expect(data[i]).assertEqual(result[0][i]) + } done() - } + }, (error) => { + expect(false).assertTrue(); + done() + }) }) var getGeomagneticDipResult = [ 0.8760581016540527, 0.862170, -Infinity, 44330] diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js index d33cd5fa689f82ef444889dc9ccbaa5c40c1c1e4..942f3657141f7f9113a893402b0fe39bb0b48a4d 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js @@ -696,8 +696,8 @@ describe("SensorJsTest_sensor_17", function () { * @tc.name: PedometerDetection_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("PedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------PedometerDetection_SensorJsTest015--------'); + it("PedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------PedometerDetection_SensorJsTest015---------------------------'); let atManager = abilityAccessCtrl.createAtManager(); await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_SYSTEM_FIXED) @@ -710,16 +710,19 @@ describe("SensorJsTest_sensor_17", function () { done(); } try { - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,5); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, 5); + done(); + }, 4000); } catch (error) { - console.error('PedometerDetection_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error)); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE) - expect(error.message).assertEqual(PARAMETER_ERROR_MSG) - done(); + console.error('PedometerDetection_SensorJsTest015 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); } }); } catch (error) { - console.error('PedometerDetection_SensorJsTest015 Sensor is not support'+error); + console.error('PedometerDetection_SensorJsTest015 Sensor is not support'); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -729,7 +732,7 @@ describe("SensorJsTest_sensor_17", function () { console.error('PedometerDetection_SensorJsTest015 error:' + JSON.stringify(error)); done(); }) - }) + }) /* * @tc.number:SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0160