From fe0f365bd3daabaf6f456653052c3501c00db176 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 26 May 2022 14:28:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=8B=E8=BD=AC?= =?UTF-8?q?=E7=9F=A2=E9=87=8F=E3=80=81=E5=9C=B0=E7=A3=81=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=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_magnetic.js | 305 +++++++++++++++++ .../test/ExampleJsunit.test_rotatingvector.js | 307 ++++++++++++++++++ 2 files changed, 612 insertions(+) create mode 100644 interfaces/plugin/test/ExampleJsunit.test_magnetic.js create mode 100644 interfaces/plugin/test/ExampleJsunit.test_rotatingvector.js diff --git a/interfaces/plugin/test/ExampleJsunit.test_magnetic.js b/interfaces/plugin/test/ExampleJsunit.test_magnetic.js new file mode 100644 index 00000000..3788c3bc --- /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(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.SENSOR_TYPE_ID_MAGNETIC_FIELD, 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_MAGNETIC_FIELD, 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_MAGNETIC_FIELD, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, 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_MAGNETIC_FIELD, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + 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_MAGNETIC_FIELD, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + console.info('----------------------SensorJsTest010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, 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_MAGNETIC_FIELD, callback, {'interval': 100000000}); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2); + setTimeout(()=>{ + console.info('----------------------SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + 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_MAGNETIC_FIELD, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + console.info('----------------------SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, 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_MAGNETIC_FIELD, callback, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + 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..ff037dcf --- /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(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 28b4745301500f91045136faaa6625352b1e71dd Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 26 May 2022 16:14:02 +0800 Subject: [PATCH 2/3] ExampleJsunit.test.js Signed-off-by: li-yaoyao777 --- .../plugin/test/unittest/ExampleJsunit.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interfaces/plugin/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/ExampleJsunit.test.js index 93781b3f..d3e882fd 100644 --- a/interfaces/plugin/test/unittest/ExampleJsunit.test.js +++ b/interfaces/plugin/test/unittest/ExampleJsunit.test.js @@ -65,7 +65,7 @@ describe("SensorJsTest", function () { console.info('----------------------SensorJsTest001---------------------------'); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); setTimeout(()=>{ - sensor.sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); done(); }, 500); }) @@ -103,7 +103,7 @@ describe("SensorJsTest", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------SensorJsTest003 off in---------------------------'); - sensor.sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); console.info('----------------------SensorJsTest003 off end---------------------------'); done(); }, 500); @@ -255,7 +255,7 @@ describe("SensorJsTest", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); console.info('----------------------SensorJsTest011 off end---------------------------'); done(); }, 1000); @@ -311,7 +311,7 @@ describe("SensorJsTest", function () { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); setTimeout(()=>{ console.info('----------------------SensorJsTest014 off in---------------------------'); - sensor.sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); console.info('----------------------SensorJsTest014 off end---------------------------'); done(); }, 1000); @@ -352,7 +352,7 @@ describe("SensorJsTest", function () { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); setTimeout(()=>{ console.info('----------------------SensorJsTest016 off in---------------------------'); - sensor.sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); console.info('----------------------SensorJsTest016 off end---------------------------'); done(); }, 1000); @@ -2447,7 +2447,7 @@ describe("SensorJsTest", function () { */ it('SensorJsTest_103', 0, async function (done) { console.info('SensorJsTest_103 start') - sensor.getAltitude(0, 100, (error, data) => { + sensor.getAltitude(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 100, (error, data) => { if (error) { console.info('SensorJsTest_103 failed'); expect(false).assertTrue(); @@ -2488,7 +2488,7 @@ describe("SensorJsTest", function () { * @tc.author: */ it('SensorJsTest_105', 0, async function (done) { - sensor.getAltitude(0, 100).then((data)=>{ + sensor.getAltitude(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 100).then((data)=>{ console.info("SensorJsTest_104" + data) expect(data).assertEqual(getGeomagneticDipResult[2]) done() @@ -2659,7 +2659,7 @@ describe("SensorJsTest", function () { */ it("SensorJsTest_113", 0, async function (done) { console.info("---------------------------SensorJsTest_113----------------------------------"); - sensor.getSingleSensor(0, (error, data) => { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, (error, data) => { if (error) { console.info('SensorJsTest_113 failed'); expect(false).assertTrue(); -- Gitee From 908442c2083448a27a3e8736a9c936c363bc5f70 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 26 May 2022 17:25:50 +0800 Subject: [PATCH 3/3] ExampleJsunit.test.js Signed-off-by: li-yaoyao777 --- .../plugin/test/unittest/ExampleJsunit.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/plugin/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/ExampleJsunit.test.js index d3e882fd..09467375 100644 --- a/interfaces/plugin/test/unittest/ExampleJsunit.test.js +++ b/interfaces/plugin/test/unittest/ExampleJsunit.test.js @@ -2447,7 +2447,7 @@ describe("SensorJsTest", function () { */ it('SensorJsTest_103', 0, async function (done) { console.info('SensorJsTest_103 start') - sensor.getAltitude(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 100, (error, data) => { + sensor.getAltitude(0, 100, (error, data) => { if (error) { console.info('SensorJsTest_103 failed'); expect(false).assertTrue(); @@ -2488,12 +2488,12 @@ describe("SensorJsTest", function () { * @tc.author: */ it('SensorJsTest_105', 0, async function (done) { - sensor.getAltitude(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 100).then((data)=>{ + sensor.getAltitude(0, 100).then((data)=>{ console.info("SensorJsTest_104" + data) expect(data).assertEqual(getGeomagneticDipResult[2]) done() }, (error)=>{ - console.info('SensorJsTest_104 failed'); + console.info('SensorJsTest_105 failed'); expect(false).assertTrue(); done() }); @@ -2507,11 +2507,11 @@ describe("SensorJsTest", function () { */ it('SensorJsTest_106', 0, async function (done) { sensor.getAltitude(5, 0).then((data)=>{ - console.info("SensorJsTest_104" + data) + console.info("SensorJsTest_106" + data) expect(data).assertEqual(getGeomagneticDipResult[3]) done() }, (error)=>{ - console.info('SensorJsTest_104 failed'); + console.info('SensorJsTest_106 failed'); expect(false).assertTrue(); done() }); @@ -2600,7 +2600,7 @@ describe("SensorJsTest", function () { } done() }, (error)=>{ - console.info('SensorJsTest_109 failed'); + console.info('SensorJsTest_110 failed'); expect(false).assertTrue(); done() }); @@ -2701,7 +2701,7 @@ describe("SensorJsTest", function () { */ it("SensorJsTest_115", 0, async function (done) { console.info("---------------------------SensorJsTest_115----------------------------------"); - sensor.getSingleSensor(0).then((data) => { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER).then((data) => { console.info("SensorJsTest_115 " + JSON.stringify(data)); expect(true).assertTrue(); done() -- Gitee