From 4f0584d69fed13fdcf1f3f1bb97324098c5c0632 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 09:32:40 +0000 Subject: [PATCH 1/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: Ia8b1913d2ac0a95b8e40f5ea805a4c8b8ea987aa --- .../plugin/test/ExampleJsunit.test_acc.js | 304 ----------- .../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 ----------- .../plugin/test/ExampleJsunit.test_system.js | 506 ------------------ .../plugin/test/unittest/gyrscope/BUILD.gn | 22 + .../unittest/gyrscope/ExampleJsunit.test.js | 446 +++++++++++++++ .../plugin/test/unittest/gyrscope/config.json | 73 +++ .../test/unittest/{ => sensor}/BUILD.gn | 5 - .../{ => sensor}/ExampleJsunit.test.js | 0 .../test/unittest/{ => sensor}/config.json | 0 13 files changed, 541 insertions(+), 2338 deletions(-) delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_acc.js delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_ambientlight.js 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 delete mode 100644 interfaces/plugin/test/ExampleJsunit.test_system.js create mode 100644 interfaces/plugin/test/unittest/gyrscope/BUILD.gn create mode 100644 interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js create mode 100644 interfaces/plugin/test/unittest/gyrscope/config.json rename interfaces/plugin/test/unittest/{ => sensor}/BUILD.gn (92%) mode change 100755 => 100644 rename interfaces/plugin/test/unittest/{ => sensor}/ExampleJsunit.test.js (100%) mode change 100755 => 100644 rename interfaces/plugin/test/unittest/{ => sensor}/config.json (100%) mode change 100755 => 100644 diff --git a/interfaces/plugin/test/ExampleJsunit.test_acc.js b/interfaces/plugin/test/ExampleJsunit.test_acc.js deleted file mode 100644 index e308fd10..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_acc.js +++ /dev/null @@ -1,304 +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"); - } - - 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_ACCELEROMETER, callback); - setTimeout(()=>{ - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - 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_ACCELEROMETER, callback, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest002 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - 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, async 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_ACCELEROMETER, 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_ACCELEROMETER, 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, async 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(); - } - }) - - /* - * @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_ACCELEROMETER, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 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_ACCELEROMETER, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest009 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - 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_ACCELEROMETER, callback); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); - setTimeout(()=>{ - 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); - }) - - /* - * @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_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); - setTimeout(()=>{ - console.info('----------------------SensorJsTest011 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); - 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_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); - console.info('----------------------SensorJsTest012 off end---------------------------'); - }, 500); - setTimeout(()=>{ - console.info('----------------------SensorJsTest012 off in---------------------------'); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, 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_ACCELEROMETER, callback, {'interval': 100000000}); - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, {'interval': 100000000}); - setTimeout(()=>{ - 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 diff --git a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js b/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js deleted file mode 100644 index 95c157dc..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_ambientlight.js +++ /dev/null @@ -1,301 +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.intensity)).assertEqual("number"); - } - - function callback2(data) { - console.info("callback2" + JSON.stringify(data)); - expect(typeof(data.intensity)).assertEqual("number"); - } - - beforeAll(function(data) { - /* - * @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 deleted file mode 100644 index c8eb59f6..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 '@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"); - } - - 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 e9a72a58..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 '@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"); - } - - 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_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 diff --git a/interfaces/plugin/test/ExampleJsunit.test_system.js b/interfaces/plugin/test/ExampleJsunit.test_system.js deleted file mode 100644 index b289be70..00000000 --- a/interfaces/plugin/test/ExampleJsunit.test_system.js +++ /dev/null @@ -1,506 +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 () { - 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: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest001", 0, async function (done) { - console.info('----------------------SensorJsTest001---------------------------'); - sensor.subscribeAccelerometer({ - interval: 'normal', - success: function(data) { - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - console.info("SensorJsTest001 success" + JSON.stringify(data)); - }, - fail: function(data, code) { - expect(false).assertTrue(); - console.error('Subscription failed. Code: ' + code + '; Data: ' + data); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeAccelerometer(); - } catch (error) { - console.info('SensorJsTest001 unsubscribe failed' + error); - expect(false).assertTrue(); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest002 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest002", 0, async function (done) { - console.info('----------------------SensorJsTest002---------------------------'); - sensor.subscribeAccelerometer({ - interval: 'xxx', - success: function(data) { - expect(false).assertTrue(); - console.info("SensorJsTest002 success" + JSON.stringify(data)); - done(); - }, - fail: function(data, code) { - expect(true).assertTrue(); - console.error('SensorJsTest002 Subscription failed. Code: ' + code + '; Data: ' + data); - done(); - }, - }); - }) - - /* - * @tc.name:SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest003", 0, async function (done) { - console.info('----------------------SensorJsTest003---------------------------'); - try { - sensor.subscribeAccelerometer({ - interval: 'xxx', - success: function(data) { - expect(false).assertTrue(); - console.info("SensorJsTest003 success" + JSON.stringify(data)); - done(); - } - }); - } catch (error) { - console.info('SensorJsTest003 Subscription failed' + error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest004 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest004", 0, async function (done) { - console.info('----------------------SensorJsTest004---------------------------'); - try { - sensor.subscribeAccelerometer({ - interval: 'normal', - }); - } catch (error) { - console.info('SensorJsTest004 Subscription failed' + error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest005 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest005", 0, async function (done) { - console.info('----------------------SensorJsTest005---------------------------'); - try { - sensor.unsubscribeAccelerometer(); - } 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: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest006", 0, async function (done) { - console.info('----------------------SensorJsTest006---------------------------'); - try { - sensor.unsubscribeAccelerometer('xxx'); - } 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: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest007", 0, async function (done) { - console.info('----------------------SensorJsTest007---------------------------'); - sensor.subscribeCompass({ - success: function(data) { - console.log('SensorJsTest007 get data direction:' + ret.direction); - expect(typeof(data.direction)).assertEqual("number"); - }, - fail: function(data, code) { - console.error('SensorJsTest007 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(false).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeCompass(); - } catch (error) { - console.info(error); - expect(false).assertTrue(); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest008 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest008", 0, async function (done) { - sensor.subscribeProximity({ - success: function(data) { - expect(typeof(data.distance)).assertEqual("number"); - console.info("SensorJsTest008 subscribeProximity" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest008 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(true).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeProximity(); - } catch (error) { - console.info(error); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest009 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest009", 0, function (done) { - sensor.subscribeLight({ - success: function(data) { - expect(typeof(data.intensity)).assertEqual("number"); - console.info("SensorJsTest009 subscribeLight" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest009 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(false).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeLight(); - } catch (error) { - console.info(error); - expect(false).assertTrue(); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest010 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest010", 0, async function (done) { - sensor.subscribeStepCounter({ - success: function(data) { - expect(typeof(data.steps)).assertEqual("number"); - console.info("SensorJsTest010 subscribeStepCounter" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest010 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(true).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeStepCounter(); - } catch (error) { - console.info(error); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest011 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest011", 0, async function (done) { - sensor.subscribeBarometer({ - success: function(data) { - expect(typeof(data.pressure)).assertEqual("number"); - console.info("subscribeBarometer" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest011 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(true).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeBarometer(); - } catch (error) { - console.info(error); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest012 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest012", 0, function (done) { - sensor.subscribeHeartRate({ - success: function(data) { - expect(typeof(data.heartRate)).assertEqual("number"); - console.info("SensorJsTest012 subscribeHeartRate" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest012 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(true).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeHeartRate(); - } catch (error) { - console.info(error); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest013 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest013", 0, async function (done) { - console.info('----------------------SensorJsTest013---------------------------'); - sensor.subscribeOnBodyState({ - success: function(data) { - expect(typeof(data.value)).assertEqual("boolean"); - console.info("SensorJsTest013 subscribeOnBodyState" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest013 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(true).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeOnBodyState(); - } catch (error) { - console.info(error); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest014 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it('SensorJsTest014', 0, async function (done) { - console.info("---------------------------SensorJsTest014----------------------------------"); - try { - sensor.getOnBodyState({ - success: function(data) { - expect(typeof(data.value)).assertEqual("boolean"); - console.info("subscribeOnBodyState" + JSON.stringify(data)); - done(); - } - }); - } catch (error) { - console.info(error); - expect(false).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest015 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it('SensorJsTest015', 0, async function (done) { - console.info("---------------------------SensorJsTest015----------------------------------"); - try { - sensor.getOnBodyState(); - } catch (error) { - console.info(error); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SensorJsTest016 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest016", 0, async function (done) { - console.info('----------------------SensorJsTest016---------------------------'); - sensor.subscribeDeviceOrientation({ - interval: 'normal', - success: function(data) { - expect(typeof(data.alpha)).assertEqual("number"); - expect(typeof(data.beta)).assertEqual("number"); - expect(typeof(data.gamma)).assertEqual("number"); - console.info("SensorJsTest016 subscribeDeviceOrientation" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest016 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(false).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeDeviceOrientation(); - } catch (error) { - console.info(error); - expect(false).assertTrue(); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) - - /* - * @tc.name:SensorJsTest017 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ - it("SensorJsTest017", 0, async function (done) { - console.info('----------------------SensorJsTest017---------------------------'); - sensor.subscribeGyroscope({ - interval: 'normal', - success: function(data) { - expect(typeof(data.x)).assertEqual("number"); - expect(typeof(data.y)).assertEqual("number"); - expect(typeof(data.z)).assertEqual("number"); - console.info("SensorJsTest017 subscribeGyroscope" + JSON.stringify(data)); - }, - fail: function(data, code) { - console.error('SensorJsTest017 Subscription failed. Code: ' + code + '; Data: ' + data); - expect(false).assertTrue(); - }, - }); - setTimeout(()=>{ - try { - sensor.unsubscribeGyroscope(); - } catch (error) { - console.info(error); - expect(false).assertTrue(); - } - setTimeout(()=>{ - expect(true).assertTrue(); - done(); - }, 500); - }, 1000); - }) -}) diff --git a/interfaces/plugin/test/unittest/gyrscope/BUILD.gn b/interfaces/plugin/test/unittest/gyrscope/BUILD.gn new file mode 100644 index 00000000..3e6384fe --- /dev/null +++ b/interfaces/plugin/test/unittest/gyrscope/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (C) 2023 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("//build/test.gni") + +module_output_path = "sensor/interfaces" +ohos_js_unittest("GyrscopeJsTest") { + module_out_path = module_output_path + hap_profile = "./config.json" + certificate_profile = + "//test/testfwk/developer_test/signature/openharmony_sx.p7b" +} diff --git a/interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js new file mode 100644 index 00000000..20a26dd1 --- /dev/null +++ b/interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js @@ -0,0 +1,446 @@ +/* + * Copyright (C) 2023 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 deviceInfo from '@ohos.deviceInfo' +import sensor from '@ohos.sensor' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("GyrscopeJsTest", function () { + var g_execute = false; + 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') + if(deviceInfo.deviceType != "default") { + g_execute = true; + } + }) + + 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') + }) + + const PARAMETER_ERROR_CODE = 401 + const SERVICE_EXCEPTION_CODE = 14500101 + const PARAMETER_ERROR_MSG = 'The parameter invalid.' + const SERVICE_EXCEPTION_MSG = 'Service exception.' + + /* + * @tc.name:GyrscopeJsTest_001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_001", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_001---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.GYROSCOPE); + done(); + }, 500); + } catch (error) { + console.info('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_002", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_002---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval':100000000}); + setTimeout(()=>{ + console.info('------------------GyrscopeJsTest_002 off in-----------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('------------------GyrscopeJsTest_002 off end-----------------------'); + done(); + }, 500); + } catch (error) { + console.info('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_003", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_003---------------------------'); + if(g_execute) { + function onSensorCallback(data) { + console.info('GyrscopeJsTest_003 callback in'); + expect(true).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback, {'interval': 100000000}, 5); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_003 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyrscopeJsTest_003 off end---------------------------'); + done(); + }, 500); + } catch (error) { + console.info('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_004", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_004---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': -100000000}); + console.info('----------------------GyrscopeJsTest_004 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyrscopeJsTest_004 off end---------------------------'); + done(); + } catch (error) { + console.info('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); + expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_005", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_005---------------------------'); + if(g_execute) { + try { + sensor.once(sensor.SensorId.GYROSCOPE, callback); + setTimeout(()=>{ + expect(true).assertTrue(); + done(); + }, 500); + } catch (error) { + console.error('Once fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_006", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_006---------------------------'); + if(g_execute) { + try{ + sensor.once(sensor.SensorId.ACCELEROMETER, callback, 5); + } catch (error) { + console.error('Once fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_007", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_007---------------------------'); + if(g_execute) { + try{ + sensor.once(sensor.SensorId.GYROSCOPE, 5); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_008", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_008---------------------------'); + if(g_execute) { + try { + sensor.off(-1, callback); + } catch (error) { + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_009", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_009---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback); + sensor.on(sensor.SensorId.GYROSCOPE, callback2); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_009 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyrscopeJsTest_009 off end---------------------------'); + done(); + }, 1000); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_010", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_010---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback); + sensor.on(sensor.SensorId.GYROSCOPE, callback2); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_010 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback); + console.info('----------------------GyrscopeJsTest_010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_010 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback2); + console.info('----------------------GyrscopeJsTest_010 off end---------------------------'); + done(); + }, 1000); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_011", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_011---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); + sensor.once(sensor.SensorId.GYROSCOPE, callback2); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_011 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyrscopeJsTest_011 off end---------------------------'); + done(); + }, 1000); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_012", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_012---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); + sensor.on(sensor.SensorId.GYROSCOPE, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_012 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback); + console.info('----------------------GyrscopeJsTest_012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_012 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback2); + console.info('----------------------GyrscopeJsTest_012 off end---------------------------'); + done(); + }, 1000); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:GyrscopeJsTest_013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyrscopeJsTest_013", 0, async function (done) { + console.info('----------------------GyrscopeJsTest_013---------------------------'); + if(g_execute) { + try { + sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); + sensor.on(sensor.SensorId.GYROSCOPE, callback2, {'interval': 100000000}); + setTimeout(()=>{ + console.info('----------------------GyrscopeJsTest_013 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyrscopeJsTest_013 off end---------------------------'); + done(); + }, 1000); + } catch (error) { + console.error('On fail, errCode:' + error.code + ' ,msg:' + error.message); + expect(false).assertTrue(); + done(); + } + } else { + console.info('Non-mobile devices cannot be excluded'); + expect(true).assertTrue(); + done(); + } + }) +}) diff --git a/interfaces/plugin/test/unittest/gyrscope/config.json b/interfaces/plugin/test/unittest/gyrscope/config.json new file mode 100644 index 00000000..b3356791 --- /dev/null +++ b/interfaces/plugin/test/unittest/gyrscope/config.json @@ -0,0 +1,73 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "reqPermissions": [ + { + "name": "ohos.permission.GYROSCOPE", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" + ], + "when": "inuse" + } + } + ], + "package": "com.example.myapplication", + "name": ".myapplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "GyrscopeJsTest", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } + \ No newline at end of file diff --git a/interfaces/plugin/test/unittest/BUILD.gn b/interfaces/plugin/test/unittest/sensor/BUILD.gn old mode 100755 new mode 100644 similarity index 92% rename from interfaces/plugin/test/unittest/BUILD.gn rename to interfaces/plugin/test/unittest/sensor/BUILD.gn index 08ff82dc..ee4adb97 --- a/interfaces/plugin/test/unittest/BUILD.gn +++ b/interfaces/plugin/test/unittest/sensor/BUILD.gn @@ -20,8 +20,3 @@ ohos_js_unittest("SensorJsTest") { certificate_profile = "//test/testfwk/developer_test/signature/openharmony_sx.p7b" } - -group("unittest") { - testonly = true - deps = [ ":SensorJsTest" ] -} diff --git a/interfaces/plugin/test/unittest/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/sensor/ExampleJsunit.test.js old mode 100755 new mode 100644 similarity index 100% rename from interfaces/plugin/test/unittest/ExampleJsunit.test.js rename to interfaces/plugin/test/unittest/sensor/ExampleJsunit.test.js diff --git a/interfaces/plugin/test/unittest/config.json b/interfaces/plugin/test/unittest/sensor/config.json old mode 100755 new mode 100644 similarity index 100% rename from interfaces/plugin/test/unittest/config.json rename to interfaces/plugin/test/unittest/sensor/config.json -- Gitee From 845d7270cb9a347cade943f489e108cf280cc3f7 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 09:55:42 +0000 Subject: [PATCH 2/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: I4dc62ddbac51c21432f88b19e884567c8541daa9 --- bundle.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index 013898ca..37617157 100644 --- a/bundle.json +++ b/bundle.json @@ -60,7 +60,8 @@ } ], "test": [ - "//base/sensors/sensor/interfaces/plugin/test/unittest:unittest", + "//base/sensors/sensor/interfaces/plugin/test/unittest/gyrscope:unittest", + "//base/sensors/sensor/interfaces/plugin/test/unittest/sensor:unittest", "//base/sensors/sensor/interfaces/native/test/fuzztest:fuzztest", "//base/sensors/sensor/interfaces/native/test:unittest" ] -- Gitee From 4e9b12c5af555a49fc87e69829b835c595eb3b7d Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 10:16:08 +0000 Subject: [PATCH 3/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: I30a8d6e3e848f73eb05bf111c2bd2dc70b7120c9 --- bundle.json | 3 +-- interfaces/plugin/test/unittest/BUILD.gn | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 interfaces/plugin/test/unittest/BUILD.gn diff --git a/bundle.json b/bundle.json index 37617157..013898ca 100644 --- a/bundle.json +++ b/bundle.json @@ -60,8 +60,7 @@ } ], "test": [ - "//base/sensors/sensor/interfaces/plugin/test/unittest/gyrscope:unittest", - "//base/sensors/sensor/interfaces/plugin/test/unittest/sensor:unittest", + "//base/sensors/sensor/interfaces/plugin/test/unittest:unittest", "//base/sensors/sensor/interfaces/native/test/fuzztest:fuzztest", "//base/sensors/sensor/interfaces/native/test:unittest" ] diff --git a/interfaces/plugin/test/unittest/BUILD.gn b/interfaces/plugin/test/unittest/BUILD.gn new file mode 100644 index 00000000..d4439fb5 --- /dev/null +++ b/interfaces/plugin/test/unittest/BUILD.gn @@ -0,0 +1,20 @@ +# 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. + +group("unittest") { + testonly = true + deps = [ + "gyrscope:GyrscopeJsTest", + "sensor:SensorJsTest", + ] +} -- Gitee From 59cd4cf78c5600d4c717628d53fcf08a83924416 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 10:32:39 +0000 Subject: [PATCH 4/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: I1a2ed9856624d35f5fc67b7ba3ed558f4563adf7 --- .../plugin/test/unittest/gyrscope/BUILD.gn | 3 +-- .../gyrscope/signature/openharmony_sx.p7b | Bin 0 -> 3437 bytes interfaces/plugin/test/unittest/sensor/BUILD.gn | 3 +-- .../unittest/sensor/signature/openharmony_sx.p7b | Bin 0 -> 3437 bytes 4 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 interfaces/plugin/test/unittest/gyrscope/signature/openharmony_sx.p7b create mode 100644 interfaces/plugin/test/unittest/sensor/signature/openharmony_sx.p7b diff --git a/interfaces/plugin/test/unittest/gyrscope/BUILD.gn b/interfaces/plugin/test/unittest/gyrscope/BUILD.gn index 3e6384fe..390c7bc9 100644 --- a/interfaces/plugin/test/unittest/gyrscope/BUILD.gn +++ b/interfaces/plugin/test/unittest/gyrscope/BUILD.gn @@ -17,6 +17,5 @@ module_output_path = "sensor/interfaces" ohos_js_unittest("GyrscopeJsTest") { module_out_path = module_output_path hap_profile = "./config.json" - certificate_profile = - "//test/testfwk/developer_test/signature/openharmony_sx.p7b" + certificate_profile = "./signature/openharmony_sx.p7b" } diff --git a/interfaces/plugin/test/unittest/gyrscope/signature/openharmony_sx.p7b b/interfaces/plugin/test/unittest/gyrscope/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 GIT binary patch literal 3437 zcmcgvX>b$g8MY4FF(5FQyMT=#m||qU)nQ9cId-MBB-<-lvSdq&snM}IENNF>t+bK| zgowuF2vC|SxSZxNN5eHhV%(WPpbeB9Fc3;JDMtzMBv1-XAc2N~c2_tCXW&OCGw6qQ z-s9VS-tT?h=bI0tMS+~WDXqHJyCPmLzdbE-fV8Nd&*MRZfG8(#POFZG3xs@Lb{0ry z=R8j3wWo!5g=yjKx#BoZMFS)uA)H}cTp@-^K`9VV?RC3J59@}eik*>n|pRKOLZ zxdn7G!Yv@9O#y<&eUy{)vMXb;fQR)ffVAADQsEMXm;IBMDLfLD0w^U;6%HVo-0Q_5 zCHEa?DBuauNpZzoF+tK27w#n~?u%toS-DhR4k@Q*{7x^8Q=D6&kd^_~J#VVG2LXkL zaAy=}U*?Jto)9hx5MGjdp9hcQAu@tfk_;l!PeyxPY<8b&+&D!CyaBh9=8BSVKLpk4 z4Ml3yY|&Th)vyK4cpC{!uU8v2YBlVV`d~(nz&<@{G1oe*DHub1z7~J5*;s2bX<)_* zV_GbsPQg`(&rpxRb_*Od7}++3+liSw-$!1 zs5*g}EHWhI3i|!-FcfzYL0`SL-rq>LENC;PMl)G(0(1U2%Va|smp0UFx0xd@soZA* zD5LYc4OlbE7@ARt#h}rr3>K@bf%B#^-c+xz8Hr)0D5ExIFltezN@Hn8>o5d~bSfYtkc+_Z&kI#-N5_GhCg*V-^TSO=!G~ z(fXy{n2XV+k}6w_W`dTOP2a4u0ly;ANZ>4OxSKAzFB!yBzdo`gX zO?o|H@WiAw$y6l?=^3jA_Hy0S)nTYs12;4hKE&ekQ|>?|ZLJ}#F`2BczC7kdE4@xV zZBD_)Otwjhz+NSaz?d45!;FsGSu-#qh#hStD%B}f!mCT!KqzSo>I`NGH_9Dea$1Qi zg29Ydt!~lQVR99_T7#Hije~(12drl-P)SV?QR*9sus`8th-8^OQ7@xI$(Yp|^;bL1 zR50O$mDXw6P>i7B(TJ)ciPzTE>XY%X6HAa)b#OBRXv&~%Bw|J#Y><i4=e%95bjtw|cJp=#P#Pf#*luqI_wR;fISDCJhAqSG6R%xItn%~QtZ@m%&u zjGGLX;t6Ls62eQvNmf@v+}J%54^CygxRZ`?8X#r|wkev7(s;Ou4T#y1XNNf)h;o7z z8a^Lfq<1uH`E{G9E z*(=)Css_LSk=>E9jr)s5^2-!+MN=Ds}>1hRma4`uCIz9%p3O77839E{xf z4c_I?**|1`K2tg4!Hvyrou4BsJQuv*UfF)<%CelYIS>D^o?X)3+MK%la6kooW8&G@BU)Y0hT`+mOm$Z_%rB=a%o>I z!2c6lHyKQN)VjiFwa!eE^p8jc$sy$vB+8i25lI~6KPFFh$!o$avA~rj#L6xvR|Z83 z*WD6T9e+5Pyy=F+)pNTf{ny3cy>7Rkd3o*TS?TZJ`NS^NF2%HMkyS{?uJ$`!P4_L^ z1`NFDUbNyg_qREifgktnp1_v{Jbb`7m}2PTyUdOmtJj~m z9bB=ecw4_^rw1IW=of+>nrW5=d3k`3qHCxsIN_F{T1A545};;+fsyC&qChi+YV zr~M63H8ZLCPYmsjY>ls9cL%I)F|JIW-#+48$+lD4k*(P*kDM%zx_fvu4u5ZYUnI}5 zdrycFq>xFU)&X3p@pP2u%$o}}YcRn(MhJ&B2o?KS@cIVz>Ye%o^xV?CB{_Qhu z;}_q1bvO^g{8<3!gYbo4Di{8qzV+(9 zdlmksohQmRTs@qB;(Wo?dER_ux6XQb@q$tQPW?CMu6GVQd;R=iR;-S{Kr%Zks7>b1 zNs{|-+jhObYE}NR&`TGGr^h^4bjh%c>R#@=8nM&Md>_a+zVulsl;){flFekV1t9ob z+SqfV_Pv3$2f)bQ8%Ul2>fdYR^1zs0BQF~olsOj5AodC&Q_7SMFzsz2 z9newxE&jodk~tNHwl%LBMMDbrk=(^b literal 0 HcmV?d00001 diff --git a/interfaces/plugin/test/unittest/sensor/BUILD.gn b/interfaces/plugin/test/unittest/sensor/BUILD.gn index ee4adb97..1e7d26c0 100644 --- a/interfaces/plugin/test/unittest/sensor/BUILD.gn +++ b/interfaces/plugin/test/unittest/sensor/BUILD.gn @@ -17,6 +17,5 @@ module_output_path = "sensor/interfaces" ohos_js_unittest("SensorJsTest") { module_out_path = module_output_path hap_profile = "./config.json" - certificate_profile = - "//test/testfwk/developer_test/signature/openharmony_sx.p7b" + certificate_profile = "./signature/openharmony_sx.p7b" } diff --git a/interfaces/plugin/test/unittest/sensor/signature/openharmony_sx.p7b b/interfaces/plugin/test/unittest/sensor/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 GIT binary patch literal 3437 zcmcgvX>b$g8MY4FF(5FQyMT=#m||qU)nQ9cId-MBB-<-lvSdq&snM}IENNF>t+bK| zgowuF2vC|SxSZxNN5eHhV%(WPpbeB9Fc3;JDMtzMBv1-XAc2N~c2_tCXW&OCGw6qQ z-s9VS-tT?h=bI0tMS+~WDXqHJyCPmLzdbE-fV8Nd&*MRZfG8(#POFZG3xs@Lb{0ry z=R8j3wWo!5g=yjKx#BoZMFS)uA)H}cTp@-^K`9VV?RC3J59@}eik*>n|pRKOLZ zxdn7G!Yv@9O#y<&eUy{)vMXb;fQR)ffVAADQsEMXm;IBMDLfLD0w^U;6%HVo-0Q_5 zCHEa?DBuauNpZzoF+tK27w#n~?u%toS-DhR4k@Q*{7x^8Q=D6&kd^_~J#VVG2LXkL zaAy=}U*?Jto)9hx5MGjdp9hcQAu@tfk_;l!PeyxPY<8b&+&D!CyaBh9=8BSVKLpk4 z4Ml3yY|&Th)vyK4cpC{!uU8v2YBlVV`d~(nz&<@{G1oe*DHub1z7~J5*;s2bX<)_* zV_GbsPQg`(&rpxRb_*Od7}++3+liSw-$!1 zs5*g}EHWhI3i|!-FcfzYL0`SL-rq>LENC;PMl)G(0(1U2%Va|smp0UFx0xd@soZA* zD5LYc4OlbE7@ARt#h}rr3>K@bf%B#^-c+xz8Hr)0D5ExIFltezN@Hn8>o5d~bSfYtkc+_Z&kI#-N5_GhCg*V-^TSO=!G~ z(fXy{n2XV+k}6w_W`dTOP2a4u0ly;ANZ>4OxSKAzFB!yBzdo`gX zO?o|H@WiAw$y6l?=^3jA_Hy0S)nTYs12;4hKE&ekQ|>?|ZLJ}#F`2BczC7kdE4@xV zZBD_)Otwjhz+NSaz?d45!;FsGSu-#qh#hStD%B}f!mCT!KqzSo>I`NGH_9Dea$1Qi zg29Ydt!~lQVR99_T7#Hije~(12drl-P)SV?QR*9sus`8th-8^OQ7@xI$(Yp|^;bL1 zR50O$mDXw6P>i7B(TJ)ciPzTE>XY%X6HAa)b#OBRXv&~%Bw|J#Y><i4=e%95bjtw|cJp=#P#Pf#*luqI_wR;fISDCJhAqSG6R%xItn%~QtZ@m%&u zjGGLX;t6Ls62eQvNmf@v+}J%54^CygxRZ`?8X#r|wkev7(s;Ou4T#y1XNNf)h;o7z z8a^Lfq<1uH`E{G9E z*(=)Css_LSk=>E9jr)s5^2-!+MN=Ds}>1hRma4`uCIz9%p3O77839E{xf z4c_I?**|1`K2tg4!Hvyrou4BsJQuv*UfF)<%CelYIS>D^o?X)3+MK%la6kooW8&G@BU)Y0hT`+mOm$Z_%rB=a%o>I z!2c6lHyKQN)VjiFwa!eE^p8jc$sy$vB+8i25lI~6KPFFh$!o$avA~rj#L6xvR|Z83 z*WD6T9e+5Pyy=F+)pNTf{ny3cy>7Rkd3o*TS?TZJ`NS^NF2%HMkyS{?uJ$`!P4_L^ z1`NFDUbNyg_qREifgktnp1_v{Jbb`7m}2PTyUdOmtJj~m z9bB=ecw4_^rw1IW=of+>nrW5=d3k`3qHCxsIN_F{T1A545};;+fsyC&qChi+YV zr~M63H8ZLCPYmsjY>ls9cL%I)F|JIW-#+48$+lD4k*(P*kDM%zx_fvu4u5ZYUnI}5 zdrycFq>xFU)&X3p@pP2u%$o}}YcRn(MhJ&B2o?KS@cIVz>Ye%o^xV?CB{_Qhu z;}_q1bvO^g{8<3!gYbo4Di{8qzV+(9 zdlmksohQmRTs@qB;(Wo?dER_ux6XQb@q$tQPW?CMu6GVQd;R=iR;-S{Kr%Zks7>b1 zNs{|-+jhObYE}NR&`TGGr^h^4bjh%c>R#@=8nM&Md>_a+zVulsl;){flFekV1t9ob z+SqfV_Pv3$2f)bQ8%Ul2>fdYR^1zs0BQF~olsOj5AodC&Q_7SMFzsz2 z9newxE&jodk~tNHwl%LBMMDbrk=(^b literal 0 HcmV?d00001 -- Gitee From eee6ece1bb8770db3f5d116a64583c1263399e25 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 11:08:17 +0000 Subject: [PATCH 5/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: I4acfe44e51dc74b243f3567f9e54c306e6b3a846 --- interfaces/plugin/test/unittest/gyrscope/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interfaces/plugin/test/unittest/gyrscope/config.json b/interfaces/plugin/test/unittest/gyrscope/config.json index b3356791..4b3a0374 100644 --- a/interfaces/plugin/test/unittest/gyrscope/config.json +++ b/interfaces/plugin/test/unittest/gyrscope/config.json @@ -28,7 +28,8 @@ "package": "com.example.myapplication", "name": ".myapplication", "deviceType": [ - "phone" + "default", + "tablet" ], "distro": { "deliveryWithInstall": true, -- Gitee From 22fd10da1d3d1a947f5dabe684a9c88c1966fe17 Mon Sep 17 00:00:00 2001 From: hui1975 Date: Fri, 3 Feb 2023 12:08:53 +0000 Subject: [PATCH 6/6] add gyroscope test cases Signed-off-by: hui1975 Change-Id: Icc5cb1060e2ee913472bf19203335ea34c5ef2b6 --- interfaces/plugin/test/unittest/BUILD.gn | 2 +- .../unittest/{gyrscope => gyroscope}/BUILD.gn | 2 +- .../ExampleJsunit.test.js | 122 +++++++++--------- .../{gyrscope => gyroscope}/config.json | 2 +- .../signature/openharmony_sx.p7b | Bin 5 files changed, 64 insertions(+), 64 deletions(-) rename interfaces/plugin/test/unittest/{gyrscope => gyroscope}/BUILD.gn (95%) rename interfaces/plugin/test/unittest/{gyrscope => gyroscope}/ExampleJsunit.test.js (72%) rename interfaces/plugin/test/unittest/{gyrscope => gyroscope}/config.json (93%) rename interfaces/plugin/test/unittest/{gyrscope => gyroscope}/signature/openharmony_sx.p7b (100%) diff --git a/interfaces/plugin/test/unittest/BUILD.gn b/interfaces/plugin/test/unittest/BUILD.gn index d4439fb5..daf71924 100644 --- a/interfaces/plugin/test/unittest/BUILD.gn +++ b/interfaces/plugin/test/unittest/BUILD.gn @@ -14,7 +14,7 @@ group("unittest") { testonly = true deps = [ - "gyrscope:GyrscopeJsTest", + "gyroscope:GyroscopeJsTest", "sensor:SensorJsTest", ] } diff --git a/interfaces/plugin/test/unittest/gyrscope/BUILD.gn b/interfaces/plugin/test/unittest/gyroscope/BUILD.gn similarity index 95% rename from interfaces/plugin/test/unittest/gyrscope/BUILD.gn rename to interfaces/plugin/test/unittest/gyroscope/BUILD.gn index 390c7bc9..87a6bd5f 100644 --- a/interfaces/plugin/test/unittest/gyrscope/BUILD.gn +++ b/interfaces/plugin/test/unittest/gyroscope/BUILD.gn @@ -14,7 +14,7 @@ import("//build/test.gni") module_output_path = "sensor/interfaces" -ohos_js_unittest("GyrscopeJsTest") { +ohos_js_unittest("GyroscopeJsTest") { module_out_path = module_output_path hap_profile = "./config.json" certificate_profile = "./signature/openharmony_sx.p7b" diff --git a/interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/gyroscope/ExampleJsunit.test.js similarity index 72% rename from interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js rename to interfaces/plugin/test/unittest/gyroscope/ExampleJsunit.test.js index 20a26dd1..5ace8866 100644 --- a/interfaces/plugin/test/unittest/gyrscope/ExampleJsunit.test.js +++ b/interfaces/plugin/test/unittest/gyroscope/ExampleJsunit.test.js @@ -17,7 +17,7 @@ import sensor from '@ohos.sensor' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -describe("GyrscopeJsTest", function () { +describe("GyroscopeJsTest", function () { var g_execute = false; function callback(data) { console.info("callback" + JSON.stringify(data)); @@ -70,13 +70,13 @@ describe("GyrscopeJsTest", function () { const SERVICE_EXCEPTION_MSG = 'Service exception.' /* - * @tc.name:GyrscopeJsTest_001 + * @tc.name:GyroscopeJsTest_001 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_001", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_001---------------------------'); + it("GyroscopeJsTest_001", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_001---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback); @@ -97,20 +97,20 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_002 + * @tc.name:GyroscopeJsTest_002 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_002", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_002---------------------------'); + it("GyroscopeJsTest_002", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_002---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval':100000000}); setTimeout(()=>{ - console.info('------------------GyrscopeJsTest_002 off in-----------------------'); + console.info('------------------GyroscopeJsTest_002 off in-----------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('------------------GyrscopeJsTest_002 off end-----------------------'); + console.info('------------------GyroscopeJsTest_002 off end-----------------------'); done(); }, 500); } catch (error) { @@ -126,25 +126,25 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_003 + * @tc.name:GyroscopeJsTest_003 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_003", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_003---------------------------'); + it("GyroscopeJsTest_003", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_003---------------------------'); if(g_execute) { function onSensorCallback(data) { - console.info('GyrscopeJsTest_003 callback in'); + console.info('GyroscopeJsTest_003 callback in'); expect(true).assertTrue(); done(); } try { sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_003 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_003 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------GyrscopeJsTest_003 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_003 off end---------------------------'); done(); }, 500); } catch (error) { @@ -160,19 +160,19 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_004 + * @tc.name:GyroscopeJsTest_004 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_004", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_004---------------------------'); + it("GyroscopeJsTest_004", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_004---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': -100000000}); - console.info('----------------------GyrscopeJsTest_004 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_004 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------GyrscopeJsTest_004 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_004 off end---------------------------'); done(); } catch (error) { console.info('On fail, errCode:' + error.code + ' ,msg:' + error.message); @@ -188,13 +188,13 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_005 + * @tc.name:GyroscopeJsTest_005 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_005", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_005---------------------------'); + it("GyroscopeJsTest_005", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_005---------------------------'); if(g_execute) { try { sensor.once(sensor.SensorId.GYROSCOPE, callback); @@ -215,13 +215,13 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_006 + * @tc.name:GyroscopeJsTest_006 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_006", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_006---------------------------'); + it("GyroscopeJsTest_006", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_006---------------------------'); if(g_execute) { try{ sensor.once(sensor.SensorId.ACCELEROMETER, callback, 5); @@ -238,13 +238,13 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_007 + * @tc.name:GyroscopeJsTest_007 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_007", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_007---------------------------'); + it("GyroscopeJsTest_007", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_007---------------------------'); if(g_execute) { try{ sensor.once(sensor.SensorId.GYROSCOPE, 5); @@ -262,13 +262,13 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_008 + * @tc.name:GyroscopeJsTest_008 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_008", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_008---------------------------'); + it("GyroscopeJsTest_008", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_008---------------------------'); if(g_execute) { try { sensor.off(-1, callback); @@ -285,21 +285,21 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_009 + * @tc.name:GyroscopeJsTest_009 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_009", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_009---------------------------'); + it("GyroscopeJsTest_009", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_009---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback); sensor.on(sensor.SensorId.GYROSCOPE, callback2); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_009 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_009 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------GyrscopeJsTest_009 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_009 off end---------------------------'); done(); }, 1000); } catch (error) { @@ -315,26 +315,26 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_010 + * @tc.name:GyroscopeJsTest_010 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_010", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_010---------------------------'); + it("GyroscopeJsTest_010", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_010---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback); sensor.on(sensor.SensorId.GYROSCOPE, callback2); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_010 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_010 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback); - console.info('----------------------GyrscopeJsTest_010 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_010 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_010 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_010 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback2); - console.info('----------------------GyrscopeJsTest_010 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_010 off end---------------------------'); done(); }, 1000); } catch (error) { @@ -350,21 +350,21 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_011 + * @tc.name:GyroscopeJsTest_011 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_011", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_011---------------------------'); + it("GyroscopeJsTest_011", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_011---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); sensor.once(sensor.SensorId.GYROSCOPE, callback2); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_011 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_011 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------GyrscopeJsTest_011 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_011 off end---------------------------'); done(); }, 1000); } catch (error) { @@ -380,26 +380,26 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_012 + * @tc.name:GyroscopeJsTest_012 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_012", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_012---------------------------'); + it("GyroscopeJsTest_012", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_012---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); sensor.on(sensor.SensorId.GYROSCOPE, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_012 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_012 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback); - console.info('----------------------GyrscopeJsTest_012 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_012 off end---------------------------'); }, 500); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_012 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_012 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback2); - console.info('----------------------GyrscopeJsTest_012 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_012 off end---------------------------'); done(); }, 1000); } catch (error) { @@ -415,21 +415,21 @@ describe("GyrscopeJsTest", function () { }) /* - * @tc.name:GyrscopeJsTest_013 + * @tc.name:GyroscopeJsTest_013 * @tc.desc:verify app info is not null * @tc.type: FUNC * @tc.require: Issue Number */ - it("GyrscopeJsTest_013", 0, async function (done) { - console.info('----------------------GyrscopeJsTest_013---------------------------'); + it("GyroscopeJsTest_013", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_013---------------------------'); if(g_execute) { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); sensor.on(sensor.SensorId.GYROSCOPE, callback2, {'interval': 100000000}); setTimeout(()=>{ - console.info('----------------------GyrscopeJsTest_013 off in---------------------------'); + console.info('----------------------GyroscopeJsTest_013 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------GyrscopeJsTest_013 off end---------------------------'); + console.info('----------------------GyroscopeJsTest_013 off end---------------------------'); done(); }, 1000); } catch (error) { diff --git a/interfaces/plugin/test/unittest/gyrscope/config.json b/interfaces/plugin/test/unittest/gyroscope/config.json similarity index 93% rename from interfaces/plugin/test/unittest/gyrscope/config.json rename to interfaces/plugin/test/unittest/gyroscope/config.json index 4b3a0374..6baaf375 100644 --- a/interfaces/plugin/test/unittest/gyrscope/config.json +++ b/interfaces/plugin/test/unittest/gyroscope/config.json @@ -52,7 +52,7 @@ "name": "com.example.myapplication.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", - "label": "GyrscopeJsTest", + "label": "GyroscopeJsTest", "type": "page", "launchType": "standard" } diff --git a/interfaces/plugin/test/unittest/gyrscope/signature/openharmony_sx.p7b b/interfaces/plugin/test/unittest/gyroscope/signature/openharmony_sx.p7b similarity index 100% rename from interfaces/plugin/test/unittest/gyrscope/signature/openharmony_sx.p7b rename to interfaces/plugin/test/unittest/gyroscope/signature/openharmony_sx.p7b -- Gitee