diff --git a/sensors/miscdevice_standard/Test.json b/sensors/miscdevice_standard/Test.json index 06651a88cfa9955995f2bb7428d1b8c9b14c5371..63de6fa109164bd2fba3fbd0d5c9bd4a4fdaeb88 100644 --- a/sensors/miscdevice_standard/Test.json +++ b/sensors/miscdevice_standard/Test.json @@ -21,7 +21,10 @@ "power-shell wakeup", "uinput -T -m 594 2117 594 864 400", "power-shell setmode 602" - ] + ], + "teardown-command":[ + "power-shell setmode 600" + ] } ] } \ No newline at end of file diff --git a/sensors/sensor_standard/Test.json b/sensors/sensor_standard/Test.json index 2214c70ecced861ecb9490b6795616dc4915c10a..38f7b439bc8a9cab9aa87d4f4d3e771028aef02f 100644 --- a/sensors/sensor_standard/Test.json +++ b/sensors/sensor_standard/Test.json @@ -21,7 +21,10 @@ "power-shell wakeup", "uinput -T -m 594 2117 594 864 400", "power-shell setmode 602" - ] + ], + "teardown-command":[ + "power-shell setmode 600" + ] } ] } \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/test/List.test.js b/sensors/sensor_standard/src/main/js/test/List.test.js index 98e165f20b9492781da82df4cc5aa218ed80cdc3..0c5ef57182359b492adbb414fc4f6751cedbafbd 100644 --- a/sensors/sensor_standard/src/main/js/test/List.test.js +++ b/sensors/sensor_standard/src/main/js/test/List.test.js @@ -16,6 +16,7 @@ import SystemParameterTest from './SensorOnOffTest.test.js' import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js' import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js' import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.test.js' +import SensorJsTest_sensor_38 from './SensorOnOffTest.test_newSensorGeomagneticOptions.test.js' import SensorJsTest_sensor_35 from './SensorOnOffTest.test_newGetSensorList.test.js' import SensorJsTest_sensor_36 from './SensorOnOffTest.test_newGetSingleSensor.test.js' import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.test.js' @@ -43,12 +44,15 @@ import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.test.js' import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.test.js' import SensorJsTest_sensor_57 from './SensorOnOffTest.test_newPedometer_Detection.test.js' import SensorJsTest_sensor_17 from './SensorOnOffTest.test_oldPedometer_Detection.test.js' +import SensorJsTest_sensor_56 from './SensorOnOffTest.test_newPedometer.test.js' +import SensorJsTest_sensor_18 from './SensorOnOffTest.test_oldPedometer.test.js' export default function testsuite() { SystemParameterTest() SensorJsTest_sensor_2() SensorJsTest_sensor_1() SensorJsTest_sensor_60() + SensorJsTest_sensor_38() SensorJsTest_sensor_35() SensorJsTest_sensor_36() SensorJsTest_sensor_3() @@ -76,4 +80,6 @@ export default function testsuite() { SensorJsTest_sensor_26() SensorJsTest_sensor_57() SensorJsTest_sensor_17() + SensorJsTest_sensor_56() + SensorJsTest_sensor_18() } diff --git a/sensors/sensor_standard/src/main/js/test/SensorGeneralalgorithm.test.js b/sensors/sensor_standard/src/main/js/test/SensorGeneralalgorithm.test.js index 1bb422734a16d18590d87cf8370047c639c39534..e5c6d7372b060ad9b69c71498b572b62ff6669e7 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorGeneralalgorithm.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorGeneralalgorithm.test.js @@ -1095,11 +1095,147 @@ describe("SensorJsTest_sensor_1", function () { done() }); }) + + /* + * @tc.name:SensorJsTest_111 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0440 + */ + it("SensorJsTest_111", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_111 start') + try { + sensor.getGeomagneticDip().then((data)=>{ + console.info("SensorJsTest_111 data:" + data) + expect(false).assertfalse() + done() + }, (error)=>{ + console.info("SensorJsTest_111 error:" + error) + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + }) + } catch(error) { + console.info("SensorJsTest_111 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_111 end") + }) + /* + * @tc.name:SensorJsTest_112 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0450 + */ + it("SensorJsTest_112", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_112 start') + try { + sensor.getGeomagneticDip(-1).then((data)=>{ + console.info("SensorJsTest_112 data:" + data) + expect(false).assertfalse() + done() + }, (error)=>{ + console.info("SensorJsTest_112 error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + }) + } catch(error) { + console.info("SensorJsTest_112 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_112 end") + }) + + /* + * @tc.name:SensorJsTest_113 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0460 + */ + it("SensorJsTest_113", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_113 start') + try { + sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]).then((data)=>{ + console.info("SensorJsTest_113 data:" + data) + expect(data).assertEqual(0); + done() + }, (error)=>{ + console.info("SensorJsTest_113 error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + }) + } catch(error) { + console.info("SensorJsTest_113 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_113 end") + }) -}) - - - + /* + * @tc.name:SensorJsTest_114 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0470 + */ + it("SensorJsTest_114", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_114 start') + let inclinationMatrix = [ + 1, 0, 0, 1, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 0, 0, 0 + ] + try { + sensor.getGeomagneticDip(inclinationMatrix).then((data)=>{ + console.info("SensorJsTest_114 data:" + data) + expect(data).assertEqual(0); + done() + }, (error)=>{ + console.info("SensorJsTest_114 error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + }) + } catch(error) { + console.info("SensorJsTest_114 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_114 end") + }) -} + /* + * @tc.name:SensorJsTest_115 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0460 + */ + it("SensorJsTest_115", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_115 start') + try { + sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], (error, data) => { + if (error) { + console.info("SensorJsTest_115 error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + } else { + console.info("SensorJsTest_115 data:" + data) + expect(data).assertEqual(0); + done() + } + }) + } catch(error) { + console.info("SensorJsTest_115 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_115 end") + }) +})} 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 da89c019960e1f351d46302f173a07e6499aa359..446e11514eb7164544e4544247ec192a15cbc44d 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 @@ -12,11 +12,46 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osAccount from '@ohos.account.osAccount' import sensor from '@ohos.sensor' - import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' export default function SensorJsTest_sensor_56() { +let PermissionFlag = { + PERMISSION_USER_SET:1, + PERMISSION_USER_FIXED:2, + PERMISSION_SYSTEM_FIXED:4 +} + +const PERMISSION_DENIED_CODE = 201 +const PARAMETER_ERROR_CODE = 401 +const SERVICE_EXCEPTION_CODE = 14500101 +const SERVICE_EXCEPTION_MSG = 'Service exception.' +const PARAMETER_ERROR_MSG = 'The parameter invalid.' +const PERMISSION_DENIED_MSG = 'Permission denied.' +let tokenID = undefined +let permissionNameUser = 'ohos.permission.ACTIVITY_MOTION' +async function grantPerm(){ + try { + let accountManager = osAccount.getAccountManager(); + let userId = await accountManager.getOsAccountLocalIdFromProcess(); + console.info("SensorJsTest_sensor_56 userId:"+userId) + console.info("============SensorJsTest_sensor_56 grant Permission start ============") + var appInfo = await bundle.getApplicationInfo('ohos.acts.sensors.sensor.function', 0, userId); + tokenID = appInfo.accessTokenId; + console.log('SensorJsTest_sensor_56 accessTokenId:' + appInfo.accessTokenId + ', name:' + appInfo.name + + ' ,bundleName:' + appInfo.process) + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + console.info('SensorJsTest_sensor_56 successful. result: ' + JSON.stringify(result)); + console.info("============SensorJsTest_sensor_56 grant Permission end ============") + } catch(error) { + console.error('SensorJsTest_sensor_56 exception in, msg:' + JSON.stringify(error)) + } +} describe("SensorJsTest_sensor_56", function () { function callback(data) { console.info("callback" + JSON.stringify(data)); @@ -28,12 +63,13 @@ describe("SensorJsTest_sensor_56", function () { expect(typeof (data.steps)).assertEqual("number"); } - beforeAll(function () { - + beforeAll(async function(done) { /* * @tc.setup: setup invoked before all testcases */ console.info('beforeAll called') + await grantPerm(); + done(); }) afterAll(function () { @@ -42,6 +78,13 @@ describe("SensorJsTest_sensor_56", function () { * @tc.teardown: teardown invoked after all testcases */ console.info('afterAll called') + let atManager = abilityAccessCtrl.createAtManager(); + atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .catch((error) => { + console.info('SensorJsTest_sensor_56 error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERR_NOT_HAVE_PERMISSION); + }) }) beforeEach(function () { @@ -59,236 +102,778 @@ describe("SensorJsTest_sensor_56", function () { */ console.info('afterEach called') }) - - const PARAMETER_ERROR_CODE = 401 - const PARAMETER_ERROR_MSG = 'The parameter invalid.' - const SERVICE_EXCEPTION_CODE = 14500101 - const SERVICE_EXCEPTION_MSG = 'Service exception.' - let invalid = -1; - let errMessages = ['ReferenceError: string is not defined','TypeError: is not callable', - 'ReferenceError: xxx is not defined'] - let errMessage /* - * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0120 - * @tc.name: newPedometer_SensorJsTest012 + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0010 + * @tc.name: newPedometer_SensorJsTest001 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newPedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('--------newPedometer_SensorJsTest012--------'); - try { - sensor.on(sensor.SensorId.PEDOMETER, callback); + it("newPedometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------newPedometer_SensorJsTest001---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest001 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest001 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest001 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0020 + * @tc.name: newPedometer_SensorJsTest002 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest002---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest002 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, 5); + } catch (error) { + console.error('newPedometer_SensorJsTest002 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest002 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0030 + * @tc.name: newPedometer_SensorJsTest003 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest003---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest003 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorId.PEDOMETER, callback); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest003 Once fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest003 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0040 + * @tc.name: newPedometer_SensorJsTest004 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest004---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest004 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorId.PEDOMETER, callback, 5); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest004 Once fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest004 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0050 + * @tc.name: newPedometer_SensorJsTest005 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest005---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest005 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorId.PEDOMETER, 5); + } catch (error) { + console.error('newPedometer_SensorJsTest005 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest005 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0060 + * @tc.name: newPedometer_SensorJsTest006 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest006---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest006 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(-1, callback); + } catch (error) { + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest006 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0070 + * @tc.name: newPedometer_SensorJsTest007 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest007---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest007 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + sensor.on(sensor.SensorId.PEDOMETER, callback2); + setTimeout(()=>{ + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest007 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest007 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0080 + * @tc.name: newPedometer_SensorJsTest008 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest008---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest008 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + sensor.on(sensor.SensorId.PEDOMETER, callback2); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER, callback2); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest008 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest008 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0090 + * @tc.name: newPedometer_SensorJsTest009 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest009---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest009 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + sensor.once(sensor.SensorId.PEDOMETER, callback2); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest009 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest009 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0100 + * @tc.name: newPedometer_SensorJsTest010 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest010---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest010 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + setTimeout(() => { + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest010 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PERMISSION_DENIED_CODE); + expect(error.message).assertEqual(PERMISSION_DENIED_MSG); + done(); + } + }); } catch (error) { - console.info("newPedometer_SensorJsTest012 error:" + error); + console.error('newPedometer_SensorJsTest010 Sensor is not support'); expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } - setTimeout(() => { - expect(true).assertTrue(); - done(); - }, 500); + }) + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0110 + * @tc.name: newPedometer_SensorJsTest011 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------newPedometer_SensorJsTest011--------'); + let errorMessage = "" + let errorMessages = "ReferenceError: xxx is not defined" + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest011 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + function onSensorCallback(data) { + console.info('newPedometer_SensorJsTest011 on error'); + expect(typeof (data.steps)).assertEqual("number"); + } + try { + xxx.on(sensor.SensorId.PEDOMETER, onSensorCallback); + } catch (error) { + console.info("newPedometer_SensorJsTest011 error:" + error); + errorMessage = error.toString(); + expect(errorMessage).assertEqual(errorMessages); + done(); + } + } catch (error) { + console.error('newPedometer_SensorJsTest011 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest011 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0130 + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0120 + * @tc.name: newPedometer_SensorJsTest012 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("newPedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------newPedometer_SensorJsTest012--------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest012 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback, {'interval': 100000000}); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest012 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest012 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0130 * @tc.name: newPedometer_SensorJsTest013 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('--------newPedometer_SensorJsTest013--------'); - try { - sensor.on(sensor.SensorId.PEDOMETER ,callback, { 'interval': 100000000 }); - } catch (error) { - console.info("newPedometer_SensorJsTest013 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest013 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback, {'interval': 100000000}, 5); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest013 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest013 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0140 + + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0140 * @tc.name: newPedometer_SensorJsTest014 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('--------newPedometer_SensorJsTest014--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest014 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.on(sensor.SensorId.PEDOMETER, - onSensorCallback, { 'interval': 100000000 }, 5); - } catch (error) { - console.info("newPedometer_SensorJsTest014 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) - - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0150 + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest014 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + function onSensorCallback(data) { + console.info('newPedometer_SensorJsTest014 callback:'+JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + } + sensor.on(sensor.SensorId.PEDOMETER, onSensorCallback, {'interval': 100000000}); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest014 On fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest014 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0150 * @tc.name: newPedometer_SensorJsTest015 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newPedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest015--------'); - try{ - sensor.once(sensor.SensorId.PEDOMETER, callback); - } catch (error) { - console.info("newPedometer_SensorJsTest015 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + it("newPedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------newPedometer_SensorJsTest015---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest015 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(sensor.SensorId.PEDOMETER,5); + } catch (error) { + console.error('newPedometer_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest015 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0160 + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0160 * @tc.name: newPedometer_SensorJsTest016 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('--------newPedometer_SensorJsTest016--------'); - function onceSensorCallback(data) { - console.info('newPedometer_SensorJsTest016 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.once(sensor.SensorId.PEDOMETER, onceSensorCallback, 5); - } catch (error) { - console.info("newPedometer_SensorJsTest016 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest016 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, (data)=>{ + console.info("newPedometer_SensorJsTest016 callback: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }, {'interval': 100000000}); + sensor.on(sensor.SensorId.PEDOMETER, (data)=>{ + console.info("newPedometer_SensorJsTest016 callback2: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }); + setTimeout(()=>{ + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest016 Off fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest016 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0170 + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0170 * @tc.name: newPedometer_SensorJsTest017 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('--------newPedometer_SensorJsTest017--------'); - try { - sensor.off(string, ""); - } catch (error) { - errMessage - console.info("newPedometer_SensorJsTest017 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[0]); - done(); - } + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest017 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, (data)=>{ + console.info("newPedometer_SensorJsTest017 callback: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }, {'interval': -100000000}); + } catch (error) { + console.error('newPedometer_SensorJsTest017 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); + expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest017 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0180 + /* + * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0180 * @tc.name: newPedometer_SensorJsTest018 * @tc.desc:Verification results of the incorrect parameters of the test interface */ - it("newPedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest018--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest018 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.on(sensor.SensorId.PEDOMETER, onSensorCallback); - sensor.off(sensor.SensorId.PEDOMETER); + it("newPedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------newPedometer_SensorJsTest018---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': undefined }); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); } catch (error) { - console.info("newPedometer_SensorJsTest018 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + console.error('newPedometer_SensorJsTest018 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0190 + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0190 * @tc.name: newPedometer_SensorJsTest019 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest019--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest019 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info("newPedometer_SensorJsTest019 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + console.info('----------------------newPedometer_SensorJsTest019---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorId.PEDOMETER, callback2, { 'interval': undefined }); + setTimeout(()=>{ + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest019 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0200 + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0200 * @tc.name: newPedometer_SensorJsTest020 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest020--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest020 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.off(invalid, onSensorCallback); - } catch (error) { - console.info("newPedometer_SensorJsTest020 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } + console.info('----------------------newPedometer_SensorJsTest020---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': null }); + sensor.on(sensor.SensorId.PEDOMETER, callback2, { 'interval': null }); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER, callback2); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest020 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0210 + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0210 * @tc.name: newPedometer_SensorJsTest021 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest021--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest021 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.xxx(sensor.SensorId.PEDOMETER, onSensorCallback); - } catch (error) { - console.info("newPedometer_SensorJsTest021 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[1]); - done(); - } + console.info('----------------------newPedometer_SensorJsTest021---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + try{ + sensor.on(sensor.SensorId.PEDOMETER, callback, undefined); + } catch(error){ + console.info('newPedometer_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest021 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) - - /* - * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0220 + + /* + * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0220 * @tc.name: newPedometer_SensorJsTest022 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("newPedometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------newPedometer_SensorJsTest022--------'); - function onSensorCallback(data) { - console.info('newPedometer_SensorJsTest022 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - xxx.on(sensor.SensorId.PEDOMETER, onSensorCallback); - } catch (error) { - console.info("newPedometer_SensorJsTest022 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[2]); - done(); - } + try { + sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => { + if (error) { + console.error('newPedometer_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorId.PEDOMETER, callback); + setTimeout(() => { + sensor.off(sensor.SensorId.PEDOMETER, null); + done(); + }, 4000); + } catch (error) { + console.error('newPedometer_SensorJsTest022 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('newPedometer_SensorJsTest022 Sensor is not support'+error); + 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_newSensorGeomagneticOptions.test.js b/sensors/sensor_standard/src/main/js/test/SensorOnOffTest.test_newSensorGeomagneticOptions.test.js index dc87e611083d6ae7d657f44231afe14137b30701..e14496c553bc66213cccd3f789249ee0b85321c3 100644 --- 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 @@ -75,13 +75,12 @@ describe("SensorJsTest_sensor_38", function () { 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 + * @tc.name:SensorJsTest_001 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0470 */ - it("Sensor_GetGeomagneticInfo_058", 0, async function (done) { - console.info("---------------------------Sensor_GetGeomagneticInfo_058----------------------------------"); + it("SensorJsTest_001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_001----------------------------------"); 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 @@ -94,23 +93,22 @@ describe("SensorJsTest_sensor_38", function () { 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); + console.info("SensorJsTest_001 promise::catch", error); }) } done() }) /* - * @tc.name:Sensor_GetGeomagneticInfo_058 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: I5SWJI + * @tc.name:SensorJsTest_002 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0480 */ - it("Sensor_GetGeomagneticInfo_059", 0, async function (done) { - console.info("---------------------------Sensor_GetGeomagneticInfo_059----------------------------------"); + it("SensorJsTest_002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_002----------------------------------"); 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 + console.info('SensorJsTest_002 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() @@ -120,23 +118,22 @@ describe("SensorJsTest_sensor_38", function () { 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); + console.info("SensorJsTest_002 promise::catch", error); }) } done() }) /* - * @tc.name:Sensor_GetGeomagneticInfo_060 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: I5SWJI + * @tc.name:SensorJsTest_003 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0490 */ - it("Sensor_GetGeomagneticInfo_060", 0, async function (done) { - console.info("---------------------------Sensor_GetGeomagneticInfo_060----------------------------------"); + it("SensorJsTest_003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_003----------------------------------"); 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 + console.info('SensorJsTest_003 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() @@ -146,7 +143,7 @@ describe("SensorJsTest_sensor_38", function () { 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); + console.info("SensorJsTest_003 promise::catch", error); }) } done() @@ -217,14 +214,13 @@ describe("SensorJsTest_sensor_38", function () { ] /* - * 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) { + * @tc.name:SensorJsTest_004 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0500 + */ + it("SensorJsTest_004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getRotationMatrix(gravity[0], geomagnetic[0], undefined).then((data) => { - console.info("Sensor_CreateRotationMatrix_015" + JSON.stringify(data)) + console.info("SensorJsTest_004" + JSON.stringify(data)) expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) done() }, (error) => { @@ -234,14 +230,13 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * 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) { + * @tc.name:SensorJsTest_005 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0510 + */ + it("SensorJsTest_005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getRotationMatrix(gravity[0], geomagnetic[0], null).then((data) => { - console.info("Sensor_CreateRotationMatrix_016" + JSON.stringify(data)) + console.info("SensorJsTest_005" + JSON.stringify(data)) expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) done() }, (error) => { @@ -251,15 +246,14 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * 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) { + * @tc.name:SensorJsTest_006 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0520 + */ + it("SensorJsTest_006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, 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]); + console.info("SensorJsTest_006 [" + i + "] : " + data[i]); expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) } done() @@ -270,15 +264,14 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * 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) { + * @tc.name:SensorJsTest_007 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0530 + */ + it("SensorJsTest_007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, 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]); + console.info("SensorJsTest_007 [" + i + "] : " + data[i]); expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) } done() @@ -288,18 +281,15 @@ describe("SensorJsTest_sensor_38", function () { }) }) - /** - * test - * - * @tc.name: Sensor_GetDirection_011 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - * @tc.require: I5SWJI - * @tc.author: + /* + * @tc.name:SensorJsTest_008 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0540 */ - it('Sensor_GetDirection_011', 0, async function (done) { + it("SensorJsTest_008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, 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]) + console.info("SensorJsTest_008" + data[i]) expect(data[i]).assertEqual(GET_DIRECTION[0][i]) } done() @@ -309,18 +299,15 @@ describe("SensorJsTest_sensor_38", function () { }) }) - /** - * test - * - * @tc.name: Sensor_GetDirection_012 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - * @tc.require: I5SWJI - * @tc.author: + /* + * @tc.name:SensorJsTest_009 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0550 */ - it('Sensor_GetDirection_012', 0, async function (done) { + it("SensorJsTest_009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, 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]) + console.info("SensorJsTest_009" + data[i]) expect(data[i]).assertEqual(GET_DIRECTION[0][i]) } done() @@ -338,16 +325,15 @@ describe("SensorJsTest_sensor_38", function () { ]; /* - * @tc.name:Sensor_GetAngleModify_017 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: I5SWJI + * @tc.name:SensorJsTest_010 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0560 */ - it('Sensor_GetAngleModify_017', 0, async function (done) { - console.info('----------------------Sensor_GetAngleModify_017---------------------------'); + it("SensorJsTest_010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------SensorJsTest_010---------------------------'); 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]); + console.info("SensorJsTest_010 [" + 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]); } @@ -359,16 +345,15 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * @tc.name:Sensor_GetAngleModify_018 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: I5SWJI + * @tc.name:SensorJsTest_011 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0570 */ - it('Sensor_GetAngleModify_018', 0, async function (done) { - console.info('----------------------Sensor_GetAngleModify_018---------------------------'); + it("SensorJsTest_011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------SensorJsTest_011---------------------------'); 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]); + console.info("SensorJsTest_011 [" + 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]); } @@ -380,16 +365,15 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * @tc.name:Sensor_GetAngleModify_019 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: I5SWJI + * @tc.name:SensorJsTest_012 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0580 */ - it('Sensor_GetAngleModify_019', 0, async function (done) { - console.info('----------------------Sensor_GetAngleModify_019---------------------------'); + it("SensorJsTest_012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------SensorJsTest_012---------------------------'); 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]); + console.info("SensorJsTest_012 [" + 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]); } @@ -409,16 +393,13 @@ describe("SensorJsTest_sensor_38", function () { ]; /* - * test - * - * @tc.name: Sensor_CreateQuaternion_016 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - * @tc.require: I5SWJI - * @tc.author: + * @tc.name:SensorJsTest_013 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0590 */ - it('Sensor_CreateQuaternion_016', 0, async function (done) { + it("SensorJsTest_013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getQuaternion([0.52, -0.336, -0.251], undefined).then((data) => { - console.info('Sensor_CreateQuaternion_016'); + console.info('SensorJsTest_013 data:' +data); for (let i = 0; i < data.length; i++) { console.info("data[" + i + "]: " + data[i]); expect(data[i]).assertEqual(result[0][i]) @@ -431,16 +412,13 @@ describe("SensorJsTest_sensor_38", function () { }) /* - * test - * - * @tc.name: Sensor_CreateQuaternion_017 - * @tc.desc: Verification results of the incorrect parameters of the test interface. - * @tc.require: I5SWJI - * @tc.author: + * @tc.name:SensorJsTest_014 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0600 */ - it('Sensor_CreateQuaternion_017', 0, async function (done) { + it("SensorJsTest_014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getQuaternion([0.52, -0.336, -0.251], null).then((data) => { - console.info('Sensor_CreateQuaternion_017'); + console.info('SensorJsTest_014 data:'+data); for (let i = 0; i < data.length; i++) { console.info("data[" + i + "]: " + data[i]); expect(data[i]).assertEqual(result[0][i]) @@ -455,90 +433,85 @@ describe("SensorJsTest_sensor_38", function () { 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) { + * @tc.name:SensorJsTest_015 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0610 + */ + it("SensorJsTest_015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], undefined).then((data) => { - console.info("Sensor_GetGeomagneticDip_008" + data) + console.info("SensorJsTest_015" + data) expect(data).assertEqual(getGeomagneticDipResult[0]) done() }, (error) => { - console.info('Sensor_GetGeomagneticDip_008 failed'); + console.info('SensorJsTest_015 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) { + * @tc.name:SensorJsTest_016 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0620 + */ + it("SensorJsTest_016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], null).then((data) => { - console.info("Sensor_GetGeomagneticDip_009" + data) + console.info("SensorJsTest_016" + data) expect(data).assertEqual(getGeomagneticDipResult[0]) done() }, (error) => { - console.info('Sensor_GetGeomagneticDip_009 failed'); + console.info('SensorJsTest_016 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) { + * @tc.name:SensorJsTest_017 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0630 + */ + it("SensorJsTest_017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getDeviceAltitude(0, 100, undefined).then((data) => { - console.info("Sensor_GetAltitude_009" + data) + console.info("SensorJsTest_017 data:" + data) expect(data).assertEqual(getGeomagneticDipResult[2]) done() }, (error) => { - console.info('Sensor_GetAltitude_009 failed'); + console.info(' SensorJsTest_017 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) { + * @tc.name:SensorJsTest_018 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0640 + */ + it("SensorJsTest_018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getDeviceAltitude(0, 100, null).then((data) => { - console.info("Sensor_GetAltitude_010" + data) + console.info("SensorJsTest_018" + data) expect(data).assertEqual(getGeomagneticDipResult[2]) done() }, (error) => { - console.info('Sensor_GetAltitude_010 failed'); + console.info('SensorJsTest_018 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) { + * @tc.name:SensorJsTest_019 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0650 + */ + it("SensorJsTest_019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { sensor.getDeviceAltitude(0, 100, "abc").then((data) => { - console.info("Sensor_GetAltitude_011" + data) + console.info("SensorJsTest_019" + data) expect(data).assertEqual(getGeomagneticDipResult[2]) done() }, (error) => { - console.info('Sensor_GetAltitude_011 failed'); + console.info('SensorJsTest_019 failed'); expect(false).assertTrue(); done() }); @@ -552,65 +525,97 @@ describe("SensorJsTest_sensor_38", function () { [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----------------------------------"); + * @tc.name:SensorJsTest_020 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0660 + */ + it("SensorJsTest_020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_020----------------------------------"); 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]); + console.info("SensorJsTest_020 data[ " + i + "] = " + data[i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); } done() }, (error) => { - console.info('Sensor_TransformCoordinateSystem_011 failed'); + console.info('SensorJsTest_020 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----------------------------------"); + * @tc.name:SensorJsTest_021 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0670 + */ + it("SensorJsTest_021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_021----------------------------------"); 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]); + console.info("SensorJsTest_021 data[ " + i + "] = " + data[i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); } done() }, (error) => { - console.info('Sensor_TransformCoordinateSystem_012 failed'); + console.info('SensorJsTest_021 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----------------------------------"); + * @tc.name:SensorJsTest_022 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0680 + */ + it("SensorJsTest_022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("---------------------------SensorJsTest_022----------------------------------"); 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]); + console.info("SensorJsTest_022 data[ " + i + "] = " + data[i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); } done() }, (error) => { - console.info('Sensor_TransformCoordinateSystem_013 failed'); + console.info('SensorJsTest_022 failed'); expect(false).assertTrue(); done() }); }) + + /* + * @tc.name:SensorJsTest_023 + * @tc.desc:Verification results of the incorrect parameters of the test interface. + * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0690 + */ + it("SensorJsTest_023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('SensorJsTest_023 start') + let inclinationMatrix = [ + 1, 0, 0, 1, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 0, 0, 0 + ] + try { + sensor.getGeomagneticDip(inclinationMatrix, (error, data) => { + if (error) { + console.info("SensorJsTest_023 error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done() + } else { + console.info("SensorJsTest_023 data:" + data) + expect(data).assertEqual(0); + done() + } + }) + } catch(error) { + console.info("SensorJsTest_023 catch error:" + error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + console.info("SensorJsTest_023 end") + }) })} \ No newline at end of file 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 377338f02e8149b7b61c705efab1a43d26b34b67..d886e4e6465474aa85689ce86e828dd2941ec11f 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 @@ -12,30 +12,66 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osAccount from '@ohos.account.osAccount' import sensor from '@ohos.sensor' - import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' export default function SensorJsTest_sensor_18() { +let PermissionFlag = { + PERMISSION_USER_SET:1, + PERMISSION_USER_FIXED:2, + PERMISSION_SYSTEM_FIXED:4 +} + +const PERMISSION_DENIED_CODE = 201 +const PARAMETER_ERROR_CODE = 401 +const SERVICE_EXCEPTION_CODE = 14500101 +const SERVICE_EXCEPTION_MSG = 'Service exception.' +const PARAMETER_ERROR_MSG = 'The parameter invalid.' +const PERMISSION_DENIED_MSG = 'Permission denied.' +let tokenID = undefined +let permissionNameUser = 'ohos.permission.ACTIVITY_MOTION' +async function grantPerm(){ + try { + let accountManager = osAccount.getAccountManager(); + let userId = await accountManager.getOsAccountLocalIdFromProcess(); + console.info("SensorJsTest_sensor_18 userId:"+userId) + console.info("============SensorJsTest_sensor_18 grant Permission start ============") + var appInfo = await bundle.getApplicationInfo('ohos.acts.sensors.sensor.function', 0, userId); + tokenID = appInfo.accessTokenId; + console.log('SensorJsTest_sensor_18 accessTokenId:' + appInfo.accessTokenId + ', name:' + appInfo.name + + ' ,bundleName:' + appInfo.process) + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + console.info('SensorJsTest_sensor_18 successful. result: ' + JSON.stringify(result)); + console.info("============SensorJsTest_sensor_18 grant Permission end ============") + } catch(error) { + console.error('SensorJsTest_sensor_18 exception in, msg:' + JSON.stringify(error)) + } +} describe("SensorJsTest_sensor_18", function () { function callback(data) { - console.info("callback" + JSON.stringify(data)); + console.info("SensorJsTest_sensor_18 callback" + JSON.stringify(data)); expect(typeof (data.steps)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } function callback2(data) { - console.info("callback2" + JSON.stringify(data)); + console.info("SensorJsTest_sensor_18 callback2" + JSON.stringify(data)); expect(typeof (data.steps)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number"); } - beforeAll(function () { - + beforeAll(async function(done) { /* * @tc.setup: setup invoked before all testcases */ console.info('beforeAll called') + await grantPerm(); + done(); }) afterAll(function () { @@ -44,6 +80,13 @@ describe("SensorJsTest_sensor_18", function () { * @tc.teardown: teardown invoked after all testcases */ console.info('afterAll called') + let atManager = abilityAccessCtrl.createAtManager(); + atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, + PermissionFlag.PERMISSION_SYSTEM_FIXED) + .catch((error) => { + console.info('SensorJsTest_sensor_18 error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERR_NOT_HAVE_PERMISSION); + }) }) beforeEach(function () { @@ -76,20 +119,33 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { - console.info('--------Pedometer_SensorJsTest001--------'); - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); - } catch (error) { - console.info("Pedometer_SensorJsTest001 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - setTimeout(() => { - expect(true).assertTrue(); - done(); - }, 500); - }) + console.info('----------------------Pedometer_SensorJsTest001---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest001 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest001 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest001 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0020 @@ -97,16 +153,30 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest002--------'); - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER ,callback, { 'interval': 100000000 }); - } catch (error) { - console.info("Pedometer_SensorJsTest002 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + console.info('----------------------Pedometer_SensorJsTest002---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest002 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, 5); + } catch (error) { + console.error('Pedometer_SensorJsTest002 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest002 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0030 @@ -114,22 +184,33 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest003--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest003 on error'); - expect(typeof (data.steps)).assertEqual("number"); - expect(typeof (data.timestamp)).assertEqual("number"); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, - onSensorCallback, { 'interval': 100000000 }, 5); - } catch (error) { - console.info("Pedometer_SensorJsTest003 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + console.info('----------------------Pedometer_SensorJsTest003---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest003 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest003 Once fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest003 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0040 @@ -137,16 +218,33 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest004--------'); - try{ - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); - } catch (error) { - console.info("Pedometer_SensorJsTest004 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + console.info('----------------------Pedometer_SensorJsTest004---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest004 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, 5); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest004 Once fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest004 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0050 @@ -154,61 +252,95 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest005--------'); - function onceSensorCallback(data) { - console.info('Pedometer_SensorJsTest005 on error'); - expect(typeof (data.steps)).assertEqual("number"); - expect(typeof (data.timestamp)).assertEqual("number"); - } - try { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onceSensorCallback, 5); - } catch (error) { - console.info("Pedometer_SensorJsTest005 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + console.info('----------------------Pedometer_SensorJsTest005---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest005 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, 5); + } catch (error) { + console.error('Pedometer_SensorJsTest005 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest005 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) - /* + /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0060 * @tc.name: Pedometer_SensorJsTest006 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest006--------'); - try { - sensor.off(string, ""); - } catch (error) { - errMessage - console.info("Pedometer_SensorJsTest006 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[0]); - done(); - } - }) + console.info('----------------------Pedometer_SensorJsTest006---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest006 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(-1, callback); + } catch (error) { + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest006 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) - /* + /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0070 * @tc.name: Pedometer_SensorJsTest007 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest007--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest007 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + console.info('----------------------Pedometer_SensorJsTest007---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest007 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest007 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); } catch (error) { - console.info("Pedometer_SensorJsTest007 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) + console.error('Pedometer_SensorJsTest007 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0080 @@ -216,59 +348,103 @@ describe("SensorJsTest_sensor_18", function () { * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest008--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest008 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.off(1000000, onSensorCallback); - } catch (error) { - console.info("Pedometer_SensorJsTest008 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) - - /* + console.info('----------------------Pedometer_SensorJsTest008---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest008 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest008 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest008 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0090 * @tc.name: Pedometer_SensorJsTest009 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest009--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest009 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - sensor.off(invalid, onSensorCallback); - } catch (error) { - console.info("Pedometer_SensorJsTest009 error:" + error); - expect(error.code).assertEqual(PARAMETER_ERROR_CODE); - expect(error.message).assertEqual(PARAMETER_ERROR_MSG); - done(); - } - }) - - /* + console.info('----------------------Pedometer_SensorJsTest009---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest009 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest009 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest009 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0100 * @tc.name: Pedometer_SensorJsTest010 * @tc.desc:Verification results of the incorrect parameters of the test interface */ it("Pedometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { - console.info('--------Pedometer_SensorJsTest010--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest010 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } + console.info('----------------------Pedometer_SensorJsTest010---------------------------'); try { - sensor.xxx(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest010 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + setTimeout(() => { + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest010 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PERMISSION_DENIED_CODE); + expect(error.message).assertEqual(PERMISSION_DENIED_MSG); + done(); + } + }); } catch (error) { - console.info("Pedometer_SensorJsTest010 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[1]); + console.error('Pedometer_SensorJsTest010 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done(); } }) @@ -280,18 +456,434 @@ describe("SensorJsTest_sensor_18", function () { */ it("Pedometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('--------Pedometer_SensorJsTest011--------'); - function onSensorCallback(data) { - console.info('Pedometer_SensorJsTest011 on error'); - expect(typeof (data.steps)).assertEqual("number"); - } - try { - xxx.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); - } catch (error) { - console.info("Pedometer_SensorJsTest011 error:" + error); - errMessage = error.toString(); - expect(errMessage).assertEqual(errMessages[2]); - done(); - } + let errorMessage = "" + let errorMessages = "ReferenceError: xxx is not defined" + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest011 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + function onSensorCallback(data) { + console.info('Pedometer_SensorJsTest011 on error'); + expect(typeof (data.steps)).assertEqual("number"); + } + try { + xxx.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); + } catch (error) { + console.info("Pedometer_SensorJsTest011 error:" + error); + errorMessage = error.toString(); + expect(errorMessage).assertEqual(errorMessages); + done(); + } + } catch (error) { + console.error('Pedometer_SensorJsTest011 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest011 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } }) -}) -} + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0120 + * @tc.name: Pedometer_SensorJsTest012 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------Pedometer_SensorJsTest012--------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest012 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, {'interval': 100000000}); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest012 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest012 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0130 + * @tc.name: Pedometer_SensorJsTest013 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------Pedometer_SensorJsTest013--------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest013 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, {'interval': 100000000}, 5); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest013 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest013 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0140 + * @tc.name: Pedometer_SensorJsTest014 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------Pedometer_SensorJsTest014--------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest014 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + function onSensorCallback(data) { + console.info('Pedometer_SensorJsTest014 callback:'+JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback, {'interval': 100000000}); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest014 On fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest014 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0150 + * @tc.name: Pedometer_SensorJsTest015 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Pedometer_SensorJsTest015---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest015 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,5); + } catch (error) { + console.error('Pedometer_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest015 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0160 + * @tc.name: Pedometer_SensorJsTest016 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------Pedometer_SensorJsTest016--------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest016 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{ + console.info("Pedometer_SensorJsTest016 callback: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }, {'interval': 100000000}); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{ + console.info("Pedometer_SensorJsTest016 callback2: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest016 Off fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE) + expect(error.message).assertEqual(PARAMETER_ERROR_MSG) + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest016 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0170 + * @tc.name: Pedometer_SensorJsTest017 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('--------Pedometer_SensorJsTest017--------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest017 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{ + console.info("Pedometer_SensorJsTest017 callback: " + JSON.stringify(data)); + expect(typeof(data.steps)).assertEqual('number'); + expect(typeof (data.timestamp)).assertEqual("number"); + }, {'interval': -100000000}); + } catch (error) { + console.error('Pedometer_SensorJsTest017 On fail, errorCode:' +JSON.stringify(error)); + expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); + expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest017 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0180 + * @tc.name: Pedometer_SensorJsTest018 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { + console.info('----------------------Pedometer_SensorJsTest018---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': undefined }); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest018 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0190 + * @tc.name: Pedometer_SensorJsTest019 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Pedometer_SensorJsTest019---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': undefined }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2, { 'interval': undefined }); + setTimeout(()=>{ + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest019 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0200 + * @tc.name: Pedometer_SensorJsTest020 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Pedometer_SensorJsTest020---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': null }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2, { 'interval': null }); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + }, 4000); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest020 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0210 + * @tc.name: Pedometer_SensorJsTest021 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('----------------------Pedometer_SensorJsTest021---------------------------'); + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + try{ + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, undefined); + } catch(error){ + console.info('Pedometer_SensorJsTest021 Repeat subscription'+error); + } + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest021 Sensor is not support'); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) + + /* + * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0220 + * @tc.name: Pedometer_SensorJsTest022 + * @tc.desc:Verification results of the incorrect parameters of the test interface + */ + it("Pedometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + try { + sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => { + if (error) { + console.error('Pedometer_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, null); + done(); + }, 4000); + } catch (error) { + console.error('Pedometer_SensorJsTest022 catch error:' +JSON.stringify(error)); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.error('Pedometer_SensorJsTest022 Sensor is not support'+error); + expect(error.code).assertEqual(PARAMETER_ERROR_CODE); + expect(error.message).assertEqual(PARAMETER_ERROR_MSG); + done(); + } + }) +})}