diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js index c0d7613c279bc57a7b6e3436f772c8a0b0b402ba..6013610683cc365ef7ea7cb6b107928131aa6627 100644 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js @@ -18,10 +18,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import sensor from '@ohos.sensor' -function sleep (NumberMillis) { +function sleep(NumberMillis) { var now = new Date() var exitTime = now.getTime() + NumberMillis - while(true) { + while (true) { now = new Date() if (now.getTime > exitTime) { return @@ -30,20 +30,20 @@ function sleep (NumberMillis) { } describe('SystemParameterTest', function () { - beforeAll(function() { - console.info('beforeAll caled') + beforeAll(function () { + console.info('beforeAll caled') }) - - afterAll(function() { - console.info('afterAll caled') + + afterAll(function () { + console.info('afterAll caled') }) - - beforeEach(function() { - console.info('beforeEach caled') + + beforeEach(function () { + console.info('beforeEach caled') }) - - afterEach(function() { - console.info('afterEach caled') + + afterEach(function () { + console.info('afterEach caled') }) /** @@ -51,9 +51,9 @@ describe('SystemParameterTest', function () { * @tc.name testRegisterSensortest001 * @tc.desc test get sensor data by sensor id. */ - it('SUB_SENSORS_Sensor_JSTest_0010', 0, async function (done) { + it('SUB_SENSORS_Sensor_JSTest_0010', 0, async function (done) { console.info('SUB_SENSORS_Sensor_JSTest_0010 start'); - await sensor.on(0, function(error, data) { + await sensor.on(0, function (error, data) { if (error) { console.info('testRegisterSensortest001 on error'); expect(false).assertTrue(); @@ -61,6 +61,7 @@ describe('SystemParameterTest', function () { } else { console.info('testRegisterSensortest001 on success'); expect(data.x).assertInstanceOf('Number'); + expect(data.timestamp).assertInstanceOf('Number'); done(); } }); @@ -72,20 +73,20 @@ describe('SystemParameterTest', function () { * @tc.name testRegisterSensortest002 * @tc.desc test get sensor data by wrong sensor id. */ - it('SUB_SENSORS_Sensor_JSTest_0020', 0, async function (done) { - console.info('SUB_SENSORS_Sensor_JSTest_0020 start'); - await sensor.on(-1, function(error, data) { - if (error) { - console.info('testRegisterSensortest002 on error'); - expect(true).assertTrue(); - done(); - } else { - console.info('testRegisterSensortest002 on success'); - expect(false).assertTrue(); - done(); - } - }); - console.info('SUB_SENSORS_Sensor_JSTest_0020 end'); - }) + it('SUB_SENSORS_Sensor_JSTest_0020', 0, async function (done) { + console.info('SUB_SENSORS_Sensor_JSTest_0020 start'); + await sensor.on(-1, function (error, data) { + if (error) { + console.info('testRegisterSensortest002 on error'); + expect(true).assertTrue(); + done(); + } else { + console.info('testRegisterSensortest002 on success'); + expect(false).assertTrue(); + done(); + } + }); + console.info('SUB_SENSORS_Sensor_JSTest_0020 end'); + }) }) \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js index 6bbf400fb832c053f66c3409ee5b35ccc88158ca..e877ccf0179f686126717682293dacfc650ea95d 100755 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js @@ -86,11 +86,12 @@ describe("SensorJsTest", function () { reject(err); }, 500); } else { - console.info('SensorRotationVectorJSTest001 on success, x: ' - + data.x + "y: " + data.y + "z: " + data.z); + console.info('SensorRotationVectorJSTest001 on success, x: ' + + data.x + "y: " + data.y + "z: " + data.z + "w: " + data.w); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.w)).assertEqual("number"); setTimeout(() => { resolve(); }, 500); @@ -117,11 +118,12 @@ describe("SensorJsTest", function () { console.info('SensorRotationVectorJSTest005 once error'); expect(false).assertTrue(); } else { - console.info('SensorRotationVectorJSTest005 on success, x: ' - + data.x + "y: " + data.y + "z: " + data.z); + console.info('SensorRotationVectorJSTest005 on success, x: ' + + data.x + "y: " + data.y + "z: " + data.z + "w: " + data.w); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); + expect(typeof (data.w)).assertEqual("number"); } setTimeout(() => { done();