From 6967b2e5a61343f6e890072ce3bae9d433466440 Mon Sep 17 00:00:00 2001 From: lidanyang16 Date: Tue, 23 May 2023 18:19:07 +0800 Subject: [PATCH] Signed-off-by: lidanyang16 --- .../src/main/js/test/List.test.js | 4 +- ...est.js => Vibrator_newSupportTest.test.js} | 0 .../src/main/js/test/Vibrator_options.test.js | 1144 +++++++++++++++++ ...sorOnOffTest.test_newAccelerometer.test.js | 354 +++-- ...test_newAccelerometer_Uncalibrated.test.js | 8 +- ...sorOnOffTest.test_newAmbient_Light.test.js | 480 ++++--- .../SensorOnOffTest.test_newBarometer.test.js | 484 ++++--- ...sorOnOffTest.test_newGetSensorList.test.js | 65 +- ...rOnOffTest.test_newGetSingleSensor.test.js | 153 ++- .../SensorOnOffTest.test_newGravity.test.js | 599 ++++++--- .../SensorOnOffTest.test_newGyroScope.test.js | 484 ++++--- ...est.test_newGyroscope_Uncalibrated.test.js | 8 +- .../test/SensorOnOffTest.test_newHall.test.js | 480 ++++--- ...SensorOnOffTest.test_newHeart_Rate.test.js | 8 +- .../SensorOnOffTest.test_newHumidity.test.js | 8 +- ...fTest.test_newLinear_Accelerometer.test.js | 8 +- ...sorOnOffTest.test_newMagneticField.test.js | 491 ++++--- ...test_newMagneticField_Uncalibrated.test.js | 8 +- ...ensorOnOffTest.test_newOrientating.test.js | 509 +++++--- .../SensorOnOffTest.test_newPedometer.test.js | 8 +- ...ffTest.test_newPedometer_Detection.test.js | 226 +++- .../SensorOnOffTest.test_newProxinity.test.js | 8 +- ...orOnOffTest.test_newRotatingVector.test.js | 480 ++++--- ...nOffTest.test_newSensorGeomagnetic.test.js | 8 +- ...t.test_newSensorGeomagneticOptions.test.js | 616 +++++++++ ...OffTest.test_newSignificant_Motion.test.js | 8 +- ...ensorOnOffTest.test_newTemperature.test.js | 8 +- ...fTest.test_newTestServiceException.test.js | 8 +- ...orOnOffTest.test_newWear_Detection.test.js | 8 +- ...sorOnOffTest.test_oldAccelerometer.test.js | 157 ++- ...test_oldAccelerometer_Uncalibrated.test.js | 8 +- ...sorOnOffTest.test_oldAmbient_light.test.js | 200 ++- .../SensorOnOffTest.test_oldBarometer.test.js | 200 ++- .../SensorOnOffTest.test_oldGravity.test.js | 200 ++- .../SensorOnOffTest.test_oldGyroScope.test.js | 200 ++- ...est.test_oldGyroscope_Uncalibrated.test.js | 8 +- .../test/SensorOnOffTest.test_oldHall.test.js | 200 ++- ...SensorOnOffTest.test_oldHeart_Rate.test.js | 8 +- .../SensorOnOffTest.test_oldHumidity.test.js | 8 +- ...ffTest.test_oldLinear_Acceleration.test.js | 8 +- ...sorOnOffTest.test_oldMagneticField.test.js | 200 ++- ...est_oldMagnetic_Field_Uncalibrated.test.js | 8 +- ...ensorOnOffTest.test_oldOrientating.test.js | 200 ++- .../SensorOnOffTest.test_oldPedometer.test.js | 8 +- ...ffTest.test_oldPedometer_Detection.test.js | 228 +++- .../SensorOnOffTest.test_oldProxinity.test.js | 8 +- ...orOnOffTest.test_oldRotatingVector.test.js | 200 ++- ...OffTest.test_oldSignificant_Motion.test.js | 8 +- ...ensorOnOffTest.test_oldTemperature.test.js | 8 +- ...orOnOffTest.test_oldWear_Detection.test.js | 8 +- .../js/test/Subscribe_getOnBodyState.test.js | 8 +- .../Subscribe_subscribeAccelerometer.test.js | 175 ++- .../test/Subscribe_subscribeBarometer.test.js | 85 +- .../test/Subscribe_subscribeCompass.test.js | 8 +- ...bscribe_subscribeDeviceOrientation.test.js | 312 +++-- .../test/Subscribe_subscribeGyroscope.test.js | 591 +++++++-- .../js/test/Subscribe_subscribeLight.test.js | 504 ++++++-- 57 files changed, 8431 insertions(+), 1998 deletions(-) rename sensors/miscdevice_standard/src/main/js/test/{Vibrator_newSupportTest.js => Vibrator_newSupportTest.test.js} (100%) create mode 100644 sensors/miscdevice_standard/src/main/js/test/Vibrator_options.test.js create mode 100644 sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagneticOptions.test.js diff --git a/sensors/miscdevice_standard/src/main/js/test/List.test.js b/sensors/miscdevice_standard/src/main/js/test/List.test.js index 91f221a9d..20a589381 100644 --- a/sensors/miscdevice_standard/src/main/js/test/List.test.js +++ b/sensors/miscdevice_standard/src/main/js/test/List.test.js @@ -15,10 +15,12 @@ import VibratorJsTest_misc_1 from './Vibrator_old.test.js' import VibratorJsTest_misc_2 from './Vibrator_new_common.test.js' import VibratorJsTest_misc_3 from './Vibrator_newSupplement_common.test.js' -import VibratorJsTest_misc_6 from './Vibrator_newSupportTest.js' +import VibratorJsTest_misc_6 from './Vibrator_newSupportTest.test.js' +import VibratorJsTest_misc_7 from './Vibrator_options.test.js' export default function testsuite() { VibratorJsTest_misc_1() VibratorJsTest_misc_2() VibratorJsTest_misc_3() VibratorJsTest_misc_6() + VibratorJsTest_misc_7() } diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupportTest.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupportTest.test.js similarity index 100% rename from sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupportTest.js rename to sensors/miscdevice_standard/src/main/js/test/Vibrator_newSupportTest.test.js diff --git a/sensors/miscdevice_standard/src/main/js/test/Vibrator_options.test.js b/sensors/miscdevice_standard/src/main/js/test/Vibrator_options.test.js new file mode 100644 index 000000000..d7ce0df58 --- /dev/null +++ b/sensors/miscdevice_standard/src/main/js/test/Vibrator_options.test.js @@ -0,0 +1,1144 @@ +/* + * Copyright (C) 2021-2022 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 vibrator from '@ohos.vibrator' +import systemVibrator from '@system.vibrator' + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' + +export default function VibratorJsTest_misc_7() { +describe("VibratorJsTest_misc_7", function () { + let EFFECT_ID = "haptic.clock.timer"; + let INVALID_EFFECT_ID = "haptic.xxx.yyy"; + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll called') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll called') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach called') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + vibrator.stop("preset"); + vibrator.stop("time"); + console.info('afterEach called') + }) + + const OPERATION_FAIL_CODE = 14600101; + const PERMISSION_ERROR_CODE = 201; + const PARAMETER_ERROR_CODE = 401; + + const OPERATION_FAIL_MSG = 'Device operation failed.' + const PERMISSION_ERROR_MSG = 'Permission denied.' + const PARAMETER_ERROR_MSG = 'The parameter invalid.' + + /* + * @tc.name:VibratorJsTest076 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0860 + */ + it("VibratorJsTest076", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + vibrator.vibrate(1000, undefined).then(() => { + console.log("VibratorJsTest076 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest076 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + }) + + /* + * @tc.name:VibratorJsTest077 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0870 + */ + it("VibratorJsTest077", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + vibrator.vibrate(1000, null).then(() => { + console.log("VibratorJsTest077 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest077 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + }) + + /* + * @tc.name:VibratorJsTest078 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0880 + */ + it("VibratorJsTest078", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + vibrator.vibrate(1000, "abc").then(() => { + console.log("VibratorJsTest078 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest078 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + }) + + /* + * @tc.name:VibratorJsTest079 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0890 + */ + it("VibratorJsTest079", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID, undefined).then(() => { + console.log("VibratorJsTest079 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest079 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest080 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0900 + */ + it("VibratorJsTest080", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID, null).then(() => { + console.log("VibratorJsTest080 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest080 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest081 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0910 + */ + it("VibratorJsTest081", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID, "abc").then(() => { + console.log("VibratorJsTest081 vibrate success"); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest081 vibrate error"); + setTimeout(() => { + done(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest082 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0920 + */ + it("VibratorJsTest082", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate(undefined); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:VibratorJsTest083 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0930 + */ + it("VibratorJsTest083", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate(null); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:VibratorJsTest084 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0940 + */ + it("VibratorJsTest084", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate("abc"); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:VibratorJsTest085 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0950 + */ + it("VibratorJsTest085", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate({ + mode: undefined, + success: function() { + expect(true).assertTrue(); + console.log('VibratorJsTest085 vibrate is successful'); + done(); + }, + fail: undefined, + complete: undefined + }); + }) + + /* + * @tc.name:VibratorJsTest086 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0960 + */ + it("VibratorJsTest086", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate({ + mode: null, + success: function() { + expect(true).assertTrue(); + console.log('VibratorJsTest086 vibrate is successful'); + done(); + }, + fail: null, + complete: null + }); + }) + + /* + * @tc.name:VibratorJsTest087 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0970 + */ + it("VibratorJsTest087", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + systemVibrator.vibrate({ + mode: 123, + success: function() { + expect(true).assertTrue(); + console.log('VibratorJsTest087 vibrate is successful'); + done(); + }, + fail: 123, + complete: 123 + }); + }) + + /* + * @tc.name:VibratorJsTest088 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0980 + */ + it("VibratorJsTest088", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID).then(() => { + console.log("VibratorJsTest088 vibrate success"); + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest088 vibrate error"); + reject(); + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stop("preset", undefined).then(() => { + console.log("VibratorJsTest088 off success"); + expect(true).assertTrue(); + setTimeout(() => { + resolve(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest088 off error"); + setTimeout(() => { + reject(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).then(() =>{ + return stopPromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest089 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0990 + */ + it("VibratorJsTest089", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID).then(() => { + console.log("VibratorJsTest089 vibrate success"); + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest089 vibrate error"); + reject(); + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stop("preset", null).then(() => { + console.log("VibratorJsTest089 off success"); + expect(true).assertTrue(); + setTimeout(() => { + resolve(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest089 off error"); + setTimeout(() => { + reject(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).then(() =>{ + return stopPromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest090 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1000 + */ + it("VibratorJsTest090", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.vibrate(EFFECT_ID).then(() => { + console.log("VibratorJsTest090 vibrate success"); + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest090 vibrate error"); + reject(); + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stop("preset", "abc").then(() => { + console.log("VibratorJsTest090 off success"); + expect(true).assertTrue(); + setTimeout(() => { + resolve(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest090 off error"); + setTimeout(() => { + reject(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).then(() =>{ + return stopPromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest091 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1010 + */ + it("VibratorJsTest091", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try { + vibrator.stopVibration("").then(() => { + console.log("VibratorJsTest091 stop error"); + expect(false).assertTrue(); + setTimeout(() => { + done(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest091 stop error"); + setTimeout(() => { + done(); + }, 500); + }); + } catch (error) { + console.info(error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.name:VibratorJsTest092 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1020 + */ + it("VibratorJsTest092", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 1, + }, { + usage: "unknown" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration((error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() => { + return vibratePromise(); + }).then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest093 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1030 + */ + it("VibratorJsTest093", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 1, + }, { + usage: "notification" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration("preset", undefined).then(() => { + console.log("VibratorJsTest093 off success"); + expect(true).assertTrue(); + setTimeout(() => { + resolve(); + }, 500); + }, (error) => { + expect(false).assertTrue(); + console.log("VibratorJsTest093 off error"); + setTimeout(() => { + reject(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).then(() =>{ + return stopPromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest094 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1040 + */ + it("VibratorJsTest094", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 3, + }, { + usage: "notification" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(); + } else { + console.log("VibratorJsTest094 vibrator success"); + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration("preset", null).then(() => { + console.log("VibratorJsTest094 off success"); + expect(true).assertTrue(); + setTimeout(() => { + resolve(); + }, 500); + }, (error) => { + expect(true).assertTrue(); + console.log("VibratorJsTest094 off error"); + setTimeout(() => { + reject(); + }, 500); + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, (error, state) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + isSupport = state; + resolve(); + } + }); + }) + + await isSupportPromise.then(() =>{ + return vibratePromise(); + }).then(() =>{ + return stopPromise(); + }).catch((error)=>{ + expect(false).assertTrue(); + }) + done(); + }) + /* + * @tc.name:VibratorJsTest095 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1050 + */ + it("VibratorJsTest095", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 1, + }, { + usage: "unknown" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration((error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, "abc").then((state) => { + expect(true).assertTrue(); + isSupport = state; + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + + await isSupportPromise.then(() => { + return vibratePromise(); + }).then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest096 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1060 + */ + it("VibratorJsTest096", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + function stopPromise() { + return new Promise((resolve, reject) => { + vibrator.stopVibration(undefined).then(() => { + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + } + + let promise = new Promise((resolve, reject) => { + vibrator.vibrate(2000, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + }) + + await promise.then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest097 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1070 + */ + it("VibratorJsTest097", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + function stopPromise() { + return new Promise((resolve, reject) => { + vibrator.stopVibration(null).then(() => { + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + } + + let promise = new Promise((resolve, reject) => { + vibrator.vibrate(2000, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + }) + + await promise.then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest098 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1080 + */ + it("VibratorJsTest098", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + function stopPromise() { + return new Promise((resolve, reject) => { + vibrator.stopVibration(123).then(() => { + expect(true).assertTrue(); + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + } + + let promise = new Promise((resolve, reject) => { + vibrator.vibrate(2000, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + }) + + await promise.then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest099 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1090 + */ + it("VibratorJsTest099", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 1, + }, { + usage: "unknown" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration((error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, undefined).then((state) => { + expect(true).assertTrue(); + isSupport = state; + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + + await isSupportPromise.then(() => { + return vibratePromise(); + }).then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) + + /* + * @tc.name:VibratorJsTest100 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorSystem_Vibrator_JsTest_1100 + */ + it("VibratorJsTest100", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let isSupport = false; + function vibratePromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.startVibration({ + type: "preset", + effectId: EFFECT_ID, + count: 1, + }, { + usage: "unknown" + }, (error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + function stopPromise() { + return new Promise((resolve, reject) => { + if (isSupport) { + vibrator.stopVibration((error) => { + if (error) { + expect(false).assertTrue(); + reject(error); + } else { + expect(true).assertTrue(); + resolve(); + } + }); + } else { + resolve(); + } + }) + } + + let isSupportPromise = new Promise((resolve, reject) => { + vibrator.isSupportEffect(EFFECT_ID, null).then((state) => { + expect(true).assertTrue(); + isSupport = state; + resolve(); + }, (error) => { + expect(false).assertTrue(); + reject(error); + }); + }) + + await isSupportPromise.then(() => { + return vibratePromise(); + }).then(() => { + return stopPromise(); + }).catch((error) => { + expect(false).assertTrue(); + }) + done(); + }) +})} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js index 361e6331f..354eee8da 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_39", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_39", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_39", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_39", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -71,13 +71,13 @@ describe("SensorJsTest_sensor_39", function () { const SERVICE_EXCEPTION_MSG = 'Service exception.' let invalid = -1; - /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0140 - * @tc.name: newAccelerometer_SensorJsTest014 - * @tc.desc: Functional Use Cases + /* + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0010 + * @tc.name: newAccelerometer_SensorJsTest001 + * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newAccelerometer_SensorJsTest014--------------'); + it("newAccelerometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newAccelerometer_SensorJsTest001--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, callback); setTimeout(()=>{ sensor.off(sensor.SensorId.ACCELEROMETER); @@ -86,20 +86,20 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0150 - * @tc.name: newAccelerometer_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0020 + * @tc.name: newAccelerometer_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newAccelerometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAccelerometer_SensorJsTest015--------------'); + it("newAccelerometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAccelerometer_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest015 callback in'); + console.info('newAccelerometer_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newAccelerometer_SensorJsTest015 error:" + error); + console.info("newAccelerometer_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -107,30 +107,30 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0160 - * @tc.name: newAccelerometer_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0030 + * @tc.name: newAccelerometer_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newAccelerometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAccelerometer_SensorJsTest016--------------'); + it("newAccelerometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAccelerometer_SensorJsTest003--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newAccelerometer_SensorJsTest016 off in--------------'); + console.info('---------newAccelerometer_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER); - console.info('---------newAccelerometer_SensorJsTest016 off end--------------'); + console.info('---------newAccelerometer_SensorJsTest003 off end--------------'); done(); }, 1000); }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0170 - * @tc.name: newAccelerometer_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0040 + * @tc.name: newAccelerometer_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newAccelerometer_SensorJsTest017--------------'); + it("newAccelerometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newAccelerometer_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest017 callback in'); + console.info('newAccelerometer_SensorJsTest004 callback in'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -139,24 +139,24 @@ describe("SensorJsTest_sensor_39", function () { try { sensor.on(sensor.SensorId.ACCELEROMETER, onSensorCallback, {'interval': 100000000}, 5); } catch (error) { - console.info("newAccelerometer_SensorJsTest017 error:" +error); + console.info("newAccelerometer_SensorJsTest004 error:" +error); expect(false).assertTrue(); done(); } setTimeout(()=>{ - console.info('---------newAccelerometer_SensorJsTest017 off in--------------'); + console.info('---------newAccelerometer_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER); - console.info('---------newAccelerometer_SensorJsTest017 off end--------------'); + console.info('---------newAccelerometer_SensorJsTest004 off end--------------'); done(); }, 1000); }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0180 - * @tc.name: newAccelerometer_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0050 + * @tc.name: newAccelerometer_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newAccelerometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.once(sensor.SensorId.ACCELEROMETER, callback); setTimeout(()=>{ expect(true).assertTrue(); @@ -165,20 +165,20 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0190 - * @tc.name: newAccelerometer_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0060 + * @tc.name: newAccelerometer_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newAccelerometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest019 callback in'); + console.info('newAccelerometer_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newAccelerometer_SensorJsTest019 error:" +error); + console.info("newAccelerometer_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -186,13 +186,13 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0200 - * @tc.name: newAccelerometer_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0070 + * @tc.name: newAccelerometer_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newAccelerometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest020 on error'); + console.info('newAccelerometer_SensorJsTest007 on error'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -202,22 +202,22 @@ describe("SensorJsTest_sensor_39", function () { try{ sensor.once(sensor.SensorId.ACCELEROMETER, onceSensorCallback, 5); } catch (error) { - console.info('newAccelerometer_SensorJsTest020 error:' +error); + console.info('newAccelerometer_SensorJsTest007 error:' +error); expect(false).assertTrue(); done(); } }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0210 - * @tc.name: newAccelerometer_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0080 + * @tc.name: newAccelerometer_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newAccelerometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newAccelerometer_SensorJsTest021 error:' +error); + console.info('newAccelerometer_SensorJsTest008 error:' +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -225,13 +225,13 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0220 - * @tc.name: newAccelerometer_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0090 + * @tc.name: newAccelerometer_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newAccelerometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest022 callback in' + JSON.stringify(data)); + console.info('newAccelerometer_SensorJsTest009 callback in' + JSON.stringify(data)); expect(false).assertTrue(); done(); } @@ -244,20 +244,20 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0230 - * @tc.name: newAccelerometer_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0100 + * @tc.name: newAccelerometer_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newAccelerometer_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newAccelerometer_SensorJsTest023 on error' + JSON.stringify(data)); + console.info('newAccelerometer_SensorJsTest010 on error' + JSON.stringify(data)); expect(false).assertTrue(); done(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newAccelerometer_SensorJsTest023 error:" +error); + console.info("newAccelerometer_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -265,40 +265,40 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0240 - * @tc.name: newAccelerometer_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0110 + * @tc.name: newAccelerometer_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newAccelerometer_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAccelerometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest011 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.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest011 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newAccelerometer_SensorJsTest024 off in--------------'); + console.info('---------newAccelerometer_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER); - console.info('---------newAccelerometer_SensorJsTest024 off end--------------'); + console.info('---------newAccelerometer_SensorJsTest011 off end--------------'); done(); }, 1000); }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0250 - * @tc.name: newAccelerometer_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0120 + * @tc.name: newAccelerometer_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newAccelerometer_SensorJsTest025--------------'); + it("newAccelerometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newAccelerometer_SensorJsTest012--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, callback); setTimeout(()=>{ sensor.off(sensor.SensorId.ACCELEROMETER, 5); @@ -307,74 +307,74 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0260 - * @tc.name: newAccelerometer_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0130 + * @tc.name: newAccelerometer_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newAccelerometer_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAccelerometer_SensorJsTest026--------------'); + it("newAccelerometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAccelerometer_SensorJsTest013--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest013 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest013 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newAccelerometer_SensorJsTest026 off in--------------'); + console.info('---------newAccelerometer_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER); - console.info('---------newAccelerometer_SensorJsTest026 off end--------------'); + console.info('---------newAccelerometer_SensorJsTest013 off end--------------'); done(); }, 1000); }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0270 - * @tc.name: newAccelerometer_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0140 + * @tc.name: newAccelerometer_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAccelerometer_SensorJsTest027--------------'); + it("newAccelerometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAccelerometer_SensorJsTest014--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ - console.info("newAccelerometer_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newAccelerometer_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newAccelerometer_SensorJsTest027 off in--------------'); + console.info('---------newAccelerometer_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER); - console.info('---------newAccelerometer_SensorJsTest027 off end--------------'); + console.info('---------newAccelerometer_SensorJsTest014 off end--------------'); done(); }, 1000); }) /* - * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0280 - * @tc.name: newAccelerometer_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0150 + * @tc.name: newAccelerometer_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAccelerometer_SensorJsTest028--------------'); + it("newAccelerometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAccelerometer_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newAccelerometer_SensorJsTest028 on error:" +error); + console.info("newAccelerometer_SensorJsTest015 on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -382,7 +382,7 @@ describe("SensorJsTest_sensor_39", function () { try { sensor.once(); } catch (error) { - console.info("newAccelerometer_SensorJsTest028 once error:" +error); + console.info("newAccelerometer_SensorJsTest015 once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -390,7 +390,7 @@ describe("SensorJsTest_sensor_39", function () { try { sensor.off(); } catch (error) { - console.info("newAccelerometer_SensorJsTest028 off error:" +error); + console.info("newAccelerometer_SensorJsTest015 off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -398,55 +398,191 @@ describe("SensorJsTest_sensor_39", function () { }) /* - * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0290 - * @tc.name: newAccelerometer_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0160 + * @tc.name: newAccelerometer_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAccelerometer_SensorJsTest029--------------'); + it("newAccelerometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest016--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, callback); sensor.on(sensor.SensorId.ACCELEROMETER, callback2); setTimeout(() => { - console.info('----------------------newAccelerometer_SensorJsTest029 off in--------------'); + console.info('----------------------newAccelerometer_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.ACCELEROMETER, callback); } catch (error) { - console.info("newAccelerometer_SensorJsTest029 error:" + error); + console.info("newAccelerometer_SensorJsTest016 error:" + error); } - console.info('----------------------newAccelerometer_SensorJsTest029 off end--------------'); + console.info('----------------------newAccelerometer_SensorJsTest016 off end--------------'); }, 1000); setTimeout(() => { - console.info('----------------------newAccelerometer_SensorJsTest029 off in--------------'); + console.info('----------------------newAccelerometer_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER, callback2); - console.info('----------------------newAccelerometer_SensorJsTest029 off end--------------'); + console.info('----------------------newAccelerometer_SensorJsTest016 off end--------------'); done(); }, 1000); }) /* - * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0300 - * @tc.name: newAccelerometer_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0170 + * @tc.name: newAccelerometer_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAccelerometer_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAccelerometer_SensorJsTest030--------------'); + it("newAccelerometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest017--------------'); sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.ACCELEROMETER, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newAccelerometer_SensorJsTest030 off in--------------'); + console.info('----------------------newAccelerometer_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.ACCELEROMETER, callback); } catch (error) { - console.info("newAccelerometer_SensorJsTest030 error:" + error); + console.info("newAccelerometer_SensorJsTest017 error:" + error); } - console - console.info('----------------------newAccelerometer_SensorJsTest030 off end--------------'); + console.info('----------------------newAccelerometer_SensorJsTest017 off end--------------'); }, 1000); setTimeout(() => { - console.info('----------------------newAccelerometer_SensorJsTest030_2 off in--------------'); + console.info('----------------------newAccelerometer_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.ACCELEROMETER, callback2); - console.info('----------------------newAccelerometer_SensorJsTest030_2 off end--------------'); + console.info('----------------------newAccelerometer_SensorJsTest017_2 off end--------------'); done(); }, 1000); }) + + /* + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0180 + * @tc.name: newAccelerometer_SensorJsTest018 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newAccelerometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.ACCELEROMETER, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newAccelerometer_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER, callback); + sensor.off(sensor.SensorId.ACCELEROMETER, callback2); + } catch (error) { + console.info("newAccelerometer_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newAccelerometer_SensorJsTest018 off end--------------'); + done() + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0190 + * @tc.name: newAccelerometer_SensorJsTest019 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newAccelerometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest019--------------'); + sensor.on(sensor.SensorId.ACCELEROMETER, callback, undefined); + try{ + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': undefined }); + } catch(error){ + console.info('newAccelerometer_SensorJsTest019 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newAccelerometer_SensorJsTest019 off in--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER); + } catch (error) { + console.info("newAccelerometer_SensorJsTest019 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0200 + * @tc.name: newAccelerometer_SensorJsTest020 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newAccelerometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest020--------------'); + sensor.on(sensor.SensorId.ACCELEROMETER, callback, null); + try{ + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': null }); + } catch(error){ + console.info('newAccelerometer_SensorJsTest020 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newAccelerometer_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER); + } catch (error) { + console.info("newAccelerometer_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0210 + * @tc.name: newAccelerometer_SensorJsTest021 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newAccelerometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest021--------------'); + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newAccelerometer_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER); + } catch (error) { + console.info("newAccelerometer_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0220 + * @tc.name: newAccelerometer_SensorJsTest022 + * @tc.desc: Functional Use Cases + */ + it("newAccelerometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest022--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER, null); + setTimeout(() => { + done(); + }, 1000); + } catch(error){ + console.info('newAccelerometer_SensorJsTest022 error:'+error); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWACCELEROMETER_JSTest_0230 + * @tc.name: newAccelerometer_SensorJsTest023 + * @tc.desc: Functional Use Cases + */ + it("newAccelerometer_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAccelerometer_SensorJsTest023--------------'); + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.ACCELEROMETER, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newAccelerometer_SensorJsTest023 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newAccelerometer_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.ACCELEROMETER); + } catch (error) { + console.info("newAccelerometer_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newAccelerometer_SensorJsTest023 off end--------------'); + done() + }, 1000); + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer_Uncalibrated.test.js index 6335aa44b..412dc9ad4 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAccelerometer_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_40", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_40", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_40", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_40", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js index 4f0d861fe..810f49bf0 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newAmbient_Light.test.js @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_41", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_41", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_41", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_41", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -68,16 +68,16 @@ describe("SensorJsTest_sensor_41", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0140 - * @tc.name: newAmbient_Light_SensorJsTest014 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0010 + * @tc.name: newAmbient_Light_SensorJsTest001 * @tc.desc: Functional Use Cases */ - it("newAmbient_Light_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest014--------------'); + it("newAmbient_Light_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest014 error'); + console.info('newAmbient_Light_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback); @@ -88,7 +88,7 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info('newAmbient_Light_SensorJsTest014 Device does not support! '); + console.info('newAmbient_Light_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -96,20 +96,20 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0150 - * @tc.name: newAmbient_Light_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0020 + * @tc.name: newAmbient_Light_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newAmbient_Light_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest015--------------'); + it("newAmbient_Light_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest015 callback in'); + console.info('newAmbient_Light_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newAmbient_Light_SensorJsTest015 error:" + error); + console.info("newAmbient_Light_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -117,29 +117,29 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0160 - * @tc.name: newAmbient_Light_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0030 + * @tc.name: newAmbient_Light_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newAmbient_Light_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest016--------------'); + it("newAmbient_Light_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest016 error'); + console.info('newAmbient_Light_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newAmbient_Light_SensorJsTest016 off in--------------'); + console.info('---------newAmbient_Light_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('---------newAmbient_Light_SensorJsTest016 off end--------------'); + console.info('---------newAmbient_Light_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newAmbient_Light_SensorJsTest016 Device does not support! '); + console.info('newAmbient_Light_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -147,34 +147,34 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0170 - * @tc.name: newAmbient_Light_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0040 + * @tc.name: newAmbient_Light_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newAmbient_Light_SensorJsTest017--------------'); + it("newAmbient_Light_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newAmbient_Light_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest017 callback in'); + console.info('newAmbient_Light_SensorJsTest004 callback in'); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest017 error'); + console.info('newAmbient_Light_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newAmbient_Light_SensorJsTest017 off in--------------'); + console.info('---------newAmbient_Light_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('---------newAmbient_Light_SensorJsTest017 off end--------------'); + console.info('---------newAmbient_Light_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest017 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -182,15 +182,15 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0180 - * @tc.name: newAmbient_Light_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0050 + * @tc.name: newAmbient_Light_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newAmbient_Light_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest018 error'); + console.info('newAmbient_Light_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.AMBIENT_LIGHT, callback); @@ -201,7 +201,7 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest018 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -209,20 +209,20 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0190 - * @tc.name: newAmbient_Light_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0060 + * @tc.name: newAmbient_Light_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newAmbient_Light_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest019 callback in'); + console.info('newAmbient_Light_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newAmbient_Light_SensorJsTest019 error:" +error); + console.info("newAmbient_Light_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -230,13 +230,13 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0200 - * @tc.name: newAmbient_Light_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0070 + * @tc.name: newAmbient_Light_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newAmbient_Light_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest020 on error'); + console.info('newAmbient_Light_SensorJsTest007 on error'); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); done(); @@ -244,14 +244,14 @@ describe("SensorJsTest_sensor_41", function () { try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest020 error'); + console.info('newAmbient_Light_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.AMBIENT_LIGHT, onceSensorCallback, 5); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest020 error:" +error); + console.info("newAmbient_Light_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -259,15 +259,15 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0210 - * @tc.name: newAmbient_Light_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0080 + * @tc.name: newAmbient_Light_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newAmbient_Light_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newAmbient_Light_SensorJsTest021 Device does not support! '); + console.info('newAmbient_Light_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -275,20 +275,20 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0220 - * @tc.name: newAmbient_Light_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0090 + * @tc.name: newAmbient_Light_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newAmbient_Light_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest022 callback in'); + console.info('newAmbient_Light_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest022 error'); + console.info('newAmbient_Light_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, onSensorCallback); @@ -300,7 +300,7 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest022 error:" +error); + console.info("newAmbient_Light_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -308,19 +308,19 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0230 - * @tc.name: newAmbient_Light_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0100 + * @tc.name: newAmbient_Light_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newAmbient_Light_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newAmbient_Light_SensorJsTest023 on error'); + console.info('newAmbient_Light_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newAmbient_Light_SensorJsTest023 error:" +error); + console.info("newAmbient_Light_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -328,37 +328,37 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0240 - * @tc.name: newAmbient_Light_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0110 + * @tc.name: newAmbient_Light_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newAmbient_Light_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newAmbient_Light_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest024 error'); + console.info('newAmbient_Light_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest011 callback: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest011 callback2: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newAmbient_Light_SensorJsTest024 off in--------------'); + console.info('---------newAmbient_Light_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('---------newAmbient_Light_SensorJsTest024 off end--------------'); + console.info('---------newAmbient_Light_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest024 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -366,16 +366,16 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0250 - * @tc.name: newAmbient_Light_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0120 + * @tc.name: newAmbient_Light_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest025--------------'); + it("newAmbient_Light_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest025 error'); + console.info('newAmbient_Light_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback); @@ -386,7 +386,7 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info('newAmbient_Light_SensorJsTest025 Device does not support! '); + console.info('newAmbient_Light_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -394,38 +394,38 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0260 - * @tc.name: newAmbient_Light_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0130 + * @tc.name: newAmbient_Light_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newAmbient_Light_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest026--------------'); + it("newAmbient_Light_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest024 error'); + console.info('newAmbient_Light_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest013 callback: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest013 callback2: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newAmbient_Light_SensorJsTest026 off in--------------'); + console.info('---------newAmbient_Light_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('---------newAmbient_Light_SensorJsTest026 off end--------------'); + console.info('---------newAmbient_Light_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest026 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -433,39 +433,39 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0270 - * @tc.name: newAmbient_Light_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0140 + * @tc.name: newAmbient_Light_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest027--------------'); + it("newAmbient_Light_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest024 error'); + console.info('newAmbient_Light_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest014 callback: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{ - console.info("newAmbient_Light_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newAmbient_Light_SensorJsTest014 callback2: " + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newAmbient_Light_SensorJsTest027 off in--------------'); + console.info('---------newAmbient_Light_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('---------newAmbient_Light_SensorJsTest027 off end--------------'); + console.info('---------newAmbient_Light_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest027 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -473,16 +473,16 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number:SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0280 - * @tc.name: newAmbient_Light_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0150 + * @tc.name: newAmbient_Light_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newAmbient_Light_SensorJsTest028--------------'); + it("newAmbient_Light_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newAmbient_Light_SensorJsTest028_on error:" +error); + console.info("newAmbient_Light_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -490,7 +490,7 @@ describe("SensorJsTest_sensor_41", function () { try { sensor.once(); } catch (error) { - console.info("newAmbient_Light_SensorJsTest028_once error:" +error); + console.info("newAmbient_Light_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -498,7 +498,7 @@ describe("SensorJsTest_sensor_41", function () { try { sensor.off(); } catch (error) { - console.info("newAmbient_Light_SensorJsTest028_off error:" +error); + console.info("newAmbient_Light_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -506,39 +506,39 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0290 - * @tc.name: newAmbient_Light_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0160 + * @tc.name: newAmbient_Light_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAmbient_Light_SensorJsTest029--------------'); + it("newAmbient_Light_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAmbient_Light_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest029 error'); + console.info('newAmbient_Light_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2); setTimeout(() => { - console.info('----------------------newAmbient_Light_SensorJsTest029 off in--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback); } catch (error) { - console.info("newAmbient_Light_SensorJsTest029 error:" + error); + console.info("newAmbient_Light_SensorJsTest016 error:" + error); } - console.info('----------------------newAmbient_Light_SensorJsTest029 off end--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newAmbient_Light_SensorJsTest029 off in--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback2); - console.info('----------------------newAmbient_Light_SensorJsTest029 off end--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest029 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -546,40 +546,39 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0300 - * @tc.name: newAmbient_Light_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0170 + * @tc.name: newAmbient_Light_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAmbient_Light_SensorJsTest030--------------'); + it("newAmbient_Light_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAmbient_Light_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest029 error'); + console.info('newAmbient_Light_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newAmbient_Light_SensorJsTest030 off in--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback); } catch (error) { - console.info("newAmbient_Light_SensorJsTest030 error:" + error); + console.info("newAmbient_Light_SensorJsTest017 error:" + error); } - console - console.info('----------------------newAmbient_Light_SensorJsTest030 off end--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newAmbient_Light_SensorJsTest030_2 off in--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback2); - console.info('----------------------newAmbient_Light_SensorJsTest030_2 off end--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest030 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -587,24 +586,24 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0310 - * @tc.name: newAmbient_Light_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0180 + * @tc.name: newAmbient_Light_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAmbient_Light_SensorJsTest031--------------'); + it("newAmbient_Light_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAmbient_Light_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest031 error'); + console.info('newAmbient_Light_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newAmbient_Light_SensorJsTest031 off in--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newAmbient_Light_SensorJsTest031 off end--------------'); + console.info('----------------------newAmbient_Light_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newAmbient_Light_SensorJsTest031 error:" + error); + console.info("newAmbient_Light_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -612,7 +611,7 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest031 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -620,25 +619,25 @@ describe("SensorJsTest_sensor_41", function () { }) /* - * @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0320 - * @tc.name: newAmbient_Light_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0190 + * @tc.name: newAmbient_Light_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newAmbient_Light_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newAmbient_Light_SensorJsTest032--------------'); + it("newAmbient_Light_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newAmbient_Light_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { if (error) { - console.info('newAmbient_Light_SensorJsTest032 error'); + console.info('newAmbient_Light_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, {'interval': -100000000}); - console.info('----------------------newAmbient_Light_SensorJsTest032 off in---------------------------'); + console.info('----------------------newAmbient_Light_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.AMBIENT_LIGHT); - console.info('----------------------newAmbient_Light_SensorJsTest032 off end---------------------------'); + console.info('----------------------newAmbient_Light_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newAmbient_Light_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newAmbient_Light_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -646,10 +645,197 @@ describe("SensorJsTest_sensor_41", function () { } }) } catch (error) { - console.info("newAmbient_Light_SensorJsTest032 Device does not support! "); + console.info("newAmbient_Light_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0200 + * @tc.name: newAmbient_Light_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newAmbient_Light_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newAmbient_Light_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback); + sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback2); + } catch (error) { + console.info("newAmbient_Light_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newAmbient_Light_SensorJsTest020 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newAmbient_Light_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0210 + * @tc.name: newAmbient_Light_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newAmbient_Light_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, undefined); + try{ + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': undefined }); + } catch(error){ + console.info('newAmbient_Light_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newAmbient_Light_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.AMBIENT_LIGHT); + } catch (error) { + console.info("newAmbient_Light_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newAmbient_Light_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0220 + * @tc.name: newAmbient_Light_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newAmbient_Light_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newAmbient_Light_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, null); + try{ + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': null }); + } catch(error){ + console.info('newAmbient_Light_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newAmbient_Light_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.AMBIENT_LIGHT); + } catch (error) { + console.info("newAmbient_Light_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newAmbient_Light_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0230 + * @tc.name: newAmbient_Light_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newAmbient_Light_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newAmbient_Light_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newAmbient_Light_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.AMBIENT_LIGHT); + } catch (error) { + console.info("newAmbient_Light_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newAmbient_Light_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWAMBIENT_LIGHT_JSTest_0240 + * @tc.name: newAmbient_Light_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newAmbient_Light_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('newAmbient_Light_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newAmbient_Light_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newAmbient_Light_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.AMBIENT_LIGHT); + } catch (error) { + console.info("newAmbient_Light_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newAmbient_Light_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newAmbient_Light_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js index a261094fb..cf44f1739 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newBarometer.test.js @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_53", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_53", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_53", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_53", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -68,17 +68,17 @@ describe("SensorJsTest_sensor_53", function () { const SERVICE_EXCEPTION_MSG = 'Service exception.' let invalid = -1; - /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0140 - * @tc.name: newBarometer_SensorJsTest014 - * @tc.desc:Verification results of the incorrect parameters of the test interface + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0010 + * @tc.name: newBarometer_SensorJsTest001 + * @tc.desc: Functional Use Cases */ - it("newBarometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newBarometer_SensorJsTest014--------------'); + it("newBarometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newBarometer_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest014 error'); + console.info('newBarometer_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, callback); @@ -89,7 +89,7 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info('newBarometer_SensorJsTest014 Device does not support! '); + console.info('newBarometer_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -97,20 +97,20 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0150 - * @tc.name: newBarometer_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0020 + * @tc.name: newBarometer_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newBarometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newBarometer_SensorJsTest015--------------'); + it("newBarometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newBarometer_SensorJsTest015 callback in'); + console.info('newBarometer_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newBarometer_SensorJsTest015 error:" + error); + console.info("newBarometer_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -118,29 +118,29 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0160 - * @tc.name: newBarometer_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0030 + * @tc.name: newBarometer_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newBarometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newBarometer_SensorJsTest016--------------'); + it("newBarometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest016 error'); + console.info('newBarometer_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newBarometer_SensorJsTest016 off in--------------'); + console.info('---------newBarometer_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('---------newBarometer_SensorJsTest016 off end--------------'); + console.info('---------newBarometer_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newBarometer_SensorJsTest016 Device does not support! '); + console.info('newBarometer_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -148,34 +148,34 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0170 - * @tc.name: newBarometer_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0040 + * @tc.name: newBarometer_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newBarometer_SensorJsTest017--------------'); + it("newBarometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newBarometer_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newBarometer_SensorJsTest017 callback in'); + console.info('newBarometer_SensorJsTest004 callback in'); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest017 error'); + console.info('newBarometer_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newBarometer_SensorJsTest017 off in--------------'); + console.info('---------newBarometer_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('---------newBarometer_SensorJsTest017 off end--------------'); + console.info('---------newBarometer_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newBarometer_SensorJsTest017 Device does not support! "); + console.info("newBarometer_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -183,15 +183,15 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0180 - * @tc.name: newBarometer_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0050 + * @tc.name: newBarometer_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newBarometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest018 error'); + console.info('newBarometer_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.BAROMETER, callback); @@ -202,7 +202,7 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info("newBarometer_SensorJsTest018 Device does not support! "); + console.info("newBarometer_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -210,20 +210,20 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0190 - * @tc.name: newBarometer_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0060 + * @tc.name: newBarometer_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newBarometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newBarometer_SensorJsTest019 callback in'); + console.info('newBarometer_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newBarometer_SensorJsTest019 error:" +error); + console.info("newBarometer_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -231,13 +231,13 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0200 - * @tc.name: newBarometer_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0070 + * @tc.name: newBarometer_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newBarometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newBarometer_SensorJsTest020 on error'); + console.info('newBarometer_SensorJsTest007 on error'); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); done(); @@ -245,14 +245,14 @@ describe("SensorJsTest_sensor_53", function () { try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest020 error'); + console.info('newBarometer_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.BAROMETER, onceSensorCallback, 5); } }) } catch (error) { - console.info("newBarometer_SensorJsTest020 error:" +error); + console.info("newBarometer_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -260,15 +260,15 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0210 - * @tc.name: newBarometer_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0080 + * @tc.name: newBarometer_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newBarometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newBarometer_SensorJsTest021 Device does not support! '); + console.info('newBarometer_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -276,20 +276,20 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0220 - * @tc.name: newBarometer_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0090 + * @tc.name: newBarometer_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newBarometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newBarometer_SensorJsTest022 callback in'); + console.info('newBarometer_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest022 error'); + console.info('newBarometer_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, onSensorCallback); @@ -301,7 +301,7 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info("newBarometer_SensorJsTest022 error:" +error); + console.info("newBarometer_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -309,19 +309,19 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0230 - * @tc.name: newBarometer_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0100 + * @tc.name: newBarometer_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newBarometer_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newBarometer_SensorJsTest023 on error'); + console.info('newBarometer_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newBarometer_SensorJsTest023 error:" +error); + console.info("newBarometer_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -329,37 +329,37 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0240 - * @tc.name: newBarometer_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0110 + * @tc.name: newBarometer_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newBarometer_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newBarometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest024 error'); + console.info('newBarometer_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest011 callback: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest011 callback2: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newBarometer_SensorJsTest024 off in--------------'); + console.info('---------newBarometer_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('---------newBarometer_SensorJsTest024 off end--------------'); + console.info('---------newBarometer_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newBarometer_SensorJsTest024 Device does not support! "); + console.info("newBarometer_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -367,16 +367,16 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0250 - * @tc.name: newBarometer_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0120 + * @tc.name: newBarometer_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newBarometer_SensorJsTest025--------------'); + it("newBarometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newBarometer_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest025 error'); + console.info('newBarometer_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, callback); @@ -387,7 +387,7 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info('newBarometer_SensorJsTest025 Device does not support! '); + console.info('newBarometer_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -395,38 +395,38 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0260 - * @tc.name: newBarometer_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0130 + * @tc.name: newBarometer_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newBarometer_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newBarometer_SensorJsTest026--------------'); + it("newBarometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest024 error'); + console.info('newBarometer_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest013 callback: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest013 callback2: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newBarometer_SensorJsTest026 off in--------------'); + console.info('---------newBarometer_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('---------newBarometer_SensorJsTest026 off end--------------'); + console.info('---------newBarometer_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newBarometer_SensorJsTest026 Device does not support! "); + console.info("newBarometer_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -434,38 +434,38 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0270 - * @tc.name: newBarometer_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0140 + * @tc.name: newBarometer_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newBarometer_SensorJsTest027--------------'); + it("newBarometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest024 error'); + console.info('newBarometer_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest014 callback: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.BAROMETER, (data)=>{ - console.info("newBarometer_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newBarometer_SensorJsTest014 callback2: " + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newBarometer_SensorJsTest027 off in--------------'); + console.info('---------newBarometer_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('---------newBarometer_SensorJsTest027 off end--------------'); + console.info('---------newBarometer_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newBarometer_SensorJsTest027 Device does not support! "); + console.info("newBarometer_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -473,16 +473,16 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0280 - * @tc.name: newBarometer_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0150 + * @tc.name: newBarometer_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newBarometer_SensorJsTest028--------------'); + it("newBarometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newBarometer_SensorJsTest028_on error:" +error); + console.info("newBarometer_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -490,7 +490,7 @@ describe("SensorJsTest_sensor_53", function () { try { sensor.once(); } catch (error) { - console.info("newBarometer_SensorJsTest028_once error:" +error); + console.info("newBarometer_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -498,7 +498,7 @@ describe("SensorJsTest_sensor_53", function () { try { sensor.off(); } catch (error) { - console.info("newBarometer_SensorJsTest028_off error:" +error); + console.info("newBarometer_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -506,39 +506,39 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0290 - * @tc.name: newBarometer_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWBAROMETER_JSTest_0160 + * @tc.name: newBarometer_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newBarometer_SensorJsTest029--------------'); + it("newBarometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newBarometer_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest029 error'); + console.info('newBarometer_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, callback); sensor.on(sensor.SensorId.BAROMETER, callback2); setTimeout(() => { - console.info('----------------------newBarometer_SensorJsTest029 off in--------------'); + console.info('----------------------newBarometer_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.BAROMETER, callback); } catch (error) { - console.info("newBarometer_SensorJsTest029 error:" + error); + console.info("newBarometer_SensorJsTest016 error:" + error); } - console.info('----------------------newBarometer_SensorJsTest029 off end--------------'); + console.info('----------------------newBarometer_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newBarometer_SensorJsTest029 off in--------------'); + console.info('----------------------newBarometer_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.BAROMETER, callback2); - console.info('----------------------newBarometer_SensorJsTest029 off end--------------'); + console.info('----------------------newBarometer_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newBarometer_SensorJsTest029 Device does not support! "); + console.info("newBarometer_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -546,40 +546,39 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0300 - * @tc.name: newBarometer_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWBAROMETER_JSTest_0170 + * @tc.name: newBarometer_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newBarometer_SensorJsTest030--------------'); + it("newBarometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newBarometer_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest029 error'); + console.info('newBarometer_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.BAROMETER, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newBarometer_SensorJsTest030 off in--------------'); + console.info('----------------------newBarometer_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.BAROMETER, callback); } catch (error) { - console.info("newBarometer_SensorJsTest030 error:" + error); + console.info("newBarometer_SensorJsTest017 error:" + error); } - console - console.info('----------------------newBarometer_SensorJsTest030 off end--------------'); + console.info('----------------------newBarometer_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newBarometer_SensorJsTest030_2 off in--------------'); + console.info('----------------------newBarometer_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.BAROMETER, callback2); - console.info('----------------------newBarometer_SensorJsTest030_2 off end--------------'); + console.info('----------------------newBarometer_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newBarometer_SensorJsTest030 Device does not support! "); + console.info("newBarometer_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -587,24 +586,24 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0310 - * @tc.name: newBarometer_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWBAROMETER_JSTest_0180 + * @tc.name: newBarometer_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newBarometer_SensorJsTest031--------------'); + it("newBarometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newBarometer_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest031 error'); + console.info('newBarometer_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newBarometer_SensorJsTest031 off in--------------'); + console.info('----------------------newBarometer_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newBarometer_SensorJsTest031 off end--------------'); + console.info('----------------------newBarometer_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newBarometer_SensorJsTest031 error:" + error); + console.info("newBarometer_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -612,7 +611,7 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info("newBarometer_SensorJsTest031 Device does not support! "); + console.info("newBarometer_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -620,25 +619,25 @@ describe("SensorJsTest_sensor_53", function () { }) /* - * @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0320 - * @tc.name: newBarometer_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWBAROMETER_JSTest_0190 + * @tc.name: newBarometer_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newBarometer_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newBarometer_SensorJsTest032--------------'); + it("newBarometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newBarometer_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { if (error) { - console.info('newBarometer_SensorJsTest032 error'); + console.info('newBarometer_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.BAROMETER, callback, {'interval': -100000000}); - console.info('----------------------newBarometer_SensorJsTest032 off in---------------------------'); + console.info('----------------------newBarometer_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.BAROMETER); - console.info('----------------------newBarometer_SensorJsTest032 off end---------------------------'); + console.info('----------------------newBarometer_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newBarometer_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newBarometer_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -646,10 +645,197 @@ describe("SensorJsTest_sensor_53", function () { } }) } catch (error) { - console.info("newBarometer_SensorJsTest032 Device does not support! "); + console.info("newBarometer_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0200 + * @tc.name: newBarometer_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newBarometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newBarometer_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.BAROMETER, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newBarometer_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.BAROMETER, callback); + sensor.off(sensor.SensorId.BAROMETER, callback2); + } catch (error) { + console.info("newBarometer_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newBarometer_SensorJsTest020 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newBarometer_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0210 + * @tc.name: newBarometer_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newBarometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback, undefined); + try{ + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': undefined }); + } catch(error){ + console.info('newBarometer_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newBarometer_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.BAROMETER); + } catch (error) { + console.info("newBarometer_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newBarometer_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0220 + * @tc.name: newBarometer_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newBarometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newBarometer_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback, null); + try{ + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': null }); + } catch(error){ + console.info('newBarometer_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newBarometer_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.BAROMETER); + } catch (error) { + console.info("newBarometer_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newBarometer_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0230 + * @tc.name: newBarometer_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newBarometer_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newBarometer_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newBarometer_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.BAROMETER); + } catch (error) { + console.info("newBarometer_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newBarometer_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWBAROMETER_JSTest_0240 + * @tc.name: newBarometer_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newBarometer_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => { + if (error) { + console.info('newBarometer_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.BAROMETER, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newBarometer_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newBarometer_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.BAROMETER); + } catch (error) { + console.info("newBarometer_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newBarometer_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newBarometer_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js index 9ad017896..314c62a3d 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSensorList.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_35", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_35", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_35", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_35", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessage; @@ -63,7 +63,6 @@ describe("SensorJsTest_sensor_35", function () { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest001",TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest001----------------------------------"); sensor.getSensorList().then((data) => { for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest001 " + JSON.stringify(data[i])); @@ -81,7 +80,6 @@ describe("SensorJsTest_sensor_35", function () { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest002----------------------------------"); sensor.getSensorList((error, data) => { if (error) { console.info('getSensorLists_SensorJsTest002 error'); @@ -101,9 +99,8 @@ describe("SensorJsTest_sensor_35", function () { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest003", 0, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest003----------------------------------"); sensor.getSensorList(null).then(data => { - console.info("---------------------------getSensorLists_SensorJsTest003 callback in-----------" + data.length); + console.info("--getSensorLists_SensorJsTest003 callback in--" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest003 " + JSON.stringify(data[i])); } @@ -122,9 +119,8 @@ describe("SensorJsTest_sensor_35", function () { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest004", 0, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest004----------------------------------"); sensor.getSensorList(errMessage).then(data => { - console.info("---------------------------getSensorLists_SensorJsTest004 callback in-----------" + data.length); + console.info("--getSensorLists_SensorJsTest004 callback in--" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest004 " + JSON.stringify(data[i])); } @@ -143,9 +139,8 @@ it("getSensorLists_SensorJsTest004", 0, async function (done) { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest005", 0, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest005----------------------------------"); sensor.getSensorList('xxx').then(data => { - console.info("---------------------------getSensorLists_SensorJsTest005 callback in-----------" + data.length); + console.info("--getSensorLists_SensorJsTest005 callback in--" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest005 " + JSON.stringify(data[i])); } @@ -164,16 +159,15 @@ it("getSensorLists_SensorJsTest005", 0, async function (done) { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest006", 0, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest006----------------------------------"); sensor.getSensorList(invild).then(data => { - console.info("---------------------------getSensorLists_SensorJsTest006 callback in-----------" + data.length); + console.info("--getSensorLists_SensorJsTest006 callback in--" + data.length); for (let i = 0; i < data.length; i++) { console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); } expect(true).assertTrue(); done(); }, (error) => { - console.info('getSensorLists_SensorJsTest006 failed'); + console.info('getSensorLists_SensorJsTest006 failed'+error); expect(false).assertTrue(); done(); }); @@ -185,7 +179,6 @@ it("getSensorLists_SensorJsTest005", 0, async function (done) { * @tc.desc: Verification results of the incorrect parameters of the test interface. */ it("getSensorLists_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info("---------------------------getSensorLists_SensorJsTest007----------------------------------"); try { sensor.getSensorList(invild).then(data => { console.info("getSensorLists_SensorJsTest007 " + JSON.stringify(data)); @@ -203,4 +196,44 @@ it("getSensorLists_SensorJsTest005", 0, async function (done) { done(); } }) + + /** + * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0080 + * @tc.name: getSensorLists_SensorJsTest008 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("getSensorLists_SensorJsTest008", 0, async function (done) { + sensor.getSensorList(undefined).then((data) => { + console.info("--getSensorLists_SensorJsTest008 callback in--" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest008 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('getSensorLists_SensorJsTest008 failed'); + expect(false).assertTrue(); + done(); + }); + }) + + /** + * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0090 + * @tc.name: getSensorLists_SensorJsTest009 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("getSensorLists_SensorJsTest009", 0, async function (done) { + sensor.getSensorList(null).then((data) => { + console.info("----------getSensorLists_SensorJsTest009 callback in-----" + data.length); + for (let i = 0; i < data.length; i++) { + console.info("getSensorLists_SensorJsTest009 " + JSON.stringify(data[i])); + } + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('getSensorLists_SensorJsTest009 failed'); + expect(false).assertTrue(); + done(); + }); + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSingleSensor.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSingleSensor.test.js index b6df66b43..0c3856932 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSingleSensor.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGetSingleSensor.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_36", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_36", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_36", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_36", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let invild; @@ -90,10 +90,10 @@ describe("SensorJsTest_sensor_36", function () { }) /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0020 - * @tc.name: GetSingleSensor_JSTest_002 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0020 + * @tc.name: GetSingleSensor_JSTest_002 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_002-------------------------"); try { @@ -107,10 +107,10 @@ describe("SensorJsTest_sensor_36", function () { }) /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0030 - * @tc.name: GetSingleSensor_JSTest_003 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0030 + * @tc.name: GetSingleSensor_JSTest_003 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_003-------------------------"); try { @@ -143,11 +143,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number: SUB_SensorsSystem_GetSingleSensor_JSTest_0040 - * @tc.name: GetSingleSensor_JSTest_004 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number: SUB_SensorsSystem_GetSingleSensor_JSTest_0040 + * @tc.name: GetSingleSensor_JSTest_004 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_004-------------------------"); try { @@ -180,11 +180,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0050 - * @tc.name: GetSingleSensor_JSTest_005 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0050 + * @tc.name: GetSingleSensor_JSTest_005 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_005-------------------------"); try { @@ -207,11 +207,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0060 - * @tc.name: GetSingleSensor_JSTest_006 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0060 + * @tc.name: GetSingleSensor_JSTest_006 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_006-------------------------"); try { @@ -225,10 +225,10 @@ describe("SensorJsTest_sensor_36", function () { }) /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0070 - * @tc.name: GetSingleSensor_JSTest_007 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0070 + * @tc.name: GetSingleSensor_JSTest_007 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it('GetSingleSensor_JSTest_007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------GetSingleSensor_JSTest_007-------------------------"); try { @@ -260,11 +260,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0080 - * @tc.name: GetSingleSensor_JSTest_008 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0080 + * @tc.name: GetSingleSensor_JSTest_008 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it("GetSingleSensor_JSTest_008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("------------------------GetSingleSensor_JSTest_008------------------"); try { @@ -284,11 +284,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0090 - * @tc.name: GetSingleSensor_JSTest_009 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0090 + * @tc.name: GetSingleSensor_JSTest_009 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it("GetSingleSensor_JSTest_009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("-------------------GetSingleSensor_JSTest_009----------------------"); sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => { @@ -310,11 +310,11 @@ describe("SensorJsTest_sensor_36", function () { }); }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0100 - * @tc.name: GetSingleSensor_JSTest_010 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0100 + * @tc.name: GetSingleSensor_JSTest_010 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it("GetSingleSensor_JSTest_010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("----------------GetSingleSensor_JSTest_010-----------------------"); try { @@ -332,11 +332,11 @@ describe("SensorJsTest_sensor_36", function () { } }) - /** - * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0110 - * @tc.name: GetSingleSensor_JSTest_011 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - */ + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0110 + * @tc.name: GetSingleSensor_JSTest_011 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ it("GetSingleSensor_JSTest_011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info("-------------------GetSingleSensor_JSTest_011----------------------"); try { @@ -348,4 +348,55 @@ describe("SensorJsTest_sensor_36", function () { done(); } }) + + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0120 + * @tc.name: GetSingleSensor_JSTest_012 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("GetSingleSensor_JSTest_012", 0, async function (done) { + sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, undefined).then((data) => { + console.info("GetSingleSensor_JSTest_012 " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('GetSingleSensor_JSTest_012 failed'); + expect(false).assertTrue(); + done(); + }); + }) + + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0130 + * @tc.name: GetSingleSensor_JSTest_013 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("GetSingleSensor_JSTest_013", 0, async function (done) { + sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, null).then((data) => { + console.info("GetSingleSensor_JSTest_013 " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('GetSingleSensor_JSTest_013 failed'); + expect(false).assertTrue(); + done(); + }); + }) + + /** + * @tc.number:SUB_SensorsSystem_GetSingleSensor_JSTest_0140 + * @tc.name: GetSingleSensor_JSTest_014 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("GetSingleSensor_JSTest_014", 0, async function (done) { + sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, "abc").then((data) => { + console.info("GetSingleSensor_JSTest_014 " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }, (error) => { + console.info('GetSingleSensor_JSTest_014 failed'); + expect(false).assertTrue(); + done(); + }); + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js index 8d83e9cf5..8324712e9 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGravity.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_42", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_42", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_42", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_42", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -72,12 +72,12 @@ describe("SensorJsTest_sensor_42", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0140 - * @tc.name: newGravity_SensorJsTest014 - * @tc.desc: Functional Use Cases - */ - it("newGravity_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newGravity_SensorJsTest014--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0010 + * @tc.name: newGravity_SensorJsTest001 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { sensor.on(sensor.SensorId.GRAVITY, callback); @@ -87,7 +87,7 @@ describe("SensorJsTest_sensor_42", function () { }, 500); }) } catch (error) { - console.info('newGravity_SensorJsTest014 Device does not support! '); + console.info('newGravity_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -95,16 +95,16 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0150 - * @tc.name: newGravity_SensorJsTest015 - * @tc.desc: Illegal ID passed in - */ - it("newGravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest015--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0020 + * @tc.name: newGravity_SensorJsTest002 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest002--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest014 error'); + console.info('newGravity_SensorJsTest002 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, callback); @@ -115,7 +115,7 @@ describe("SensorJsTest_sensor_42", function () { } }) } catch (error) { - console.info('newGravity_SensorJsTest014 Device does not support! '); + console.info('newGravity_SensorJsTest002 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -123,20 +123,20 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0150 - * @tc.name: newGravity_SensorJsTest015 - * @tc.desc: Illegal ID passed in - */ - it("newGravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest015--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0030 + * @tc.name: newGravity_SensorJsTest003 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest003--------------'); function onSensorCallback(data) { - console.info('newGravity_SensorJsTest015 callback in'); + console.info('newGravity_SensorJsTest003 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newGravity_SensorJsTest015 error:" + error); + console.info("newGravity_SensorJsTest003 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -144,29 +144,29 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0160 - * @tc.name: newGravity_SensorJsTest016 - * @tc.desc: For normal scenarios - */ - it("newGravity_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest016--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0040 + * @tc.name: newGravity_SensorJsTest004 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest004--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest016 error'); + console.info('newGravity_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newGravity_SensorJsTest016 off in--------------'); + console.info('---------newGravity_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('---------newGravity_SensorJsTest016 off end--------------'); + console.info('---------newGravity_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newGravity_SensorJsTest016 Device does not support! '); + console.info('newGravity_SensorJsTest004 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -174,14 +174,14 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0170 - * @tc.name: newGravity_SensorJsTest017 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newGravity_SensorJsTest017--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0050 + * @tc.name: newGravity_SensorJsTest005 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newGravity_SensorJsTest005--------------'); function onSensorCallback(data) { - console.info('newGravity_SensorJsTest017 callback in'); + console.info('newGravity_SensorJsTest005 callback in'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -190,20 +190,20 @@ describe("SensorJsTest_sensor_42", function () { try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest017 error'); + console.info('newGravity_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newGravity_SensorJsTest017 off in--------------'); + console.info('---------newGravity_SensorJsTest005 off in--------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('---------newGravity_SensorJsTest017 off end--------------'); + console.info('---------newGravity_SensorJsTest005 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newGravity_SensorJsTest017 Device does not support! "); + console.info("newGravity_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -211,15 +211,15 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0180 - * @tc.name: newGravity_SensorJsTest018 - * @tc.desc: Once Normal Subscription Scenario Use Case - */ - it("newGravity_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0060 + * @tc.name: newGravity_SensorJsTest006 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest018 error'); + console.info('newGravity_SensorJsTest006 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.GRAVITY, callback); @@ -230,7 +230,7 @@ describe("SensorJsTest_sensor_42", function () { } }) } catch (error) { - console.info("newGravity_SensorJsTest018 Device does not support! "); + console.info("newGravity_SensorJsTest006 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -238,20 +238,20 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0190 - * @tc.name: newGravity_SensorJsTest019 - * @tc.desc: Use case of illegal parameter passed into once interface - */ - it("newGravity_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0070 + * @tc.name: newGravity_SensorJsTest007 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newGravity_SensorJsTest019 callback in'); + console.info('newGravity_SensorJsTest007 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newGravity_SensorJsTest019 error:" +error); + console.info("newGravity_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -259,13 +259,13 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0200 - * @tc.name: newGravity_SensorJsTest020 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0080 + * @tc.name: newGravity_SensorJsTest008 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newGravity_SensorJsTest020 on error'); + console.info('newGravity_SensorJsTest008 on error'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -275,14 +275,14 @@ describe("SensorJsTest_sensor_42", function () { try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest020 error'); + console.info('newGravity_SensorJsTest008 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.GRAVITY, onceSensorCallback, 5); } }) } catch (error) { - console.info("newGravity_SensorJsTest020 error:" +error); + console.info("newGravity_SensorJsTest008 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -290,15 +290,15 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0210 - * @tc.name: newGravity_SensorJsTest021 - * @tc.desc: Use case of illegal parameter passed into off interface - */ - it("newGravity_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0090 + * @tc.name: newGravity_SensorJsTest009 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newGravity_SensorJsTest021 Device does not support! '); + console.info('newGravity_SensorJsTest009 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -306,20 +306,20 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0220 - * @tc.name: newGravity_SensorJsTest022 - * @tc.desc: Unsubscribe directly without waiting after starting subscription - */ - it("newGravity_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0100 + * @tc.name: newGravity_SensorJsTest010 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newGravity_SensorJsTest022 callback in'); + console.info('newGravity_SensorJsTest010 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest022 error'); + console.info('newGravity_SensorJsTest010 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, onSensorCallback); @@ -331,7 +331,7 @@ describe("SensorJsTest_sensor_42", function () { } }) } catch (error) { - console.info("newGravity_SensorJsTest022 error:" +error); + console.info("newGravity_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -339,19 +339,19 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0230 - * @tc.name: newGravity_SensorJsTest023 - * @tc.desc:SensorId1000000 of incoming exception - */ - it("newGravity_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0110 + * @tc.name: newGravity_SensorJsTest011 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newGravity_SensorJsTest023 on error'); + console.info('newGravity_SensorJsTest011 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newGravity_SensorJsTest023 error:" +error); + console.info("newGravity_SensorJsTest011 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -359,41 +359,41 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0240 - * @tc.name: newGravity_SensorJsTest024 - * @tc.desc:Call interface multiple times - */ - it("newGravity_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0120 + * @tc.name: newGravity_SensorJsTest012 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest024 error'); + console.info('newGravity_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest012 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.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest012 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newGravity_SensorJsTest024 off in--------------'); + console.info('---------newGravity_SensorJsTest012 off in--------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('---------newGravity_SensorJsTest024 off end--------------'); + console.info('---------newGravity_SensorJsTest012 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGravity_SensorJsTest024 Device does not support! "); + console.info("newGravity_SensorJsTest012 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -401,12 +401,12 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0250 - * @tc.name: newGravity_SensorJsTest025 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newGravity_SensorJsTest025--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0130 + * @tc.name: newGravity_SensorJsTest013 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { sensor.on(sensor.SensorId.GRAVITY, callback); @@ -416,7 +416,7 @@ describe("SensorJsTest_sensor_42", function () { }, 500); }) } catch (error) { - console.info('newGravity_SensorJsTest025 Device does not support! '); + console.info('newGravity_SensorJsTest013 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -424,42 +424,42 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0260 - * @tc.name: newGravity_SensorJsTest026 - * @tc.desc:Call on interface and once interface respectively, and use an off interface to close - */ - it("newGravity_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest026--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0140 + * @tc.name: newGravity_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest024 error'); + console.info('newGravity_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest014 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newGravity_SensorJsTest026 off in--------------'); + console.info('---------newGravity_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('---------newGravity_SensorJsTest026 off end--------------'); + console.info('---------newGravity_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGravity_SensorJsTest026 Device does not support! "); + console.info("newGravity_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -467,42 +467,42 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0270 - * @tc.name: newGravity_SensorJsTest027 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest027--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0150 + * @tc.name: newGravity_SensorJsTest015 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest015--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest024 error'); + console.info('newGravity_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest015 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.GRAVITY, (data)=>{ - console.info("newGravity_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest015 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newGravity_SensorJsTest027 off in--------------'); + console.info('---------newGravity_SensorJsTest015 off in--------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('---------newGravity_SensorJsTest027 off end--------------'); + console.info('---------newGravity_SensorJsTest015 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGravity_SensorJsTest027 Device does not support! "); + console.info("newGravity_SensorJsTest015 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -510,16 +510,16 @@ describe("SensorJsTest_sensor_42", function () { }) /* - * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0280 - * @tc.name: newGravity_SensorJsTest028 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGravity_SensorJsTest028--------------'); + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0160 + * @tc.name: newGravity_SensorJsTest016 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest016--------------'); try { sensor.on(); } catch (error) { - console.info("newGravity_SensorJsTest028_on error:" +error); + console.info("newGravity_SensorJsTest016 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -527,7 +527,7 @@ describe("SensorJsTest_sensor_42", function () { try { sensor.once(); } catch (error) { - console.info("newGravity_SensorJsTest028_once error:" +error); + console.info("newGravity_SensorJsTest016_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -535,113 +535,112 @@ describe("SensorJsTest_sensor_42", function () { try { sensor.off(); } catch (error) { - console.info("newGravity_SensorJsTest028_off error:" +error); + console.info("newGravity_SensorJsTest016_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) - /* - * @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0290 - * @tc.name: newGravity_SensorJsTest029 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGravity_SensorJsTest029--------------'); + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0170 + * @tc.name: newGravity_SensorJsTest017 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest029 error'); + console.info('newGravity_SensorJsTest017 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, callback); sensor.on(sensor.SensorId.GRAVITY, callback2); setTimeout(() => { - console.info('----------------------newGravity_SensorJsTest029 off in--------------'); + console.info('----------------------newGravity_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.GRAVITY, callback); } catch (error) { - console.info("newGravity_SensorJsTest029 error:" + error); + console.info("newGravity_SensorJsTest017 error:" + error); } - console.info('----------------------newGravity_SensorJsTest029 off end--------------'); + console.info('----------------------newGravity_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newGravity_SensorJsTest029 off in--------------'); + console.info('----------------------newGravity_SensorJsTest017 off in--------------'); sensor.off(sensor.SensorId.GRAVITY, callback2); - console.info('----------------------newGravity_SensorJsTest029 off end--------------'); + console.info('----------------------newGravity_SensorJsTest017 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGravity_SensorJsTest029 Device does not support! "); + console.info("newGravity_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) - /* - * @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0300 - * @tc.name: newGravity_SensorJsTest030 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGravity_SensorJsTest030--------------'); + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0180 + * @tc.name: newGravity_SensorJsTest018 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest029 error'); + console.info('newGravity_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.GRAVITY, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newGravity_SensorJsTest030 off in--------------'); + console.info('----------------------newGravity_SensorJsTest018 off in--------------'); try { sensor.off(sensor.SensorId.GRAVITY, callback); } catch (error) { - console.info("newGravity_SensorJsTest030 error:" + error); + console.info("newGravity_SensorJsTest018 error:" + error); } - console - console.info('----------------------newGravity_SensorJsTest030 off end--------------'); + console.info('----------------------newGravity_SensorJsTest018 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newGravity_SensorJsTest030_2 off in--------------'); + console.info('----------------------newGravity_SensorJsTest018_2 off in--------------'); sensor.off(sensor.SensorId.GRAVITY, callback2); - console.info('----------------------newGravity_SensorJsTest030_2 off end--------------'); + console.info('----------------------newGravity_SensorJsTest018_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGravity_SensorJsTest030 Device does not support! "); + console.info("newGravity_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) - /* - * @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0310 - * @tc.name: newGravity_SensorJsTest031 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGravity_SensorJsTest031--------------'); + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0190 + * @tc.name: newGravity_SensorJsTest019 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest031 error'); + console.info('newGravity_SensorJsTest019 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newGravity_SensorJsTest031 off in--------------'); + console.info('----------------------newGravity_SensorJsTest019 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newGravity_SensorJsTest031 off end--------------'); + console.info('----------------------newGravity_SensorJsTest019 off end--------------'); } catch (error) { - console.info("newGravity_SensorJsTest031 error:" + error); + console.info("newGravity_SensorJsTest019 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -649,33 +648,33 @@ describe("SensorJsTest_sensor_42", function () { } }) } catch (error) { - console.info("newGravity_SensorJsTest031 Device does not support! "); + console.info("newGravity_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) - /* - * @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0320 - * @tc.name: newGravity_SensorJsTest032 - * @tc.desc:Verification results of the incorrect parameters of the test interface - */ - it("newGravity_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGravity_SensorJsTest032--------------'); + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0200 + * @tc.name: newGravity_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest020--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { if (error) { - console.info('newGravity_SensorJsTest032 error'); + console.info('newGravity_SensorJsTest020 error'); } else { try { sensor.on(sensor.SensorId.GRAVITY, callback, {'interval': -100000000}); - console.info('----------------------newGravity_SensorJsTest032 off in---------------------------'); + console.info('----------------------newGravity_SensorJsTest020 off in---------------------------'); sensor.off(sensor.SensorId.GRAVITY); - console.info('----------------------newGravity_SensorJsTest032 off end---------------------------'); + console.info('----------------------newGravity_SensorJsTest020 off end---------------------------'); done(); } catch (error) { - console.info('newGravity_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newGravity_SensorJsTest020 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -683,10 +682,220 @@ describe("SensorJsTest_sensor_42", function () { } }) } catch (error) { - console.info("newGravity_SensorJsTest032 Device does not support! "); + console.info("newGravity_SensorJsTest020 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0210 + * @tc.name: newGravity_SensorJsTest021 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest021--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + sensor.on(sensor.SensorId.GRAVITY, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.GRAVITY); + done(); + }, 500); + }) + } catch (error) { + console.info('newGravity_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0220 + * @tc.name: newGravity_SensorJsTest022 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + if (error) { + console.info('newGravity_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GRAVITY, callback, undefined); + try{ + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': undefined }); + } catch(error){ + console.info('newGravity_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newGravity_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.GRAVITY); + } catch (error) { + console.info("newGravity_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newGravity_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0230 + * @tc.name: newGravity_SensorJsTest023 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + if (error) { + console.info('newGravity_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GRAVITY, callback, null); + try{ + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': null }); + } catch(error){ + console.info('newGravity_SensorJsTest023 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newGravity_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.GRAVITY); + } catch (error) { + console.info("newGravity_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newGravity_SensorJsTest023 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0240 + * @tc.name: newGravity_SensorJsTest024 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newGravity_SensorJsTest024--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + if (error) { + console.info('newGravity_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newGravity_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.GRAVITY); + } catch (error) { + console.info("newGravity_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newGravity_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0250 + * @tc.name: newGravity_SensorJsTest025 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + if (error) { + console.info('newGravity_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newGravity_SensorJsTest025 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newGravity_SensorJsTest025 off in--------------'); + try { + sensor.off(sensor.SensorId.GRAVITY); + } catch (error) { + console.info("newGravity_SensorJsTest025 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newGravity_SensorJsTest025 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newGravity_SensorJsTest025 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0260 + * @tc.name: newGravity_SensorJsTest026 + * @tc.desc: Functional Use Cases + */ + it("newGravity_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest026--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => { + if (error) { + console.info('newGravity_SensorJsTest026 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.GRAVITY, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newGravity_SensorJsTest026 off in--------------'); + try { + sensor.off(sensor.SensorId.GRAVITY, callback); + sensor.off(sensor.SensorId.GRAVITY, callback2); + } catch (error) { + console.info("newGravity_SensorJsTest026 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newGravity_SensorJsTest026 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newGravity_SensorJsTest026 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js index c202749dd..9ccc6dceb 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroScope.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_43", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_43", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_43", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_43", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -72,16 +72,16 @@ describe("SensorJsTest_sensor_43", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0140 - * @tc.name: newGyroScope_SensorJsTest014 - * @tc.desc: Functional Use Cases - */ - it("newGyroScope_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newGyroScope_SensorJsTest014--------------'); + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0010 + * @tc.name: newGyroScope_SensorJsTest001 + * @tc.desc: Functional Use Cases + */ + it("newGyroScope_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGyroScope_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest014 error'); + console.info('newGyroScope_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, callback); @@ -92,7 +92,7 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info('newGyroScope_SensorJsTest014 Device does not support! '); + console.info('newGyroScope_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -100,20 +100,20 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0150 - * @tc.name: newGyroScope_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0020 + * @tc.name: newGyroScope_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newGyroScope_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGyroScope_SensorJsTest015--------------'); + it("newGyroScope_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGyroScope_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newGyroScope_SensorJsTest015 callback in'); + console.info('newGyroScope_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newGyroScope_SensorJsTest015 error:" + error); + console.info("newGyroScope_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -121,29 +121,29 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0160 - * @tc.name: newGyroScope_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0030 + * @tc.name: newGyroScope_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newGyroScope_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGyroScope_SensorJsTest016--------------'); + it("newGyroScope_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGyroScope_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest016 error'); + console.info('newGyroScope_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newGyroScope_SensorJsTest016 off in--------------'); + console.info('---------newGyroScope_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('---------newGyroScope_SensorJsTest016 off end--------------'); + console.info('---------newGyroScope_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newGyroScope_SensorJsTest016 Device does not support! '); + console.info('newGyroScope_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -151,14 +151,14 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0170 - * @tc.name: newGyroScope_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0040 + * @tc.name: newGyroScope_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newGyroScope_SensorJsTest017--------------'); + it("newGyroScope_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newGyroScope_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newGyroScope_SensorJsTest017 callback in'); + console.info('newGyroScope_SensorJsTest004 callback in'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -167,20 +167,20 @@ describe("SensorJsTest_sensor_43", function () { try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest017 error'); + console.info('newGyroScope_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newGyroScope_SensorJsTest017 off in--------------'); + console.info('---------newGyroScope_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('---------newGyroScope_SensorJsTest017 off end--------------'); + console.info('---------newGyroScope_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest017 Device does not support! "); + console.info("newGyroScope_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -188,15 +188,15 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0180 - * @tc.name: newGyroScope_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0050 + * @tc.name: newGyroScope_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newGyroScope_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest018 error'); + console.info('newGyroScope_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.GYROSCOPE, callback); @@ -207,7 +207,7 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info("newGyroScope_SensorJsTest018 Device does not support! "); + console.info("newGyroScope_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -215,20 +215,20 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0190 - * @tc.name: newGyroScope_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0060 + * @tc.name: newGyroScope_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newGyroScope_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newGyroScope_SensorJsTest019 callback in'); + console.info('newGyroScope_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newGyroScope_SensorJsTest019 error:" +error); + console.info("newGyroScope_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -236,13 +236,13 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0200 - * @tc.name: newGyroScope_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0070 + * @tc.name: newGyroScope_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newGyroScope_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newGyroScope_SensorJsTest020 on error'); + console.info('newGyroScope_SensorJsTest007 on error'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -252,14 +252,14 @@ describe("SensorJsTest_sensor_43", function () { try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest020 error'); + console.info('newGyroScope_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.GYROSCOPE, onceSensorCallback, 5); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest020 error:" +error); + console.info("newGyroScope_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -267,15 +267,15 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0210 - * @tc.name: newGyroScope_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0080 + * @tc.name: newGyroScope_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newGyroScope_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newGyroScope_SensorJsTest021 Device does not support! '); + console.info('newGyroScope_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -283,20 +283,20 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0220 - * @tc.name: newGyroScope_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0090 + * @tc.name: newGyroScope_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newGyroScope_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newGyroScope_SensorJsTest022 callback in'); + console.info('newGyroScope_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest022 error'); + console.info('newGyroScope_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback); @@ -308,7 +308,7 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info("newGyroScope_SensorJsTest022 error:" +error); + console.info("newGyroScope_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -316,19 +316,19 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0230 - * @tc.name: newGyroScope_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0100 + * @tc.name: newGyroScope_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newGyroScope_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newGyroScope_SensorJsTest023 on error'); + console.info('newGyroScope_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newGyroScope_SensorJsTest023 error:" +error); + console.info("newGyroScope_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -336,41 +336,41 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0240 - * @tc.name: newGyroScope_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0110 + * @tc.name: newGyroScope_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newGyroScope_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newGyroScope_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest024 error'); + console.info('newGyroScope_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newGyroScope_SensorJsTest011 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.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newGyroScope_SensorJsTest011 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newGyroScope_SensorJsTest024 off in--------------'); + console.info('---------newGyroScope_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('---------newGyroScope_SensorJsTest024 off end--------------'); + console.info('---------newGyroScope_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest024 Device does not support! "); + console.info("newGyroScope_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -378,16 +378,16 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0250 - * @tc.name: newGyroScope_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0120 + * @tc.name: newGravity_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newGyroScope_SensorJsTest025--------------'); + it("newGravity_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGravity_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest025 error'); + console.info('newGravity_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, callback); @@ -398,7 +398,7 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info('newGyroScope_SensorJsTest025 Device does not support! '); + console.info('newGravity_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -406,42 +406,42 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0260 - * @tc.name: newGyroScope_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0130 + * @tc.name: newGravity_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newGyroScope_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGyroScope_SensorJsTest026--------------'); + it("newGravity_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest024 error'); + console.info('newGyroScope_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest013 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest013 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newGyroScope_SensorJsTest026 off in--------------'); + console.info('---------newGravity_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('---------newGyroScope_SensorJsTest026 off end--------------'); + console.info('---------newGravity_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest026 Device does not support! "); + console.info("newGravity_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -449,42 +449,42 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0270 - * @tc.name: newGyroScope_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0140 + * @tc.name: newGravity_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGyroScope_SensorJsTest027--------------'); + it("newGravity_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest024 error'); + console.info('newGyroScope_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{ - console.info("newGyroScope_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newGravity_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newGyroScope_SensorJsTest027 off in--------------'); + console.info('---------newGravity_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('---------newGyroScope_SensorJsTest027 off end--------------'); + console.info('---------newGravity_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest027 Device does not support! "); + console.info("newGravity_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -492,16 +492,16 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0280 - * @tc.name: newGyroScope_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0150 + * @tc.name: newGravity_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newGyroScope_SensorJsTest028--------------'); + it("newGravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGravity_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newGyroScope_SensorJsTest028_on error:" +error); + console.info("newGravity_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -509,7 +509,7 @@ describe("SensorJsTest_sensor_43", function () { try { sensor.once(); } catch (error) { - console.info("newGyroScope_SensorJsTest028_once error:" +error); + console.info("newGravity_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -517,7 +517,7 @@ describe("SensorJsTest_sensor_43", function () { try { sensor.off(); } catch (error) { - console.info("newGyroScope_SensorJsTest028_off error:" +error); + console.info("newGravity_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -525,39 +525,39 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0290 - * @tc.name: newGyroScope_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0160 + * @tc.name: newGravity_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGyroScope_SensorJsTest029--------------'); + it("newGravity_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest029 error'); + console.info('newGravity_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, callback); sensor.on(sensor.SensorId.GYROSCOPE, callback2); setTimeout(() => { - console.info('----------------------newGyroScope_SensorJsTest029 off in--------------'); + console.info('----------------------newGravity_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.GYROSCOPE, callback); } catch (error) { - console.info("newGyroScope_SensorJsTest029 error:" + error); + console.info("newGravity_SensorJsTest016 error:" + error); } - console.info('----------------------newGyroScope_SensorJsTest029 off end--------------'); + console.info('----------------------newGravity_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newGyroScope_SensorJsTest029 off in--------------'); + console.info('----------------------newGravity_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback2); - console.info('----------------------newGyroScope_SensorJsTest029 off end--------------'); + console.info('----------------------newGravity_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest029 Device does not support! "); + console.info("newGravity_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -565,40 +565,39 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0300 - * @tc.name: newGyroScope_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0170 + * @tc.name: newGravity_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGyroScope_SensorJsTest030--------------'); + it("newGravity_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest029 error'); + console.info('newGravity_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.GYROSCOPE, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newGyroScope_SensorJsTest030 off in--------------'); + console.info('----------------------newGravity_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.GYROSCOPE, callback); } catch (error) { - console.info("newGyroScope_SensorJsTest030 error:" + error); + console.info("newGravity_SensorJsTest017 error:" + error); } - console - console.info('----------------------newGyroScope_SensorJsTest030 off end--------------'); + console.info('----------------------newGravity_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newGyroScope_SensorJsTest030_2 off in--------------'); + console.info('----------------------newGravity_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.GYROSCOPE, callback2); - console.info('----------------------newGyroScope_SensorJsTest030_2 off end--------------'); + console.info('----------------------newGravity_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newGyroScope_SensorJsTest030 Device does not support! "); + console.info("newGravity_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -606,24 +605,24 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0310 - * @tc.name: newGyroScope_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0180 + * @tc.name: newGravity_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGyroScope_SensorJsTest031--------------'); + it("newGravity_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest031 error'); + console.info('newGravity_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newGyroScope_SensorJsTest031 off in--------------'); + console.info('----------------------newGravity_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newGyroScope_SensorJsTest031 off end--------------'); + console.info('----------------------newGravity_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newGyroScope_SensorJsTest031 error:" + error); + console.info("newGravity_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -631,7 +630,7 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info("newGyroScope_SensorJsTest031 Device does not support! "); + console.info("newGravity_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -639,25 +638,25 @@ describe("SensorJsTest_sensor_43", function () { }) /* - * @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0320 - * @tc.name: newGyroScope_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0190 + * @tc.name: newGravity_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newGyroScope_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newGyroScope_SensorJsTest032--------------'); + it("newGravity_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newGravity_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { if (error) { - console.info('newGyroScope_SensorJsTest032 error'); + console.info('newGravity_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': -100000000}); - console.info('----------------------newGyroScope_SensorJsTest032 off in---------------------------'); + console.info('----------------------newGravity_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.GYROSCOPE); - console.info('----------------------newGyroScope_SensorJsTest032 off end---------------------------'); + console.info('----------------------newGravity_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newGyroScope_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newGravity_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -665,10 +664,197 @@ describe("SensorJsTest_sensor_43", function () { } }) } catch (error) { - console.info("newGyroScope_SensorJsTest032 Device does not support! "); + console.info("newGravity_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0200 + * @tc.name: newGyroScope_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newGyroScope_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newGyroScope_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.GYROSCOPE, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newGyroScope_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.GYROSCOPE, callback); + sensor.off(sensor.SensorId.GYROSCOPE, callback2); + } catch (error) { + console.info("newGyroScope_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newGyroScope_SensorJsTest020 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newGyroScope_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0210 + * @tc.name: newGyroScope_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newGyroScope_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback, undefined); + try{ + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': undefined }); + } catch(error){ + console.info('newGyroScope_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newGyroScope_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.GYROSCOPE); + } catch (error) { + console.info("newGyroScope_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newGyroScope_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0220 + * @tc.name: newGyroScope_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newGyroScope_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newGyroScope_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback, null); + try{ + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': null }); + } catch(error){ + console.info('newGyroScope_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newGyroScope_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.GYROSCOPE); + } catch (error) { + console.info("newGyroScope_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newGyroScope_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0230 + * @tc.name: newGyroScope_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newGyroScope_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newGyroScope_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newGyroScope_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.GYROSCOPE); + } catch (error) { + console.info("newGyroScope_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newGyroScope_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWGYROSCOPE_JSTest_0240 + * @tc.name: newGyroScope_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newGyroScope_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => { + if (error) { + console.info('newGyroScope_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newGyroScope_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newGyroScope_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.GYROSCOPE); + } catch (error) { + console.info("newGyroScope_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newGyroScope_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newGyroScope_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroscope_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroscope_Uncalibrated.test.js index 2ca8cdb2e..09c866f97 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroscope_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newGyroscope_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_44", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_44", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_44", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_44", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js index ae8dfd171..4a8391f0d 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHall.test.js @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_45", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_45", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_45", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_45", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -68,16 +68,16 @@ describe("SensorJsTest_sensor_45", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0140 - * @tc.name: newHall_SensorJsTest014 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0010 + * @tc.name: newHall_SensorJsTest001 * @tc.desc: Functional Use Cases */ - it("newHall_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newHall_SensorJsTest014--------------'); + it("newHall_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newHall_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest014 error'); + console.info('newHall_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, callback); @@ -88,7 +88,7 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info('newHall_SensorJsTest014 Device does not support! '); + console.info('newHall_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -96,20 +96,20 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0150 - * @tc.name: newHall_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0020 + * @tc.name: newHall_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newHall_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newHall_SensorJsTest015--------------'); + it("newHall_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newHall_SensorJsTest015 callback in'); + console.info('newHall_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newHall_SensorJsTest015 error:" + error); + console.info("newHall_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -117,29 +117,29 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0160 - * @tc.name: newHall_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0030 + * @tc.name: newHall_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newHall_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newHall_SensorJsTest016--------------'); + it("newHall_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest016 error'); + console.info('newHall_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newHall_SensorJsTest016 off in--------------'); + console.info('---------newHall_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.HALL); - console.info('---------newHall_SensorJsTest016 off end--------------'); + console.info('---------newHall_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newHall_SensorJsTest016 Device does not support! '); + console.info('newHall_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -147,34 +147,34 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0170 - * @tc.name: newHall_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0040 + * @tc.name: newHall_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newHall_SensorJsTest017--------------'); + it("newHall_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newHall_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newHall_SensorJsTest017 callback in'); + console.info('newHall_SensorJsTest004 callback in'); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest017 error'); + console.info('newHall_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newHall_SensorJsTest017 off in--------------'); + console.info('---------newHall_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.HALL); - console.info('---------newHall_SensorJsTest017 off end--------------'); + console.info('---------newHall_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newHall_SensorJsTest017 Device does not support! "); + console.info("newHall_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -182,15 +182,15 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0180 - * @tc.name: newHall_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0050 + * @tc.name: newHall_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newHall_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest018 error'); + console.info('newHall_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.HALL, callback); @@ -201,7 +201,7 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info("newHall_SensorJsTest018 Device does not support! "); + console.info("newHall_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -209,20 +209,20 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0190 - * @tc.name: newHall_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0060 + * @tc.name: newHall_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newHall_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newHall_SensorJsTest019 callback in'); + console.info('newHall_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newHall_SensorJsTest019 error:" +error); + console.info("newHall_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -230,13 +230,13 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0200 - * @tc.name: newHall_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0070 + * @tc.name: newHall_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newHall_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newHall_SensorJsTest020 on error'); + console.info('newHall_SensorJsTest007 on error'); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); done(); @@ -244,14 +244,14 @@ describe("SensorJsTest_sensor_45", function () { try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest020 error'); + console.info('newHall_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.HALL, onceSensorCallback, 5); } }) } catch (error) { - console.info("newHall_SensorJsTest020 error:" +error); + console.info("newHall_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -259,15 +259,15 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0210 - * @tc.name: newHall_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0080 + * @tc.name: newHall_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newHall_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newHall_SensorJsTest021 Device does not support! '); + console.info('newHall_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -275,20 +275,20 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0220 - * @tc.name: newHall_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0090 + * @tc.name: newHall_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newHall_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newHall_SensorJsTest022 callback in'); + console.info('newHall_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest022 error'); + console.info('newHall_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, onSensorCallback); @@ -300,7 +300,7 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info("newHall_SensorJsTest022 error:" +error); + console.info("newHall_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -308,19 +308,19 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0230 - * @tc.name: newHall_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0100 + * @tc.name: newHall_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newHall_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newHall_SensorJsTest023 on error'); + console.info('newHall_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newHall_SensorJsTest023 error:" +error); + console.info("newHall_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -328,37 +328,37 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0240 - * @tc.name: newHall_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0110 + * @tc.name: newHall_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newHall_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newHall_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest024 error'); + console.info('newHall_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest011 callback: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest011 callback2: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newHall_SensorJsTest024 off in--------------'); + console.info('---------newHall_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.HALL); - console.info('---------newHall_SensorJsTest024 off end--------------'); + console.info('---------newHall_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newHall_SensorJsTest024 Device does not support! "); + console.info("newHall_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -366,16 +366,16 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0250 - * @tc.name: newHall_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0120 + * @tc.name: newHall_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newHall_SensorJsTest025--------------'); + it("newHall_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newHall_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest025 error'); + console.info('newHall_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, callback); @@ -386,7 +386,7 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info('newHall_SensorJsTest025 Device does not support! '); + console.info('newHall_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -394,38 +394,38 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0260 - * @tc.name: newHall_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0130 + * @tc.name: newHall_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newHall_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newHall_SensorJsTest026--------------'); + it("newHall_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest024 error'); + console.info('newHall_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest013 callback: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest013 callback2: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newHall_SensorJsTest026 off in--------------'); + console.info('---------newHall_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.HALL); - console.info('---------newHall_SensorJsTest026 off end--------------'); + console.info('---------newHall_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newHall_SensorJsTest026 Device does not support! "); + console.info("newHall_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -433,38 +433,38 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0270 - * @tc.name: newHall_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0140 + * @tc.name: newHall_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newHall_SensorJsTest027--------------'); + it("newHall_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest024 error'); + console.info('newHall_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest014 callback: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.HALL, (data)=>{ - console.info("newHall_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newHall_SensorJsTest014 callback2: " + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newHall_SensorJsTest027 off in--------------'); + console.info('---------newHall_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.HALL); - console.info('---------newHall_SensorJsTest027 off end--------------'); + console.info('---------newHall_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newHall_SensorJsTest027 Device does not support! "); + console.info("newHall_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -472,16 +472,16 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number:SUB_SensorsSystem_HALL_JSTest_0280 - * @tc.name: newHall_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0150 + * @tc.name: newHall_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newHall_SensorJsTest028--------------'); + it("newHall_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newHall_SensorJsTest028_on error:" +error); + console.info("newHall_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -489,7 +489,7 @@ describe("SensorJsTest_sensor_45", function () { try { sensor.once(); } catch (error) { - console.info("newHall_SensorJsTest028_once error:" +error); + console.info("newHall_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -497,7 +497,7 @@ describe("SensorJsTest_sensor_45", function () { try { sensor.off(); } catch (error) { - console.info("newHall_SensorJsTest028_off error:" +error); + console.info("newHall_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -505,39 +505,39 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number: SUB_SensorsSystem_HALL_JSTest_0290 - * @tc.name: newHall_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWHALL_JSTest_0160 + * @tc.name: newHall_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newHall_SensorJsTest029--------------'); + it("newHall_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newHall_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest029 error'); + console.info('newHall_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, callback); sensor.on(sensor.SensorId.HALL, callback2); setTimeout(() => { - console.info('----------------------newHall_SensorJsTest029 off in--------------'); + console.info('----------------------newHall_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.HALL, callback); } catch (error) { - console.info("newHall_SensorJsTest029 error:" + error); + console.info("newHall_SensorJsTest016 error:" + error); } - console.info('----------------------newHall_SensorJsTest029 off end--------------'); + console.info('----------------------newHall_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newHall_SensorJsTest029 off in--------------'); + console.info('----------------------newHall_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.HALL, callback2); - console.info('----------------------newHall_SensorJsTest029 off end--------------'); + console.info('----------------------newHall_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newHall_SensorJsTest029 Device does not support! "); + console.info("newHall_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -545,40 +545,39 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number: SUB_SensorsSystem_HALL_JSTest_0300 - * @tc.name: newHall_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWHALL_JSTest_0170 + * @tc.name: newHall_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newHall_SensorJsTest030--------------'); + it("newHall_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newHall_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest029 error'); + console.info('newHall_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.HALL, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.HALL, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newHall_SensorJsTest030 off in--------------'); + console.info('----------------------newHall_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.HALL, callback); } catch (error) { - console.info("newHall_SensorJsTest030 error:" + error); + console.info("newHall_SensorJsTest017 error:" + error); } - console - console.info('----------------------newHall_SensorJsTest030 off end--------------'); + console.info('----------------------newHall_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newHall_SensorJsTest030_2 off in--------------'); + console.info('----------------------newHall_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.HALL, callback2); - console.info('----------------------newHall_SensorJsTest030_2 off end--------------'); + console.info('----------------------newHall_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newHall_SensorJsTest030 Device does not support! "); + console.info("newHall_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -586,24 +585,24 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number: SUB_SensorsSystem_HALL_JSTest_0310 - * @tc.name: newHall_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWHALL_JSTest_0180 + * @tc.name: newHall_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newHall_SensorJsTest031--------------'); + it("newHall_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newHall_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest031 error'); + console.info('newHall_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newHall_SensorJsTest031 off in--------------'); + console.info('----------------------newHall_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newHall_SensorJsTest031 off end--------------'); + console.info('----------------------newHall_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newHall_SensorJsTest031 error:" + error); + console.info("newHall_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -611,7 +610,7 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info("newHall_SensorJsTest031 Device does not support! "); + console.info("newHall_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -619,25 +618,25 @@ describe("SensorJsTest_sensor_45", function () { }) /* - * @tc.number: SUB_SensorsSystem_HALL_JSTest_0320 - * @tc.name: newHall_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWHALL_JSTest_0190 + * @tc.name: newHall_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newHall_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newHall_SensorJsTest032--------------'); + it("newHall_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newHall_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { if (error) { - console.info('newHall_SensorJsTest032 error'); + console.info('newHall_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.HALL, callback, {'interval': -100000000}); - console.info('----------------------newHall_SensorJsTest032 off in---------------------------'); + console.info('----------------------newHall_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.HALL); - console.info('----------------------newHall_SensorJsTest032 off end---------------------------'); + console.info('----------------------newHall_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newHall_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newHall_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -645,10 +644,197 @@ describe("SensorJsTest_sensor_45", function () { } }) } catch (error) { - console.info("newHall_SensorJsTest032 Device does not support! "); + console.info("newHall_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0200 + * @tc.name: newHall_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newHall_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newHall_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.HALL, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newHall_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.HALL, callback); + sensor.off(sensor.SensorId.HALL, callback2); + } catch (error) { + console.info("newHall_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newHall_SensorJsTest020 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newHall_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0210 + * @tc.name: newHall_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newHall_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback, undefined); + try{ + sensor.on(sensor.SensorId.HALL, callback, { 'interval': undefined }); + } catch(error){ + console.info('newHall_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newHall_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.HALL); + } catch (error) { + console.info("newHall_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newHall_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0220 + * @tc.name: newHall_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newHall_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newHall_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback, null); + try{ + sensor.on(sensor.SensorId.HALL, callback, { 'interval': null }); + } catch(error){ + console.info('newHall_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newHall_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.HALL); + } catch (error) { + console.info("newHall_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newHall_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0230 + * @tc.name: newHall_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newHall_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newHall_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newHall_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.HALL); + } catch (error) { + console.info("newHall_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newHall_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWHALL_JSTest_0240 + * @tc.name: newHall_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newHall_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => { + if (error) { + console.info('newHall_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.HALL, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.HALL, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newHall_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newHall_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.HALL); + } catch (error) { + console.info("newHall_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newHall_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newHall_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHeart_Rate.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHeart_Rate.test.js index c1932e92a..cce9ff81c 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHeart_Rate.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHeart_Rate.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_52", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_52", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_52", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_52", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHumidity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHumidity.test.js index 441729796..3f75c3db8 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHumidity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newHumidity.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_55", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_55", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_55", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_55", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newLinear_Accelerometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newLinear_Accelerometer.test.js index e7208815f..04e765d36 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newLinear_Accelerometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newLinear_Accelerometer.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_51", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_51", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_51", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_51", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js index d2ad21c5b..3e8dc34de 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_37", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_37", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_37", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_37", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -72,12 +72,12 @@ describe("SensorJsTest_sensor_37", function () { let invalid = -1; /* - * @tc.number:SUB_SensorSystem_MAGNETIC_FIELD_JsTest_0140 - * @tc.name: newMagneticField_SensorJsTest014 - * @tc.desc: Functional Use Cases + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0010 + * @tc.name: newMagneticField_SensorJsTest001 + * @tc.desc: Illegal ID passed in */ - it("newMagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newMagneticField_SensorJsTest014--------------'); + it("newMagneticField_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newMagneticField_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback); @@ -87,7 +87,7 @@ describe("SensorJsTest_sensor_37", function () { }, 500); }) } catch (error) { - console.info('newMagneticField_SensorJsTest014 Device does not support! '); + console.info('newMagneticField_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -95,16 +95,16 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0150 - * @tc.name: newMagneticField_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0020 + * @tc.name: newMagneticField_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newMagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newMagneticField_SensorJsTest014--------------'); + it("newMagneticField_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newMagneticField_SensorJsTest002--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest014 error'); + console.info('newMagneticField_SensorJsTest002 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback); @@ -115,7 +115,7 @@ describe("SensorJsTest_sensor_37", function () { } }) } catch (error) { - console.info('newMagneticField_SensorJsTest014 Device does not support! '); + console.info('newMagneticField_SensorJsTest002 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -123,20 +123,20 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0150 - * @tc.name: newMagneticField_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0030 + * @tc.name: newMagneticField_SensorJsTest003 * @tc.desc: Illegal ID passed in */ - it("newMagneticField_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newMagneticField_SensorJsTest015--------------'); + it("newMagneticField_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest003--------------'); function onSensorCallback(data) { - console.info('newMagneticField_SensorJsTest015 callback in'); + console.info('newMagneticField_SensorJsTest003 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newMagneticField_SensorJsTest015 error:" + error); + console.info("newMagneticField_SensorJsTest003 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -144,29 +144,29 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0160 - * @tc.name: newMagneticField_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0040 + * @tc.name: newMagneticField_SensorJsTest004 * @tc.desc: For normal scenarios */ - it("newMagneticField_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newMagneticField_SensorJsTest016--------------'); + it("newMagneticField_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest004--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest016 error'); + console.info('newMagneticField_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newMagneticField_SensorJsTest016 off in--------------'); + console.info('---------newMagneticField_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('---------newMagneticField_SensorJsTest016 off end--------------'); + console.info('---------newMagneticField_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newMagneticField_SensorJsTest016 Device does not support! '); + console.info('newMagneticField_SensorJsTest004 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -174,14 +174,14 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0170 - * @tc.name: newMagneticField_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0050 + * @tc.name: newMagneticField_SensorJsTest005 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newMagneticField_SensorJsTest017--------------'); + it("newMagneticField_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newMagneticField_SensorJsTest005--------------'); function onSensorCallback(data) { - console.info('newMagneticField_SensorJsTest017 callback in'); + console.info('newMagneticField_SensorJsTest005 callback in'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -190,20 +190,20 @@ describe("SensorJsTest_sensor_37", function () { try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest017 error'); + console.info('newMagneticField_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newMagneticField_SensorJsTest017 off in--------------'); + console.info('---------newMagneticField_SensorJsTest005 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('---------newMagneticField_SensorJsTest017 off end--------------'); + console.info('---------newMagneticField_SensorJsTest005 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest017 Device does not support! "); + console.info("newMagneticField_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -211,15 +211,15 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0180 - * @tc.name: newMagneticField_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0060 + * @tc.name: newMagneticField_SensorJsTest006 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newMagneticField_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest018 error'); + console.info('newMagneticField_SensorJsTest006 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.MAGNETIC_FIELD, callback); @@ -230,7 +230,7 @@ describe("SensorJsTest_sensor_37", function () { } }) } catch (error) { - console.info("newMagneticField_SensorJsTest018 Device does not support! "); + console.info("newMagneticField_SensorJsTest006 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -238,20 +238,20 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0190 - * @tc.name: newMagneticField_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0070 + * @tc.name: newMagneticField_SensorJsTest007 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newMagneticField_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newMagneticField_SensorJsTest019 callback in'); + console.info('newMagneticField_SensorJsTest007 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newMagneticField_SensorJsTest019 error:" +error); + console.info("newMagneticField_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -259,13 +259,13 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0200 - * @tc.name: newMagneticField_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0080 + * @tc.name: newMagneticField_SensorJsTest008 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newMagneticField_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newMagneticField_SensorJsTest020 on error'); + console.info('newMagneticField_SensorJsTest008 on error'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -275,14 +275,14 @@ describe("SensorJsTest_sensor_37", function () { try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest020 error'); + console.info('newMagneticField_SensorJsTest008 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.MAGNETIC_FIELD, onceSensorCallback, 5); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest020 error:" +error); + console.info("newMagneticField_SensorJsTest008 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -290,15 +290,15 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0210 - * @tc.name: newMagneticField_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0090 + * @tc.name: newMagneticField_SensorJsTest009 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newMagneticField_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newMagneticField_SensorJsTest021 Device does not support! '); + console.info('newMagneticField_SensorJsTest009 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -306,20 +306,20 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0220 - * @tc.name: newMagneticField_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0100 + * @tc.name: newMagneticField_SensorJsTest010 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newMagneticField_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newMagneticField_SensorJsTest022 callback in'); + console.info('newMagneticField_SensorJsTest010 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest022 error'); + console.info('newMagneticField_SensorJsTest010 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, onSensorCallback); @@ -331,7 +331,7 @@ describe("SensorJsTest_sensor_37", function () { } }) } catch (error) { - console.info("newMagneticField_SensorJsTest022 error:" +error); + console.info("newMagneticField_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -339,19 +339,19 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0230 - * @tc.name: newMagneticField_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0110 + * @tc.name: newMagneticField_SensorJsTest011 * @tc.desc:SensorId1000000 of incoming exception */ - it("newMagneticField_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newMagneticField_SensorJsTest023 on error'); + console.info('newMagneticField_SensorJsTest011 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newMagneticField_SensorJsTest023 error:" +error); + console.info("newMagneticField_SensorJsTest011 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -359,41 +359,41 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0240 - * @tc.name: newMagneticField_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0120 + * @tc.name: newMagneticField_SensorJsTest012 * @tc.desc:Call interface multiple times */ - it("newMagneticField_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newMagneticField_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest024 error'); + console.info('newMagneticField_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest012 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.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest012 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newMagneticField_SensorJsTest024 off in--------------'); + console.info('---------newMagneticField_SensorJsTest012 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('---------newMagneticField_SensorJsTest024 off end--------------'); + console.info('---------newMagneticField_SensorJsTest012 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest024 Device does not support! "); + console.info("newMagneticField_SensorJsTest012 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -401,12 +401,12 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0250 - * @tc.name: newMagneticField_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0130 + * @tc.name: newMagneticField_SensorJsTest013 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newMagneticField_SensorJsTest025--------------'); + it("newMagneticField_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newMagneticField_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback); @@ -416,7 +416,7 @@ describe("SensorJsTest_sensor_37", function () { }, 500); }) } catch (error) { - console.info('newMagneticField_SensorJsTest025 Device does not support! '); + console.info('newMagneticField_SensorJsTest013 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -424,42 +424,42 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0260 - * @tc.name: newMagneticField_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0140 + * @tc.name: newMagneticField_SensorJsTest014 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newMagneticField_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newMagneticField_SensorJsTest026--------------'); + it("newMagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest024 error'); + console.info('newMagneticField_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest014 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest014 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.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newMagneticField_SensorJsTest026 off in--------------'); + console.info('---------newMagneticField_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('---------newMagneticField_SensorJsTest026 off end--------------'); + console.info('---------newMagneticField_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest026 Device does not support! "); + console.info("newMagneticField_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -467,42 +467,42 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0270 - * @tc.name: newMagneticField_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0150 + * @tc.name: newMagneticField_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newMagneticField_SensorJsTest027--------------'); + it("newMagneticField_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest015--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest024 error'); + console.info('newMagneticField_SensorJsTest015 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest015 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{ - console.info("newMagneticField_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newMagneticField_SensorJsTest015 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.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newMagneticField_SensorJsTest027 off in--------------'); + console.info('---------newMagneticField_SensorJsTest015 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('---------newMagneticField_SensorJsTest027 off end--------------'); + console.info('---------newMagneticField_SensorJsTest015 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest027 Device does not support! "); + console.info("newMagneticField_SensorJsTest015 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -510,16 +510,16 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0280 - * @tc.name: newMagneticField_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0160 + * @tc.name: newMagneticField_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newMagneticField_SensorJsTest028--------------'); + it("newMagneticField_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest016--------------'); try { sensor.on(); } catch (error) { - console.info("newMagneticField_SensorJsTest028_on error:" +error); + console.info("newMagneticField_SensorJsTest016_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -527,7 +527,7 @@ describe("SensorJsTest_sensor_37", function () { try { sensor.once(); } catch (error) { - console.info("newMagneticField_SensorJsTest028_once error:" +error); + console.info("newMagneticField_SensorJsTest016_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -535,7 +535,7 @@ describe("SensorJsTest_sensor_37", function () { try { sensor.off(); } catch (error) { - console.info("newMagneticField_SensorJsTest028_off error:" +error); + console.info("newMagneticField_SensorJsTest016_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -543,39 +543,39 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0290 - * @tc.name: newMagneticField_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0170 + * @tc.name: newMagneticField_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newMagneticField_SensorJsTest029--------------'); + it("newMagneticField_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newMagneticField_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest029 error'); + console.info('newMagneticField_SensorJsTest017 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2); setTimeout(() => { - console.info('----------------------newMagneticField_SensorJsTest029 off in--------------'); + console.info('----------------------newMagneticField_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback); } catch (error) { - console.info("newMagneticField_SensorJsTest029 error:" + error); + console.info("newMagneticField_SensorJsTest017 error:" + error); } - console.info('----------------------newMagneticField_SensorJsTest029 off end--------------'); + console.info('----------------------newMagneticField_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newMagneticField_SensorJsTest029 off in--------------'); + console.info('----------------------newMagneticField_SensorJsTest017 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback2); - console.info('----------------------newMagneticField_SensorJsTest029 off end--------------'); + console.info('----------------------newMagneticField_SensorJsTest017 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest029 Device does not support! "); + console.info("newMagneticField_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -583,40 +583,39 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0300 - * @tc.name: newMagneticField_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0180 + * @tc.name: newMagneticField_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newMagneticField_SensorJsTest030--------------'); + it("newMagneticField_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newMagneticField_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest029 error'); + console.info('newMagneticField_SensorJsTest017 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newMagneticField_SensorJsTest030 off in--------------'); + console.info('----------------------newMagneticField_SensorJsTest018 off in--------------'); try { sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback); } catch (error) { - console.info("newMagneticField_SensorJsTest030 error:" + error); + console.info("newMagneticField_SensorJsTest018 error:" + error); } - console - console.info('----------------------newMagneticField_SensorJsTest030 off end--------------'); + console.info('----------------------newMagneticField_SensorJsTest018 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newMagneticField_SensorJsTest030_2 off in--------------'); + console.info('----------------------newMagneticField_SensorJsTest018_2 off in--------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback2); - console.info('----------------------newMagneticField_SensorJsTest030_2 off end--------------'); + console.info('----------------------newMagneticField_SensorJsTest018_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newMagneticField_SensorJsTest030 Device does not support! "); + console.info("newMagneticField_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -624,24 +623,24 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0310 - * @tc.name: newMagneticField_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0190 + * @tc.name: newMagneticField_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newMagneticField_SensorJsTest031--------------'); + it("newMagneticField_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newMagneticField_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest031 error'); + console.info('newMagneticField_SensorJsTest019 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newMagneticField_SensorJsTest031 off in--------------'); + console.info('----------------------newMagneticField_SensorJsTest019 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newMagneticField_SensorJsTest031 off end--------------'); + console.info('----------------------newMagneticField_SensorJsTest019 off end--------------'); } catch (error) { - console.info("newMagneticField_SensorJsTest031 error:" + error); + console.info("newMagneticField_SensorJsTest019 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -649,7 +648,7 @@ describe("SensorJsTest_sensor_37", function () { } }) } catch (error) { - console.info("newMagneticField_SensorJsTest031 Device does not support! "); + console.info("newMagneticField_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -657,25 +656,25 @@ describe("SensorJsTest_sensor_37", function () { }) /* - * @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0320 - * @tc.name: newMagneticField_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0200 + * @tc.name: newMagneticField_SensorJsTest020 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newMagneticField_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newMagneticField_SensorJsTest032--------------'); + it("newMagneticField_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newMagneticField_SensorJsTest020--------------'); try{ sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { if (error) { - console.info('newMagneticField_SensorJsTest032 error'); + console.info('newMagneticField_SensorJsTest020 error'); } else { try { sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, {'interval': -100000000}); - console.info('----------------------newMagneticField_SensorJsTest032 off in---------------------------'); + console.info('----------------------newMagneticField_SensorJsTest020 off in---------------------------'); sensor.off(sensor.SensorId.MAGNETIC_FIELD); - console.info('----------------------newMagneticField_SensorJsTest032 off end---------------------------'); + console.info('----------------------newMagneticField_SensorJsTest020 off end---------------------------'); done(); } catch (error) { - console.info('newMagneticField_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newMagneticField_SensorJsTest020 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -683,10 +682,198 @@ describe("SensorJsTest_sensor_37", function () { } }) } catch (error) { - console.info("newMagneticField_SensorJsTest032 Device does not support! "); + console.info("newMagneticField_SensorJsTest020 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0210 + * @tc.name: newMagneticField_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newMagneticField_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('newMagneticField_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, undefined); + try{ + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': undefined }); + } catch(error){ + console.info('newMagneticField_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newMagneticField_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.MAGNETIC_FIELD); + } catch (error) { + console.info("newMagneticField_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newMagneticField_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0220 + * @tc.name: newMagneticField_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newMagneticField_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newMagneticField_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('newMagneticField_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, null); + try{ + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': null }); + } catch(error){ + console.info('newMagneticField_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newMagneticField_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.MAGNETIC_FIELD); + } catch (error) { + console.info("newMagneticField_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newMagneticField_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0230 + * @tc.name: newMagneticField_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newMagneticField_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newMagneticField_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('newMagneticField_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newMagneticField_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.MAGNETIC_FIELD); + } catch (error) { + console.info("newMagneticField_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newMagneticField_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0240 + * @tc.name: newMagneticField_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newMagneticField_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('newMagneticField_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newMagneticField_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newMagneticField_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.MAGNETIC_FIELD); + } catch (error) { + console.info("newMagneticField_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newMagneticField_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newMagneticField_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + + /* + * @tc.number:SUB_SensorsSystem_NEWMAGNETIC_FIELD_JSTest_0250 + * @tc.name: newMagneticField_SensorJsTest025 + * @tc.desc: Functional Use Cases + */ + it("newMagneticField_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newMagneticField_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('newMagneticField_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newMagneticField_SensorJsTest025 off in--------------'); + try { + sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback); + sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback2); + } catch (error) { + console.info("newMagneticField_SensorJsTest025 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newMagneticField_SensorJsTest025 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newMagneticField_SensorJsTest025 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField_Uncalibrated.test.js index b435d7343..791c99247 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newMagneticField_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_47", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_47", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_47", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_47", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js index f686ad977..192c3126b 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newOrientating.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_48", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_48", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_48", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_48", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -72,16 +72,16 @@ describe("SensorJsTest_sensor_48", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0140 - * @tc.name: newOrientating_SensorJsTest014 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0010 + * @tc.name: newOrientating_SensorJsTest001 * @tc.desc: Functional Use Cases */ - it("newOrientating_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newOrientating_SensorJsTest014--------------'); + it("newOrientating_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newOrientating_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest014 error'); + console.info('newOrientating_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, callback); @@ -92,7 +92,7 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info('newOrientating_SensorJsTest014 Device does not support! '); + console.info('newOrientating_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -100,20 +100,20 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0150 - * @tc.name: newOrientating_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0020 + * @tc.name: newOrientating_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newOrientating_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newOrientating_SensorJsTest015--------------'); + it("newOrientating_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newOrientating_SensorJsTest015 callback in'); + console.info('newOrientating_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newOrientating_SensorJsTest015 error:" + error); + console.info("newOrientating_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -121,29 +121,29 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0160 - * @tc.name: newOrientating_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0030 + * @tc.name: newOrientating_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newOrientating_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newOrientating_SensorJsTest016--------------'); + it("newOrientating_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest016 error'); + console.info('newOrientating_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newOrientating_SensorJsTest016 off in--------------'); + console.info('---------newOrientating_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('---------newOrientating_SensorJsTest016 off end--------------'); + console.info('---------newOrientating_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newOrientating_SensorJsTest016 Device does not support! '); + console.info('newOrientating_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -151,14 +151,14 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0170 - * @tc.name: newOrientating_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0040 + * @tc.name: newOrientating_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newOrientating_SensorJsTest017--------------'); + it("newOrientating_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newOrientating_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newOrientating_SensorJsTest017 callback in'); + console.info('newOrientating_SensorJsTest004 callback in'); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); @@ -167,20 +167,20 @@ describe("SensorJsTest_sensor_48", function () { try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest017 error'); + console.info('newOrientating_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newOrientating_SensorJsTest017 off in--------------'); + console.info('---------newOrientating_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('---------newOrientating_SensorJsTest017 off end--------------'); + console.info('---------newOrientating_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newOrientating_SensorJsTest017 Device does not support! "); + console.info("newOrientating_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -188,15 +188,15 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0180 - * @tc.name: newOrientating_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0050 + * @tc.name: newOrientating_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newOrientating_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest018 error'); + console.info('newOrientating_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.ORIENTATION, callback); @@ -207,7 +207,7 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info("newOrientating_SensorJsTest018 Device does not support! "); + console.info("newOrientating_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -215,20 +215,20 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0190 - * @tc.name: newOrientating_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0060 + * @tc.name: newOrientating_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newOrientating_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newOrientating_SensorJsTest019 callback in'); + console.info('newOrientating_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newOrientating_SensorJsTest019 error:" +error); + console.info("newOrientating_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -236,13 +236,13 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0200 - * @tc.name: newOrientating_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0070 + * @tc.name: newOrientating_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newOrientating_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newOrientating_SensorJsTest020 on error'); + console.info('newOrientating_SensorJsTest007 on error'); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); @@ -252,14 +252,14 @@ describe("SensorJsTest_sensor_48", function () { try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest020 error'); + console.info('newOrientating_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.ORIENTATION, onceSensorCallback, 5); } }) } catch (error) { - console.info("newOrientating_SensorJsTest020 error:" +error); + console.info("newOrientating_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -267,15 +267,15 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0210 - * @tc.name: newOrientating_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0080 + * @tc.name: newOrientating_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newOrientating_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newOrientating_SensorJsTest021 Device does not support! '); + console.info('newOrientating_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -283,20 +283,20 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0220 - * @tc.name: newOrientating_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0090 + * @tc.name: newOrientating_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newOrientating_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newOrientating_SensorJsTest022 callback in'); + console.info('newOrientating_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest022 error'); + console.info('newOrientating_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, onSensorCallback); @@ -308,7 +308,7 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info("newOrientating_SensorJsTest022 error:" +error); + console.info("newOrientating_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -316,19 +316,19 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0230 - * @tc.name: newOrientating_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0100 + * @tc.name: newOrientating_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newOrientating_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newOrientating_SensorJsTest023 on error'); + console.info('newOrientating_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newOrientating_SensorJsTest023 error:" +error); + console.info("newOrientating_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -336,41 +336,41 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0240 - * @tc.name: newOrientating_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0110 + * @tc.name: newOrientating_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newOrientating_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newOrientating_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest024 error'); + console.info('newOrientating_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest011 callback: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest011 callback2: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newOrientating_SensorJsTest024 off in--------------'); + console.info('---------newOrientating_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('---------newOrientating_SensorJsTest024 off end--------------'); + console.info('---------newOrientating_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newOrientating_SensorJsTest024 Device does not support! "); + console.info("newOrientating_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -378,16 +378,16 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0250 - * @tc.name: newOrientating_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0120 + * @tc.name: newOrientating_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newOrientating_SensorJsTest025--------------'); + it("newOrientating_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newOrientating_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest025 error'); + console.info('newOrientating_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, callback); @@ -398,7 +398,7 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info('newOrientating_SensorJsTest025 Device does not support! '); + console.info('newOrientating_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -406,42 +406,42 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0260 - * @tc.name: newOrientating_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0130 + * @tc.name: newOrientating_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newOrientating_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newOrientating_SensorJsTest026--------------'); + it("newOrientating_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest024 error'); + console.info('newOrientating_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest013 callback: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest013 callback2: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newOrientating_SensorJsTest026 off in--------------'); + console.info('---------newOrientating_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('---------newOrientating_SensorJsTest026 off end--------------'); + console.info('---------newOrientating_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newOrientating_SensorJsTest026 Device does not support! "); + console.info("newOrientating_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -449,42 +449,42 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0270 - * @tc.name: newOrientating_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0140 + * @tc.name: newOrientating_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newOrientating_SensorJsTest027--------------'); + it("newOrientating_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest024 error'); + console.info('newOrientating_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest014 callback: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.ORIENTATION, (data)=>{ - console.info("newOrientating_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newOrientating_SensorJsTest014 callback2: " + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newOrientating_SensorJsTest027 off in--------------'); + console.info('---------newOrientating_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('---------newOrientating_SensorJsTest027 off end--------------'); + console.info('---------newOrientating_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newOrientating_SensorJsTest027 Device does not support! "); + console.info("newOrientating_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -492,16 +492,16 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0280 - * @tc.name: newOrientating_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0150 + * @tc.name: newOrientating_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newOrientating_SensorJsTest028--------------'); + it("newOrientating_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newOrientating_SensorJsTest028_on error:" +error); + console.info("newOrientating_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -509,7 +509,7 @@ describe("SensorJsTest_sensor_48", function () { try { sensor.once(); } catch (error) { - console.info("newOrientating_SensorJsTest028_once error:" +error); + console.info("newOrientating_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -517,7 +517,7 @@ describe("SensorJsTest_sensor_48", function () { try { sensor.off(); } catch (error) { - console.info("newOrientating_SensorJsTest028_off error:" +error); + console.info("newOrientating_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -525,39 +525,39 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0290 - * @tc.name: newOrientating_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWORIENTATION_JSTest_0160 + * @tc.name: newOrientating_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newOrientating_SensorJsTest029--------------'); + it("newOrientating_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newOrientating_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest029 error'); + console.info('newOrientating_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, callback); sensor.on(sensor.SensorId.ORIENTATION, callback2); setTimeout(() => { - console.info('----------------------newOrientating_SensorJsTest029 off in--------------'); + console.info('----------------------newOrientating_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.ORIENTATION, callback); } catch (error) { - console.info("newOrientating_SensorJsTest029 error:" + error); + console.info("newOrientating_SensorJsTest016 error:" + error); } - console.info('----------------------newOrientating_SensorJsTest029 off end--------------'); + console.info('----------------------newOrientating_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newOrientating_SensorJsTest029 off in--------------'); + console.info('----------------------newOrientating_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION, callback2); - console.info('----------------------newOrientating_SensorJsTest029 off end--------------'); + console.info('----------------------newOrientating_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newOrientating_SensorJsTest029 Device does not support! "); + console.info("newOrientating_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -565,40 +565,39 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0300 - * @tc.name: newOrientating_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWORIENTATION_JSTest_0170 + * @tc.name: newOrientating_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newOrientating_SensorJsTest030--------------'); + it("newOrientating_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newOrientating_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest029 error'); + console.info('newOrientating_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.ORIENTATION, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newOrientating_SensorJsTest030 off in--------------'); + console.info('----------------------newOrientating_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.ORIENTATION, callback); } catch (error) { - console.info("newOrientating_SensorJsTest030 error:" + error); + console.info("newOrientating_SensorJsTest017 error:" + error); } - console - console.info('----------------------newOrientating_SensorJsTest030 off end--------------'); + console.info('----------------------newOrientating_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newOrientating_SensorJsTest030_2 off in--------------'); + console.info('----------------------newOrientating_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.ORIENTATION, callback2); - console.info('----------------------newOrientating_SensorJsTest030_2 off end--------------'); + console.info('----------------------newOrientating_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newOrientating_SensorJsTest030 Device does not support! "); + console.info("newOrientating_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -606,24 +605,24 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0310 - * @tc.name: newOrientating_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWORIENTATION_JSTest_0180 + * @tc.name: newOrientating_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newOrientating_SensorJsTest031--------------'); + it("newOrientating_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newOrientating_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest031 error'); + console.info('newOrientating_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newOrientating_SensorJsTest031 off in--------------'); + console.info('----------------------newOrientating_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newOrientating_SensorJsTest031 off end--------------'); + console.info('----------------------newOrientating_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newOrientating_SensorJsTest031 error:" + error); + console.info("newOrientating_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -631,7 +630,7 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info("newOrientating_SensorJsTest031 Device does not support! "); + console.info("newOrientating_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -639,25 +638,25 @@ describe("SensorJsTest_sensor_48", function () { }) /* - * @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0320 - * @tc.name: newOrientating_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWORIENTATION_JSTest_0190 + * @tc.name: newOrientating_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newOrientating_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newOrientating_SensorJsTest032--------------'); + it("newOrientating_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newOrientating_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { if (error) { - console.info('newOrientating_SensorJsTest032 error'); + console.info('newOrientating_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.ORIENTATION, callback, {'interval': -100000000}); - console.info('----------------------newOrientating_SensorJsTest032 off in---------------------------'); + console.info('----------------------newOrientating_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.ORIENTATION); - console.info('----------------------newOrientating_SensorJsTest032 off end---------------------------'); + console.info('----------------------newOrientating_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newOrientating_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newOrientating_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -665,10 +664,226 @@ describe("SensorJsTest_sensor_48", function () { } }) } catch (error) { - console.info("newOrientating_SensorJsTest032 Device does not support! "); + console.info("newOrientating_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0200 + * @tc.name: newOrientating_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newOrientating_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newOrientating_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback); + setTimeout(()=>{ + sensor.off(sensor.SensorId.ORIENTATION); + done(); + }, 500); + } + }) + } catch (error) { + console.info('newOrientating_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0210 + * @tc.name: newOrientating_SensorJsTest021 + * @tc.desc: Functional Use Cases + */ + it("newOrientating_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newOrientating_SensorJsTest021--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.ORIENTATION, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newOrientating_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.ORIENTATION, callback); + sensor.off(sensor.SensorId.ORIENTATION, callback2); + } catch (error) { + console.info("newOrientating_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newOrientating_SensorJsTest021 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newOrientating_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0220 + * @tc.name: newOrientating_SensorJsTest022 + * @tc.desc: Illegal ID passed in + */ + it("newOrientating_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback, undefined); + try{ + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': undefined }); + } catch(error){ + console.info('newOrientating_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newOrientating_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.ORIENTATION); + } catch (error) { + console.info("newOrientating_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newOrientating_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0230 + * @tc.name: newOrientating_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newOrientating_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newOrientating_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newOrientating_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.ORIENTATION); + } catch (error) { + console.info("newOrientating_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newOrientating_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0240 + * @tc.name: newOrientating_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newOrientating_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newOrientating_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newOrientating_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.ORIENTATION); + } catch (error) { + console.info("newOrientating_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newOrientating_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newOrientating_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + + /* + * @tc.number:SUB_SensorsSystem_NEWORIENTATION_JSTest_0250 + * @tc.name: newOrientating_SensorJsTest025 + * @tc.desc: For normal scenarios + */ + it("newOrientating_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newOrientating_SensorJsTest025--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => { + if (error) { + console.info('newOrientating_SensorJsTest025 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ORIENTATION, callback, null); + try{ + sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': null }); + } catch(error){ + console.info('newOrientating_SensorJsTest025 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newOrientating_SensorJsTest025 off in--------------'); + try { + sensor.off(sensor.SensorId.ORIENTATION); + } catch (error) { + console.info("newOrientating_SensorJsTest025 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newOrientating_SensorJsTest025 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer.test.js index 55779df9b..da89c0199 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_56", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_56", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_56", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_56", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js index 6edc37d95..48cd77103 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newPedometer_Detection.test.js @@ -829,5 +829,229 @@ describe("SensorJsTest_sensor_57", function () { console.error('newPedometerDetection_SensorJsTest017 error:' + JSON.stringify(error)); done(); }) - }) + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0180 + * @tc.name: newPedometerDetection_SensorJsTest018 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometerDetection_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------newPedometerDetection_SensorJsTest018---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('newPedometerDetection_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback, { 'interval': undefined }); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest018 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('newPedometerDetection_SensorJsTest018 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0190 + * @tc.name: newPedometerDetection_SensorJsTest019 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometerDetection_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometerDetection_SensorJsTest019---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('newPedometerDetection_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2, { 'interval': undefined }); + setTimeout(()=>{ + sensor.off(sensor.SensorId.PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest019 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('newPedometerDetection_SensorJsTest019 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0200 + * @tc.name: newPedometerDetection_SensorJsTest020 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometerDetection_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometerDetection_SensorJsTest020---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('newPedometerDetection_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback, { 'interval': null }); + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2, { 'interval': null }); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback2); + done(); + }, 4000); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest020 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('newPedometerDetection_SensorJsTest020 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0210 + * @tc.name: newPedometerDetection_SensorJsTest021 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometerDetection_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometerDetection_SensorJsTest021---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('newPedometerDetection_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback); + try{ + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback, undefined); + } catch(error){ + console.info('newPedometerDetection_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest021 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('newPedometerDetection_SensorJsTest021 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_DETECTION_JSTest_0220 + * @tc.name: newPedometerDetection_SensorJsTest022 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometerDetection_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('newPedometerDetection_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER_DETECTION, null); + done(); + }, 4000); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest022 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometerDetection_SensorJsTest022 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('newPedometerDetection_SensorJsTest022 error:' + JSON.stringify(error)); + done(); + }) + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newProxinity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newProxinity.test.js index 75ff09931..161111141 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newProxinity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newProxinity.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_54", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_54", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_54", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_54", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js index 8cefbe09b..fffcb4657 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newRotatingVector.test.js @@ -40,7 +40,7 @@ describe("SensorJsTest_sensor_49", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -48,7 +48,7 @@ describe("SensorJsTest_sensor_49", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -56,7 +56,7 @@ describe("SensorJsTest_sensor_49", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -64,7 +64,7 @@ describe("SensorJsTest_sensor_49", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -74,16 +74,16 @@ describe("SensorJsTest_sensor_49", function () { let invalid = -1; /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0140 - * @tc.name: newRotatingVector_SensorJsTest014 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0010 + * @tc.name: newRotatingVector_SensorJsTest001 * @tc.desc: Functional Use Cases */ - it("newRotatingVector_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newRotatingVector_SensorJsTest014--------------'); + it("newRotatingVector_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newRotatingVector_SensorJsTest001--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest014 error'); + console.info('newRotatingVector_SensorJsTest001 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback); @@ -94,7 +94,7 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info('newRotatingVector_SensorJsTest014 Device does not support! '); + console.info('newRotatingVector_SensorJsTest001 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -102,20 +102,20 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0150 - * @tc.name: newRotatingVector_SensorJsTest015 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0020 + * @tc.name: newRotatingVector_SensorJsTest002 * @tc.desc: Illegal ID passed in */ - it("newRotatingVector_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newRotatingVector_SensorJsTest015--------------'); + it("newRotatingVector_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest002--------------'); function onSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest015 callback in'); + console.info('newRotatingVector_SensorJsTest002 callback in'); expect(false).assertTrue(); } try { sensor.on(invalid, onSensorCallback); } catch (error) { - console.info("newRotatingVector_SensorJsTest015 error:" + error); + console.info("newRotatingVector_SensorJsTest002 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -123,29 +123,29 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0160 - * @tc.name: newRotatingVector_SensorJsTest016 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0030 + * @tc.name: newRotatingVector_SensorJsTest003 * @tc.desc: For normal scenarios */ - it("newRotatingVector_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newRotatingVector_SensorJsTest016--------------'); + it("newRotatingVector_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest003--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest016 error'); + console.info('newRotatingVector_SensorJsTest003 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newRotatingVector_SensorJsTest016 off in--------------'); + console.info('---------newRotatingVector_SensorJsTest003 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('---------newRotatingVector_SensorJsTest016 off end--------------'); + console.info('---------newRotatingVector_SensorJsTest003 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info('newRotatingVector_SensorJsTest016 Device does not support! '); + console.info('newRotatingVector_SensorJsTest003 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -153,14 +153,14 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0170 - * @tc.name: newRotatingVector_SensorJsTest017 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0040 + * @tc.name: newRotatingVector_SensorJsTest004 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { - console.info('---------newRotatingVector_SensorJsTest017--------------'); + it("newRotatingVector_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newRotatingVector_SensorJsTest004--------------'); function onSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest017 callback in'); + console.info('newRotatingVector_SensorJsTest004 callback in'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -169,20 +169,20 @@ describe("SensorJsTest_sensor_49", function () { try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest017 error'); + console.info('newRotatingVector_SensorJsTest004 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, onSensorCallback, {'interval': 100000000}, 5); setTimeout(()=>{ - console.info('---------newRotatingVector_SensorJsTest017 off in--------------'); + console.info('---------newRotatingVector_SensorJsTest004 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('---------newRotatingVector_SensorJsTest017 off end--------------'); + console.info('---------newRotatingVector_SensorJsTest004 off end--------------'); done(); }, 500); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest017 Device does not support! "); + console.info("newRotatingVector_SensorJsTest004 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -190,15 +190,15 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0180 - * @tc.name: newRotatingVector_SensorJsTest018 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0050 + * @tc.name: newRotatingVector_SensorJsTest005 * @tc.desc: Once Normal Subscription Scenario Use Case */ - it("newRotatingVector_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest018 error'); + console.info('newRotatingVector_SensorJsTest005 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.ROTATION_VECTOR, callback); @@ -209,7 +209,7 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest018 Device does not support! "); + console.info("newRotatingVector_SensorJsTest005 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -217,20 +217,20 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0190 - * @tc.name: newRotatingVector_SensorJsTest019 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0060 + * @tc.name: newRotatingVector_SensorJsTest006 * @tc.desc: Use case of illegal parameter passed into once interface */ - it("newRotatingVector_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onceSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest019 callback in'); + console.info('newRotatingVector_SensorJsTest006 callback in'); expect(false).assertTrue(); done(); } try { sensor.once(invalid, onceSensorCallback); } catch (error) { - console.info("newRotatingVector_SensorJsTest019 error:" +error); + console.info("newRotatingVector_SensorJsTest006 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -238,13 +238,13 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0200 - * @tc.name: newRotatingVector_SensorJsTest020 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0070 + * @tc.name: newRotatingVector_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + it("newRotatingVector_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { function onceSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest020 on error'); + console.info('newRotatingVector_SensorJsTest007 on error'); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -255,14 +255,14 @@ describe("SensorJsTest_sensor_49", function () { try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest020 error'); + console.info('newRotatingVector_SensorJsTest007 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.once(sensor.SensorId.ROTATION_VECTOR, onceSensorCallback, 5); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest020 error:" +error); + console.info("newRotatingVector_SensorJsTest007 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -270,15 +270,15 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0210 - * @tc.name: newRotatingVector_SensorJsTest021 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0080 + * @tc.name: newRotatingVector_SensorJsTest008 * @tc.desc: Use case of illegal parameter passed into off interface */ - it("newRotatingVector_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try { sensor.off(invalid, callback); } catch (error) { - console.info('newRotatingVector_SensorJsTest021 Device does not support! '); + console.info('newRotatingVector_SensorJsTest008 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -286,20 +286,20 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0220 - * @tc.name: newRotatingVector_SensorJsTest022 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0090 + * @tc.name: newRotatingVector_SensorJsTest009 * @tc.desc: Unsubscribe directly without waiting after starting subscription */ - it("newRotatingVector_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest022 callback in'); + console.info('newRotatingVector_SensorJsTest009 callback in'); expect(false).assertTrue(); done(); } try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest022 error'); + console.info('newRotatingVector_SensorJsTest009 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, onSensorCallback); @@ -311,7 +311,7 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest022 error:" +error); + console.info("newRotatingVector_SensorJsTest009 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -319,19 +319,19 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0230 - * @tc.name: newRotatingVector_SensorJsTest023 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0100 + * @tc.name: newRotatingVector_SensorJsTest010 * @tc.desc:SensorId1000000 of incoming exception */ - it("newRotatingVector_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { function onSensorCallback(data) { - console.info('newRotatingVector_SensorJsTest023 on error'); + console.info('newRotatingVector_SensorJsTest010 on error'); expect(false).assertTrue(); } try { sensor.off(1000000, onSensorCallback); } catch (error) { - console.info("newRotatingVector_SensorJsTest023 error:" +error); + console.info("newRotatingVector_SensorJsTest010 error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE) expect(error.message).assertEqual(PARAMETER_ERROR_MSG) done(); @@ -339,19 +339,19 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0240 - * @tc.name: newRotatingVector_SensorJsTest024 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0110 + * @tc.name: newRotatingVector_SensorJsTest011 * @tc.desc:Call interface multiple times */ - it("newRotatingVector_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("newRotatingVector_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest024 error'); + console.info('newRotatingVector_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest024 callback: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest011 callback: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -359,7 +359,7 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }); sensor.on(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest024 callback2: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest011 callback2: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -367,15 +367,15 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newRotatingVector_SensorJsTest024 off in--------------'); + console.info('---------newRotatingVector_SensorJsTest011 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('---------newRotatingVector_SensorJsTest024 off end--------------'); + console.info('---------newRotatingVector_SensorJsTest011 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest024 Device does not support! "); + console.info("newRotatingVector_SensorJsTest011 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -383,16 +383,16 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0250 - * @tc.name: newRotatingVector_SensorJsTest025 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0120 + * @tc.name: newRotatingVector_SensorJsTest012 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('---------newRotatingVector_SensorJsTest025--------------'); + it("newRotatingVector_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newRotatingVector_SensorJsTest012--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest025 error'); + console.info('newRotatingVector_SensorJsTest012 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback); @@ -403,7 +403,7 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info('newRotatingVector_SensorJsTest025 Device does not support! '); + console.info('newRotatingVector_SensorJsTest012 Device does not support! '); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -411,20 +411,20 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0260 - * @tc.name: newRotatingVector_SensorJsTest026 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0130 + * @tc.name: newRotatingVector_SensorJsTest013 * @tc.desc:Call on interface and once interface respectively, and use an off interface to close */ - it("newRotatingVector_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newRotatingVector_SensorJsTest026--------------'); + it("newRotatingVector_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest013--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest024 error'); + console.info('newRotatingVector_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest026 callback: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest013 callback: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -432,7 +432,7 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.once(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest026 callback2: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest013 callback2: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -440,15 +440,15 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }); setTimeout(()=>{ - console.info('---------newRotatingVector_SensorJsTest026 off in--------------'); + console.info('---------newRotatingVector_SensorJsTest013 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('---------newRotatingVector_SensorJsTest026 off end--------------'); + console.info('---------newRotatingVector_SensorJsTest013 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest026 Device does not support! "); + console.info("newRotatingVector_SensorJsTest013 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -456,20 +456,20 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0270 - * @tc.name: newRotatingVector_SensorJsTest027 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0140 + * @tc.name: newRotatingVector_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newRotatingVector_SensorJsTest027--------------'); + it("newRotatingVector_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest014--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest024 error'); + console.info('newRotatingVector_SensorJsTest011 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest027 callback: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest014 callback: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -477,7 +477,7 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); sensor.on(sensor.SensorId.ROTATION_VECTOR, (data)=>{ - console.info("newRotatingVector_SensorJsTest027 callback2: " + JSON.stringify(data)); + console.info("newRotatingVector_SensorJsTest014 callback2: " + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -485,15 +485,15 @@ describe("SensorJsTest_sensor_49", function () { expect(typeof (data.timestamp)).assertEqual("number"); }, {'interval': 100000000}); setTimeout(()=>{ - console.info('---------newRotatingVector_SensorJsTest027 off in--------------'); + console.info('---------newRotatingVector_SensorJsTest014 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('---------newRotatingVector_SensorJsTest027 off end--------------'); + console.info('---------newRotatingVector_SensorJsTest014 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest027 Device does not support! "); + console.info("newRotatingVector_SensorJsTest014 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -501,16 +501,16 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0280 - * @tc.name: newRotatingVector_SensorJsTest028 + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0150 + * @tc.name: newRotatingVector_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('---------newRotatingVector_SensorJsTest028--------------'); + it("newRotatingVector_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest015--------------'); try { sensor.on(); } catch (error) { - console.info("newRotatingVector_SensorJsTest028_on error:" +error); + console.info("newRotatingVector_SensorJsTest015_on error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -518,7 +518,7 @@ describe("SensorJsTest_sensor_49", function () { try { sensor.once(); } catch (error) { - console.info("newRotatingVector_SensorJsTest028_once error:" +error); + console.info("newRotatingVector_SensorJsTest015_once error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -526,7 +526,7 @@ describe("SensorJsTest_sensor_49", function () { try { sensor.off(); } catch (error) { - console.info("newRotatingVector_SensorJsTest028_off error:" +error); + console.info("newRotatingVector_SensorJsTest015_off error:" +error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -534,39 +534,39 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number: SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0290 - * @tc.name: newRotatingVector_SensorJsTest029 + * @tc.number: SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0160 + * @tc.name: newRotatingVector_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newRotatingVector_SensorJsTest029--------------'); + it("newRotatingVector_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newRotatingVector_SensorJsTest016--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest029 error'); + console.info('newRotatingVector_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2); setTimeout(() => { - console.info('----------------------newRotatingVector_SensorJsTest029 off in--------------'); + console.info('----------------------newRotatingVector_SensorJsTest016 off in--------------'); try { sensor.off(sensor.SensorId.ROTATION_VECTOR, callback); } catch (error) { - console.info("newRotatingVector_SensorJsTest029 error:" + error); + console.info("newRotatingVector_SensorJsTest016 error:" + error); } - console.info('----------------------newRotatingVector_SensorJsTest029 off end--------------'); + console.info('----------------------newRotatingVector_SensorJsTest016 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newRotatingVector_SensorJsTest029 off in--------------'); + console.info('----------------------newRotatingVector_SensorJsTest016 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR, callback2); - console.info('----------------------newRotatingVector_SensorJsTest029 off end--------------'); + console.info('----------------------newRotatingVector_SensorJsTest016 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest029 Device does not support! "); + console.info("newRotatingVector_SensorJsTest016 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -574,40 +574,39 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number: SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0300 - * @tc.name: newRotatingVector_SensorJsTest030 + * @tc.number: SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_017 + * @tc.name: newRotatingVector_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newRotatingVector_SensorJsTest030--------------'); + it("newRotatingVector_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newRotatingVector_SensorJsTest017--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest029 error'); + console.info('newRotatingVector_SensorJsTest016 error'); } else { expect(typeof(data)).assertEqual("object"); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': 100000000 }); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2, { 'interval': 100000000 }); setTimeout(() => { - console.info('----------------------newRotatingVector_SensorJsTest030 off in--------------'); + console.info('----------------------newRotatingVector_SensorJsTest017 off in--------------'); try { sensor.off(sensor.SensorId.ROTATION_VECTOR, callback); } catch (error) { - console.info("newRotatingVector_SensorJsTest030 error:" + error); + console.info("newRotatingVector_SensorJsTest017 error:" + error); } - console - console.info('----------------------newRotatingVector_SensorJsTest030 off end--------------'); + console.info('----------------------newRotatingVector_SensorJsTest017 off end--------------'); }, 500); setTimeout(() => { - console.info('----------------------newRotatingVector_SensorJsTest030_2 off in--------------'); + console.info('----------------------newRotatingVector_SensorJsTest017_2 off in--------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR, callback2); - console.info('----------------------newRotatingVector_SensorJsTest030_2 off end--------------'); + console.info('----------------------newRotatingVector_SensorJsTest017_2 off end--------------'); done(); }, 1000); } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest030 Device does not support! "); + console.info("newRotatingVector_SensorJsTest017 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -615,24 +614,24 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number: SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0310 - * @tc.name: newRotatingVector_SensorJsTest031 + * @tc.number: SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0180 + * @tc.name: newRotatingVector_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newRotatingVector_SensorJsTest031--------------'); + it("newRotatingVector_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newRotatingVector_SensorJsTest018--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest031 error'); + console.info('newRotatingVector_SensorJsTest018 error'); } else { expect(typeof(data)).assertEqual("object"); - console.info('----------------------newRotatingVector_SensorJsTest031 off in--------------'); + console.info('----------------------newRotatingVector_SensorJsTest018 off in--------------'); try{ sensor.off(-1, callback); - console.info('----------------------newRotatingVector_SensorJsTest031 off end--------------'); + console.info('----------------------newRotatingVector_SensorJsTest018 off end--------------'); } catch (error) { - console.info("newRotatingVector_SensorJsTest031 error:" + error); + console.info("newRotatingVector_SensorJsTest018 error:" + error); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -640,7 +639,7 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest031 Device does not support! "); + console.info("newRotatingVector_SensorJsTest018 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); @@ -648,25 +647,25 @@ describe("SensorJsTest_sensor_49", function () { }) /* - * @tc.number: SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0320 - * @tc.name: newRotatingVector_SensorJsTest032 + * @tc.number: SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0190 + * @tc.name: newRotatingVector_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newRotatingVector_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------newRotatingVector_SensorJsTest032--------------'); + it("newRotatingVector_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newRotatingVector_SensorJsTest019--------------'); try{ sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { if (error) { - console.info('newRotatingVector_SensorJsTest032 error'); + console.info('newRotatingVector_SensorJsTest019 error'); } else { try { sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, {'interval': -100000000}); - console.info('----------------------newRotatingVector_SensorJsTest032 off in---------------------------'); + console.info('----------------------newRotatingVector_SensorJsTest019 off in---------------------------'); sensor.off(sensor.SensorId.ROTATION_VECTOR); - console.info('----------------------newRotatingVector_SensorJsTest032 off end---------------------------'); + console.info('----------------------newRotatingVector_SensorJsTest019 off end---------------------------'); done(); } catch (error) { - console.info('newRotatingVector_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message); + console.info('newRotatingVector_SensorJsTest019 On fail, errCode:' + error.code + ' ,msg:' + error.message); expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); done(); @@ -674,10 +673,197 @@ describe("SensorJsTest_sensor_49", function () { } }) } catch (error) { - console.info("newRotatingVector_SensorJsTest032 Device does not support! "); + console.info("newRotatingVector_SensorJsTest019 Device does not support! "); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0200 + * @tc.name: newRotatingVector_SensorJsTest020 + * @tc.desc: Functional Use Cases + */ + it("newRotatingVector_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------newRotatingVector_SensorJsTest020--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest020 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------newRotatingVector_SensorJsTest020 off in--------------'); + try { + sensor.off(sensor.SensorId.ROTATION_VECTOR, callback); + sensor.off(sensor.SensorId.ROTATION_VECTOR, callback2); + } catch (error) { + console.info("newRotatingVector_SensorJsTest020 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newRotatingVector_SensorJsTest020 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('newRotatingVector_SensorJsTest020 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0210 + * @tc.name: newRotatingVector_SensorJsTest021 + * @tc.desc: Illegal ID passed in + */ + it("newRotatingVector_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest021 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, undefined); + try{ + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': undefined }); + } catch(error){ + console.info('newRotatingVector_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newRotatingVector_SensorJsTest021 off in--------------'); + try { + sensor.off(sensor.SensorId.ROTATION_VECTOR); + } catch (error) { + console.info("newRotatingVector_SensorJsTest021 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newRotatingVector_SensorJsTest021 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0220 + * @tc.name: newRotatingVector_SensorJsTest022 + * @tc.desc: For normal scenarios + */ + it("newRotatingVector_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------newRotatingVector_SensorJsTest022--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest022 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, null); + try{ + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': null }); + } catch(error){ + console.info('newRotatingVector_SensorJsTest022 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------newRotatingVector_SensorJsTest022 off in--------------'); + try { + sensor.off(sensor.SensorId.ROTATION_VECTOR); + } catch (error) { + console.info("newRotatingVector_SensorJsTest022 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('newRotatingVector_SensorJsTest022 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0230 + * @tc.name: newRotatingVector_SensorJsTest023 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newRotatingVector_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------newRotatingVector_SensorJsTest023--------------'); + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest023 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------newRotatingVector_SensorJsTest023 off in--------------'); + try { + sensor.off(sensor.SensorId.ROTATION_VECTOR); + } catch (error) { + console.info("newRotatingVector_SensorJsTest023 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("newRotatingVector_SensorJsTest023 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWROTATION_VECTOR_JSTest_0240 + * @tc.name: newRotatingVector_SensorJsTest024 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("newRotatingVector_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('newRotatingVector_SensorJsTest024 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorId.ROTATION_VECTOR, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("newRotatingVector_SensorJsTest024 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------newRotatingVector_SensorJsTest024 off in--------------'); + try { + sensor.off(sensor.SensorId.ROTATION_VECTOR); + } catch (error) { + console.info("newRotatingVector_SensorJsTest024 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------newRotatingVector_SensorJsTest024 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("newRotatingVector_SensorJsTest024 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js index 0099205d2..3910d77df 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagnetic.test.js @@ -24,7 +24,7 @@ describe("SensorJsTest_sensor_60", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function() { @@ -32,7 +32,7 @@ describe("SensorJsTest_sensor_60", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function() { @@ -40,7 +40,7 @@ describe("SensorJsTest_sensor_60", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function() { @@ -48,7 +48,7 @@ describe("SensorJsTest_sensor_60", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagneticOptions.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagneticOptions.test.js new file mode 100644 index 000000000..dc87e6110 --- /dev/null +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagneticOptions.test.js @@ -0,0 +1,616 @@ +/* + * 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, TestType, Size, Level } from '@ohos/hypium' + +export default function SensorJsTest_sensor_38() { +describe("SensorJsTest_sensor_38", function () { + beforeAll(function() { + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll called') + }) + + afterAll(function() { + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll called') + }) + + beforeEach(function() { + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach called') + }) + + afterEach(function() { + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach called') + }) + + const PARAMETER_ERROR_CODE = 401 + const SERVICE_EXCEPTION_CODE = 14500101 + const EPS = 0.01 + const PARAMETER_ERROR_MSG = 'The parameter invalid.' + const SERVICE_EXCEPTION_MSG = 'Service exception.' + + let GEOMAGNETIC_COMPONENT_YEAR_RESULT = [ + [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], + [6554.17041015625, -87.19947052001953, 54649.078125, -0.7622424364089966, 83.16046905517578, 6554.75048828125, 55040.7734375], + [6537.99169921875, -28.231582641601562, 54692.02734375, -0.24740631878376007, 83.18303680419922, 6538.052734375, 55081.4296875], + [6521.81201171875, 30.73670768737793, 54734.97265625, 0.2700277864933014, 83.20502471923828, 6521.88427734375, 55122.15625], + [6505.6328125, 89.70511627197266, 54777.90625, 0.7899921536445618, 83.22642517089844, 6506.2509765625, 55162.9453125]] + + let GEOMAGNETIC_COMPONENT_COORDINATES_RESULT = [ + [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], + [39624.28125, 109.8766098022461, -10932.4638671875, 0.15887857973575592, -15.424291610717773, 39624.43359375, 41104.921875], + [37636.72265625, 104.90892791748047, -10474.810546875, 0.15970633924007416, -15.552550315856934, 37636.8671875, 39067.3203125], + [5940.583984375, 15772.0927734375, -52480.7578125, 69.36103820800781, -72.19599914550781, 16853.765625, 55120.58984375], + [5744.87255859375, 14799.48046875, -49969.40234375, 68.78474426269531, -72.37483215332031, 15875.3955078125, 52430.61328125]] + + let GEOMAGNETIC_COORDINATES = [[80, 0, 0], + [0, 120, 0], + [0, 120, 100000], + [-80, 240, 0], + [-80, 240, 100000]] + + let timeMillis = [1580486400000, 1612108800000, 1643644800000, 1675180800000, 1706716800000] + + /* + * @tc.name:Sensor_GetGeomagneticField_058 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it("Sensor_GetGeomagneticInfo_058", 0, async function (done) { + console.info("---------------------------Sensor_GetGeomagneticInfo_058----------------------------------"); + for (let i = 0; i < timeMillis.length; i++) { + await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], undefined).then((data) => { + console.info('Sensor_GetGeomagneticField_058 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue() + expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue() + expect(Math.abs(data.z - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) < EPS).assertTrue() + expect(Math.abs(data.deflectionAngle - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) < EPS).assertTrue() + expect(Math.abs(data.geomagneticDip - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) < EPS).assertTrue() + expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() + expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() + }).catch((error) => { + console.info("Sensor_GetGeomagneticInfo_058 promise::catch", error); + }) + } + done() + }) + + /* + * @tc.name:Sensor_GetGeomagneticInfo_058 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it("Sensor_GetGeomagneticInfo_059", 0, async function (done) { + console.info("---------------------------Sensor_GetGeomagneticInfo_059----------------------------------"); + for (let i = 0; i < timeMillis.length; i++) { + await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], null).then((data) => { + console.info('Sensor_GetGeomagneticInfo_059 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue() + expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue() + expect(Math.abs(data.z - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) < EPS).assertTrue() + expect(Math.abs(data.deflectionAngle - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) < EPS).assertTrue() + expect(Math.abs(data.geomagneticDip - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) < EPS).assertTrue() + expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() + expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }) + } + done() + }) + + /* + * @tc.name:Sensor_GetGeomagneticInfo_060 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it("Sensor_GetGeomagneticInfo_060", 0, async function (done) { + console.info("---------------------------Sensor_GetGeomagneticInfo_060----------------------------------"); + for (let i = 0; i < timeMillis.length; i++) { + await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], "abc").then((data) => { + console.info('Sensor_GetGeomagneticInfo_060 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue() + expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue() + expect(Math.abs(data.z - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) < EPS).assertTrue() + expect(Math.abs(data.deflectionAngle - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) < EPS).assertTrue() + expect(Math.abs(data.geomagneticDip - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) < EPS).assertTrue() + expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() + expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }) + } + done() + }) + + const SENSOR_DATA_MATRIX = [ + { + "rotation": [-0.7980074882507324, 0.5486301183700562, 0.24937734007835388, -0.17277367413043976, + -0.6047078967094421, 0.7774815559387207, 0.5773502588272095, 0.5773502588272095,0.5773502588272095], + "inclination":[1, 0, 0, 0, 0.20444221794605255,0.9788785576820374, 0, -0.9788785576820374, 0.20444221794605255] + }, + { + "rotation": [-0.8206444382667542, 0.3832680284976959, 0.42384934425354004, 0.021023601293563843, + -0.7209705710411072,0.6926466822624207, 0.5710522532463074,0.57732754945755,0.5836028456687927], + "inclination":[1, 0, 0, 0, 0.2584352493286133,0.9660285115242004, 0, -0.9660285115242004, 0.2584352493286133] + }, + { + "rotation": [0.9583651423454285, 0.08038506656885147, -0.27399733662605286, 0.160231813788414, + -0.9456362724304199, 0.2830156981945038, -0.23635157942771912, -0.3151354491710663, -0.9191450476646423], + "inclination":[1, 0, 0, 0, 0.34239840507507324, 0.9395548701286316, 0, -0.9395548701286316, 0.34239840507507324] + }, + { + "rotation":[null, null, null, null, null, null, null, null, null], + "inclination":[1, 0, 0, 0, null, null, 0, null ,null] + }, + { + "rotation":[null, null, null, null, null, null,0, 0, 0], + "inclination":[1, 0, 0, 0, null, 0, 0, 0, null] + } + ]; + + let GET_DIRECTION = [ + [ 0.38050639629364014, -0.9783217310905457, -0.6610431671142578], + [-2.7610862255096436, 1.5018651485443115, 2.987273931503296], + [0.32175055146217346, -1.006853699684143, -0.6857295036315918], + [1.3332617282867432, -1.5440233945846558, -0.6627295017242432], + [NaN, NaN, NaN], + [0.7853981852531433, -0.6154797077178955, -0.7853981852531433], + [0.7853981852531433, -0.7853981852531433, -0.7853981852531433], + [0.785398, -0.615480, -0.785398], + [0.785398, -0.785398, -0.785398] + ] + + let rotationMatrix = [ + [1, 2, 3, 4, 5, 6, 7, 8, 9], + [-1, -2, -3, -4, -5, -6, -7, -78, -45], + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], + [11111111, 21111111, 31111111, 4111111, 5111111, 61111111, 71111111, 811111111, 91111111], + [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], + [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], + [3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39], + [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], + [3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39] + ] + + let gravity = [ + [9, 9, 9], [91, 92, 93], [-9, -12, -35], [NaN, NaN, NaN], [3.40282e+38, 3.40282e+38, 3.40282e+38], [3.40282e+39, 3.40282e+39, 3.40282e+39] + ] + + let geomagnetic = [ + [30, 25, 41], [3, 2, 4], [-123, -456, -564], [3.40282e+38, 3.40282e+38, 3.40282e+38], [NaN, NaN, NaN] + ] + + let createRotationMatrixResult = [ + [0.6724675297737122,-0.10471208393573761,0.7326819896697998,0.06531608104705811,0.9944750070571899, + 0.08217836916446686,-0.7372390031814575,-0.007406365126371384,0.6755914688110352], + [1,0,0,0,1,0,0,0,1] + ] + + /* + * tc.name: Sensor_CreateRotationMatrix_015 + * tc.desc: Verification results of the incorrect parameters of test interface. + * tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateRotationMatrix_015', 0, async function (done) { + sensor.getRotationMatrix(gravity[0], geomagnetic[0], undefined).then((data) => { + console.info("Sensor_CreateRotationMatrix_015" + JSON.stringify(data)) + expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * tc.name: Sensor_CreateRotationMatrix_016 + * tc.desc: Verification results of the incorrect parameters of test interface. + * tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateRotationMatrix_016', 0, async function (done) { + sensor.getRotationMatrix(gravity[0], geomagnetic[0], null).then((data) => { + console.info("Sensor_CreateRotationMatrix_016" + JSON.stringify(data)) + expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * tc.name: Sensor_CreateRotationMatrix_017 + * tc.desc: Verification results of the incorrect parameters of test interface. + * tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateRotationMatrix_017', 0, async function (done) { + sensor.getRotationMatrix([0, 0, 0], undefined).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_CreateRotationMatrix_017 [" + i + "] : " + data[i]); + expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * tc.name: Sensor_CreateRotationMatrix_018 + * tc.desc: Verification results of the incorrect parameters of test interface. + * tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateRotationMatrix_018', 0, async function (done) { + sensor.getRotationMatrix([0, 0, 0], null).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_CreateRotationMatrix_018 [" + i + "] : " + data[i]); + expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /** + * test + * + * @tc.name: Sensor_GetDirection_011 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetDirection_011', 0, async function (done) { + sensor.getOrientation(rotationMatrix[0], undefined).then((data) => { + for (let i = 0; i < data.length; i++) { + console.info("Sensor_GetDirection_011" + data[i]) + expect(data[i]).assertEqual(GET_DIRECTION[0][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /** + * test + * + * @tc.name: Sensor_GetDirection_012 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetDirection_012', 0, async function (done) { + sensor.getOrientation(rotationMatrix[0], null).then((data) => { + for (let i = 0; i < data.length; i++) { + console.info("Sensor_GetDirection_012" + data[i]) + expect(data[i]).assertEqual(GET_DIRECTION[0][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + let ANGLECHANGE_9_RESULT = [ + [0.7853981852531433, NaN, -0.32175055146217346], //123123123 + [0.7853981852531433, NaN, -0.7853981852531433], //FLOAT.MAXVALUE + [0.0, -0.0, -0.0], //FLOAT.MINVALUE + [0.7853981852531433, NaN, -0.7853981852531433], //FLOAT.MAXVALUE+1 + ]; + + /* + * @tc.name:Sensor_GetAngleModify_017 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it('Sensor_GetAngleModify_017', 0, async function (done) { + console.info('----------------------Sensor_GetAngleModify_017---------------------------'); + sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], undefined).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_GetAngleModify_017 [" + i + "] = " + data[i]); + expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && + expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); + } + done(); + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * @tc.name:Sensor_GetAngleModify_018 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it('Sensor_GetAngleModify_018', 0, async function (done) { + console.info('----------------------Sensor_GetAngleModify_018---------------------------'); + sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_GetAngleModify_018 [" + i + "] = " + data[i]); + expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && + expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); + } + done(); + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * @tc.name:Sensor_GetAngleModify_019 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: I5SWJI + */ + it('Sensor_GetAngleModify_019', 0, async function (done) { + console.info('----------------------Sensor_GetAngleModify_019---------------------------'); + sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => { + for(let i = 0; i < data.length; i++) { + console.info("Sensor_GetAngleModify_019 [" + i + "] = " + data[i]); + expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && + expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); + } + done(); + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + const result = [ + [0.7441122531890869, 0.5199999809265137, -0.335999995470047, -0.25099998712539673], + [0, 3.402820018375656e+38, 3.402820018375656e+38, 3.402820018375656e+38], + [1, 0, 0, 0], + [0.7183529734611511, -0.32499998807907104, -0.5619999766349792, -0.25], + [0, 0, 0, 0] + ]; + + /* + * test + * + * @tc.name: Sensor_CreateQuaternion_016 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateQuaternion_016', 0, async function (done) { + sensor.getQuaternion([0.52, -0.336, -0.251], undefined).then((data) => { + console.info('Sensor_CreateQuaternion_016'); + for (let i = 0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + expect(data[i]).assertEqual(result[0][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + /* + * test + * + * @tc.name: Sensor_CreateQuaternion_017 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_CreateQuaternion_017', 0, async function (done) { + sensor.getQuaternion([0.52, -0.336, -0.251], null).then((data) => { + console.info('Sensor_CreateQuaternion_017'); + for (let i = 0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + expect(data[i]).assertEqual(result[0][i]) + } + done() + }, (error) => { + expect(false).assertTrue(); + done() + }) + }) + + const getGeomagneticDipResult = [ 0.8760581016540527, 0.862170, -Infinity, 44330]; + + /* + * @tc.name: Sensor_GetGeomagneticDip_008 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetGeomagneticDip_008', 0, async function (done) { + sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], undefined).then((data) => { + console.info("Sensor_GetGeomagneticDip_008" + data) + expect(data).assertEqual(getGeomagneticDipResult[0]) + done() + }, (error) => { + console.info('Sensor_GetGeomagneticDip_008 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_GetGeomagneticDip_009 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetGeomagneticDip_009', 0, async function (done) { + sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], null).then((data) => { + console.info("Sensor_GetGeomagneticDip_009" + data) + expect(data).assertEqual(getGeomagneticDipResult[0]) + done() + }, (error) => { + console.info('Sensor_GetGeomagneticDip_009 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_GetAltitude_009 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetAltitude_009', 0, async function (done) { + sensor.getDeviceAltitude(0, 100, undefined).then((data) => { + console.info("Sensor_GetAltitude_009" + data) + expect(data).assertEqual(getGeomagneticDipResult[2]) + done() + }, (error) => { + console.info('Sensor_GetAltitude_009 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_GetAltitude_010 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetAltitude_010', 0, async function (done) { + sensor.getDeviceAltitude(0, 100, null).then((data) => { + console.info("Sensor_GetAltitude_010" + data) + expect(data).assertEqual(getGeomagneticDipResult[2]) + done() + }, (error) => { + console.info('Sensor_GetAltitude_010 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_GetAltitude_011 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it('Sensor_GetAltitude_011', 0, async function (done) { + sensor.getDeviceAltitude(0, 100, "abc").then((data) => { + console.info("Sensor_GetAltitude_011" + data) + expect(data).assertEqual(getGeomagneticDipResult[2]) + done() + }, (error) => { + console.info('Sensor_GetAltitude_011 failed'); + expect(false).assertTrue(); + done() + }); + }) + + let transformCoordinateSystemResult = [ + [1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000], + [340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, + 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, + 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000], + [Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity]] + + /* + * @tc.name: Sensor_TransformCoordinateSystem_011 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it("Sensor_TransformCoordinateSystem_011", 0, async function (done) { + console.info("---------------------------Sensor_TransformCoordinateSystem_011----------------------------------"); + sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, undefined).then((data) => { + for (let i = 0; i < data.length; i++) { + console.info("Sensor_TransformCoordinateSystem_011 data[ " + i + "] = " + data[i]); + expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); + } + done() + }, (error) => { + console.info('Sensor_TransformCoordinateSystem_011 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_TransformCoordinateSystem_012 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it("Sensor_TransformCoordinateSystem_012", 0, async function (done) { + console.info("---------------------------Sensor_TransformCoordinateSystem_012----------------------------------"); + sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, null).then((data) => { + for (let i = 0; i < data.length; i++) { + console.info("Sensor_TransformCoordinateSystem_012 data[ " + i + "] = " + data[i]); + expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); + } + done() + }, (error) => { + console.info('Sensor_TransformCoordinateSystem_012 failed'); + expect(false).assertTrue(); + done() + }); + }) + + /* + * @tc.name: Sensor_TransformCoordinateSystem_013 + * @tc.desc: Verification results of the incorrect parameters of test interface. + * @tc.require: I5SWJI + * @tc.author: + */ + it("Sensor_TransformCoordinateSystem_013", 0, async function (done) { + console.info("---------------------------Sensor_TransformCoordinateSystem_013----------------------------------"); + sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, "abc").then((data) => { + for (let i = 0; i < data.length; i++) { + console.info("Sensor_TransformCoordinateSystem_013 data[ " + i + "] = " + data[i]); + expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); + } + done() + }, (error) => { + console.info('Sensor_TransformCoordinateSystem_013 failed'); + expect(false).assertTrue(); + done() + }); + }) +})} \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSignificant_Motion.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSignificant_Motion.test.js index 4d2a51e41..3a0342d88 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSignificant_Motion.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSignificant_Motion.test.js @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_50", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_50", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_50", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_50", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTemperature.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTemperature.test.js index f2908d9ee..688a2449c 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTemperature.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTemperature.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_58", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_58", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_58", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_58", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTestServiceException.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTestServiceException.test.js index 6f67a1089..9bd6d0d3a 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTestServiceException.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newTestServiceException.test.js @@ -23,7 +23,7 @@ describe("SystemServiceExceptionTest", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SystemServiceExceptionTest", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SystemServiceExceptionTest", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SystemServiceExceptionTest", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let invild = -1; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newWear_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newWear_Detection.test.js index e082a8f0f..4ec6abdd2 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newWear_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newWear_Detection.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_59", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_59", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_59", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_59", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer.test.js index 451bac09d..ba89e5877 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_3() { describe("SensorJsTest_sensor_3", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -26,7 +26,7 @@ describe("SensorJsTest_sensor_3", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_3", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_3", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_3", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,11 +62,14 @@ describe("SensorJsTest_sensor_3", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) - + + const PARAMETER_ERROR_CODE = 401 + const SERVICE_EXCEPTION_CODE = 14500101 + const PARAMETER_ERROR_MSG = 'The parameter invalid.' + const SERVICE_EXCEPTION_MSG = 'Service exception.' let errMessages = ['string is not defined','The parameter invalid']; - let errMessage; /* @@ -295,7 +298,6 @@ describe("SensorJsTest_sensor_3", function () { } catch (error) { console.info("Accelerometer_SensorJsTest012 error:" + error); } - console console.info('----------------------Accelerometer_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -322,4 +324,141 @@ describe("SensorJsTest_sensor_3", function () { done(); }, 1000); }) + + /* + * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0140 + * @tc.name: Accelerometer_SensorJsTest014 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Accelerometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Accelerometer_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback2); + } catch (error) { + console.info("Accelerometer_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Accelerometer_SensorJsTest014 off end--------------'); + done() + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0150 + * @tc.name: Accelerometer_SensorJsTest015 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Accelerometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Accelerometer_SensorJsTest015--------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': undefined }); + } catch(error){ + console.info('Accelerometer_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Accelerometer_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + } catch (error) { + console.info("Accelerometer_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0160 + * @tc.name: Accelerometer_SensorJsTest016 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Accelerometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Accelerometer_SensorJsTest016--------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': null }); + } catch(error){ + console.info('Accelerometer_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Accelerometer_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + } catch (error) { + console.info("Accelerometer_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + }) + + /* + * @tc.number: SUB_SensorsSystem_ACCELEROMETER_JSTest_0170 + * @tc.name: Accelerometer_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Accelerometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Accelerometer_SensorJsTest017--------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Accelerometer_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + } catch (error) { + console.info("Accelerometer_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + }) + + /* + * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0180 + * @tc.name: Accelerometer_SensorJsTest018 + * @tc.desc: Functional Use Cases + */ + it("Accelerometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Accelerometer_SensorJsTest018--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, null); + setTimeout(() => { + done(); + }, 1000); + } catch(error){ + console.info('Accelerometer_SensorJsTest018 error:'+error); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ACCELEROMETER_JSTest_0190 + * @tc.name: Accelerometer_SensorJsTest019 + * @tc.desc: Functional Use Cases + */ + it("Accelerometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Accelerometer_SensorJsTest019--------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Accelerometer_SensorJsTest019 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Accelerometer_SensorJsTest019 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + } catch (error) { + console.info("Accelerometer_SensorJsTest019 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Accelerometer_SensorJsTest019 off end--------------'); + done() + }, 1000); + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer_Uncalibrated.test.js index 00adb54af..8563e1ccf 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAccelerometer_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_6", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_6", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_6", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_6", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessages = ['string is not defined','The parameter invalid']; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAmbient_light.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAmbient_light.test.js index 7a1b9165a..6a4cdc053 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAmbient_light.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldAmbient_light.test.js @@ -18,13 +18,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_4() { describe("SensorJsTest_sensor_4", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_4", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_4", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_4", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_4", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -385,7 +385,6 @@ describe("SensorJsTest_sensor_4", function () { } catch (error) { console.info("Ambient_Light_SensorJsTest012 error:" + error); } - console console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -428,4 +427,191 @@ describe("SensorJsTest_sensor_4", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_Ambient_Light_JSTest_0140 + * @tc.name: Ambient_Light_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Ambient_Light_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Ambient_Light_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('Ambient_Light_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + } catch (error) { + console.info("Ambient_Light_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Ambient_Light_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Ambient_Light_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_Ambient_Light_JSTest_0150 + * @tc.name: Ambient_Light_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Ambient_Light_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('Ambient_Light_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': undefined }); + } catch(error){ + console.info('Ambient_Light_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + } catch (error) { + console.info("Ambient_Light_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Ambient_Light_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_Ambient_Light_JSTest_0160 + * @tc.name: Ambient_Light_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Ambient_Light_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Ambient_Light_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('Ambient_Light_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': null }); + } catch(error){ + console.info('Ambient_Light_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + } catch (error) { + console.info("Ambient_Light_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Ambient_Light_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_Ambient_Light_JSTest_0170 + * @tc.name: Ambient_Light_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Ambient_Light_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Ambient_Light_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('Ambient_Light_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + } catch (error) { + console.info("Ambient_Light_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Ambient_Light_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_Ambient_Light_JSTest_0180 + * @tc.name: Ambient_Light_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Ambient_Light_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => { + if (error) { + console.info('Ambient_Light_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Ambient_Light_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + } catch (error) { + console.info("Ambient_Light_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Ambient_Light_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Ambient_Light_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldBarometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldBarometer.test.js index 85117bae1..df5a13bd1 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldBarometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldBarometer.test.js @@ -19,13 +19,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_8() { describe("SensorJsTest_sensor_8", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.pressure)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_8", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_8", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_8", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_8", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -387,7 +387,6 @@ describe("SensorJsTest_sensor_8", function () { } catch (error) { console.info("Barometer_SensorJsTest012 error:" + error); } - console console.info('----------------------Barometer_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -430,4 +429,191 @@ describe("SensorJsTest_sensor_8", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0140 + * @tc.name: Barometer_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Barometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Barometer_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => { + if (error) { + console.info('Barometer_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Barometer_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2); + } catch (error) { + console.info("Barometer_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Barometer_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Barometer_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0150 + * @tc.name: Barometer_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Barometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => { + if (error) { + console.info('Barometer_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': undefined }); + } catch(error){ + console.info('Barometer_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Barometer_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER); + } catch (error) { + console.info("Barometer_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Barometer_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0160 + * @tc.name: Barometer_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Barometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Barometer_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => { + if (error) { + console.info('Barometer_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': null }); + } catch(error){ + console.info('Barometer_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Barometer_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER); + } catch (error) { + console.info("Barometer_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Barometer_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0170 + * @tc.name: Barometer_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Barometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Barometer_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => { + if (error) { + console.info('Barometer_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Barometer_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER); + } catch (error) { + console.info("Barometer_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Barometer_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0180 + * @tc.name: Barometer_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Barometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => { + if (error) { + console.info('Barometer_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Barometer_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Barometer_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER); + } catch (error) { + console.info("Barometer_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Barometer_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Barometer_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGravity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGravity.test.js index 774fd3781..8ec269cad 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGravity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGravity.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_9() { describe("SensorJsTest_sensor_9", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -26,7 +26,7 @@ describe("SensorJsTest_sensor_9", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_9", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_9", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_9", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_9", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -393,7 +393,6 @@ describe("SensorJsTest_sensor_9", function () { } catch (error) { console.info("Gravity_SensorJsTest012 error:" + error); } - console console.info('----------------------Gravity_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -436,4 +435,191 @@ describe("SensorJsTest_sensor_9", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0140 + * @tc.name: Gravity_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Gravity_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Gravity_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => { + if (error) { + console.info('Gravity_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Gravity_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); + } catch (error) { + console.info("Gravity_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Gravity_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Gravity_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0150 + * @tc.name: Gravity_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Gravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => { + if (error) { + console.info('Gravity_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': undefined }); + } catch(error){ + console.info('Gravity_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Gravity_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + } catch (error) { + console.info("Gravity_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Gravity_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0160 + * @tc.name: Gravity_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Gravity_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Gravity_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => { + if (error) { + console.info('Gravity_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': null }); + } catch(error){ + console.info('Gravity_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Gravity_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + } catch (error) { + console.info("Gravity_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Gravity_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0170 + * @tc.name: Gravity_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Gravity_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Gravity_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => { + if (error) { + console.info('Gravity_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Gravity_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + } catch (error) { + console.info("Gravity_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Gravity_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0180 + * @tc.name: Gravity_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Gravity_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => { + if (error) { + console.info('Gravity_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Gravity_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Gravity_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY); + } catch (error) { + console.info("Gravity_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Gravity_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Gravity_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroScope.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroScope.test.js index 968fd2a75..8029e1e83 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroScope.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroScope.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_5() { describe("SensorJsTest_sensor_5", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -26,7 +26,7 @@ describe("SensorJsTest_sensor_5", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_5", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_5", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_5", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_5", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -393,7 +393,6 @@ describe("SensorJsTest_sensor_5", function () { } catch (error) { console.info("Gyroscope_SensorJsTest012 error:" + error); } - console console.info('----------------------Gyroscope_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -436,4 +435,191 @@ describe("SensorJsTest_sensor_5", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0140 + * @tc.name: Gyroscope_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Gyroscope_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Gyroscope_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,(error, data) => { + if (error) { + console.info('Gyroscope_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Gyroscope_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback2); + } catch (error) { + console.info("Gyroscope_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Gyroscope_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Gyroscope_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0150 + * @tc.name: Gyroscope_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Gyroscope_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,(error, data) => { + if (error) { + console.info('Gyroscope_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': undefined }); + } catch(error){ + console.info('Gyroscope_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Gyroscope_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE); + } catch (error) { + console.info("Gyroscope_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Gyroscope_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0160 + * @tc.name: Gyroscope_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Gyroscope_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Gyroscope_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,(error, data) => { + if (error) { + console.info('Gyroscope_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': null }); + } catch(error){ + console.info('Gyroscope_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Gyroscope_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE); + } catch (error) { + console.info("Gyroscope_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Gyroscope_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0170 + * @tc.name: Gyroscope_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Gyroscope_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Gyroscope_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,(error, data) => { + if (error) { + console.info('Gyroscope_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Gyroscope_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE); + } catch (error) { + console.info("Gyroscope_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Gyroscope_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0180 + * @tc.name: Gyroscope_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Gyroscope_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,(error, data) => { + if (error) { + console.info('Gyroscope_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Gyroscope_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Gyroscope_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE); + } catch (error) { + console.info("Gyroscope_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Gyroscope_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Gyroscope_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroscope_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroscope_Uncalibrated.test.js index a853cdde0..c9dc3765e 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroscope_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldGyroscope_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_10", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_10", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_10", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_10", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessages = ['string is not defined','The parameter invalid']; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHall.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHall.test.js index 905d7d123..8da4bfe66 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHall.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHall.test.js @@ -18,13 +18,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_7() { describe("SensorJsTest_sensor_7", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.status)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_7", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_7", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_7", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_7", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -383,7 +383,6 @@ describe("SensorJsTest_sensor_7", function () { } catch (error) { console.info("Hall_SensorJsTest012 error:" + error); } - console console.info('----------------------Hall_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -426,4 +425,191 @@ describe("SensorJsTest_sensor_7", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_HALL_JSTest_0140 + * @tc.name: Hall_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Hall_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Hall_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_HALL,(error, data) => { + if (error) { + console.info('Hall_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Hall_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback2); + } catch (error) { + console.info("Hall_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Hall_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Hall_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_HALL_JSTest_0150 + * @tc.name: Hall_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Hall_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_HALL,(error, data) => { + if (error) { + console.info('Hall_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': undefined }); + } catch(error){ + console.info('Hall_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Hall_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL); + } catch (error) { + console.info("Hall_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Hall_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_HALL_JSTest_0160 + * @tc.name: Hall_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Hall_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Hall_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_HALL,(error, data) => { + if (error) { + console.info('Hall_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': null }); + } catch(error){ + console.info('Hall_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Hall_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL); + } catch (error) { + console.info("Hall_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Hall_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_HALL_JSTest_0170 + * @tc.name: Hall_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Hall_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Hall_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_HALL,(error, data) => { + if (error) { + console.info('Hall_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Hall_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL); + } catch (error) { + console.info("Hall_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Hall_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_HALL_JSTest_0180 + * @tc.name: Hall_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Hall_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_HALL,(error, data) => { + if (error) { + console.info('Hall_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Hall_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Hall_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL); + } catch (error) { + console.info("Hall_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Hall_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Hall_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHeart_Rate.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHeart_Rate.test.js index 0c1b714f6..57575aafa 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHeart_Rate.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHeart_Rate.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_11", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_11", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_11", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_11", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHumidity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHumidity.test.js index 9a52c3e1d..4e41dae11 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHumidity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldHumidity.test.js @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_12", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_12", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_12", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_12", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldLinear_Acceleration.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldLinear_Acceleration.test.js index d1c63d6e1..7e60d9339 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldLinear_Acceleration.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldLinear_Acceleration.test.js @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_13", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_13", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_13", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_13", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessages = ['string is not defined','The parameter invalid']; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagneticField.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagneticField.test.js index afb2481ca..35ba8ef6d 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagneticField.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagneticField.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_15() { describe("SensorJsTest_sensor_15", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -26,7 +26,7 @@ describe("SensorJsTest_sensor_15", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_15", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_15", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_15", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_15", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -393,7 +393,6 @@ describe("SensorJsTest_sensor_15", function () { } catch (error) { console.info("MagneticField_SensorJsTest012 error:" + error); } - console console.info('----------------------MagneticField_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -436,4 +435,191 @@ describe("SensorJsTest_sensor_15", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0140 + * @tc.name: MagneticField_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("MagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------MagneticField_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('MagneticField_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------MagneticField_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback2); + } catch (error) { + console.info("MagneticField_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------MagneticField_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('MagneticField_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0150 + * @tc.name: MagneticField_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("MagneticField_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('MagneticField_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': undefined }); + } catch(error){ + console.info('MagneticField_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------MagneticField_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + } catch (error) { + console.info("MagneticField_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('MagneticField_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0160 + * @tc.name: MagneticField_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("MagneticField_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------MagneticField_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('MagneticField_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': null }); + } catch(error){ + console.info('MagneticField_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------MagneticField_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + } catch (error) { + console.info("MagneticField_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('MagneticField_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0170 + * @tc.name: MagneticField_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("MagneticField_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------MagneticField_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('MagneticField_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------MagneticField_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + } catch (error) { + console.info("MagneticField_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("MagneticField_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0180 + * @tc.name: MagneticField_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("MagneticField_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,(error, data) => { + if (error) { + console.info('MagneticField_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("MagneticField_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------MagneticField_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD); + } catch (error) { + console.info("MagneticField_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------MagneticField_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("MagneticField_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagnetic_Field_Uncalibrated.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagnetic_Field_Uncalibrated.test.js index a7f74775a..3a2d305f1 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagnetic_Field_Uncalibrated.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldMagnetic_Field_Uncalibrated.test.js @@ -44,7 +44,7 @@ describe("SensorJsTest_sensor_14", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -52,7 +52,7 @@ describe("SensorJsTest_sensor_14", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -60,7 +60,7 @@ describe("SensorJsTest_sensor_14", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -68,7 +68,7 @@ describe("SensorJsTest_sensor_14", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessages = ['string is not defined','The parameter invalid']; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldOrientating.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldOrientating.test.js index c2ae00d87..75e15a938 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldOrientating.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldOrientating.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_16() { describe("SensorJsTest_sensor_16", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); @@ -26,7 +26,7 @@ describe("SensorJsTest_sensor_16", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof(data.beta)).assertEqual("number"); expect(typeof(data.gamma)).assertEqual("number"); expect(typeof(data.alpha)).assertEqual("number"); @@ -38,7 +38,7 @@ describe("SensorJsTest_sensor_16", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -46,7 +46,7 @@ describe("SensorJsTest_sensor_16", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -54,7 +54,7 @@ describe("SensorJsTest_sensor_16", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -62,7 +62,7 @@ describe("SensorJsTest_sensor_16", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -393,7 +393,6 @@ describe("SensorJsTest_sensor_16", function () { } catch (error) { console.info("Orientating_SensorJsTest012 error:" + error); } - console console.info('----------------------Orientating_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -436,4 +435,191 @@ describe("SensorJsTest_sensor_16", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0140 + * @tc.name: Orientating_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("Orientating_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------Orientating_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,(error, data) => { + if (error) { + console.info('Orientating_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------Orientating_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); + } catch (error) { + console.info("Orientating_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Orientating_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('Orientating_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0150 + * @tc.name: Orientating_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("Orientating_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,(error, data) => { + if (error) { + console.info('Orientating_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': undefined }); + } catch(error){ + console.info('Orientating_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Orientating_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + } catch (error) { + console.info("Orientating_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Orientating_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0160 + * @tc.name: Orientating_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("Orientating_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------Orientating_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,(error, data) => { + if (error) { + console.info('Orientating_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': null }); + } catch(error){ + console.info('Orientating_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------Orientating_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + } catch (error) { + console.info("Orientating_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('Orientating_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0170 + * @tc.name: Orientating_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Orientating_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------Orientating_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,(error, data) => { + if (error) { + console.info('Orientating_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------Orientating_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + } catch (error) { + console.info("Orientating_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("Orientating_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ORIENTATION_JSTest_0180 + * @tc.name: Orientating_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("Orientating_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,(error, data) => { + if (error) { + console.info('Orientating_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("Orientating_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------Orientating_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION); + } catch (error) { + console.info("Orientating_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------Orientating_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("Orientating_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer.test.js index 71f661a5c..377338f02 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer.test.js @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_18", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_18", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_18", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_18", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js index 942f36571..380fa05cc 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldPedometer_Detection.test.js @@ -38,12 +38,12 @@ let permissionNameUser = 'ohos.permission.ACTIVITY_MOTION' describe("SensorJsTest_sensor_17", function () { function callback(data) { - console.info('callback success' + JSON.stringify(data)); + console.info('old callback success' + JSON.stringify(data)); expect(typeof(data.scalar)).assertEqual('number'); } function callback2(data) { - console.info('callback2 sucess' + JSON.stringify(data)); + console.info('old callback2 sucess' + JSON.stringify(data)); expect(typeof(data.scalar)).assertEqual('number'); } @@ -830,4 +830,228 @@ describe("SensorJsTest_sensor_17", function () { done(); }) }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0180 + * @tc.name: PedometerDetection_SensorJsTest018 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("PedometerDetection_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------PedometerDetection_SensorJsTest018---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('PedometerDetection_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback, { 'interval': undefined }); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('PedometerDetection_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('PedometerDetection_SensorJsTest018 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('PedometerDetection_SensorJsTest018 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0190 + * @tc.name: PedometerDetection_SensorJsTest019 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("PedometerDetection_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------PedometerDetection_SensorJsTest019---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('PedometerDetection_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback2, { 'interval': undefined }); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('PedometerDetection_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('PedometerDetection_SensorJsTest019 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('PedometerDetection_SensorJsTest019 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0200 + * @tc.name: PedometerDetection_SensorJsTest020 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("PedometerDetection_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------PedometerDetection_SensorJsTest020---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('PedometerDetection_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback, { 'interval': null }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback2, { 'interval': null }); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback2); + done(); + }, 4000); + } catch (error) { + console.error('PedometerDetection_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('PedometerDetection_SensorJsTest020 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('PedometerDetection_SensorJsTest020 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0210 + * @tc.name: PedometerDetection_SensorJsTest021 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("PedometerDetection_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------PedometerDetection_SensorJsTest021---------------------------'); + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('PedometerDetection_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback, undefined); + } catch(error){ + console.info('PedometerDetection_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION); + done(); + }, 4000); + } catch (error) { + console.error('PedometerDetection_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('PedometerDetection_SensorJsTest021 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('PedometerDetection_SensorJsTest021 error:' + JSON.stringify(error)); + done(); + }) + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_DETECTION_JSTest_0220 + * @tc.name: PedometerDetection_SensorJsTest022 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("PedometerDetection_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + let atManager = abilityAccessCtrl.createAtManager(); + await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .then(() => { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, (error, data) => { + if (error) { + console.error('PedometerDetection_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, null); + done(); + }, 4000); + } catch (error) { + console.error('PedometerDetection_SensorJsTest022 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('PedometerDetection_SensorJsTest022 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + .catch ((error) => { + console.error('PedometerDetection_SensorJsTest022 error:' + JSON.stringify(error)); + done(); + }) + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldProxinity.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldProxinity.test.js index 912760cb2..b5a9a461b 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldProxinity.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldProxinity.test.js @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_19", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_19", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_19", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_19", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldRotatingVector.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldRotatingVector.test.js index cd5229a1a..08e09af21 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldRotatingVector.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldRotatingVector.test.js @@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT export default function SensorJsTest_sensor_20() { describe("SensorJsTest_sensor_20", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("old callback" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -27,7 +27,7 @@ describe("SensorJsTest_sensor_20", function () { } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("old callback2" + JSON.stringify(data)); expect(typeof (data.x)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number"); @@ -40,7 +40,7 @@ describe("SensorJsTest_sensor_20", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -48,7 +48,7 @@ describe("SensorJsTest_sensor_20", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -56,7 +56,7 @@ describe("SensorJsTest_sensor_20", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -64,7 +64,7 @@ describe("SensorJsTest_sensor_20", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 @@ -395,7 +395,6 @@ describe("SensorJsTest_sensor_20", function () { } catch (error) { console.info("RotatingVector_SensorJsTest012 error:" + error); } - console console.info('----------------------RotatingVector_SensorJsTest012 off end---------------------------'); }, 500); setTimeout(() => { @@ -438,4 +437,191 @@ describe("SensorJsTest_sensor_20", function () { done(); } }) + + /* + * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0140 + * @tc.name: RotatingVector_SensorJsTest014 + * @tc.desc: Functional Use Cases + */ + it("RotatingVector_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('---------RotatingVector_SensorJsTest014--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('RotatingVector_SensorJsTest014 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2, { 'interval': undefined }); + setTimeout(() => { + console.info('----------------------RotatingVector_SensorJsTest014 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback2); + } catch (error) { + console.info("RotatingVector_SensorJsTest014 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------RotatingVector_SensorJsTest014 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info('RotatingVector_SensorJsTest014 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0150 + * @tc.name: RotatingVector_SensorJsTest015 + * @tc.desc: Illegal ID passed in + */ + it("RotatingVector_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('RotatingVector_SensorJsTest015 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, undefined); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': undefined }); + } catch(error){ + console.info('RotatingVector_SensorJsTest015 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------RotatingVector_SensorJsTest015 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + } catch (error) { + console.info("RotatingVector_SensorJsTest015 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('RotatingVector_SensorJsTest015 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0160 + * @tc.name: RotatingVector_SensorJsTest016 + * @tc.desc: For normal scenarios + */ + it("RotatingVector_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('---------RotatingVector_SensorJsTest016--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('RotatingVector_SensorJsTest016 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, null); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': null }); + } catch(error){ + console.info('RotatingVector_SensorJsTest016 Repeat subscription'+error); + } + setTimeout(() => { + console.info('----------------------RotatingVector_SensorJsTest016 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + } catch (error) { + console.info("RotatingVector_SensorJsTest016 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 1000); + } + }) + } catch (error) { + console.info('RotatingVector_SensorJsTest016 Device does not support! '); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0170 + * @tc.name: RotatingVector_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("RotatingVector_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { + console.info('---------RotatingVector_SensorJsTest017--------------'); + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('RotatingVector_SensorJsTest017 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': null }); + setTimeout(() => { + console.info('----------------------RotatingVector_SensorJsTest017 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + } catch (error) { + console.info("RotatingVector_SensorJsTest017 error:" + error); + expect(false).assertTrue(); + } + done(); + }, 500); + } + }) + } catch (error) { + console.info("RotatingVector_SensorJsTest017 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_ROTATION_VECTOR_JSTest_0180 + * @tc.name: RotatingVector_SensorJsTest018 + * @tc.desc: Once Normal Subscription Scenario Use Case + */ + it("RotatingVector_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,(error, data) => { + if (error) { + console.info('RotatingVector_SensorJsTest018 error'); + } else { + expect(typeof(data)).assertEqual("object"); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': 100000000 }); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback, { 'interval': 100000000 }); + } catch(error){ + console.info("RotatingVector_SensorJsTest018 catch error:" + error); + } + setTimeout(() => { + console.info('----------------------RotatingVector_SensorJsTest018 off in--------------'); + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR); + } catch (error) { + console.info("RotatingVector_SensorJsTest018 error:" + error); + expect(false).assertTrue(); + } + console.info('----------------------RotatingVector_SensorJsTest018 off end--------------'); + done() + }, 1000); + } + }) + } catch (error) { + console.info("RotatingVector_SensorJsTest018 Device does not support! "); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) })} \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldSignificant_Motion.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldSignificant_Motion.test.js index 40317a5f6..ed197dc57 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldSignificant_Motion.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldSignificant_Motion.test.js @@ -34,7 +34,7 @@ describe("SensorJsTest_sensor_21", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -42,7 +42,7 @@ describe("SensorJsTest_sensor_21", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -50,7 +50,7 @@ describe("SensorJsTest_sensor_21", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -58,7 +58,7 @@ describe("SensorJsTest_sensor_21", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let errMessages = ['string is not defined','The parameter invalid']; diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldTemperature.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldTemperature.test.js index 38eb12d9f..dff190f89 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldTemperature.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldTemperature.test.js @@ -35,7 +35,7 @@ describe("SensorJsTest_sensor_22", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -43,7 +43,7 @@ describe("SensorJsTest_sensor_22", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -51,7 +51,7 @@ describe("SensorJsTest_sensor_22", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -59,7 +59,7 @@ describe("SensorJsTest_sensor_22", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldWear_Detection.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldWear_Detection.test.js index 218d4ed0a..eeebb63ef 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldWear_Detection.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_oldWear_Detection.test.js @@ -33,7 +33,7 @@ describe("SensorJsTest_sensor_23", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -41,7 +41,7 @@ describe("SensorJsTest_sensor_23", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -49,7 +49,7 @@ describe("SensorJsTest_sensor_23", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -57,7 +57,7 @@ describe("SensorJsTest_sensor_23", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) const PARAMETER_ERROR_CODE = 401 diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_getOnBodyState.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_getOnBodyState.test.js index a35ebf5dd..c67ff6f83 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_getOnBodyState.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_getOnBodyState.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_24", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_24", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_24", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_24", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) /* diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeAccelerometer.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeAccelerometer.test.js index f18b203a3..52fa3570b 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeAccelerometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeAccelerometer.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_25", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_25", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_25", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_25", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) /* @@ -252,4 +252,171 @@ describe("SensorJsTest_sensor_25", function () { done(); }, 1000); }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0080 + * @tc.name: subscribeAccelerometer_SensorJsTest008 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest008---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'game', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest008 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0090 + * @tc.name: subscribeAccelerometer_SensorJsTest009 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest009---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'ui', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest009 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0100 + * @tc.name: subscribeAccelerometer_SensorJsTest010 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest010---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'normal', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest010 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0110 + * @tc.name: subscribeAccelerometer_SensorJsTest011 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest011---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'normal', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest011 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + + sensor.subscribeAccelerometer({ + interval: 'normal', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest011_1 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0120 + * @tc.name: subscribeAccelerometer_SensorJsTest012 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest012---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'xxx', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest012 success" + JSON.stringify(data)); + expect(false).assertTrue(); + }, + fail: undefined, + }); + setTimeout(() => { + done(); + }, 500); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0130 + * @tc.name: subscribeAccelerometer_SensorJsTest013 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest013---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'xxx', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest013 success" + JSON.stringify(data)); + expect(false).assertTrue(); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0140 + * @tc.name: subscribeAccelerometer_SensorJsTest014 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeAccelerometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeAccelerometer_SensorJsTest014---------------------------'); + sensor.subscribeAccelerometer({ + interval: 'game', + success: function (data) { + console.info("subscribeAccelerometer_SensorJsTest014 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeAccelerometer(); + done(); + }, 1000); + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.test.js index 1e8a17121..9274f8495 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_26", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_26", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_26", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,10 +47,11 @@ describe("SensorJsTest_sensor_26", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let BarometerId = 8 + /* * @tc.number:SUB_SensorsSystem_SubscribeBarometer_JSTest_0010 * @tc.name:subscribeBarometer_SensorJsTest001 @@ -149,5 +150,79 @@ describe("SensorJsTest_sensor_26", function () { console.info('subscribeBarometer_SensorJsTest003 Device does not support! '); done(); } - }) + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeBarometer_JSTest_0040 + * @tc.name: subscribeBarometer_SensorJsTest004 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeBarometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeBarometer_SensorJsTest004---------------------------'); + try{ + sensor.getSingleSensor(BarometerId ,(error, data) => { + if (error) { + console.info('subscribeBarometer_SensorJsTest004 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeBarometer({ + success: function (data) { + console.info("subscribeBarometer_SensorJsTest004 success" + JSON.stringify(data)); + expect(typeof (data.pressure)).assertEqual("number"); + }, + fail: undefined, + }); + + sensor.subscribeBarometer({ + success: function (data) { + console.info("subscribeBarometer_SensorJsTest004_1 success" + JSON.stringify(data)); + expect(typeof (data.pressure)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeBarometer(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeBarometer_SensorJsTest004 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeBarometer_JSTest_0050 + * @tc.name: subscribeBarometer_SensorJsTest005 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeBarometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeBarometer_SensorJsTest005---------------------------'); + try{ + sensor.getSingleSensor(BarometerId ,(error, data) => { + if (error) { + console.info('subscribeBarometer_SensorJsTest005 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeBarometer({ + success: function (data) { + console.info("subscribeBarometer_SensorJsTest005 success" + JSON.stringify(data)); + expect(typeof (data.pressure)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeBarometer(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeBarometer_SensorJsTest005 Device does not support! '); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeCompass.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeCompass.test.js index 66f273903..4cf6987cd 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeCompass.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeCompass.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_28", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_28", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_28", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_28", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) /* diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.test.js index 0100db750..17edfcd22 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_27", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_27", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_27", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_27", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let DeviceOrientationId = 256 @@ -60,26 +60,32 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest001---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'game', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest001 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest001 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - done() - }, - }); - setTimeout(() => { - sensor.unsubscribeDeviceOrientation(); - done(); - }, 500); + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'game', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest001 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest001 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + done() + }, + }); + setTimeout(() => { + sensor.unsubscribeDeviceOrientation(); + done(); + }, 500); + } }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest001 Device does not support! '); @@ -95,27 +101,33 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest002---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'ui', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest002 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - done() - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest002 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - done() - }, - }); - setTimeout(() => { - sensor.unsubscribeDeviceOrientation(); - done(); - }, 500); + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'ui', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest002 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + done() + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest002 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + done() + }, + }); + setTimeout(() => { + sensor.unsubscribeDeviceOrientation(); + done(); + }, 500); + } }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest002 Device does not support! '); @@ -131,27 +143,33 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest003---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'normal', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest003 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest003 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - done() - }, - }); - setTimeout(() => { - sensor.unsubscribeDeviceOrientation(); - done(); - }, 500); - }) + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'normal', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest003 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest003 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + done() + }, + }); + setTimeout(() => { + sensor.unsubscribeDeviceOrientation(); + done(); + }, 500); + } + }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest003 Device does not support! '); done(); @@ -166,41 +184,47 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest004---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'normal', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest004 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest004 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - }, - }); - - sensor.subscribeDeviceOrientation({ - interval: 'normal', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest004_1 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - }, - }); - setTimeout(() => { - sensor.unsubscribeDeviceOrientation(); - done(); - }, 500); - }) + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'normal', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest004 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest004 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + }, + }); + + sensor.subscribeDeviceOrientation({ + interval: 'normal', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest004_1 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + }, + }); + setTimeout(() => { + sensor.unsubscribeDeviceOrientation(); + done(); + }, 500); + } + }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest004 Device does not support! '); done(); @@ -215,23 +239,29 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest005---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'xxx', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest005 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest005 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('input error'); - expect(code).assertEqual(202); - done() - }, - }); - }) + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'xxx', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest005 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest005 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('input error'); + expect(code).assertEqual(202); + done() + }, + }); + } + }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest005 Device does not support! '); done(); @@ -246,26 +276,32 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest006---------------------------'); try{ - sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { - sensor.subscribeDeviceOrientation({ - interval: 'normal', - success: function (data) { - console.info("subscribeDeviceOrientation_SensorJsTest006 success" + JSON.stringify(data)); - expect(typeof (data.alpha)).assertEqual("number"); - expect(typeof (data.beta)).assertEqual("number"); - expect(typeof (data.gamma)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeDeviceOrientation_SensorJsTest006 is failed, data: " + data + ", code: " + code); - expect(data).assertEqual('subscribe fail'); - expect(code).assertEqual(1001); - done() - }, - }); - setTimeout(() => { - sensor.unsubscribeDeviceOrientation(); - done(); - }, 500); + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { + if (error) { + console.info('subscribeDeviceOrientation_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeDeviceOrientation({ + interval: 'normal', + success: function (data) { + console.info("subscribeDeviceOrientation_SensorJsTest006 success" + JSON.stringify(data)); + expect(typeof (data.alpha)).assertEqual("number"); + expect(typeof (data.beta)).assertEqual("number"); + expect(typeof (data.gamma)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeDeviceOrientation_SensorJsTest006 is failed, data: " + data + ", code: " + code); + expect(data).assertEqual('subscribe fail'); + expect(code).assertEqual(1001); + done() + }, + }); + setTimeout(() => { + sensor.unsubscribeDeviceOrientation(); + done(); + }, 500); + } }) } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest006 Device does not support! '); diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.test.js index 2bd3d59ad..b546e35b0 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_29", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_29", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_29", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,7 +47,7 @@ describe("SensorJsTest_sensor_29", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let GyroscopeId = 2 @@ -60,30 +60,36 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest001---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'game', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest001 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest001 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeGyroscope(); - done(); - }, 1000); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest002 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'game', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest002 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest002 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } }) } catch (error) { - console.info('subscribeGyroscope_SensorJsTest001 Device does not support! '); + console.info('subscribeGyroscope_SensorJsTest002 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0020 @@ -91,32 +97,37 @@ describe("SensorJsTest_sensor_29", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeGyroscope_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeGyroscope_SensorJsTest002---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'ui', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest002 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest002 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeGyroscope(); - done(); - }, 1000); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest002 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'ui', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest002 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest002 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest002 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0030 @@ -124,32 +135,37 @@ describe("SensorJsTest_sensor_29", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeGyroscope_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeGyroscope_SensorJsTest003---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'normal', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest003 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest003 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeGyroscope(); - done(); - }, 1000); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest003 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest003 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest003 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest003 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0040 @@ -157,46 +173,51 @@ describe("SensorJsTest_sensor_29", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeGyroscope_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeGyroscope_SensorJsTest004---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'normal', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest004 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest004 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - - sensor.subscribeGyroscope({ - interval: 'normal', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest004_1 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeGyroscope(); - done(); - }, 1000); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest004 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest004 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest004 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest004_1 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest004 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0050 @@ -204,29 +225,34 @@ describe("SensorJsTest_sensor_29", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeGyroscope_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeGyroscope_SensorJsTest005---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'xxx', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest005 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest005 is failed, data: " + data + ", code: " + code); - expect(code).assertEqual(202); - done(); - }, - }); - }) + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest005 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'xxx', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest005 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest005 is failed, data: " + data + ", code: " + code); + expect(code).assertEqual(202); + done(); + }, + }); + } + }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest005 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0060 @@ -236,23 +262,33 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest006---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'normal', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest006 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest006 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + done(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); done(); - }, - }); + }, 1000); + } }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest006 Device does not support! '); done(); } - }) + }) /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0070 @@ -262,25 +298,296 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest007---------------'); try{ - sensor.getSingleSensor(GyroscopeId ,(error, data) => { - sensor.subscribeGyroscope({ - interval: 'normal', - success: function (data) { - console.info("subscribeGyroscope_SensorJsTest007 success" + JSON.stringify(data)); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest008 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest007 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + done(); + }, + fail: function (data, code) { + console.log("subscribeGyroscope_SensorJsTest007 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); done(); - }, - fail: function (data, code) { - console.log("subscribeGyroscope_SensorJsTest007 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); + }, 1000); + } }) } catch (error) { console.info('subscribeGyroscope_SensorJsTest007 Device does not support! '); done(); } - }) + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0080 + * @tc.name: subscribeGyroscope_SensorJsTest008 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest008---------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest008 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'game', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest008 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest008 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0090 + * @tc.name: subscribeGyroscope_SensorJsTest009 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest009 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'ui', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest009 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest009 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0100 + * @tc.name: subscribeGyroscope_SensorJsTest010 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest010---------------------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest010 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest010 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest010 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0110 + * @tc.name: subscribeGyroscope_SensorJsTest011 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest011---------------------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest011 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest011 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + + sensor.subscribeGyroscope({ + interval: 'normal', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest011_1 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest011 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0120 + * @tc.name: subscribeGyroscope_SensorJsTest012 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest012---------------------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest012 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'xxx', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest012 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + done(); + }, 500); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest012 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0130 + * @tc.name: subscribeGyroscope_SensorJsTest013 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest013---------------------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest013 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'xxx', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest013 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest013 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0140 + * @tc.name: subscribeGyroscope_SensorJsTest014 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeGyroscope_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeGyroscope_SensorJsTest014---------------------------'); + try{ + sensor.getSingleSensor(GyroscopeId ,(error, data) => { + if (error) { + console.info('subscribeGyroscope_SensorJsTest014 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeGyroscope({ + interval: 'game', + success: function (data) { + console.info("subscribeGyroscope_SensorJsTest014 success" + JSON.stringify(data)); + expect(typeof (data.x)).assertEqual("number"); + expect(typeof (data.y)).assertEqual("number"); + expect(typeof (data.z)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeGyroscope(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeGyroscope_SensorJsTest014 Device does not support! '); + done(); + } + }) })} diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.test.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.test.js index 22a0b22f2..6008a9e1e 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.test.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.test.js @@ -23,7 +23,7 @@ describe("SensorJsTest_sensor_31", function () { /* * @tc.setup: setup invoked before all testcases */ - console.info('beforeAll caled') + console.info('beforeAll called') }) afterAll(function () { @@ -31,7 +31,7 @@ describe("SensorJsTest_sensor_31", function () { /* * @tc.teardown: teardown invoked after all testcases */ - console.info('afterAll caled') + console.info('afterAll called') }) beforeEach(function () { @@ -39,7 +39,7 @@ describe("SensorJsTest_sensor_31", function () { /* * @tc.setup: setup invoked before each testcases */ - console.info('beforeEach caled') + console.info('beforeEach called') }) afterEach(function () { @@ -47,34 +47,40 @@ describe("SensorJsTest_sensor_31", function () { /* * @tc.teardown: teardown invoked after each testcases */ - console.info('afterEach caled') + console.info('afterEach called') }) let LightId = 5 + /* * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0010 * @tc.name: subscribeLight_SensorJsTest001 * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeLight_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('----------------------subscribeLight_SensorJsTest001---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'game', - success: function (data) { - console.info("subscribeLight_SensorJsTest001 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest001 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeLight(); - done(); - }, 1000); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest001 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'game', + success: function (data) { + console.info("subscribeLight_SensorJsTest001 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest001 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest001 Device does not support! '); @@ -88,24 +94,29 @@ describe("SensorJsTest_sensor_31", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeLight_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeLight_SensorJsTest002---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'ui', - success: function (data) { - console.info("subscribeLight_SensorJsTest002 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest002 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeLight(); - done(); - }, 1000); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest002 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'ui', + success: function (data) { + console.info("subscribeLight_SensorJsTest002 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest002 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest002 Device does not support! '); @@ -121,21 +132,28 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest003---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - success: function (data) { - console.info("subscribeLight_SensorJsTest003 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest003 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeLight(); - done(); - }, 1000); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest003 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest003 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest003 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest003 Device does not support! '); @@ -149,42 +167,47 @@ describe("SensorJsTest_sensor_31", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeLight_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeLight_SensorJsTest004---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'normal', - success: function (data) { - console.info("subscribeLight_SensorJsTest004 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest004 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - - sensor.subscribeLight({ - interval: 'normal', - success: function (data) { - console.info("subscribeLight_SensorJsTest004_1 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); - setTimeout(() => { - sensor.unsubscribeLight(); - done(); - }, 1000); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest004 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest004 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest004 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest004_1 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest004_1 is failed, data: " + data + ", code: " + code); + expect(false).assertTrue(); + }, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest004 Device does not support! '); done(); - } - }) + } + }) /* * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0050 @@ -192,28 +215,33 @@ describe("SensorJsTest_sensor_31", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeLight_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeLight_SensorJsTest005---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'xxx', - success: function (data) { - console.info("subscribeLight_SensorJsTest005 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - done(); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest005 is failed, data: " + data + ", code: " + code); - expect(code).assertEqual(202); - done(); - }, - }); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest005 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'xxx', + success: function (data) { + console.info("subscribeLight_SensorJsTest005 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + done(); + }, + fail: function (data, code) { + console.log("subscribeLight_SensorJsTest005 is failed, data: " + data + ", code: " + code); + expect(code).assertEqual(202); + done(); + }, + }); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest005 Device does not support! '); done(); - } - }) + } + }) /* * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0060 @@ -221,49 +249,271 @@ describe("SensorJsTest_sensor_31", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface. */ it("subscribeLight_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('----------------------subscribeLight_SensorJsTest006---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'normal', - success: function (data) { - console.info("subscribeLight_SensorJsTest006 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - done(); - }, - }); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest006 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest006 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + done(); + }, + }); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest006 Device does not support! '); done(); - } - }) + } + }) /* * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0070 * @tc.name: subscribeLight_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface. */ - it("subscribeLight_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + it("subscribeLight_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest007---------------------------'); try{ - sensor.getSingleSensor(LightId ,(error, data) => { - sensor.subscribeLight({ - interval: 'normal', - success: function (data) { - console.info("subscribeLight_SensorJsTest007 success" + JSON.stringify(data)); - expect(typeof (data.intensity)).assertEqual("number"); - done(); - }, - fail: function (data, code) { - console.log("subscribeLight_SensorJsTest007 is failed, data: " + data + ", code: " + code); - expect(false).assertTrue(); - }, - }); + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest007 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'game', + success: function (data) { + console.info("subscribeLight_SensorJsTest007 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } }) } catch (error) { console.info('subscribeLight_SensorJsTest007 Device does not support! '); done(); } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0080 + * @tc.name: subscribeLight_SensorJsTest008 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------subscribeLight_SensorJsTest008---------------'); + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest008 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'game', + success: function (data) { + console.info("subscribeLight_SensorJsTest008 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest008 Device does not support! '); + done(); + } }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0090 + * @tc.name: subscribeLight_SensorJsTest009 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest009 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'ui', + success: function (data) { + console.info("subscribeLight_SensorJsTest009 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest009 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0100 + * @tc.name: subscribeLight_SensorJsTest010 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeLight_SensorJsTest010---------------------------'); + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest010 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest010 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest010 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0110 + * @tc.name: subscribeLight_SensorJsTest011 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeLight_SensorJsTest011---------------------------'); + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest011 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest011 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: undefined, + }); + + sensor.subscribeLight({ + interval: 'normal', + success: function (data) { + console.info("subscribeLight_SensorJsTest011_1 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest011 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0120 + * @tc.name: subscribeLight_SensorJsTest012 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeLight_SensorJsTest012---------------------------'); + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest012 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'xxx', + success: function (data) { + console.info("subscribeLight_SensorJsTest012 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: undefined, + }); + setTimeout(() => { + done(); + }, 500); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest012 Device does not support! '); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_SubscribeAccelerometer_JSTest_0130 + * @tc.name: subscribeLight_SensorJsTest013 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + */ + it("subscribeLight_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------subscribeLight_SensorJsTest013---------------------------'); + try{ + sensor.getSingleSensor(LightId ,(error, data) => { + if (error) { + console.info('subscribeLight_SensorJsTest013 error'); + expect(false).assertTrue(); + done(); + } else { + sensor.subscribeLight({ + interval: 'xxx', + success: function (data) { + console.info("subscribeLight_SensorJsTest013 success" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + }, + fail: null, + }); + setTimeout(() => { + sensor.unsubscribeLight(); + done(); + }, 1000); + } + }) + } catch (error) { + console.info('subscribeLight_SensorJsTest013 Device does not support! '); + done(); + } + }) })} -- GitLab