未验证 提交 4fbccaec 编写于 作者: O openharmony_ci 提交者: Gitee

!2002 Sensor用例补充

Merge pull request !2002 from logic42/master
......@@ -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
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册