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 aabb6596342d7e31d55435269aa6fa81b4f854ab..36bc310a7cd5a521a80923fb3c4f0172f36c7190 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 @@ -381,16 +381,16 @@ describe("VibratorJsTest_misc_2", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0150 */ - it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - vibrator.vibrate("").then(() => { - console.log("VibratorJsTest015 vibrate error"); - expect(false).assertTrue(); + it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + vibrator.stop("preset").then(() => { + console.log("VibratorJsTest015 off success"); + expect(true).assertTrue(); setTimeout(() => { done(); }, 500); }, (error) => { - expect(true).assertTrue(); - console.log("VibratorJsTest015 vibrate success"); + expect(false).assertTrue(); + console.log("VibratorJsTest015 off error"); setTimeout(() => { done(); }, 500); @@ -424,15 +424,15 @@ describe("VibratorJsTest_misc_2", function () { * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0170 */ it("VibratorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - vibrator.stop("preset").then(() => { - console.log("VibratorJsTest017 off success"); - expect(true).assertTrue(); + vibrator.vibrate("").then(() => { + console.log("VibratorJsTest017 vibrate error"); + expect(false).assertTrue(); setTimeout(() => { done(); }, 500); }, (error) => { - expect(false).assertTrue(); - console.log("VibratorJsTest017 off error"); + expect(true).assertTrue(); + console.log("VibratorJsTest017 vibrate success"); setTimeout(() => { done(); }, 500); 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 85308bd477fe3362169e138642bf53e231bf1732..93f9f860564df99b70b769c7a036dbda30dc068b 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 @@ -50,8 +50,7 @@ describe("VibratorJsTest_misc_1", function () { console.info('afterEach caled') }) - let errMessages = ['Param number is invalid', 'Wrong argument type. function expected', - 'Wrong argument type', 'Wrong argument number'] + let errMessages = ['Error: ParseParameter: "Get vibrate type fail"', 'Error: ParseParameter: "Wrong argument number"'] let errMessage; @@ -194,7 +193,7 @@ describe("VibratorJsTest_misc_1", function () { }, }, 25); } catch (error) { - errMessage = error.toString().slice(39); + errMessage = error.toString(); console.info('SubVibratorJsTest0007 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -243,9 +242,9 @@ describe("VibratorJsTest_misc_1", function () { try { vibrator.vibrate(); } catch (error) { - errMessage = error.toString().slice(7); + errMessage = error.toString(); console.info('SubVibratorJsTest0009 error:' + error); - expect(errMessage).assertEqual(errMessages[2]); + expect(errMessage).assertEqual(errMessages[1]); done(); } }) @@ -268,9 +267,9 @@ describe("VibratorJsTest_misc_1", function () { }, function () { }, 25); } catch (error) { - errMessage = error.toString().slice(39); + errMessage = error.toString(); console.info('SubVibratorJsTest0010 error:' + error); - expect(errMessage).assertEqual(errMessages[3]); + expect(errMessage).assertEqual(errMessages[0]); done(); } }) diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test.js index 41d0b8a1afc822116ab1bb2ab847b220edc9bbec..0a9b27f8ad78bcadaae8e63403b2881388eff99e 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test.js @@ -18,17 +18,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import sensor from '@ohos.sensor' -function sleep(NumberMillis) { - let now = new Date() - let exitTime = now.getTime() + NumberMillis - while (true) { - now = new Date() - if (now.getTime > exitTime) { - return - } - } -} - export default function SystemParameterTest() { describe('SystemParameterTest', function () { beforeAll(function () { @@ -47,19 +36,22 @@ describe('SystemParameterTest', function () { console.info('afterEach caled') }) - let testSensorId = 0; let testNullSensorId = -1; + + let errMessages = ['SubscribeSensor failed']; + + let errMessage; /** * @tc.number SUB_SENSORS_Sensor_JSTest_0020 - * @tc.name testRegisterSensortest002 + * @tc.name testRegisterSensortest001 * @tc.desc test get sensor data by wrong sensor id. */ - it('SUB_SENSORS_Sensor_JSTest_0020', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('SUB_SENSORS_Sensor_JSTest_0020 start'); + it('testRegisterSensortest001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('testRegisterSensortest001 start'); function onSensorCallback(data) { - console.info('SensorJsTest002 on error'); + console.info('testRegisterSensortest001 on error'); expect(false).assertTrue(); done(); } @@ -67,10 +59,11 @@ describe('SystemParameterTest', function () { try { sensor.on(testNullSensorId, onSensorCallback); } catch (error) { - console.info(error); - expect(true).assertTrue(); + console.info('testRegisterSensortest001 error' +error); + errMessage = error.toString().slice(12, 34); + expect(errMessage).assertEqual(errMessages[0]); done(); } - console.info('SUB_SENSORS_Sensor_JSTest_0020 end'); + console.info('testRegisterSensortest001 end'); }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_GetSensorLists.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_GetSensorLists.js index b5d2cf67a3064d43801a3d184eb4e2c66d0c650b..12011d8f86a7e00b2b65a137be095f19a41af332 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_GetSensorLists.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_GetSensorLists.js @@ -65,7 +65,6 @@ describe("SensorJsTest_sensor_35", function () { it("getSensorLists_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info("---------------------------getSensorLists_SensorJsTest001----------------------------------"); sensor.getSensorList().then((data) => { - console.info("---------------------------getSensorLists_SensorJsTest001 in-----------" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest001 " + JSON.stringify(data[i])); } @@ -88,7 +87,6 @@ it("getSensorLists_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level console.info('getSensorLists_SensorJsTest002 error'); expect(false).assertTrue(); } else { - console.info("---------------------------getSensorLists_SensorJsTest002 in-----------" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest002 " + JSON.stringify(data[i])); } @@ -164,7 +162,6 @@ it("getSensorLists_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level expect(true).assertTrue(); done() } else { - console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); } @@ -177,7 +174,6 @@ it("getSensorLists_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level expect(true).assertTrue(); done() } else { - console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); } diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Gravity.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Gravity.js index 032c40bca4059bf8fd8172c21d06890c15b44960..d70bd73b8789b3a64e40600011121ba81ef36cb4 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Gravity.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Gravity.js @@ -23,6 +23,7 @@ describe("SensorJsTest_sensor_9", function () { expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -30,6 +31,7 @@ describe("SensorJsTest_sensor_9", function () { expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -237,7 +239,11 @@ describe("SensorJsTest_sensor_9", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); setTimeout(()=>{ console.info('----------------------gravity_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + } catch (error) { + console.info("gravity_SensorJsTest010 error:" + error); + } console.info('----------------------gravity_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(()=>{ @@ -276,7 +282,11 @@ describe("SensorJsTest_sensor_9", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------gravity_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + } catch (error) { + console.info("gravity_SensorJsTest012 error:" + error); + } console.info('----------------------gravity_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_MagneticField.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_MagneticField.js index 02c92b451cfc73f9ee1a07386af12bb4f6be46cb..df64e9da46a48e7dc97df1002bcc15ddeb2ca548 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_MagneticField.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_MagneticField.js @@ -23,6 +23,7 @@ describe("SensorJsTest_sensor_15", function () { expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -30,6 +31,7 @@ describe("SensorJsTest_sensor_15", function () { expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function() { @@ -145,7 +147,7 @@ describe("SensorJsTest_sensor_15", function () { expect(false).assertTrue(); done(); } - try{ + try { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, onceSensorCallback, 5); } catch (error) { console.info('magnetic_SensorJsTest005 error' +error); @@ -237,7 +239,11 @@ describe("SensorJsTest_sensor_15", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2); setTimeout(()=>{ console.info('----------------------magnetic_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + try{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + } catch (error) { + console.info("magnetic_SensorJsTest010 error:" + error); + } console.info('----------------------magnetic_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(()=>{ @@ -276,7 +282,11 @@ describe("SensorJsTest_sensor_15", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------magnetic_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + } catch (error) { + console.info("magnetic_SensorJsTest012 error:" + error); + } console.info('----------------------magnetic_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Orientating.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Orientating.js index 37a4fb9aabce747d9b6533bacd398e74098f3206..5f3a77ca750120cd58d512ef50db411dc72a54f2 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Orientating.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_Orientating.js @@ -23,6 +23,7 @@ describe("SensorJsTest_sensor_16", function () { expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -30,6 +31,7 @@ describe("SensorJsTest_sensor_16", function () { expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -145,7 +147,7 @@ describe("SensorJsTest_sensor_16", function () { expect(false).assertTrue(); done(); } - try{ + try { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onceSensorCallback, 5); } catch (error) { console.info('orientating_SensorJsTest005 error' + error); @@ -237,7 +239,11 @@ describe("SensorJsTest_sensor_16", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); setTimeout(()=>{ console.info('----------------------orientating_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + } catch (error) { + console.info("orientating_SensorJsTest010 error:" + error); + } console.info('----------------------orientating_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(()=>{ @@ -276,7 +282,11 @@ describe("SensorJsTest_sensor_16", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------orientating_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + } catch (error) { + console.info("orientating_SensorJsTest012 error:" + error); + } console.info('----------------------orientating_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_RotatingVector.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_RotatingVector.js index 436fee7f0956d597bae3dece9a55cf2317bd9897..6947a3528358db928a57eb73e0f9b6e7e3e583d3 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_RotatingVector.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_RotatingVector.js @@ -24,6 +24,7 @@ describe("SensorJsTest_sensor_20", function () { expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); expect(typeof(data.w)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -32,6 +33,7 @@ describe("SensorJsTest_sensor_20", function () { expect(typeof(data.y)).assertEqual("number"); expect(typeof(data.z)).assertEqual("number"); expect(typeof(data.w)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function() { @@ -147,7 +149,7 @@ describe("SensorJsTest_sensor_20", function () { expect(false).assertTrue(); done(); } - try{ + try { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onceSensorCallback, 5); } catch (error) { console.info('rotatingvector_SensorJsTest005 error' +error); @@ -239,7 +241,11 @@ describe("SensorJsTest_sensor_20", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); setTimeout(()=>{ console.info('----------------------rotatingvector_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + } catch (error) { + console.info("rotatingvector_SensorJsTest010 error:" + error); + } console.info('----------------------rotatingvector_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(()=>{ @@ -278,7 +284,11 @@ describe("SensorJsTest_sensor_20", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------rotatingvector_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + } catch (error) { + console.info("rotatingvector_SensorJsTest012 error:" + error); + } console.info('----------------------rotatingvector_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Accelerometer.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Accelerometer.js index b00b7f2ac53ac307eba096d10a5a4246023e99fc..21b71bdd18d3ccfea1e2f806ae612a54fa5c415b 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Accelerometer.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Accelerometer.js @@ -22,6 +22,7 @@ describe("SensorJsTest_sensor_3", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -29,6 +30,7 @@ describe("SensorJsTest_sensor_3", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -243,7 +245,11 @@ describe("SensorJsTest_sensor_3", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(() => { console.info('----------------------Accelerometer_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + } catch (error) { + console.info("Accelerometer_SensorJsTest010 error:" + error); + } console.info('----------------------Accelerometer_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(() => { @@ -282,7 +288,12 @@ describe("SensorJsTest_sensor_3", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, { 'interval': 100000000 }); setTimeout(() => { console.info('----------------------Accelerometer_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + } catch (error) { + console.info("Accelerometer_SensorJsTest012 error:" + error); + } + console console.info('----------------------Accelerometer_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Ambient_light.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Ambient_light.js index 91dae503e89f42485e9810a0da660da4e7332e6e..c9d6c151db621b74323b132beb3134062712e1c5 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Ambient_light.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Ambient_light.js @@ -21,11 +21,13 @@ describe("SensorJsTest_sensor_4", function () { function callback(data) { console.info("callback" + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -244,7 +246,11 @@ describe("SensorJsTest_sensor_4", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); setTimeout(() => { console.info('----------------------Ambient_Light_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + } catch (error) { + console.info("Ambient_Light_SensorJsTest010 error:" + error); + } console.info('----------------------Ambient_Light_SensorJsTest010 off end---------------------------'); }, 1000); setTimeout(() => { @@ -283,7 +289,11 @@ describe("SensorJsTest_sensor_4", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': 100000000 }); setTimeout(() => { console.info('----------------------Ambient_Light_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + } catch (error) { + console.info("Ambient_Light_SensorJsTest012 error:" + error); + } console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_GyroScope.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_GyroScope.js index b65424581b0af824a092b62f0cc701cd5011809a..7d132333904fea208fc3293b4f79c878a53ad8df 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_GyroScope.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_GyroScope.js @@ -22,6 +22,7 @@ describe("SensorJsTest_sensor_5", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -29,6 +30,7 @@ describe("SensorJsTest_sensor_5", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -243,7 +245,11 @@ describe("SensorJsTest_sensor_5", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback2); setTimeout(() => { console.info('----------------------GYROSCOPE_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); + } catch (error) { + console.info("GYROSCOPE_SensorJsTest010 error:" + error); + } console.info('----------------------GYROSCOPE_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(() => { @@ -282,7 +288,11 @@ describe("SensorJsTest_sensor_5", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback2, { 'interval': 100000000 }); setTimeout(() => { console.info('----------------------GYROSCOPE_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); + } catch (error) { + console.info("GYROSCOPE_SensorJsTest012 error:" + error); + } console.info('----------------------GYROSCOPE_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Hall.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Hall.js index 11bf463c879d12c44041de02b489302521e80128..654b12782d6be9dc45fc3f0b22210a71bf778dce 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Hall.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Hall.js @@ -20,11 +20,13 @@ describe("SensorJsTest_sensor_7", function () { function callback(data) { console.info("callback" + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -232,7 +234,11 @@ describe("SensorJsTest_sensor_7", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback2); setTimeout(() => { console.info('----------------------Hall_SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); + } catch (error) { + console.info("Hall_SensorJsTest010 error:" + error); + } console.info('----------------------Hall_SensorJsTest010 off end---------------------------'); }, 500); setTimeout(() => { @@ -271,7 +277,11 @@ describe("SensorJsTest_sensor_7", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback2, { 'interval': 100000000 }); setTimeout(() => { console.info('----------------------Hall_SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); + } catch (error) { + console.info("Hall_SensorJsTest012 error:" + error); + } console.info('----------------------Hall_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Linear_Accelerometer_test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Linear_Accelerometer_test.js index 042a2d9218b35d7a92296716f1e1899d7622b72e..d25f44df62b4a71ab8b895bd2800022cac34e141 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Linear_Accelerometer_test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest_Linear_Accelerometer_test.js @@ -22,6 +22,7 @@ describe("SensorJsTest_sensor_37", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { @@ -29,6 +30,7 @@ describe("SensorJsTest_sensor_37", function () { expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.timestamp)).assertEqual("number"); } beforeAll(function () { @@ -244,7 +246,11 @@ describe("SensorJsTest_sensor_37", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback2); setTimeout(() => { console.info('-----------SensorLinearAccelerometerJSTest010 off in----------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); + } catch (error) { + console.info("SensorLinearAccelerometerJSTest010 error:" + error); + } console.info('-----------SensorLinearAccelerometerJSTest010 off end----------------'); }, 500); setTimeout(() => { @@ -283,7 +289,11 @@ describe("SensorJsTest_sensor_37", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback2, { 'interval': 100000000 }); setTimeout(() => { console.info('-----------SensorLinearAccelerometerJSTest012 off in----------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); + } catch (error) { + console.info("SensorLinearAccelerometerJSTest012 error:" + error); + } console.info('-----------SensorLinearAccelerometerJSTest012 off end----------------'); }, 500); setTimeout(() => {