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

!2002 Sensor用例补充

Merge pull request !2002 from logic42/master
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
function sleep (NumberMillis) { function sleep(NumberMillis) {
var now = new Date() var now = new Date()
var exitTime = now.getTime() + NumberMillis var exitTime = now.getTime() + NumberMillis
while(true) { while (true) {
now = new Date() now = new Date()
if (now.getTime > exitTime) { if (now.getTime > exitTime) {
return return
...@@ -30,20 +30,20 @@ function sleep (NumberMillis) { ...@@ -30,20 +30,20 @@ function sleep (NumberMillis) {
} }
describe('SystemParameterTest', function () { describe('SystemParameterTest', function () {
beforeAll(function() { beforeAll(function () {
console.info('beforeAll caled') console.info('beforeAll caled')
}) })
afterAll(function() { afterAll(function () {
console.info('afterAll caled') console.info('afterAll caled')
}) })
beforeEach(function() { beforeEach(function () {
console.info('beforeEach caled') console.info('beforeEach caled')
}) })
afterEach(function() { afterEach(function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
/** /**
...@@ -51,9 +51,9 @@ describe('SystemParameterTest', function () { ...@@ -51,9 +51,9 @@ describe('SystemParameterTest', function () {
* @tc.name testRegisterSensortest001 * @tc.name testRegisterSensortest001
* @tc.desc test get sensor data by sensor id. * @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'); console.info('SUB_SENSORS_Sensor_JSTest_0010 start');
await sensor.on(0, function(error, data) { await sensor.on(0, function (error, data) {
if (error) { if (error) {
console.info('testRegisterSensortest001 on error'); console.info('testRegisterSensortest001 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -61,6 +61,7 @@ describe('SystemParameterTest', function () { ...@@ -61,6 +61,7 @@ describe('SystemParameterTest', function () {
} else { } else {
console.info('testRegisterSensortest001 on success'); console.info('testRegisterSensortest001 on success');
expect(data.x).assertInstanceOf('Number'); expect(data.x).assertInstanceOf('Number');
expect(data.timestamp).assertInstanceOf('Number');
done(); done();
} }
}); });
...@@ -72,20 +73,20 @@ describe('SystemParameterTest', function () { ...@@ -72,20 +73,20 @@ describe('SystemParameterTest', function () {
* @tc.name testRegisterSensortest002 * @tc.name testRegisterSensortest002
* @tc.desc test get sensor data by wrong sensor id. * @tc.desc test get sensor data by wrong sensor id.
*/ */
it('SUB_SENSORS_Sensor_JSTest_0020', 0, async function (done) { it('SUB_SENSORS_Sensor_JSTest_0020', 0, async function (done) {
console.info('SUB_SENSORS_Sensor_JSTest_0020 start'); console.info('SUB_SENSORS_Sensor_JSTest_0020 start');
await sensor.on(-1, function(error, data) { await sensor.on(-1, function (error, data) {
if (error) { if (error) {
console.info('testRegisterSensortest002 on error'); console.info('testRegisterSensortest002 on error');
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
} else { } else {
console.info('testRegisterSensortest002 on success'); console.info('testRegisterSensortest002 on success');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}); });
console.info('SUB_SENSORS_Sensor_JSTest_0020 end'); console.info('SUB_SENSORS_Sensor_JSTest_0020 end');
}) })
}) })
\ No newline at end of file
...@@ -86,11 +86,12 @@ describe("SensorJsTest", function () { ...@@ -86,11 +86,12 @@ describe("SensorJsTest", function () {
reject(err); reject(err);
}, 500); }, 500);
} else { } else {
console.info('SensorRotationVectorJSTest001 on success, x: ' console.info('SensorRotationVectorJSTest001 on success, x: '
+ data.x + "y: " + data.y + "z: " + data.z); + data.x + "y: " + data.y + "z: " + data.z + "w: " + data.w);
expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.w)).assertEqual("number");
setTimeout(() => { setTimeout(() => {
resolve(); resolve();
}, 500); }, 500);
...@@ -117,11 +118,12 @@ describe("SensorJsTest", function () { ...@@ -117,11 +118,12 @@ describe("SensorJsTest", function () {
console.info('SensorRotationVectorJSTest005 once error'); console.info('SensorRotationVectorJSTest005 once error');
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
console.info('SensorRotationVectorJSTest005 on success, x: ' console.info('SensorRotationVectorJSTest005 on success, x: '
+ data.x + "y: " + data.y + "z: " + data.z); + data.x + "y: " + data.y + "z: " + data.z + "w: " + data.w);
expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.w)).assertEqual("number");
} }
setTimeout(() => { setTimeout(() => {
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册