diff --git a/sensors/sensor_standard/src/main/js/test/SensorGeomagneticTest.test.js b/sensors/sensor_standard/src/main/js/test/SensorGeomagneticTest.test.js index fe504a8edc859fbab1c3114dfaf740d342db69a7..e8cae01d975fa264eec656d4f4be698e3988162b 100644 --- a/sensors/sensor_standard/src/main/js/test/SensorGeomagneticTest.test.js +++ b/sensors/sensor_standard/src/main/js/test/SensorGeomagneticTest.test.js @@ -169,6 +169,47 @@ describe("SensorJsTest_sensor_2", function () { Promise.all(promiseArray).then(done) }) + /** + * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030 + * @tc.name: SensorGeomagenticAlgorithmJSTest003 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it('SensorGeomagenticAlgorithmJSTest003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info("------------------SensorGeomagenticAlgorithmJSTest003-------------------------"); + let geomagneticComponent = [-1417119616, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488, -1417119360, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488] + sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, 9223372036854775807, + (error, data) => { + if (error) { + console.info('SensorGeomagenticAlgorithmJSTest003 failed'); + expect(false).assertTrue(); + } else { + console.info('SensorGeomagenticAlgorithmJSTest003 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 - geomagneticComponent[0]) < EPS) + || (Math.abs(data.x - geomagneticComponent[7]) < EPS)).assertTrue(); + expect((Math.abs(data.y - geomagneticComponent[1]) < EPS) + || (Math.abs(data.y - geomagneticComponent[8]) < EPS)).assertTrue(); + expect((Math.abs(data.z - geomagneticComponent[2]) < EPS) + || (Math.abs(data.z - geomagneticComponent[9]) < EPS)).assertTrue(); + expect((Math.abs(data.geomagneticDip - geomagneticComponent[3]) < EPS) + || (Math.abs(data.geomagneticDip - geomagneticComponent[10]) < EPS)).assertTrue(); + expect((Math.abs(data.deflectionAngle - geomagneticComponent[4]) < EPS) + || (Math.abs(data.deflectionAngle - geomagneticComponent[11]) < EPS)).assertTrue(); + expect((Math.abs(data.levelIntensity - geomagneticComponent[5]) < EPS) + || (Math.abs(data.levelIntensity - geomagneticComponent[12]) < EPS)).assertTrue(); + expect((Math.abs(data.totalIntensity - geomagneticComponent[6]) < EPS) + || (Math.abs(data.totalIntensity - geomagneticComponent[13]) < EPS)).assertTrue(); + } + setTimeout(() => { + done() + }, 500) + }) + }) + /** * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0040 * @tc.name: SensorGeomagenticAlgorithmJSTest004 @@ -803,6 +844,42 @@ describe("SensorJsTest_sensor_2", function () { done() }) + /** + * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270 + * @tc.name: SensorGeomagenticAlgorithmJSTest027 + * @tc.desc: Verification results of the incorrect parameters of the test interface. + */ + it("SensorGeomagenticAlgorithmJSTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { + console.info('------------------SensorGeomagenticAlgorithmJSTest027------------------'); + let geomagneticComponent = [-1417119616, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488, -1417119360, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488] + await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, + 9223372036854775807).then((data) => { + console.info('SensorGeomagenticAlgorithmJSTest027 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 - geomagneticComponent[0]) < EPS) + || (Math.abs(data.x - geomagneticComponent[7]) < EPS)).assertTrue(); + expect((Math.abs(data.y - geomagneticComponent[1]) < EPS) + || (Math.abs(data.y - geomagneticComponent[8]) < EPS)).assertTrue(); + expect((Math.abs(data.z - geomagneticComponent[2]) < EPS) + || (Math.abs(data.z - geomagneticComponent[9]) < EPS)).assertTrue(); + expect((Math.abs(data.geomagneticDip - geomagneticComponent[3]) < EPS) + || (Math.abs(data.geomagneticDip - geomagneticComponent[10]) < EPS)).assertTrue(); + expect((Math.abs(data.deflectionAngle - geomagneticComponent[4]) < EPS) + || (Math.abs(data.deflectionAngle - geomagneticComponent[11]) < EPS)).assertTrue(); + expect((Math.abs(data.levelIntensity - geomagneticComponent[5]) < EPS) + || (Math.abs(data.levelIntensity - geomagneticComponent[12]) < EPS)).assertTrue(); + expect((Math.abs(data.totalIntensity - geomagneticComponent[6]) < EPS) + || (Math.abs(data.totalIntensity - geomagneticComponent[13]) < EPS)).assertTrue(); + }).catch((error) => { + console.info("promise::catch", error) + }); + done() + }) + /** * @tc.number:SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0280 * @tc.name: SensorGeomagenticAlgorithmJSTest028 diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.js index ceb38d27b282edea4c52c480adef6e229a3d0448..1e8a17121e07df4c7c146f0039aafa22ce3274b5 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeBarometer.js @@ -50,6 +50,7 @@ describe("SensorJsTest_sensor_26", function () { console.info('afterEach caled') }) + let BarometerId = 8 /* * @tc.number:SUB_SensorsSystem_SubscribeBarometer_JSTest_0010 * @tc.name:subscribeBarometer_SensorJsTest001 @@ -58,7 +59,7 @@ describe("SensorJsTest_sensor_26", function () { it("subscribeBarometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeBarometer_SensorJsTest001---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeBarometer ,(error, data) => { + sensor.getSingleSensor(BarometerId ,(error, data) => { sensor.subscribeBarometer({ success: function (data) { console.info("subscribeBarometer_SensorJsTest001 success" + JSON.stringify(data)); @@ -88,7 +89,7 @@ describe("SensorJsTest_sensor_26", function () { it("subscribeBarometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { console.info('----------------------subscribeBarometer_SensorJsTest002---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeBarometer ,(error, data) => { + sensor.getSingleSensor(BarometerId ,(error, data) => { sensor.subscribeBarometer({ success: function (data) { console.info("subscribeBarometer_SensorJsTest002 success:" + JSON.stringify(data)); @@ -128,7 +129,7 @@ describe("SensorJsTest_sensor_26", function () { it("subscribeBarometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) { console.info('----------------------subscribeBarometer_SensorJsTest003---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeBarometer ,(error, data) => { + sensor.getSingleSensor(BarometerId,(error, data) => { sensor.subscribeBarometer({ success: function (data) { console.info("subscribeBarometer_SensorJsTest003 success:" + JSON.stringify(data)); diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.js index 1fe14bdf2bac6b0740ee7987f9f9fd414e70a0db..0100db7508cfd8acbbfdef21224f5d06ee3f7385 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeDeviceOrientation.js @@ -49,6 +49,8 @@ describe("SensorJsTest_sensor_27", function () { */ console.info('afterEach caled') }) + + let DeviceOrientationId = 256 /* * @tc.number:SUB_SensorsSystem_SubscribeDeviceOrientation_JSTest_0010 @@ -58,7 +60,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest001---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'game', success: function (data) { @@ -93,7 +95,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest002---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'ui', success: function (data) { @@ -129,7 +131,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest003---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'normal', success: function (data) { @@ -164,7 +166,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest004---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'normal', success: function (data) { @@ -213,7 +215,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest005---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'xxx', success: function (data) { @@ -244,7 +246,7 @@ describe("SensorJsTest_sensor_27", function () { it("subscribeDeviceOrientation_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeDeviceOrientation_SensorJsTest006---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeDeviceOrientation ,(error, data) => { + sensor.getSingleSensor(DeviceOrientationId ,(error, data) => { sensor.subscribeDeviceOrientation({ interval: 'normal', success: function (data) { diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.js index 62a983ab40b0cb20eed6c6bff30d1b8b27f4065b..2bd3d59ad4c5dd8c3d7e2187d86b41a8e9c248a4 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeGyroscope.js @@ -50,6 +50,8 @@ describe("SensorJsTest_sensor_29", function () { console.info('afterEach caled') }) + let GyroscopeId = 2 + /* * @tc.number:SUB_SensorsSystem_SubscribeGyroscope_JSTest_0010 * @tc.name: subscribeGyroscope_SensorJsTest001 @@ -58,7 +60,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest001---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'game', success: function (data) { @@ -91,7 +93,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest002---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'ui', success: function (data) { @@ -124,7 +126,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest003---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'normal', success: function (data) { @@ -157,7 +159,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest004---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'normal', success: function (data) { @@ -204,7 +206,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest005---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'xxx', success: function (data) { @@ -234,7 +236,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest006---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'normal', success: function (data) { @@ -260,7 +262,7 @@ describe("SensorJsTest_sensor_29", function () { it("subscribeGyroscope_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeGyroscope_SensorJsTest007---------------'); try{ - sensor.getSingleSensor(sensor.subscribeGyroscope ,(error, data) => { + sensor.getSingleSensor(GyroscopeId ,(error, data) => { sensor.subscribeGyroscope({ interval: 'normal', success: function (data) { diff --git a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.js b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.js index a27ee64d6980ab85b9ce7b352eaed17dad5e3256..22a0b22f211bc44858d323659e3cd77e7264e9cf 100644 --- a/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.js +++ b/sensors/sensor_standard/src/main/js/test/Subscribe_subscribeLight.js @@ -50,6 +50,7 @@ describe("SensorJsTest_sensor_31", function () { console.info('afterEach caled') }) + let LightId = 5 /* * @tc.number:SUB_SensorsSystem_SubscribeLight_JSTest_0010 * @tc.name: subscribeLight_SensorJsTest001 @@ -58,7 +59,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { console.info('----------------------subscribeLight_SensorJsTest001---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'game', success: function (data) { @@ -89,7 +90,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest002---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'ui', success: function (data) { @@ -120,7 +121,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest003---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ success: function (data) { console.info("subscribeLight_SensorJsTest003 success" + JSON.stringify(data)); @@ -150,7 +151,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest004---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'normal', success: function (data) { @@ -193,7 +194,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest005---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'xxx', success: function (data) { @@ -222,7 +223,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest006---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'normal', success: function (data) { @@ -246,7 +247,7 @@ describe("SensorJsTest_sensor_31", function () { it("subscribeLight_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { console.info('----------------------subscribeLight_SensorJsTest007---------------------------'); try{ - sensor.getSingleSensor(sensor.subscribeLight ,(error, data) => { + sensor.getSingleSensor(LightId ,(error, data) => { sensor.subscribeLight({ interval: 'normal', success: function (data) {