From 6f4f6ca77d7853a5d90e047bc2d2d1d63d323857 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 25 Apr 2022 15:46:31 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E9=AA=8C=E8=AF=81acc=E5=8A=A0=E9=80=9F?= =?UTF-8?q?=E5=BA=A6=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../test/unittest/ExampleJsunit.test.js | 211 +++++++----------- interfaces/plugin/test/unittest/config.json | 12 + 2 files changed, 91 insertions(+), 132 deletions(-) diff --git a/interfaces/plugin/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/ExampleJsunit.test.js index ff75e1a6..ffb8047e 100644 --- a/interfaces/plugin/test/unittest/ExampleJsunit.test.js +++ b/interfaces/plugin/test/unittest/ExampleJsunit.test.js @@ -20,11 +20,15 @@ describe("SensorJsTest", function () { function callback(data) { console.info("callback" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); } function callback2() { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); } beforeAll(function() { @@ -63,9 +67,9 @@ describe("SensorJsTest", function () { */ it("SensorJsTest001", 0, async function (done) { console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(0, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); setTimeout(()=>{ - sensor.off(0); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); done(); }, 500); }) @@ -78,52 +82,30 @@ describe("SensorJsTest", function () { */ it("SensorJsTest002", 0, async function (done) { console.info('----------------------SensorJsTest002---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest002 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.on(-1, onSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest003", 0, async function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - sensor.on(0, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest003 off in---------------------------'); - sensor.off(0); - console.info('----------------------SensorJsTest003 off end---------------------------'); + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest002 off end---------------------------'); done(); }, 500); }) /* - * @tc.name:SensorJsTest004 + * @tc.name:SensorJsTest003 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest004", 0, function (done) { - console.info('----------------------SensorJsTest004---------------------------'); + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); function onSensorCallback(data) { - console.info('SensorJsTest004 on error'); + console.info('SensorJsTest003 on error'); expect(false).assertTrue(); done(); } try { - sensor.on(0, onSensorCallback, {'interval': 100000000}, 5); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, {'interval': 100000000}, 5); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -132,13 +114,13 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest005 + * @tc.name:SensorJsTest003 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest005", 0, async function (done) { - sensor.once(0, callback); + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); setTimeout(()=>{ expect(true).assertTrue(); done(); @@ -146,40 +128,19 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest006 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest006", 0, async function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest006 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.once(-1, onceSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest007 + * @tc.name:SensorJsTest004 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest007", 0, function (done) { + it("SensorJsTest005", 0, function (done) { function onceSensorCallback(data) { - console.info('SensorJsTest007 on error'); + console.info('SensorJsTest005 on error'); expect(false).assertTrue(); done(); } try{ - sensor.once(0, onceSensorCallback, 5); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -188,14 +149,14 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest008 + * @tc.name:SensorJsTest006 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest008", 0, async function (done) { + it("SensorJsTest006", 0, async function (done) { try { - sensor.off(-1, callback); + sensor.off(string, ""); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -204,19 +165,19 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest009 + * @tc.name:SensorJsTest007 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest009", 0, async function (done) { + it("SensorJsTest007", 0, async function (done) { function onSensorCallback(data) { - console.info('SensorJsTest009 on error'); + console.info('SensorJsTest007 on error'); expect(false).assertTrue(); done(); } - sensor.on(0, onSensorCallback); - sensor.off(0, onSensorCallback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); setTimeout(()=>{ expect(true).assertTrue(); done(); @@ -224,14 +185,14 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest010 + * @tc.name:SensorJsTest008 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest010", 0, async function (done) { + it("SensorJsTest008", 0, async function (done) { function onSensorCallback(data) { - console.info('SensorJsTest010 on error'); + console.info('SensorJsTest008 on error'); expect(false).assertTrue(); done(); } @@ -245,119 +206,105 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest011 + * @tc.name:SensorJsTest009 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest011", 0, async function (done) { - sensor.on(0, callback); - sensor.on(0, callback2); + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(0); - console.info('----------------------SensorJsTest011 off end---------------------------'); + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest009 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest012 + * @tc.name:SensorJsTest010 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest012", 0, async function (done) { - sensor.on(0, callback); - sensor.on(0, callback2); + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(0, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(0, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, function (done) { - try { - sensor.off(0, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest014 + * @tc.name:SensorJsTest011 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest014", 0, async function (done) { - console.info('----------------------SensorJsTest014---------------------------'); - sensor.on(0, callback, {'interval': 100000000}); - sensor.once(0, callback2); + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest014 off in---------------------------'); - sensor.off(0); - console.info('----------------------SensorJsTest014 off end---------------------------'); + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest011 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest015 + * @tc.name:SensorJsTest012 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest015", 0, async function (done) { - console.info('----------------------SensorJsTest015---------------------------'); - sensor.on(0, callback, {'interval': 100000000}); - sensor.on(0, callback2, {'interval': 100000000}); + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest015 off in---------------------------'); - sensor.off(0, callback); - console.info('----------------------SensorJsTest015 off end---------------------------'); + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------SensorJsTest015 off in---------------------------'); - sensor.off(0, callback2); - console.info('----------------------SensorJsTest015 off end---------------------------'); + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest016 + * @tc.name:SensorJsTest013 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest016", 0, async function (done) { - console.info('----------------------SensorJsTest016---------------------------'); - sensor.on(0, callback, {'interval': 100000000}); - sensor.on(0, callback2, {'interval': 100000000}); + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest016 off in---------------------------'); - sensor.off(0); - console.info('----------------------SensorJsTest016 off end---------------------------'); + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest013 off end---------------------------'); done(); }, 1000); }) + + let GEOMAGNETIC_COMPONENT_YEAR_RESULT = [ [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], [6554.17041015625, -87.19947052001953, 54649.078125, -0.7622424364089966, 83.16046905517578, 6554.75048828125, 55040.7734375], diff --git a/interfaces/plugin/test/unittest/config.json b/interfaces/plugin/test/unittest/config.json index 2ca85895..b4bc5993 100755 --- a/interfaces/plugin/test/unittest/config.json +++ b/interfaces/plugin/test/unittest/config.json @@ -13,6 +13,18 @@ }, "deviceConfig": {}, "module": { + "reqPermissions": [ + { + "name": "ohos.permission.ACCELEROMETER", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" + ], + "when": "inuse" + } + } + ], "package": "com.example.myapplication", "name": ".MyApplication", "deviceType": [ -- Gitee From 697256e588586cdfcd8b1d9065d2fe387ee44767 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 25 Apr 2022 15:50:39 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../test/unittest/ExampleJsunit.test.js | 211 +++++++++++------- 1 file changed, 132 insertions(+), 79 deletions(-) diff --git a/interfaces/plugin/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/ExampleJsunit.test.js index ffb8047e..ff75e1a6 100644 --- a/interfaces/plugin/test/unittest/ExampleJsunit.test.js +++ b/interfaces/plugin/test/unittest/ExampleJsunit.test.js @@ -20,15 +20,11 @@ describe("SensorJsTest", function () { function callback(data) { console.info("callback" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); } function callback2() { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); } beforeAll(function() { @@ -67,9 +63,9 @@ describe("SensorJsTest", function () { */ it("SensorJsTest001", 0, async function (done) { console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.on(0, callback); setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + sensor.off(0); done(); }, 500); }) @@ -82,13 +78,18 @@ describe("SensorJsTest", function () { */ it("SensorJsTest002", 0, async function (done) { console.info('----------------------SensorJsTest002---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - console.info('----------------------SensorJsTest002 off end---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest002 on error'); + expect(false).assertTrue(); done(); - }, 500); + } + try { + sensor.on(-1, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } }) /* @@ -97,15 +98,32 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest003", 0, function (done) { + it("SensorJsTest003", 0, async function (done) { console.info('----------------------SensorJsTest003---------------------------'); + sensor.on(0, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest003 off in---------------------------'); + sensor.off(0); + console.info('----------------------SensorJsTest003 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, function (done) { + console.info('----------------------SensorJsTest004---------------------------'); function onSensorCallback(data) { - console.info('SensorJsTest003 on error'); + console.info('SensorJsTest004 on error'); expect(false).assertTrue(); done(); } try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, {'interval': 100000000}, 5); + sensor.on(0, onSensorCallback, {'interval': 100000000}, 5); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -114,13 +132,13 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest003 + * @tc.name:SensorJsTest005 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest004", 0, async function (done) { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + it("SensorJsTest005", 0, async function (done) { + sensor.once(0, callback); setTimeout(()=>{ expect(true).assertTrue(); done(); @@ -128,19 +146,40 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest004 + * @tc.name:SensorJsTest006 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest005", 0, function (done) { + it("SensorJsTest006", 0, async function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest006 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(-1, onceSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, function (done) { function onceSensorCallback(data) { - console.info('SensorJsTest005 on error'); + console.info('SensorJsTest007 on error'); expect(false).assertTrue(); done(); } try{ - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5); + sensor.once(0, onceSensorCallback, 5); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -149,14 +188,14 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest006 + * @tc.name:SensorJsTest008 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest006", 0, async function (done) { + it("SensorJsTest008", 0, async function (done) { try { - sensor.off(string, ""); + sensor.off(-1, callback); } catch (error) { console.info(error); expect(true).assertTrue(); @@ -165,19 +204,19 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest007 + * @tc.name:SensorJsTest009 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest007", 0, async function (done) { + it("SensorJsTest009", 0, async function (done) { function onSensorCallback(data) { - console.info('SensorJsTest007 on error'); + console.info('SensorJsTest009 on error'); expect(false).assertTrue(); done(); } - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); + sensor.on(0, onSensorCallback); + sensor.off(0, onSensorCallback); setTimeout(()=>{ expect(true).assertTrue(); done(); @@ -185,14 +224,14 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest008 + * @tc.name:SensorJsTest010 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest008", 0, async function (done) { + it("SensorJsTest010", 0, async function (done) { function onSensorCallback(data) { - console.info('SensorJsTest008 on error'); + console.info('SensorJsTest010 on error'); expect(false).assertTrue(); done(); } @@ -206,105 +245,119 @@ describe("SensorJsTest", function () { }) /* - * @tc.name:SensorJsTest009 + * @tc.name:SensorJsTest011 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest009", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + it("SensorJsTest011", 0, async function (done) { + sensor.on(0, callback); + sensor.on(0, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - console.info('----------------------SensorJsTest009 off end---------------------------'); + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(0); + console.info('----------------------SensorJsTest011 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest010 + * @tc.name:SensorJsTest012 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest010", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + it("SensorJsTest012", 0, async function (done) { + sensor.on(0, callback); + sensor.on(0, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); - console.info('----------------------SensorJsTest010 off end---------------------------'); + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(0, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); - console.info('----------------------SensorJsTest010 off end---------------------------'); + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(0, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest011 + * @tc.name:SensorJsTest013 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest011", 0, async function (done) { - console.info('----------------------SensorJsTest011---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + it("SensorJsTest013", 0, function (done) { + try { + sensor.off(0, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest014 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest014", 0, async function (done) { + console.info('----------------------SensorJsTest014---------------------------'); + sensor.on(0, callback, {'interval': 100000000}); + sensor.once(0, callback2); setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - console.info('----------------------SensorJsTest011 off end---------------------------'); + console.info('----------------------SensorJsTest014 off in---------------------------'); + sensor.off(0); + console.info('----------------------SensorJsTest014 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest012 + * @tc.name:SensorJsTest015 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest012", 0, async function (done) { - console.info('----------------------SensorJsTest012---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); + it("SensorJsTest015", 0, async function (done) { + console.info('----------------------SensorJsTest015---------------------------'); + sensor.on(0, callback, {'interval': 100000000}); + sensor.on(0, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); + console.info('----------------------SensorJsTest015 off in---------------------------'); + sensor.off(0, callback); + console.info('----------------------SensorJsTest015 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); + console.info('----------------------SensorJsTest015 off in---------------------------'); + sensor.off(0, callback2); + console.info('----------------------SensorJsTest015 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest013 + * @tc.name:SensorJsTest016 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); + it("SensorJsTest016", 0, async function (done) { + console.info('----------------------SensorJsTest016---------------------------'); + sensor.on(0, callback, {'interval': 100000000}); + sensor.on(0, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest013 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - console.info('----------------------SensorJsTest013 off end---------------------------'); + console.info('----------------------SensorJsTest016 off in---------------------------'); + sensor.off(0); + console.info('----------------------SensorJsTest016 off end---------------------------'); done(); }, 1000); }) - - let GEOMAGNETIC_COMPONENT_YEAR_RESULT = [ [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], [6554.17041015625, -87.19947052001953, 54649.078125, -0.7622424364089966, 83.16046905517578, 6554.75048828125, 55040.7734375], -- Gitee From 36399677ca914bd528f38340af96e99e79c224a5 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 25 Apr 2022 15:54:35 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9acc=E5=8A=A0=E9=80=9F?= =?UTF-8?q?=E5=BA=A6=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../plugin/test/ExampleJsunit.test_acc.js | 212 ++++++++---------- 1 file changed, 88 insertions(+), 124 deletions(-) diff --git a/interfaces/plugin/test/ExampleJsunit.test_acc.js b/interfaces/plugin/test/ExampleJsunit.test_acc.js index e863c356..eea2572a 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_acc.js +++ b/interfaces/plugin/test/ExampleJsunit.test_acc.js @@ -66,9 +66,9 @@ describe("SensorJsTest", function () { */ it("SensorJsTest001", 0, async function (done) { console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(1, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); setTimeout(()=>{ - sensor.off(1); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); done(); }, 500); }) @@ -81,14 +81,11 @@ describe("SensorJsTest", function () { */ it("SensorJsTest002", 0, async function (done) { console.info('----------------------SensorJsTest002---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest002 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(-1, onSensorCallback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); setTimeout(()=>{ - expect(true).assertTrue(); + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest002 off end---------------------------'); done(); }, 500); }) @@ -99,15 +96,20 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest003", 0, async function (done) { + it("SensorJsTest003", 0, function (done) { console.info('----------------------SensorJsTest003---------------------------'); - sensor.on(1, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest003 off in---------------------------'); - sensor.off(1); - console.info('----------------------SensorJsTest003 off end---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); done(); - }, 500); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } }) /* @@ -116,19 +118,12 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest004", 0, function () { - console.info('----------------------SensorJsTest004---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest004 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(1, onSensorCallback, {'interval': 100000000}, 5); + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); setTimeout(()=>{ expect(true).assertTrue(); done(); }, 500); - console.info('----------------------SensorJsTest004--------------------------- end'); }) /* @@ -137,12 +132,19 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest005", 0, async function (done) { - sensor.once(1, callback); - setTimeout(()=>{ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5); + } catch (error) { + console.info(error); expect(true).assertTrue(); done(); - }, 500); + } }) /* @@ -152,16 +154,13 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest006", 0, async function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest006 on error'); - expect(false).assertTrue(); - done(); - } - sensor.once(-1, onceSensorCallback); - setTimeout(()=>{ + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); expect(true).assertTrue(); done(); - }, 500); + } }) /* @@ -170,13 +169,14 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest007", 0, function () { - function onceSensorCallback(data) { + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { console.info('SensorJsTest007 on error'); expect(false).assertTrue(); done(); } - sensor.once(1, onceSensorCallback, 5); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); setTimeout(()=>{ expect(true).assertTrue(); done(); @@ -190,11 +190,18 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest008", 0, async function (done) { - sensor.off(-1, callback); - setTimeout(()=>{ + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); expect(true).assertTrue(); done(); - }, 500); + } }) /* @@ -204,17 +211,14 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest009", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest009 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(1, onSensorCallback); - sensor.off(1, onSensorCallback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ - expect(true).assertTrue(); + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest009 off end---------------------------'); done(); - }, 500); + }, 1000); }) /* @@ -224,16 +228,19 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest010", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest010 on error'); - expect(false).assertTrue(); - done(); - } - sensor.off(1000000, onSensorCallback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ - expect(true).assertTrue(); - done(); + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); }) /* @@ -243,11 +250,12 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest011", 0, async function (done) { - sensor.on(1, callback); - sensor.on(1, callback2); + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(1); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); console.info('----------------------SensorJsTest011 off end---------------------------'); done(); }, 1000); @@ -260,81 +268,37 @@ describe("SensorJsTest", function () { * @tc.require: Issue Number */ it("SensorJsTest012", 0, async function (done) { - sensor.on(1, callback); - sensor.on(1, callback2); + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(1, callback); - sensor.off(1, callback2); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); console.info('----------------------SensorJsTest012 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, function () { - sensor.off(1, 5); - expect(true).assertTrue(); - }) - - /* - * @tc.name:SensorJsTest014 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest014", 0, async function (done) { - console.info('----------------------SensorJsTest014---------------------------'); - sensor.on(1, callback, {'interval': 100000000}); - sensor.once(1, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest014 off in---------------------------'); - sensor.off(1, callback); - sensor.off(1, callback2); - console.info('----------------------SensorJsTest014 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest015 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest015", 0, async function (done) { - console.info('----------------------SensorJsTest015---------------------------'); - sensor.on(1, callback, {'interval': 100000000}); - sensor.on(1, callback2, {'interval': 100000000}); + }, 500); setTimeout(()=>{ - console.info('----------------------SensorJsTest015 off in---------------------------'); - sensor.off(1, callback); - sensor.off(1, callback2); - console.info('----------------------SensorJsTest015 off end---------------------------'); + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); done(); }, 1000); }) /* - * @tc.name:SensorJsTest016 + * @tc.name:SensorJsTest013 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest016", 0, async function (done) { - console.info('----------------------SensorJsTest016---------------------------'); - sensor.on(1, callback, {'interval': 100000000}); - sensor.on(1, callback2, {'interval': 100000000}); + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------SensorJsTest016 off in---------------------------'); - sensor.off(1); - console.info('----------------------SensorJsTest016 off end---------------------------'); + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + console.info('----------------------SensorJsTest013 off end---------------------------'); done(); }, 1000); }) -}) +}) \ No newline at end of file -- Gitee From 2b27fc674959107545e3cefc46027d5ff6058174 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 25 Apr 2022 15:59:36 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/test/ExampleJsunit.test_acc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/plugin/test/ExampleJsunit.test_acc.js b/interfaces/plugin/test/ExampleJsunit.test_acc.js index eea2572a..4b544364 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_acc.js +++ b/interfaces/plugin/test/ExampleJsunit.test_acc.js @@ -96,7 +96,7 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest003", 0, function (done) { + it("SensorJsTest003", 0, async function (done) { console.info('----------------------SensorJsTest003---------------------------'); function onSensorCallback(data) { console.info('SensorJsTest003 on error'); @@ -132,7 +132,7 @@ describe("SensorJsTest", function () { * @tc.type: FUNC * @tc.require: Issue Number */ - it("SensorJsTest005", 0, function (done) { + it("SensorJsTest005", 0, async function (done) { function onceSensorCallback(data) { console.info('SensorJsTest005 on error'); expect(false).assertTrue(); -- Gitee From c51c3d312dd296517b0866ac173bd9e2f2f6da91 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 5 May 2022 11:18:02 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=85=89=E3=80=81=E9=87=8D=E5=8A=9B=E7=AD=89=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E8=AE=A2=E9=98=85=E5=8F=8A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../test/ExampleJsunit.test_ambientlight.js | 301 +++++++++++++++++ .../plugin/test/ExampleJsunit.test_gravity.js | 305 +++++++++++++++++ .../test/ExampleJsunit.test_magnetic.js | 305 +++++++++++++++++ .../test/ExampleJsunit.test_orientating.js | 305 +++++++++++++++++ .../test/ExampleJsunit.test_rotatingvector.js | 307 ++++++++++++++++++ 5 files changed, 1523 insertions(+) create mode 100644 interfaces/plugin/test/ExampleJsunit.test_ambientlight.js create mode 100644 interfaces/plugin/test/ExampleJsunit.test_gravity.js create mode 100644 interfaces/plugin/test/ExampleJsunit.test_magnetic.js create mode 100644 interfaces/plugin/test/ExampleJsunit.test_orientating.js create mode 100644 interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js diff --git a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js new file mode 100644 index 00000000..ca0e5e8b --- /dev/null +++ b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js @@ -0,0 +1,301 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@ohos.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof(data.intensity)).assertEqual("number"); + } + + function callback2() { + console.info("callback2" + JSON.stringify(data)); + expect(typeof(data.intensity)).assertEqual("number"); + } + + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + /* + * @tc.name:SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest001", 0, async function (done) { + console.info('----------------------SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest002", 0, async function (done) { + console.info('----------------------SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------SensorJsTest002 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onceSensorCallback, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest006", 0, async function (done) { + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest008", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------SensorJsTest009 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_gravity.js b/interfaces/plugin/test/ExampleJsunit.test_gravity.js new file mode 100644 index 00000000..954d3944 --- /dev/null +++ b/interfaces/plugin/test/ExampleJsunit.test_gravity.js @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@system.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + } + + function callback2() { + console.info("callback2" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + } + + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + /* + * @tc.name:SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest001", 0, async function (done) { + console.info('----------------------SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest002", 0, async function (done) { + console.info('----------------------SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + console.info('----------------------SensorJsTest002 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onceSensorCallback, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest006", 0, async function (done) { + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest008", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + console.info('----------------------SensorJsTest009 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + console.info('----------------------SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + console.info('----------------------SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js new file mode 100644 index 00000000..1068bad8 --- /dev/null +++ b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@system.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + } + + function callback2() { + console.info("callback2" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + } + + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + /* + * @tc.name:SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest001", 0, async function (done) { + console.info('----------------------SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest002", 0, async function (done) { + console.info('----------------------SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + console.info('----------------------SensorJsTest002 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.getGeomagneticField, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.getGeomagneticField, onceSensorCallback, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest006", 0, async function (done) { + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.getGeomagneticField, onSensorCallback); + sensor.off(sensor.SensorType.getGeomagneticField, onSensorCallback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest008", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.getGeomagneticField, callback); + sensor.on(sensor.SensorType.getGeomagneticField, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField); + console.info('----------------------SensorJsTest009 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.getGeomagneticField, callback); + sensor.on(sensor.SensorType.getGeomagneticField, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.getGeomagneticField, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField); + console.info('----------------------SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.getGeomagneticField, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.getGeomagneticField, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.getGeomagneticField); + console.info('----------------------SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_orientating.js b/interfaces/plugin/test/ExampleJsunit.test_orientating.js new file mode 100644 index 00000000..2178c111 --- /dev/null +++ b/interfaces/plugin/test/ExampleJsunit.test_orientating.js @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@ohos.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof(data.beta)).assertEqual("number"); + expect(typeof(data.gamma)).assertEqual("number"); + expect(typeof(data.alpha)).assertEqual("number"); + } + + function callback2() { + console.info("callback2" + JSON.stringify(data)); + expect(typeof(data.beta)).assertEqual("number"); + expect(typeof(data.gamma)).assertEqual("number"); + expect(typeof(data.alpha)).assertEqual("number"); + } + + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + /* + * @tc.name:SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest001", 0, async function (done) { + console.info('----------------------SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest002", 0, async function (done) { + console.info('----------------------SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + console.info('----------------------SensorJsTest002 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onceSensorCallback, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest006", 0, async function (done) { + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest008", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + console.info('----------------------SensorJsTest009 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + console.info('----------------------SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + console.info('----------------------SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js b/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js new file mode 100644 index 00000000..4451ad4f --- /dev/null +++ b/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@ohos.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + expect(typeof(data.w)).assertEqual("number"); + } + + function callback2() { + console.info("callback2" + JSON.stringify(data)); + expect(typeof(data.x)).assertEqual("number"); + expect(typeof(data.y)).assertEqual("number"); + expect(typeof(data.z)).assertEqual("number"); + expect(typeof(data.w)).assertEqual("number"); + } + + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + /* + * @tc.name:SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest001", 0, async function (done) { + console.info('----------------------SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest002", 0, async function (done) { + console.info('----------------------SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + console.info('----------------------SensorJsTest002 off end---------------------------'); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest003", 0, function (done) { + console.info('----------------------SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback, {'interval': 100000000}, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest004", 0, async function (done) { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest005", 0, function (done) { + function onceSensorCallback(data) { + console.info('SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try{ + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onceSensorCallback, 5); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest006", 0, async function (done) { + try { + sensor.off(string, ""); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest007", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest008", 0, async function (done) { + function onSensorCallback(data) { + console.info('SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info(error); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest009", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + console.info('----------------------SensorJsTest009 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest010", 0, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + console.info('----------------------SensorJsTest010 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest011", 0, async function (done) { + console.info('----------------------SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + console.info('----------------------SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest012", 0, async function (done) { + console.info('----------------------SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + console.info('----------------------SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SensorJsTest013", 0, async function (done) { + console.info('----------------------SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + console.info('----------------------SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file -- Gitee From 6aad5c00f3e0d78158ee3ca2c35d67edb4e41b56 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Sat, 7 May 2022 10:21:33 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E8=AE=A2=E9=98=85=E5=8F=8A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/test/ExampleJsunit.test_acc.js | 2 +- interfaces/plugin/test/ExampleJsunit.test_ambientlight.js | 2 +- interfaces/plugin/test/ExampleJsunit.test_gravity.js | 2 +- interfaces/plugin/test/ExampleJsunit.test_magnetic.js | 2 +- interfaces/plugin/test/ExampleJsunit.test_orientating.js | 2 +- interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/plugin/test/ExampleJsunit.test_acc.js b/interfaces/plugin/test/ExampleJsunit.test_acc.js index 4b544364..e308fd10 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_acc.js +++ b/interfaces/plugin/test/ExampleJsunit.test_acc.js @@ -24,7 +24,7 @@ describe("SensorJsTest", function () { expect(typeof(data.z)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); diff --git a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js index ca0e5e8b..490ad771 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js +++ b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js @@ -22,7 +22,7 @@ describe("SensorJsTest", function () { expect(typeof(data.intensity)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.intensity)).assertEqual("number"); } diff --git a/interfaces/plugin/test/ExampleJsunit.test_gravity.js b/interfaces/plugin/test/ExampleJsunit.test_gravity.js index 954d3944..2c66aefc 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_gravity.js +++ b/interfaces/plugin/test/ExampleJsunit.test_gravity.js @@ -24,7 +24,7 @@ describe("SensorJsTest", function () { expect(typeof(data.z)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); diff --git a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js index 1068bad8..f27843f6 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js +++ b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js @@ -24,7 +24,7 @@ describe("SensorJsTest", function () { expect(typeof(data.z)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); diff --git a/interfaces/plugin/test/ExampleJsunit.test_orientating.js b/interfaces/plugin/test/ExampleJsunit.test_orientating.js index 2178c111..6516c8e9 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_orientating.js +++ b/interfaces/plugin/test/ExampleJsunit.test_orientating.js @@ -24,7 +24,7 @@ describe("SensorJsTest", function () { expect(typeof(data.alpha)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); diff --git a/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js b/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js index 4451ad4f..ff037dcf 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js +++ b/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js @@ -25,7 +25,7 @@ describe("SensorJsTest", function () { expect(typeof(data.w)).assertEqual("number"); } - function callback2() { + function callback2(data) { console.info("callback2" + JSON.stringify(data)); expect(typeof(data.x)).assertEqual("number"); expect(typeof(data.y)).assertEqual("number"); -- Gitee From 1e3834e486e607cac55f76b36807c77ba0565f2d Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 9 May 2022 16:26:08 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=85=89=E4=BC=A0=E6=84=9F=E5=99=A8=E7=9A=84=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=8F=8A=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../plugin/test/ExampleJsunit.test_gravity.js | 305 ----------------- .../test/ExampleJsunit.test_magnetic.js | 305 ----------------- .../test/ExampleJsunit.test_orientating.js | 305 ----------------- .../test/ExampleJsunit.test_rotatingvector.js | 307 ------------------ 4 files changed, 1222 deletions(-) delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_gravity.js delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_magnetic.js delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_orientating.js delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js diff --git a/interfaces/plugin/test/ExampleJsunit.test_gravity.js b/interfaces/plugin/test/ExampleJsunit.test_gravity.js deleted file mode 100644 index 2c66aefc..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_gravity.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@system.sensor' - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe("SensorJsTest", function () { - function callback(data) { - console.info("callback" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - } - - function callback2(data) { - console.info("callback2" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - } - - beforeAll(function() { - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function() { - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function() { - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function() { - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.name:SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest001", 0, async function (done) { - console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest002 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest002", 0, async function (done) { - console.info('----------------------SensorJsTest002---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); - console.info('----------------------SensorJsTest002 off end---------------------------'); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest003", 0, function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest003 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback, {'interval': 100000000}, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest004 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest004", 0, async function (done) { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest005 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest005", 0, function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest005 on error'); - expect(false).assertTrue(); - done(); - } - try{ - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onceSensorCallback, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest006 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest006", 0, async function (done) { - try { - sensor.off(string, ""); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest007 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest007", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest007 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest008 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest008", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest008 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest009 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest009", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); - console.info('----------------------SensorJsTest009 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest010 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest010", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - console.info('----------------------SensorJsTest010 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); - console.info('----------------------SensorJsTest010 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest011 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest011", 0, async function (done) { - console.info('----------------------SensorJsTest011---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); - console.info('----------------------SensorJsTest011 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest012 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest012", 0, async function (done) { - console.info('----------------------SensorJsTest012---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest013 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); - console.info('----------------------SensorJsTest013 off end---------------------------'); - done(); - }, 1000); - }) -}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js deleted file mode 100644 index f27843f6..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@system.sensor' - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe("SensorJsTest", function () { - function callback(data) { - console.info("callback" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - } - - function callback2(data) { - console.info("callback2" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - } - - beforeAll(function() { - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function() { - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function() { - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function() { - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.name:SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest001", 0, async function (done) { - console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); - setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest002 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest002", 0, async function (done) { - console.info('----------------------SensorJsTest002---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); - console.info('----------------------SensorJsTest002 off end---------------------------'); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest003", 0, function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest003 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, onSensorCallback, {'interval': 100000000}, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest004 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest004", 0, async function (done) { - sensor.once(sensor.SensorType.getGeomagneticField, callback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest005 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest005", 0, function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest005 on error'); - expect(false).assertTrue(); - done(); - } - try{ - sensor.once(sensor.SensorType.getGeomagneticField, onceSensorCallback, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest006 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest006", 0, async function (done) { - try { - sensor.off(string, ""); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest007 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest007", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest007 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(sensor.SensorType.getGeomagneticField, onSensorCallback); - sensor.off(sensor.SensorType.getGeomagneticField, onSensorCallback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest008 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest008", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest008 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest009 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest009", 0, async function (done) { - sensor.on(sensor.SensorType.getGeomagneticField, callback); - sensor.on(sensor.SensorType.getGeomagneticField, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField); - console.info('----------------------SensorJsTest009 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest010 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest010", 0, async function (done) { - sensor.on(sensor.SensorType.getGeomagneticField, callback); - sensor.on(sensor.SensorType.getGeomagneticField, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField, callback); - console.info('----------------------SensorJsTest010 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField, callback2); - console.info('----------------------SensorJsTest010 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest011 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest011", 0, async function (done) { - console.info('----------------------SensorJsTest011---------------------------'); - sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.getGeomagneticField, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField); - console.info('----------------------SensorJsTest011 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest012 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest012", 0, async function (done) { - console.info('----------------------SensorJsTest012---------------------------'); - sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.getGeomagneticField, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.on(sensor.SensorType.getGeomagneticField, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.getGeomagneticField, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest013 off in---------------------------'); - sensor.off(sensor.SensorType.getGeomagneticField); - console.info('----------------------SensorJsTest013 off end---------------------------'); - done(); - }, 1000); - }) -}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_orientating.js b/interfaces/plugin/test/ExampleJsunit.test_orientating.js deleted file mode 100644 index 6516c8e9..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_orientating.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe("SensorJsTest", function () { - function callback(data) { - console.info("callback" + JSON.stringify(data)); - expect(typeof(data.beta)).assertEqual("number"); - expect(typeof(data.gamma)).assertEqual("number"); - expect(typeof(data.alpha)).assertEqual("number"); - } - - function callback2(data) { - console.info("callback2" + JSON.stringify(data)); - expect(typeof(data.beta)).assertEqual("number"); - expect(typeof(data.gamma)).assertEqual("number"); - expect(typeof(data.alpha)).assertEqual("number"); - } - - beforeAll(function() { - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function() { - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function() { - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function() { - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.name:SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest001", 0, async function (done) { - console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest002 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest002", 0, async function (done) { - console.info('----------------------SensorJsTest002---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); - console.info('----------------------SensorJsTest002 off end---------------------------'); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest003", 0, function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest003 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback, {'interval': 100000000}, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest004 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest004", 0, async function (done) { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest005 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest005", 0, function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest005 on error'); - expect(false).assertTrue(); - done(); - } - try{ - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onceSensorCallback, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest006 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest006", 0, async function (done) { - try { - sensor.off(string, ""); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest007 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest007", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest007 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, onSensorCallback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest008 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest008", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest008 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest009 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest009", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); - console.info('----------------------SensorJsTest009 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest010 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest010", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - console.info('----------------------SensorJsTest010 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); - console.info('----------------------SensorJsTest010 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest011 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest011", 0, async function (done) { - console.info('----------------------SensorJsTest011---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); - console.info('----------------------SensorJsTest011 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest012 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest012", 0, async function (done) { - console.info('----------------------SensorJsTest012---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest013 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); - console.info('----------------------SensorJsTest013 off end---------------------------'); - done(); - }, 1000); - }) -}) \ No newline at end of file diff --git a/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js b/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js deleted file mode 100644 index ff037dcf..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe("SensorJsTest", function () { - function callback(data) { - console.info("callback" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - expect(typeof(data.w)).assertEqual("number"); - } - - function callback2(data) { - console.info("callback2" + JSON.stringify(data)); - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - expect(typeof(data.w)).assertEqual("number"); - } - - beforeAll(function() { - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function() { - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function() { - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function() { - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.name:SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest001", 0, async function (done) { - console.info('----------------------SensorJsTest001---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest002 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest002", 0, async function (done) { - console.info('----------------------SensorJsTest002---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); - console.info('----------------------SensorJsTest002 off end---------------------------'); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest003", 0, function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - function onSensorCallback(data) { - console.info('SensorJsTest003 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback, {'interval': 100000000}, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest004 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest004", 0, async function (done) { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest005 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest005", 0, function (done) { - function onceSensorCallback(data) { - console.info('SensorJsTest005 on error'); - expect(false).assertTrue(); - done(); - } - try{ - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onceSensorCallback, 5); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest006 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest006", 0, async function (done) { - try { - sensor.off(string, ""); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest007 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest007", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest007 on error'); - expect(false).assertTrue(); - done(); - } - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, onSensorCallback); - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }) - - /* - * @tc.name:SensorJsTest008 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest008", 0, async function (done) { - function onSensorCallback(data) { - console.info('SensorJsTest008 on error'); - expect(false).assertTrue(); - done(); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest009 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest009", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); - console.info('----------------------SensorJsTest009 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest010 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest010", 0, async function (done) { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - console.info('----------------------SensorJsTest010 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest010 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); - console.info('----------------------SensorJsTest010 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest011 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest011", 0, async function (done) { - console.info('----------------------SensorJsTest011---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); - console.info('----------------------SensorJsTest011 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest012 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest012", 0, async function (done) { - console.info('----------------------SensorJsTest012---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); - console.info('----------------------SensorJsTest012 off end---------------------------'); - done(); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest013 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); - console.info('----------------------SensorJsTest013 off end---------------------------'); - done(); - }, 1000); - }) -}) \ No newline at end of file -- Gitee From 7d2b8286f55a80590b41258f72af6223caff7a22 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 9 May 2022 16:27:40 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=85=89=E4=BC=A0=E6=84=9F=E5=99=A8=E7=9A=84=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=8F=8A=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/test/ExampleJsunit.test_ambientlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js index 490ad771..95c157dc 100644 --- a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js +++ b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js @@ -27,7 +27,7 @@ describe("SensorJsTest", function () { expect(typeof(data.intensity)).assertEqual("number"); } - beforeAll(function() { + beforeAll(function(data) { /* * @tc.setup: setup invoked before all testcases */ -- Gitee