diff --git a/interfaces/plugin/test/ExampleJsunit.test_acc.js b/interfaces/plugin/test/ExampleJsunit.test_acc.js deleted file mode 100644 index e308fd102061c61ce923e0d46801a3135442b8ba..0000000000000000000000000000000000000000 --- 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 95c157dc1703cbdaa5cc0fce43d80dec2900ba6d..0000000000000000000000000000000000000000 --- 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 c8eb59f6151a40f962d2ab3d741c8b385eb22959..0000000000000000000000000000000000000000 --- 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 e9a72a58451b8071e5d566f49ef21f3ea13f0362..0000000000000000000000000000000000000000 --- 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 6516c8e9440d4210595ba4842915d5114ac4acda..0000000000000000000000000000000000000000 --- 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 ff037dcfb39b3608702a553916036cd4cb8fc3b7..0000000000000000000000000000000000000000 --- 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 b289be700f82b938f18758cb04a623327ca851c8..0000000000000000000000000000000000000000 --- 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/BUILD.gn b/interfaces/plugin/test/unittest/BUILD.gn old mode 100755 new mode 100644 index 08ff82dc93dd8416c604161cb8fe3a1446361b65..daf719240ca3ffd2f35886c0f72bd1200a46483d --- a/interfaces/plugin/test/unittest/BUILD.gn +++ b/interfaces/plugin/test/unittest/BUILD.gn @@ -11,17 +11,10 @@ # 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("SensorJsTest") { - module_out_path = module_output_path - hap_profile = "./config.json" - certificate_profile = - "//test/testfwk/developer_test/signature/openharmony_sx.p7b" -} - group("unittest") { testonly = true - deps = [ ":SensorJsTest" ] + deps = [ + "gyroscope:GyroscopeJsTest", + "sensor:SensorJsTest", + ] } diff --git a/interfaces/plugin/test/unittest/gyroscope/BUILD.gn b/interfaces/plugin/test/unittest/gyroscope/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..87a6bd5f1b3209641b413be326603935b9fb3b01 --- /dev/null +++ b/interfaces/plugin/test/unittest/gyroscope/BUILD.gn @@ -0,0 +1,21 @@ +# 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("GyroscopeJsTest") { + module_out_path = module_output_path + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} diff --git a/interfaces/plugin/test/unittest/gyroscope/ExampleJsunit.test.js b/interfaces/plugin/test/unittest/gyroscope/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5ace8866dc84f8b61e42d7401cc0f15bdc8f8350 --- /dev/null +++ b/interfaces/plugin/test/unittest/gyroscope/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("GyroscopeJsTest", 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:GyroscopeJsTest_001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_001", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('------------------GyroscopeJsTest_002 off in-----------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('------------------GyroscopeJsTest_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:GyroscopeJsTest_003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_003", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_003---------------------------'); + if(g_execute) { + function onSensorCallback(data) { + console.info('GyroscopeJsTest_003 callback in'); + expect(true).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback, {'interval': 100000000}, 5); + setTimeout(()=>{ + console.info('----------------------GyroscopeJsTest_003 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_004 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_005", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_006", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_007", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("GyroscopeJsTest_008", 0, async function (done) { + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_009 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_010 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback); + console.info('----------------------GyroscopeJsTest_010 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------GyroscopeJsTest_010 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback2); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_011 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_012 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback); + console.info('----------------------GyroscopeJsTest_012 off end---------------------------'); + }, 500); + setTimeout(()=>{ + console.info('----------------------GyroscopeJsTest_012 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE, callback2); + console.info('----------------------GyroscopeJsTest_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:GyroscopeJsTest_013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + 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('----------------------GyroscopeJsTest_013 off in---------------------------'); + sensor.off(sensor.SensorId.GYROSCOPE); + console.info('----------------------GyroscopeJsTest_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/gyroscope/config.json b/interfaces/plugin/test/unittest/gyroscope/config.json new file mode 100644 index 0000000000000000000000000000000000000000..6baaf3750dc39c5eb693dd759a78d499c8fd5e45 --- /dev/null +++ b/interfaces/plugin/test/unittest/gyroscope/config.json @@ -0,0 +1,74 @@ +{ + "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": [ + "default", + "tablet" + ], + "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": "GyroscopeJsTest", + "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/gyroscope/signature/openharmony_sx.p7b b/interfaces/plugin/test/unittest/gyroscope/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/interfaces/plugin/test/unittest/gyroscope/signature/openharmony_sx.p7b differ diff --git a/interfaces/plugin/test/unittest/sensor/BUILD.gn b/interfaces/plugin/test/unittest/sensor/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1e7d26c0752a662dd5e8159f1a436bf5d34975db --- /dev/null +++ b/interfaces/plugin/test/unittest/sensor/BUILD.gn @@ -0,0 +1,21 @@ +# 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("//build/test.gni") + +module_output_path = "sensor/interfaces" +ohos_js_unittest("SensorJsTest") { + module_out_path = module_output_path + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} 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 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 Binary files /dev/null and b/interfaces/plugin/test/unittest/sensor/signature/openharmony_sx.p7b differ