diff --git a/sensors/miscdevice_standard/src/main/js/default/test/vibrate.js b/sensors/miscdevice_standard/src/main/js/default/test/Subscribe_vibrate.js similarity index 90% rename from sensors/miscdevice_standard/src/main/js/default/test/vibrate.js rename to sensors/miscdevice_standard/src/main/js/default/test/Subscribe_vibrate.js index e0e8a80f7b5ec1cf765a89d76279da09813ccc9c..d0a76fa2b874e8477fcc4d1cca347d2d3e156198 100644 --- a/sensors/miscdevice_standard/src/main/js/default/test/vibrate.js +++ b/sensors/miscdevice_standard/src/main/js/default/test/Subscribe_vibrate.js @@ -48,7 +48,10 @@ describe("VibratorJsTest", function () { console.info('afterEach caled') }) - var errMessages = ['Param number is invalid', 'Wrong argument type. function expected', 'Wrong argument type', 'Wrong argument number'] + let errMessages = ['Param number is invalid', 'Wrong argument type. function expected', + 'Wrong argument type', 'Wrong argument number'] + + let errMessage; /* * @tc.name:VibratorJsTest0001 @@ -62,7 +65,6 @@ describe("VibratorJsTest", function () { mode: 'long', success: function () { console.info("VibratorJsTest0001 success"); - expect(true).assertTrue(); done(); }, fail: function (data, code) { @@ -87,7 +89,6 @@ describe("VibratorJsTest", function () { mode: 'short', success: function () { console.info("VibratorJsTest0002 success"); - expect(true).assertTrue(); done(); }, fail: function (data, code) { @@ -112,7 +113,6 @@ describe("VibratorJsTest", function () { mode: 'short', success: function () { console.info("VibratorJsTest0003 success"); - expect(true).assertTrue(); done(); }, fail: function (data, code) { @@ -134,7 +134,6 @@ describe("VibratorJsTest", function () { mode: 'short', success: function () { console.info("VibratorJsTest0004 success"); - expect(true).assertTrue(); done(); }, }); @@ -151,7 +150,6 @@ describe("VibratorJsTest", function () { vibrator.vibrate({ success: function () { console.info("VibratorJsTest0005 success"); - expect(true).assertTrue(); done(); }, fail: function (data, code) { @@ -174,7 +172,6 @@ describe("VibratorJsTest", function () { inInvalid: 2, success: function () { console.info("VibratorJsTest0006 success"); - expect(true).assertTrue(); done(); }, fail: function (data, code) { @@ -202,7 +199,7 @@ describe("VibratorJsTest", function () { }, }, 25); } catch (error) { - var errMessage = error.toString().slice(39); + errMessage = error.toString().slice(39); console.info('VibratorJsTest0007 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -221,26 +218,22 @@ describe("VibratorJsTest", function () { mode: 'short', success: function () { console.info("VibratorJsTest0008 success"); - expect(true).assertTrue(); }, fail: function (data, code) { console.error('VibratorJsTest0008 failed. Code: ' + code + '; Data: ' + data); expect(false).assertTrue(); }, }); - vibrator.vibrate({ mode: 'short', success: function () { console.info("VibratorJsTest0008_1 success"); - expect(true).assertTrue(); }, fail: function (data, code) { console.error('VibratorJsTest0008_1 failed. Code: ' + code + '; Data: ' + data); expect(false).assertTrue(); }, }); - setTimeout(() => { done(); }, 500); @@ -258,7 +251,7 @@ describe("VibratorJsTest", function () { vibrator.vibrate('xxx', done); } catch (error) { console.info('VibratorJsTest0009 error:' + error); - var errMessage = error.toString().slice(68); + errMessage = error.toString().slice(68); expect(errMessage).assertEqual(errMessages[1]); done(); } @@ -275,7 +268,7 @@ describe("VibratorJsTest", function () { try { vibrator.vibrate(done); } catch (error) { - var errMessage = error.toString().slice(7); + errMessage = error.toString().slice(7); console.info('VibratorJsTest0010 error:' + error); expect(errMessage).assertEqual(errMessages[2]); done(); @@ -301,7 +294,7 @@ describe("VibratorJsTest", function () { }, function () { }, 25); } catch (error) { - var errMessage = error.toString().slice(39); + errMessage = error.toString().slice(39); console.info('VibratorJsTest0011 error:' + error); expect(errMessage).assertEqual(errMessages[3]); done(); diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js b/sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js index b3c9b5efeab32ab4d6a20037fbaf4a8def9df184..6f04ab801a4427ad4be6305b7fac57559cc11b58 100755 --- a/sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js @@ -13,7 +13,6 @@ * limitations under the License. */ import sensor from '@ohos.sensor' - import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' describe("SensorJsTest", function () { @@ -51,27 +50,27 @@ describe("SensorJsTest", function () { let GEOMAGNETIC_COMPONENT_YEAR_RESULT = [ [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, - 55000.0703125], + 55000.0703125], [6554.17041015625, -87.19947052001953, 54649.078125, -0.7622424364089966, 83.16046905517578, 6554.75048828125, - 55040.7734375], + 55040.7734375], [6537.99169921875, -28.231582641601562, 54692.02734375, -0.24740631878376007, 83.18303680419922, - 6538.052734375, 55081.4296875], + 6538.052734375, 55081.4296875], [6521.81201171875, 30.73670768737793, 54734.97265625, 0.2700277864933014, 83.20502471923828, 6521.88427734375, - 55122.15625], + 55122.15625], [6505.6328125, 89.70511627197266, 54777.90625, 0.7899921536445618, 83.22642517089844, 6506.2509765625, - 55162.9453125]] + 55162.9453125]] let GEOMAGNETIC_COMPONENT_COORDINATES_RESULT = [ [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, - 55000.0703125], + 55000.0703125], [39624.28125, 109.8766098022461, -10932.4638671875, 0.15887857973575592, -15.424291610717773, 39624.43359375, - 41104.921875], + 41104.921875], [37636.72265625, 104.90892791748047, -10474.810546875, 0.15970633924007416, -15.552550315856934, 37636.8671875, - 39067.3203125], + 39067.3203125], [5940.583984375, 15772.0927734375, -52480.7578125, 69.36103820800781, -72.19599914550781, 16853.765625, - 55120.58984375], + 55120.58984375], [5744.87255859375, 14799.48046875, -49969.40234375, 68.78474426269531, -72.37483215332031, 15875.3955078125, - 52430.61328125]] + 52430.61328125]] let GEOMAGNETIC_COORDINATES = [[80, 0, 0], [0, 120, 0], @@ -102,9 +101,9 @@ describe("SensorJsTest", function () { }, 500) } else { console.info('SensorGeomagenticAlgorithmJSTest001 success x: ' + data.x + ',y: ' - + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' - + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) + + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][0]) expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][1]) expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][2]) @@ -145,10 +144,10 @@ describe("SensorJsTest", function () { }, 500) } else { console.info('SensorGeomagenticAlgorithmJSTest002 success x: ' + data.x + ',y: ' - + data.y + ',z: ' - + data.z + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][0]) expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][1]) expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][2]) @@ -173,8 +172,8 @@ describe("SensorJsTest", function () { */ it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030-------------------------"); - let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, -27.667943954467773, - -12.610970497131348, 28465.9765625, 32141.2109375] + let geomagneticComponent = [-1417119616, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488] sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, Number.MAX_VALUE, (error, data) => { if (error) { @@ -182,9 +181,9 @@ describe("SensorJsTest", function () { 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) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -207,7 +206,7 @@ describe("SensorJsTest", function () { it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0040', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0040-------------------------"); let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, -27.667943954467773, - -12.610970497131348, 28465.9765625, 32141.2109375] + -12.610970497131348, 28465.9765625, 32141.2109375] sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, Number.MIN_VALUE, (error, data) => { if (error) { @@ -215,10 +214,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest004 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -241,7 +240,7 @@ describe("SensorJsTest", function () { it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0050', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0050-------------------------"); let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, - 3.6568238735198975, 1827.8634033203125, 56757.21484375] + 3.6568238735198975, 1827.8634033203125, 56757.21484375] sensor.getGeomagneticField({ 'latitude': Number.MAX_VALUE, 'longitude': 0, 'altitude': 0 }, timeMillis[0], (error, data) => { if (error) { @@ -249,9 +248,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest005 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -274,7 +273,7 @@ describe("SensorJsTest", function () { it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0060', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0060-------------------------"); let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, - 3.6568238735198975, 1827.8634033203125, 56757.21484375] + 3.6568238735198975, 1827.8634033203125, 56757.21484375] sensor.getGeomagneticField({ 'latitude': Number.NaN, 'longitude': 0, 'altitude': 0 }, timeMillis[0], (error, data) => { if (error) { @@ -282,9 +281,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest006 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -307,7 +306,7 @@ describe("SensorJsTest", function () { it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0070', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0070-------------------------"); let geomagneticComponent = [14425.57421875, -17156.767578125, -52023.21484375, -66.69005584716797, - -49.94255447387695, 22415.4375, 56646.859375] + -49.94255447387695, 22415.4375, 56646.859375] sensor.getGeomagneticField({ 'latitude': Number.NEGATIVE_INFINITY, 'longitude': 0, 'altitude': 0 }, timeMillis[0], (error, data) => { if (error) { @@ -315,10 +314,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest007 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -347,10 +346,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest008 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue(); } setTimeout(() => { @@ -373,10 +372,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest009 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() } setTimeout(() => { @@ -399,10 +398,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest010 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() } setTimeout(() => { @@ -425,10 +424,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest011 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() } setTimeout(() => { @@ -445,7 +444,7 @@ describe("SensorJsTest", function () { it('SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0120', 0, async function (done) { console.info("------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0120-------------------------"); let geomagneticComponent = [27536.40234375, -2248.586669921875, -16022.4306640625, -30.110872268676758, - -4.66834020614624, 27628.05859375, 31937.875] + -4.66834020614624, 27628.05859375, 31937.875] sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.MIN_VALUE }, timeMillis[0], (error, data) => { if (error) { @@ -453,10 +452,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest012 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(data.x).assertEqual(geomagneticComponent[0]) expect(data.y).assertEqual(geomagneticComponent[1]) expect(data.z).assertEqual(geomagneticComponent[2]) @@ -485,10 +484,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest013 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() } setTimeout(() => { @@ -511,10 +510,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest014 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() } setTimeout(() => { @@ -537,10 +536,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest015 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -563,10 +562,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest016 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -589,9 +588,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest017 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -614,10 +613,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest018 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -640,10 +639,10 @@ describe("SensorJsTest", function () { expect(false).assertfalse(); } else { console.info('SensorGeomagenticAlgorithmJSTest019 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -666,9 +665,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest020 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue(); } setTimeout(() => { @@ -691,10 +690,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest021 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() } setTimeout(() => { @@ -717,10 +716,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest022 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() } setTimeout(() => { @@ -743,10 +742,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest023 success x: ' + data.x + ',y: ' + data.y - + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() } setTimeout(() => { @@ -769,9 +768,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest024 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() } setTimeout(() => { @@ -794,9 +793,9 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); } else { console.info('SensorGeomagenticAlgorithmJSTest025 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() } setTimeout(() => { @@ -815,20 +814,20 @@ describe("SensorJsTest", function () { for (let i = 0; i < timeMillis.length; i++) { await sensor.getGeomagneticField({ 'latitude': 80, 'longitude': 0, 'altitude': 0 }, timeMillis[i]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest026 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity); - expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) - expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) - expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) - expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) - expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) - expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) - expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) - }).catch((error) => { - console.info("promise::catch", error); - }) + console.info('SensorGeomagenticAlgorithmJSTest026 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity); + expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) + expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) + expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) + expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) + expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) + expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) + expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) + }).catch((error) => { + console.info("promise::catch", error); + }) } done() }) @@ -840,24 +839,24 @@ describe("SensorJsTest", function () { */ it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270------------------'); - let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, -27.667943954467773, - -12.610970497131348, 28465.9765625, 32141.2109375] + let geomagneticComponent = [-1417119616, 23146989568, -6406359552, -15.442885398864746, + 93.50342559814453, 23190329344, 24058943488] await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, Number.MAX_VALUE).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(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + 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(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -869,23 +868,23 @@ describe("SensorJsTest", function () { it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0280", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0280------------------'); let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, -27.667943954467773, - -12.610970497131348, 28465.9765625, 32141.2109375] + -12.610970497131348, 28465.9765625, 32141.2109375] await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': 0 }, Number.MIN_VALUE).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest028 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest028 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -897,23 +896,23 @@ describe("SensorJsTest", function () { it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0290", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0290------------------'); let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, - 3.6568238735198975, 1827.8634033203125, 56757.21484375] + 3.6568238735198975, 1827.8634033203125, 56757.21484375] await sensor.getGeomagneticField({ 'latitude': Number.MAX_VALUE, 'longitude': 0, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest029 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest029 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -925,23 +924,23 @@ describe("SensorJsTest", function () { it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0300", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0300------------------'); let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, - 3.6568238735198975, 1827.8634033203125, 56757.21484375] + 3.6568238735198975, 1827.8634033203125, 56757.21484375] await sensor.getGeomagneticField({ 'latitude': Number.NaN, 'longitude': 0, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest030 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest030 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -953,23 +952,23 @@ describe("SensorJsTest", function () { it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0310", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0310------------------'); let geomagneticComponent = [14425.57421875, -17156.767578125, -52023.21484375, -66.69005584716797, - -49.94255447387695, 22415.4375, 56646.859375] + -49.94255447387695, 22415.4375, 56646.859375] await sensor.getGeomagneticField({ 'latitude': Number.NEGATIVE_INFINITY, 'longitude': 0, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest031 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest031 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -983,14 +982,14 @@ describe("SensorJsTest", function () { let geomagneticComponent = [NaN, NaN, NaN] await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.MAX_VALUE, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest032 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest032 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1003,14 +1002,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0330------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NaN, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest033 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest033 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1023,14 +1022,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0340------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NEGATIVE_INFINITY, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest034 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest034 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1043,14 +1042,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0350------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.MAX_VALUE }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest035 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest035 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1062,23 +1061,23 @@ describe("SensorJsTest", function () { it("SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0360", 0, async function (done) { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0360------------------'); let geomagneticComponent = [27536.40234375, -2248.586669921875, -16022.4306640625, -30.110872268676758, - -4.66834020614624, 27628.05859375, 31937.875] + -4.66834020614624, 27628.05859375, 31937.875] await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.MIN_VALUE }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest036 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(geomagneticComponent[0]) - expect(data.y).assertEqual(geomagneticComponent[1]) - expect(data.z).assertEqual(geomagneticComponent[2]) - expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) - expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) - expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) - expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest036 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(geomagneticComponent[0]) + expect(data.y).assertEqual(geomagneticComponent[1]) + expect(data.z).assertEqual(geomagneticComponent[2]) + expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) + expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) + expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) + expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1091,14 +1090,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0370------------------start'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NaN }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest037 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest037 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1113,14 +1112,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0380------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NEGATIVE_INFINITY }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest038 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest038 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1134,20 +1133,20 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0390------------------'); await sensor.getGeomagneticField({ 'latitude': 80, 'longitude': 0, 'altitude': 0 }, timeMillis[i]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest039 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity); - expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) - expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) - expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) - expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) - expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) - expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) - expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest039 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity); + expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) + expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) + expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) + expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) + expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) + expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) + expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) + }).catch((error) => { + console.info("promise::catch", error) + }); } done() }) @@ -1161,14 +1160,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0400------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NaN, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest040 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest040 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1181,14 +1180,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0410------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NEGATIVE_INFINITY, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest041 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest041 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1201,14 +1200,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0420 max ------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.MAX_VALUE }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest042 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest042 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1221,14 +1220,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0430------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NaN }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest043 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest043 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1241,14 +1240,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0440------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NEGATIVE_INFINITY }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest044 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error) - }); + console.info('SensorGeomagenticAlgorithmJSTest044 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error) + }); done() }) @@ -1265,20 +1264,20 @@ describe("SensorJsTest", function () { 'longitude': GEOMAGNETIC_COORDINATES[i][1], 'altitude': GEOMAGNETIC_COORDINATES[i][2] }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest045 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][0]) - expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][1]) - expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][2]) - expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][3]) - expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][4]) - expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][5]) - expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][6]) - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest045 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][0]) + expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][1]) + expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][2]) + expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][3]) + expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][4]) + expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][5]) + expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][6]) + }).catch((error) => { + console.info("promise::catch", error); + }); } done() }) @@ -1292,14 +1291,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0460------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.MAX_VALUE, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest046 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue(); - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest046 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue(); + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -1312,14 +1311,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0470------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NaN, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest047 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest047 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -1332,14 +1331,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0480------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': Number.NEGATIVE_INFINITY, 'altitude': 0 }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest048 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest048 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -1352,14 +1351,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0490------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.MAX_VALUE }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest049 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest049 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -1372,14 +1371,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0500------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NaN }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest050 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest050 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) @@ -1392,14 +1391,14 @@ describe("SensorJsTest", function () { console.info('------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0510------------------'); await sensor.getGeomagneticField({ 'latitude': 0, 'longitude': 0, 'altitude': Number.NEGATIVE_INFINITY }, timeMillis[0]).then((data) => { - console.info('SensorGeomagenticAlgorithmJSTest051 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z - + ',geomagneticDip: ' + data.geomagneticDip - + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity - + ',totalIntensity: ' + data.totalIntensity) - expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() - }).catch((error) => { - console.info("promise::catch", error); - }); + console.info('SensorGeomagenticAlgorithmJSTest051 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + + ',geomagneticDip: ' + data.geomagneticDip + + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + + ',totalIntensity: ' + data.totalIntensity) + expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() + }).catch((error) => { + console.info("promise::catch", error); + }); done() }) }) diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Accelerometer.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Accelerometer.js deleted file mode 100755 index 0eb242c67e5a399766b4f2c123fa35a3b2b6e37e..0000000000000000000000000000000000000000 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Accelerometer.js +++ /dev/null @@ -1,610 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe("SensorJsTest", function () { - beforeAll(function () { - - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function () { - - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function () { - - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function () { - - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0010 - * @tc.name: SensorAccelerometerJSTest001 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0010", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0010---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest001 off error'); - expect(false).assertTrue(); - console.info('setTimeout ..start') - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest001 off success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest001 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest001 on success, x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorAccelerometerJSTest001 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0020 - * @tc.name: SensorAccelerometerJSTest002 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0020", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0020---------------------------'); - function onSensorCallback(error, data) { - if (error) { - console.info('SensorAccelerometerJSTest002 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest002 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(-1, onSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0030 - * @tc.name: SensorAccelerometerJSTest003 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0030", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0030---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(1, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest003 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest003 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest003 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest003 on success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }, { 'interval': 200000000 }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorAccelerometerJSTest003 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0040 - * @tc.name: SensorAccelerometerJSTest004 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0040", 0, function () { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0040---------------------------'); - sensor.on(1, function () { }, { 'interval': 100000000 }, 5); - expect(true).assertTrue(); - console.info('----------------------SensorAccelerometerJSTest004--------------------------- end'); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0050 - * @tc.name: SensorAccelerometerJSTest005 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0050", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAccelerometerJSTest005 once error'); - expect(false).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest005 once success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0060 - * @tc.name: SensorAccelerometerJSTest006 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0060", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAccelerometerJSTest006 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest006 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(-1, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0070 - * @tc.name: SensorAccelerometerJSTest007 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0070", 0, function () { - sensor.once(1, function () { }, 5); - expect(true).assertTrue(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0080 - * @tc.name: SensorAccelerometerJSTest008 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0080", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAccelerometerJSTest008 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest008 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(-1, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0090 - * @tc.name: SensorAccelerometerJSTest009 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0090", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAccelerometerJSTest009 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest009 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(1, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0100 - * @tc.name: SensorAccelerometerJSTest010 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0100", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAccelerometerJSTest010 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest010 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(1000000, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0110 - * @tc.name: SensorAccelerometerJSTest011 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0110", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAccelerometerJSTest011 once success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest011 once error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(1000000, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0120 - * @tc.name: SensorAccelerometerJSTest012 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0120", 0, async function (done) { - function onCallback(error) { - if (error) { - console.info('SensorAccelerometerJSTest012 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAccelerometerJSTest012 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(1000000, onCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0130 - * @tc.name: SensorAccelerometerJSTest013 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0130", 0, function () { - sensor.off(1, 5); - expect(true).assertTrue(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0140 - * @tc.name: SensorAccelerometerJSTest014 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0140", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0140---------------------------'); - function offPromise2() { - return new Promise((resolve, reject) => { - sensor.off(1, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest014 off2 success'); - expect(true).assertTrue(); - setTimeout(() => { - done(err); - reject(err) - }, 500); - } else { - console.info('SensorAccelerometerJSTest014 off2 error'); - expect(false).assertTrue(); - setTimeout(() => { - done(); - resolve() - }, 500); - } - }); - }) - } - - function offPromise1() { - return new Promise((resolve, reject) => { - sensor.off(1, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest014 off1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest014 off1 success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest014 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest014 on success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise1(); - }).then(() => { - return offPromise2(); - }); - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0150 - * @tc.name: SensorAccelerometerJSTest015 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0150", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0150---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(1, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest015 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest015 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function onPromise2() { - return new Promise((resolve, reject) => { - sensor.on(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest015 on2 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest015 on2 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest015 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest015 on1 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return onPromise2(); - }).then(() => { - return offPromise(); - }); - done(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0160 - * @tc.name: SensorAccelerometerJSTest016 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Accelerometer_JSTest_0160", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Accelerometer_JSTest_0160---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(1, (error) => { - if (error) { - console.info('SensorAccelerometerJSTest016 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest016 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function oncePromise() { - return new Promise((resolve, reject) => { - sensor.once(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest016 once error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest016 once success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(1, function (error, data) { - if (error) { - console.info('SensorAccelerometerJSTest016 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAccelerometerJSTest016 on1 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return oncePromise(); - }).then(() => { - return offPromise(); - }); - done(); - }) -}) diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Ambient_Light.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Ambient_Light.js deleted file mode 100755 index c206be81187a85d6aa62674e0048ef49050b2144..0000000000000000000000000000000000000000 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Ambient_Light.js +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe("SensorJsTest", function () { - beforeAll(function () { - - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function () { - - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function () { - - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function () { - - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0010 - * @tc.name: SensorAmbientLightJSTest001 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0010", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0010---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest001 off error'); - expect(false).assertTrue(); - console.info('setTimeout ..start') - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest001 off success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest001 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest001 on success, success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorAmbientLightJSTest001 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0020 - * @tc.name: SensorAmbientLightJSTest002 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0020", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0020---------------------------'); - function onSensorCallback(error, data) { - if (error) { - console.info('SensorAmbientLightJSTest002 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest002 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(-1, onSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0030 - * @tc.name: SensorAmbientLightJSTest003 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0030", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0030---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(5, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest003 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest003 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest003 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest003 on success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }, { 'interval': 200000000 }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorAmbientLightJSTest003 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0040 - * @tc.name: SensorAmbientLightJSTest004 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0040", 0, function () { - console.info('----------------------SensorAmbientLightJSTest004---------------------------'); - sensor.on(5, function () { }, { 'interval': 100000000 }, 5); - expect(true).assertTrue(); - console.info('----------------------SensorAmbientLightJSTest004--------------------------- end'); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0050 - * @tc.name: SensorAmbientLightJSTest005 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0050", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAmbientLightJSTest005 once error'); - expect(false).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest005 once success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0060 - * @tc.name: SensorAmbientLightJSTest006 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0060", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAmbientLightJSTest006 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest006 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(-1, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0070 - * @tc.name: SensorAmbientLightJSTest007 - * @tc.desc:verify app info is not null - */ - it("SensorJsTest007", 0, function () { - sensor.once(5, function () { }, 5); - expect(true).assertTrue(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0080 - * @tc.name: SensorAmbientLightJSTest008 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0080", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAmbientLightJSTest008 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest008 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(-1, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0090 - * @tc.name: SensorAmbientLightJSTest009 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0090", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAmbientLightJSTest009 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest009 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(5, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0100 - * @tc.name: SensorAmbientLightJSTest010 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0100", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorAmbientLightJSTest010 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest010 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(2000000, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0110 - * @tc.name: SensorAmbientLightJSTest011 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0110", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorAmbientLightJSTest011 once success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest011 once error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(2000000, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0120 - * @tc.name: SensorAmbientLightJSTest012 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0120", 0, async function (done) { - function onCallback(error) { - if (error) { - console.info('SensorAmbientLightJSTest012 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorAmbientLightJSTest012 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(2000000, onCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0130 - * @tc.name: SensorAmbientLightJSTest013 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0130", 0, function () { - sensor.off(5, 5); - expect(true).assertTrue(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0140 - * @tc.name: SensorAmbientLightJSTest014 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0140", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0140---------------------------'); - function offPromise2() { - return new Promise((resolve, reject) => { - sensor.off(5, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest014 off2 success'); - expect(true).assertTrue(); - setTimeout((err) => { - done(); - reject(err) - }, 500); - } else { - console.info('SensorAmbientLightJSTest014 off2 error'); - expect(false).assertTrue(); - setTimeout(() => { - done(); - resolve() - }, 500); - } - }); - }) - } - - function offPromise1() { - return new Promise((resolve, reject) => { - sensor.off(5, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest014 off1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest014 off1 success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest014 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest014 on success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise1(); - }).then(() => { - return offPromise2(); - }); - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0150 - * @tc.name: SensorAmbientLightJSTest015 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0150", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0150---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(5, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest015 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest015 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function onPromise2() { - return new Promise((resolve, reject) => { - sensor.on(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest015 on2 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest015 on2 success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest015 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest015 on1 success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return onPromise2(); - }).then(() => { - return offPromise(); - }); - done(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0160 - * @tc.name: SensorAmbientLightJSTest016 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Ambient_Light_JSTest_0160", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0160---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(5, (error) => { - if (error) { - console.info('SensorAmbientLightJSTest016 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest016 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function oncePromise() { - return new Promise((resolve, reject) => { - sensor.once(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest016 once error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest016 once success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(5, function (error, data) { - if (error) { - console.info('SensorAmbientLightJSTest016 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorAmbientLightJSTest016 on1 success data: ' + data.intensity); - expect(typeof (data.intensity)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return oncePromise(); - }).then(() => { - return offPromise(); - }); - done(); - }) -}) diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Gyroscope.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Gyroscope.js deleted file mode 100755 index 7f235cbea3fd5c596caa1c6d6e1968584f4eae6d..0000000000000000000000000000000000000000 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Gyroscope.js +++ /dev/null @@ -1,609 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe("SensorJsTest", function () { - beforeAll(function () { - - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function () { - - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function () { - - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function () { - - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0010 - * @tc.name: SensorGyroscopeJSTest001 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0010", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0010---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest001 off error'); - expect(false).assertTrue(); - console.info('setTimeout ..start') - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest001 off success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest001 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest001 on success, x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorGyroscopeJSTest001 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0020 - * @tc.name: SensorGyroscopeJSTest002 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0020", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0020---------------------------'); - function onSensorCallback(error, data) { - if (error) { - console.info('SensorGyroscopeJSTest002 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest002 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(-1, onSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0030 - * @tc.name: SensorGyroscopeJSTest003 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0030", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0030---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(2, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest003 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest003 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest003 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest003 on success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }, { 'interval': 200000000 }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorGyroscopeJSTest003 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0040 - * @tc.name: SensorGyroscopeJSTest004 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0040", 0, function () { - console.info('----------------------SensorGyroscopeJSTest004---------------------------'); - sensor.on(2, function () { }, { 'interval': 100000000 }, 5); - expect(true).assertTrue(); - console.info('----------------------SensorGyroscopeJSTest004--------------------------- end'); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0050 - * @tc.name: SensorGyroscopeJSTest005 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0050", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorGyroscopeJSTest005 once error'); - expect(false).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest005 once success x: ' + data.x + "y: " + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0060 - * @tc.name: SensorGyroscopeJSTest006 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0060", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorGyroscopeJSTest006 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest006 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(-1, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0070 - * @tc.name: SensorGyroscopeJSTest007 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0070", 0, function () { - sensor.once(2, function () { }, 5); - expect(true).assertTrue(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0080 - * @tc.name: SensorGyroscopeJSTest008 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0080", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorGyroscopeJSTest008 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest008 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(-1, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0090 - * @tc.name: SensorGyroscopeJSTest009 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0090", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorGyroscopeJSTest009 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest009 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(2, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0100 - * @tc.name: SensorGyroscopeJSTest010 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0100", 0, async function (done) { - function offCallback(error) { - if (error) { - console.info('SensorGyroscopeJSTest010 off success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest010 off error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.off(1000000, offCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0110 - * @tc.name: SensorGyroscopeJSTest011 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0110", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorGyroscopeJSTest011 once success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest011 once error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(1000000, onceSensorCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0120 - * @tc.name: SensorGyroscopeJSTest012 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0120", 0, async function (done) { - function onCallback(error) { - if (error) { - console.info('SensorGyroscopeJSTest012 on success'); - expect(true).assertTrue(); - } else { - console.info('SensorGyroscopeJSTest012 on error'); - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.on(1000000, onCallback); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0130 - * @tc.name: SensorGyroscopeJSTest013 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0130", 0, function () { - sensor.off(2, 5); - expect(true).assertTrue(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0140 - * @tc.name: SensorGyroscopeJSTest014 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0140", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0140---------------------------'); - function offPromise2() { - return new Promise((resolve, reject) => { - sensor.off(2, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest014 off2 success'); - expect(true).assertTrue(); - setTimeout((err) => { - done(); - reject(err) - }, 500); - } else { - console.info('SensorGyroscopeJSTest014 off2 error'); - expect(false).assertTrue(); - setTimeout(() => { - done(); - resolve() - }, 500); - } - }); - }) - } - - function offPromise1() { - return new Promise((resolve, reject) => { - sensor.off(2, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest014 off1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest014 off1 success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest014 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest014 on success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise1(); - }).then(() => { - return offPromise2(); - }); - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0150 - * @tc.name: SensorGyroscopeJSTest015 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0150", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0150---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(2, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest015 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest015 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function onPromise2() { - return new Promise((resolve, reject) => { - sensor.on(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest015 on2 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest015 on2 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest015 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest015 on1 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return onPromise2(); - }).then(() => { - return offPromise(); - }); - done(); - }) - - - /* - * @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0160 - * @tc.name: SensorGyroscopeJSTest016 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Gyroscope_JSTest_0160", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Gyroscope_JSTest_0160---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(2, (error) => { - if (error) { - console.info('SensorGyroscopeJSTest016 off error'); - expect(false).assertTrue(); - setTimeout((err) => { - done(); - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest016 off success'); - expect(true).assertTrue(); - setTimeout(() => { - done(); - resolve(); - }, 500); - } - }); - }) - } - function oncePromise() { - return new Promise((resolve, reject) => { - sensor.once(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest016 once error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest016 once success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - } - - let onPromise1 = new Promise((resolve, reject) => { - sensor.on(2, function (error, data) { - if (error) { - console.info('SensorGyroscopeJSTest016 on1 error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorGyroscopeJSTest016 on1 success x: ' + data.x + "y: " - + data.y + "z: " + data.z); - expect(typeof (data.x)).assertEqual("number"); - expect(typeof (data.y)).assertEqual("number"); - expect(typeof (data.z)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await onPromise1.then(() => { - return oncePromise(); - }).then(() => { - return offPromise(); - }); - done(); - }) -}) diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Hall.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Hall.js deleted file mode 100755 index 313653f76006a059c738097491fcb693468d417f..0000000000000000000000000000000000000000 --- a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Hall.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import sensor from '@ohos.sensor' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe("SensorJsTest", function () { - beforeAll(function () { - - /* - * @tc.setup: setup invoked before all testcases - */ - console.info('beforeAll caled') - }) - - afterAll(function () { - - /* - * @tc.teardown: teardown invoked after all testcases - */ - console.info('afterAll caled') - }) - - beforeEach(function () { - - /* - * @tc.setup: setup invoked before each testcases - */ - console.info('beforeEach caled') - }) - - afterEach(function () { - - /* - * @tc.teardown: teardown invoked after each testcases - */ - console.info('afterEach caled') - }) - - /* - * @tc.number: SUB_SensorsSystem_Hall_JSTest_0010 - * @tc.name: SensorHallJSTest001 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Hall_JSTest_0010", 0, async function (done) { - console.info('----------------------SUB_SensorsSystem_Hall_JSTest_0010---------------------------'); - function offPromise() { - return new Promise((resolve, reject) => { - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, (error) => { - if (error) { - console.info('SensorHallJSTest001 off error'); - expect(false).assertTrue(); - console.info('setTimeout ..start') - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorHallJSTest001 off success'); - expect(true).assertTrue(); - setTimeout(() => { - resolve(); - }, 500); - } - }, 1000) - }) - } - - let promise = new Promise((resolve, reject) => { - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (error, data) { - if (error) { - console.info('SensorHallJSTest001 on error'); - expect(false).assertTrue(); - setTimeout((err) => { - reject(err); - }, 500); - } else { - console.info('SensorHallJSTest001 on success status: ' + data.status); - expect(typeof (data.status)).assertEqual("number"); - setTimeout(() => { - resolve(); - }, 500); - } - }); - }) - - await promise.then(() => { - return offPromise(); - }, () => { - console.info("SensorHallJSTest001 reject"); - }) - done(); - }) - - /* - * @tc.number: SUB_SensorsSystem_Hall_JSTest_0050 - * @tc.name: SensorHallJSTest005 - * @tc.desc:verify app info is not null - */ - it("SUB_SensorsSystem_Hall_JSTest_0050", 0, async function (done) { - function onceSensorCallback(error, data) { - if (error) { - console.info('SensorHallJSTest005 once error'); - expect(false).assertTrue(); - } else { - console.info('SensorHallJSTest005 once success status: ' + data.status); - expect(typeof (data.status)).assertEqual("number"); - } - setTimeout(() => { - done(); - }, 500); - } - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, onceSensorCallback); - }) -}) diff --git a/sensors/sensor_standard/src/main/js/default/test/Accelerometer.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Accelerometer.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/Accelerometer.js rename to sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Accelerometer.js index 1f740228abf6ec5727cb719c35e064bfe0b62c58..796c6a69f97a6321eb4f471340dcfd7e1aab7c53 100644 --- a/sensors/sensor_standard/src/main/js/default/test/Accelerometer.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Accelerometer.js @@ -31,7 +31,7 @@ describe("SensorJsTest", function () { } beforeAll(function () { - + /* * @tc.setup: setup invoked before all testcases */ @@ -64,6 +64,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'Should subscribe first', 'string is not defined']; + let errMessage; /* @@ -106,13 +107,11 @@ describe("SensorJsTest", function () { */ it("Accelerometer_SensorJsTest003", 0, async function (done) { console.info('----------------------Accelerometer_SensorJsTest003---------------------------'); - function onSensorCallback(data) { console.info('Accelerometer_SensorJsTest003 on error'); expect(false).assertTrue(); done(); } - try { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, { 'interval': 100000000 }, 5); } catch (error) { @@ -146,13 +145,11 @@ describe("SensorJsTest", function () { */ it("Accelerometer_SensorJsTest005", 0, async function (done) { console.info('----------------------Accelerometer_SensorJsTest005---------------------------'); - function onceSensorCallback(data) { console.info('Accelerometer_SensorJsTest005 on error'); expect(false).assertTrue(); done(); } - try { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5); } catch (error) { @@ -189,13 +186,11 @@ describe("SensorJsTest", function () { */ it("Accelerometer_SensorJsTest007", 0, async function (done) { console.info('----------------------Accelerometer_SensorJsTest007---------------------------'); - function onSensorCallback(data) { console.info('Accelerometer_SensorJsTest007 on error'); expect(false).assertTrue(); done(); } - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); setTimeout(() => { @@ -212,13 +207,11 @@ describe("SensorJsTest", function () { */ it("Accelerometer_SensorJsTest008", 0, async function (done) { console.info('----------------------Accelerometer_SensorJsTest008---------------------------'); - function onSensorCallback(data) { console.info('Accelerometer_SensorJsTest008 on error'); expect(false).assertTrue(); done(); } - try { sensor.off(1000000, onSensorCallback); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Ambient_light.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Ambient_light.js new file mode 100644 index 0000000000000000000000000000000000000000..09e64b260adc5bc5766d6c0e18f25f1d705662ba --- /dev/null +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Ambient_light.js @@ -0,0 +1,324 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import sensor from '@ohos.sensor' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +describe("SensorJsTest", function () { + function callback(data) { + console.info("callback" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + } + + function callback2(data) { + console.info("callback2" + JSON.stringify(data)); + expect(typeof (data.intensity)).assertEqual("number"); + } + + beforeAll(function () { + + /* + * @tc.setup: setup invoked before all testcases + */ + console.info('beforeAll caled') + }) + + afterAll(function () { + + /* + * @tc.teardown: teardown invoked after all testcases + */ + console.info('afterAll caled') + }) + + beforeEach(function () { + + /* + * @tc.setup: setup invoked before each testcases + */ + console.info('beforeEach caled') + }) + + afterEach(function () { + + /* + * @tc.teardown: teardown invoked after each testcases + */ + console.info('afterEach caled') + }) + + let errMessages = ['The number of parameters is not valid', 'Should subscribe first', + 'string is not defined']; + + let errMessage; + + /* + * @tc.name:Ambient_Light_SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest001", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest001---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + setTimeout(() => { + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + done(); + }, 1500); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest002 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest002", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest002---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest002 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------Ambient_Light_SensorJsTest002 off end---------------------------'); + done(); + }, 1500); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest003", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest003---------------------------'); + function onSensorCallback(data) { + console.info('Ambient_Light_SensorJsTest003 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback, { 'interval': 100000000 }, 5); + } catch (error) { + console.info("Ambient_Light_SensorJsTest003 error:" + error); + errMessage = error.toString().slice(12, 49); + console.info('Ambient_Light_SensorJsTest003 errMessage:' + errMessage); + expect(errMessage).assertEqual(errMessages[0]); + done(); + } + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest004 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest004", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest004---------------------------'); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest005 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest005", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest005---------------------------'); + function onceSensorCallback(data) { + console.info('Ambient_Light_SensorJsTest005 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onceSensorCallback, 5); + } catch (error) { + console.info("Ambient_Light_SensorJsTest005 error:" + error); + errMessage = error.toString().slice(14, 51); + console.info('Ambient_Light_SensorJsTest005 errMessage:' + errMessage); + expect(errMessage).assertEqual(errMessages[0]); + done(); + } + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest006 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest006", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest006---------------------------'); + try { + sensor.off(string, ""); + } catch (error) { + console.info("Ambient_Light_SensorJsTest006 error:" + error); + errMessage = error.toString().slice(16, 40); + console.info('Ambient_Light_SensorJsTest006 errMessage:' + errMessage); + expect(errMessage).assertEqual(errMessages[2]); + done(); + } + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest007 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest007", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest007---------------------------'); + function onSensorCallback(data) { + console.info('Ambient_Light_SensorJsTest007 on error'); + expect(false).assertTrue(); + done(); + } + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback); + setTimeout(() => { + expect(true).assertTrue(); + done(); + }, 500); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest008 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest008", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest008---------------------------'); + function onSensorCallback(data) { + console.info('Ambient_Light_SensorJsTest008 on error'); + expect(false).assertTrue(); + done(); + } + try { + sensor.off(1000000, onSensorCallback); + } catch (error) { + console.info("Ambient_Light_SensorJsTest008 error:" + error); + errMessage = error.toString().slice(13, 35); + console.info('Ambient_Light_SensorJsTest008 errMessage:' + errMessage); + expect(errMessage).assertEqual(errMessages[1]); + done(); + } + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest009 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest009", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest009---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest009 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------Ambient_Light_SensorJsTest009 off end---------------------------'); + done(); + }, 2000); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest010 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest010", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest010---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + console.info('----------------------Ambient_Light_SensorJsTest010 off end---------------------------'); + }, 1000); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest010 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + console.info('----------------------Ambient_Light_SensorJsTest010 off end---------------------------'); + done(); + }, 2000); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest011 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest011", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest011---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest011 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------Ambient_Light_SensorJsTest011 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest012 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest012", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest012---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': 100000000 }); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); + console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------'); + }, 500); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest012 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2); + console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------'); + done(); + }, 1000); + }) + + /* + * @tc.name:Ambient_Light_SensorJsTest013 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("Ambient_Light_SensorJsTest013", 0, async function (done) { + console.info('----------------------Ambient_Light_SensorJsTest013---------------------------'); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 }); + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': 100000000 }); + setTimeout(() => { + console.info('----------------------Ambient_Light_SensorJsTest013 off in---------------------------'); + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT); + console.info('----------------------Ambient_Light_SensorJsTest013 off end---------------------------'); + done(); + }, 1000); + }) +}) \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/default/test/GyroScope.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_GyroScope.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/GyroScope.js rename to sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_GyroScope.js index 82bf5bf583018f1de551fd96c56be050673b3dae..549e1188057d0ad37d6c7d6b5e0468d4141d8060 100644 --- a/sensors/sensor_standard/src/main/js/default/test/GyroScope.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_GyroScope.js @@ -64,6 +64,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'Should subscribe first', 'string is not defined']; + let errMessage; /* @@ -106,13 +107,11 @@ describe("SensorJsTest", function () { */ it("GYROSCOPE_SensorJsTest003", 0, async function (done) { console.info('----------------------GYROSCOPE_SensorJsTest003---------------------------'); - function onSensorCallback(data) { console.info('GYROSCOPE_SensorJsTest003 on error'); expect(false).assertTrue(); done(); } - try { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onSensorCallback, { 'interval': 100000000 }, 5); } catch (error) { @@ -146,13 +145,11 @@ describe("SensorJsTest", function () { */ it("GYROSCOPE_SensorJsTest005", 0, async function (done) { console.info('----------------------GYROSCOPE_SensorJsTest005---------------------------'); - function onceSensorCallback(data) { console.info('GYROSCOPE_SensorJsTest005 on error'); expect(false).assertTrue(); done(); } - try { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onceSensorCallback, 5); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/Hall.js b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Hall.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/Hall.js rename to sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Hall.js index 37b52ef664f9b586953ddbaa2e1be76940fc91ff..ed63d574f1054fabee5efa958c74584e00111a47 100644 --- a/sensors/sensor_standard/src/main/js/default/test/Hall.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Hall.js @@ -60,6 +60,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'Should subscribe first', 'string is not defined']; + let errMessage; /* @@ -102,13 +103,11 @@ describe("SensorJsTest", function () { */ it("Hall_SensorJsTest003", 0, async function (done) { console.info('----------------------Hall_SensorJsTest003---------------------------'); - function onSensorCallback(data) { console.info('Hall_SensorJsTest003 on error'); expect(false).assertTrue(); done(); } - try { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, onSensorCallback, { 'interval': 100000000 }, 5); } catch (error) { @@ -204,7 +203,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); done(); } - try { sensor.off(1000000, onSensorCallback); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_getOnBodyState.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_getOnBodyState.js index 1c10c4e2b8bf06aeb9cda9df66be12398c271fa3..cdd71b5b19f83c1bbed44c9c7f0e8a60dc50bd9e 100644 --- a/sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_getOnBodyState.js @@ -50,6 +50,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'Wrong argument type, function expected', 'Wrong argument type, should be object'] + let errMessage; /* diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeAccelerometer.js similarity index 94% rename from sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeAccelerometer.js index 25c529be79a925b375ac66951ada3a3fbf4bc7b0..d2a8d6487b11a51e225e847cb78db6971a7917d3 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeAccelerometer.js @@ -16,7 +16,7 @@ import sensor from '@system.sensor' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' describe("SensorJsTest", function () { - beforeAll(function () { + beforeAll(function () { /* * @tc.setup: setup invoked before all testcases @@ -48,7 +48,10 @@ describe("SensorJsTest", function () { console.info('afterEach caled') }) - var errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', 'UnsubscribeSensor failed']; + let errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', + 'UnsubscribeSensor failed']; + + let errMessage; /* * @tc.name:subscribeAccelerometer_SensorJsTest001 @@ -71,7 +74,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeAccelerometer(); @@ -107,7 +109,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeAccelerometer(); @@ -181,7 +182,7 @@ describe("SensorJsTest", function () { }, }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeAccelerometer_SensorJsTest004 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -212,7 +213,7 @@ describe("SensorJsTest", function () { }, function () { }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeAccelerometer_SensorJsTest005 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -280,7 +281,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeAccelerometer(); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeAccelerometer_SensorJsTest007 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -298,7 +299,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeAccelerometer('xxx'); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeAccelerometer_SensorJsTest008 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -316,7 +317,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeAccelerometer('xxx'); } catch (error) { - var errMessage = error.toString().slice(21, 58); + errMessage = error.toString().slice(21, 58); console.info('subscribeAccelerometer_SensorJsTest009 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -358,7 +359,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeAccelerometer(); } catch (error) { - var errMessage = error.toString().slice(21, 45); + errMessage = error.toString().slice(21, 45); console.info('subscribeAccelerometer_SensorJsTest011 error:' + error); expect(errMessage).assertEqual(errMessages[2]); done(); @@ -430,12 +431,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - try { sensor.unsubscribeAccelerometer(); } catch (error) { console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error); - expect(true).assertTrue(); } setTimeout(() => { expect(true).assertTrue(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeBarometer.js similarity index 96% rename from sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeBarometer.js index 6359bed37418445602c6d073515605e96328aba6..693f7f2c8cd21d50f5cf5825a9fcf97d9a2aaeac 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeBarometer.js @@ -49,7 +49,8 @@ describe("SensorJsTest", function () { }) let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', - 'Wrong argument type, should be object']; + 'Wrong argument type, should be object']; + let errMessage; /* @@ -83,7 +84,6 @@ describe("SensorJsTest", function () { }, 1000); }) - /* * @tc.name:subscribeBarometer_SensorJsTest002 * @tc.desc:verify app info is not null @@ -221,7 +221,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - setTimeout(() => { try { sensor.unsubscribeBarometer(); @@ -246,7 +245,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeBarometer(); } catch (error) { - var errMessage = error.toString().slice(21, 45); + errMessage = error.toString().slice(21, 45); console.info('subscribeBarometer_SensorJsTest008 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -271,7 +270,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - try { sensor.unsubscribeBarometer(); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeCompass.js similarity index 96% rename from sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeCompass.js index 80467d7b9d82fea2c0b6498e593f7841d9a2710e..af5120dceacf361df5562d097038272bff7a472d 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeCompass.js @@ -50,6 +50,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', 'Wrong argument type, should be object']; + let errMessage; /* @@ -125,7 +126,6 @@ describe("SensorJsTest", function () { expect(typeof (data.direction)).assertEqual("number"); }, }); - setTimeout(() => { try { sensor.unsubscribeCompass(); @@ -250,7 +250,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeCompass(); @@ -301,12 +300,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - try { sensor.unsubscribeCompass(); } catch (error) { console.info('subscribeLight_SensorJsTest010_unsubscribeLight error' + error); - expect(true).assertTrue(); } setTimeout(() => { expect(true).assertTrue(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeDeviceOrientation.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeDeviceOrientation.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/subscribeDeviceOrientation.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeDeviceOrientation.js index f57b4903f15d9ee366ae113581214d1018cd1a1c..e5432f1b182e970b22798de0edd8e660e90f1482 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeDeviceOrientation.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeDeviceOrientation.js @@ -49,9 +49,10 @@ describe("SensorJsTest", function () { }) let errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', - 'UnsubscribeSensor failed']; + 'UnsubscribeSensor failed']; + let errMessage; - + /* * @tc.name:subscribeDeviceOrientation_SensorJsTest001 * @tc.desc:verify app info is not null @@ -437,7 +438,6 @@ describe("SensorJsTest", function () { sensor.unsubscribeDeviceOrientation(); } catch (error) { console.info('subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation error' + error); - expect(true).assertTrue(); } setTimeout(() => { expect(true).assertTrue(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeGyroscope.js similarity index 94% rename from sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeGyroscope.js index 5840a065cad2efd82db743fadf85195ab460cf87..99d39d6e768c3b5bea485fa908a00861e01dfa7d 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeGyroscope.js @@ -48,7 +48,10 @@ describe("SensorJsTest", function () { console.info('afterEach caled') }) - var errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', 'UnsubscribeSensor failed']; + let errMessages = ['The number of parameters is not valid', + 'Wrong argument type, should be object', 'UnsubscribeSensor failed']; + + let errMessage; /* * @tc.name:subscribeGyroscope_SensorJsTest001 @@ -71,7 +74,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeGyroscope(); @@ -107,7 +109,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeGyroscope(); @@ -229,7 +230,7 @@ describe("SensorJsTest", function () { }, }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeGyroscope_SensorJsTest006 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -260,7 +261,7 @@ describe("SensorJsTest", function () { }, function () { }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeGyroscope_SensorJsTest007 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -288,7 +289,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - sensor.subscribeGyroscope({ interval: 'normal', success: function (data) { @@ -302,7 +302,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeGyroscope(); @@ -328,7 +327,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeGyroscope(); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeGyroscope_SensorJsTest009 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -346,7 +345,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeGyroscope('xxx'); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeGyroscope_SensorJsTest010 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -364,7 +363,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeGyroscope(); } catch (error) { - var errMessage = error.toString().slice(21, 45); + errMessage = error.toString().slice(21, 45); console.info('subscribeGyroscope_SensorJsTest011 error:' + error); expect(errMessage).assertEqual(errMessages[2]); done(); @@ -382,7 +381,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeGyroscope('xxx'); } catch (error) { - var errMessage = error.toString().slice(21, 58); + errMessage = error.toString().slice(21, 58); console.info('subscribeGyroscope_SensorJsTest012 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -431,12 +430,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - try { sensor.unsubscribeGyroscope(); } catch (error) { console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error); - expect(false).assertTrue(); } setTimeout(() => { expect(true).assertTrue(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeHeartRate.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeHeartRate.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/subscribeHeartRate.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeHeartRate.js index ab319862b2691c13fe6ad79f02a227da6e432304..28916e29548cebcbb4daece43a1a635347cc08ff 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeHeartRate.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeHeartRate.js @@ -50,6 +50,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', 'Wrong argument type, should be object']; + let errMessage; /* @@ -220,7 +221,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - setTimeout(() => { try { sensor.unsubscribeHeartRate(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeLight.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeLight.js similarity index 86% rename from sensors/sensor_standard/src/main/js/default/test/subscribeLight.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeLight.js index 464c6f2fea0021679868cc1e772a03dc4bbe2e69..3bc97d0a84cd24d79a08b731942c81270eecea10 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeLight.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeLight.js @@ -48,7 +48,10 @@ describe("SensorJsTest", function () { console.info('afterEach caled') }) - var errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', 'Wrong argument type, should be object']; + let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', + 'Wrong argument type, should be object']; + + let errMessage; /* * @tc.name:subscribeLight_SensorJsTest001 @@ -57,7 +60,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeLight_SensorJsTest001", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest001---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest001---------------------------'); sensor.subscribeLight({ success: function (data) { console.info("subscribeLight_SensorJsTest001 success:" + JSON.stringify(data)); @@ -68,7 +71,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeLight(); @@ -90,7 +92,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeLight_SensorJsTest002", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest002---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest002---------------------------'); try { sensor.subscribeLight({ success: function (data) { @@ -103,28 +105,27 @@ describe("SensorJsTest", function () { }, }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeLight_SensorJsTest002 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); } }) - /* - * @tc.name:subscribeLight_SensorJsTest003 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ + /* + * @tc.name:subscribeLight_SensorJsTest003 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: SR000H0ALK, AR000H0ALM + */ it("subscribeLight_SensorJsTest003", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest003---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest003---------------------------'); sensor.subscribeLight({ success: function (data) { console.info("subscribeLight_SensorJsTest003 success:" + JSON.stringify(data)); expect(typeof (data.intensity)).assertEqual("number"); }, }); - setTimeout(() => { try { sensor.unsubscribeLight(); @@ -146,7 +147,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeLight_SensorJsTest004", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest004---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest004---------------------------'); try { sensor.subscribeLight({ success: function (data) { @@ -160,7 +161,7 @@ describe("SensorJsTest", function () { }, function () { }, 25); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeLight_SensorJsTest004 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -178,7 +179,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeLight('xxx'); } catch (error) { - var errMessage = error.toString().slice(21, 58); + errMessage = error.toString().slice(21, 58); console.info('subscribeLight_SensorJsTest005 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -196,7 +197,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeLight(); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeLight_SensorJsTest006 error:' + error); expect(errMessage).assertEqual(errMessages[0]); done(); @@ -214,7 +215,7 @@ describe("SensorJsTest", function () { try { sensor.subscribeLight('xxx'); } catch (error) { - var errMessage = error.toString().slice(19, 56); + errMessage = error.toString().slice(19, 56); console.info('subscribeLight_SensorJsTest007 error:' + error); expect(errMessage).assertEqual(errMessages[2]); done(); @@ -228,7 +229,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeLight_SensorJsTest008", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest008---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest008---------------------------'); sensor.subscribeLight({ success: function (data) { console.info("subscribeLight_SensorJsTest008 success:" + JSON.stringify(data)); @@ -249,7 +250,6 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - setTimeout(() => { try { sensor.unsubscribeLight(); @@ -275,7 +275,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeLight(); } catch (error) { - var errMessage = error.toString().slice(21,45); + errMessage = error.toString().slice(21, 45); console.info('subscribeLight_SensorJsTest009 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -289,7 +289,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeLight_SensorJsTest010", 0, function (done) { - console.info('----------------------subscribeLight_SensorJsTest010---------------------------'); + console.info('----------------------subscribeLight_SensorJsTest010---------------------------'); sensor.subscribeLight({ success: function (data) { console.info("subscribeLight_SensorJsTest010 success:" + JSON.stringify(data)); @@ -300,12 +300,10 @@ describe("SensorJsTest", function () { expect(false).assertTrue(); }, }); - try { sensor.unsubscribeLight(); } catch (error) { console.info('subscribeLight_SensorJsTest008_unsubscribeLight error' + error); - expect(true).assertTrue(); } setTimeout(() => { expect(true).assertTrue(); diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeOnBodyState.js similarity index 97% rename from sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeOnBodyState.js index e45cf86a2244047ea2baf3c757015134dee00cf9..2f1ddbea108a5104778bcbe43fb9fde901e3e2de 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeOnBodyState.js @@ -50,6 +50,7 @@ describe("SensorJsTest", function () { let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', 'Wrong argument type, should be object']; + let errMessage; /* @@ -210,7 +211,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - sensor.subscribeOnBodyState({ success: function (data) { console.info("subscribeOnBodyState_SensorJsTest007_1 success:" + JSON.stringify(data)); @@ -221,7 +221,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - setTimeout(() => { try { sensor.unsubscribeOnBodyState(); @@ -271,7 +270,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - try { sensor.unsubscribeOnBodyState(); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeProximity.js similarity index 87% rename from sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeProximity.js index 4a504993e6c66d1f347eb606867bb5267392184e..7f1435ff9d64835c5799342f43fd9534fda5b18b 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeProximity.js @@ -49,34 +49,35 @@ describe("SensorJsTest", function () { }) let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', - 'Wrong argument type, should be object']; + 'Wrong argument type, should be object']; + let errMessage; - /* - * @tc.name:subscribeProximity_SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ + /* + * @tc.name:subscribeProximity_SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: SR000H0ALK, AR000H0ALM + */ it("subscribeProximity_SensorJsTest001", 0, async function (done) { - console.info('----------------------subscribeProximity_SensorJsTest001---------------------------'); + console.info('----------------------subscribeProximity_SensorJsTest001---------------------------'); sensor.subscribeProximity({ - success: function(data) { + success: function (data) { console.info("subscribeProximity_SensorJsTest001 success" + JSON.stringify(data)); - expect(typeof(data.distance)).assertEqual("number"); + expect(typeof (data.distance)).assertEqual("number"); }, - fail: function(data, code) { + fail: function (data, code) { console.error('subscribeProximity_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data); expect(code).assertEqual(1001); }, - }); - setTimeout(()=>{ + }); + setTimeout(() => { try { sensor.unsubscribeProximity(); } catch (error) { console.info(error); } - setTimeout(()=>{ + setTimeout(() => { expect(true).assertTrue(); done(); }, 500); @@ -90,7 +91,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeProximity_SensorJsTest002", 0, function (done) { - console.info('----------------------subscribeProximity_SensorJsTest002---------------------------'); + console.info('----------------------subscribeProximity_SensorJsTest002---------------------------'); try { sensor.subscribeProximity({ success: function (data) { @@ -117,7 +118,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeProximity_SensorJsTest003", 0, function (done) { - console.info('----------------------subscribeProximity_SensorJsTest003---------------------------'); + console.info('----------------------subscribeProximity_SensorJsTest003---------------------------'); try { sensor.subscribeProximity({ success: function (data) { @@ -199,7 +200,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeProximity_SensorJsTest007", 0, function (done) { - console.info('----------------------subscribeProximity_SensorJsTest007---------------------------'); + console.info('----------------------subscribeProximity_SensorJsTest007---------------------------'); sensor.subscribeProximity({ success: function (data) { console.info("subscribeProximity_SensorJsTest007 success:" + JSON.stringify(data)); @@ -220,7 +221,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - setTimeout(() => { try { sensor.unsubscribeProximity(); @@ -245,7 +245,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeProximity(); } catch (error) { - errMessage = error.toString().slice(21,45); + errMessage = error.toString().slice(21, 45); console.info('subscribeProximity_SensorJsTest008 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -259,7 +259,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeProximity_SensorJsTest009", 0, function (done) { - console.info('----------------------subscribeProximity_SensorJsTest009---------------------------'); + console.info('----------------------subscribeProximity_SensorJsTest009---------------------------'); sensor.subscribeProximity({ success: function (data) { console.info("subscribeProximity_SensorJsTest009 success:" + JSON.stringify(data)); @@ -270,7 +270,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - try { sensor.unsubscribeProximity(); } catch (error) { diff --git a/sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeStepCounter.js similarity index 87% rename from sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js rename to sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeStepCounter.js index 181c6fd86f97cb9f0de0e13834d306bc8fcc5b51..45bba2cd51dbf0477cbdb722e653e029b7e466ad 100644 --- a/sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js +++ b/sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeStepCounter.js @@ -49,34 +49,35 @@ describe("SensorJsTest", function () { }) let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', - 'Wrong argument type, should be object']; + 'Wrong argument type, should be object']; + let errMessage; - /* - * @tc.name:subscribeStepCounter_SensorJsTest001 - * @tc.desc:verify app info is not null - * @tc.type: FUNC - * @tc.require: SR000H0ALK, AR000H0ALM - */ + /* + * @tc.name:subscribeStepCounter_SensorJsTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: SR000H0ALK, AR000H0ALM + */ it("subscribeStepCounter_SensorJsTest001", 0, async function (done) { - console.info('----------------------subscribeStepCounter_SensorJsTest001---------------------------'); + console.info('----------------------subscribeStepCounter_SensorJsTest001---------------------------'); sensor.subscribeStepCounter({ - success: function(data) { + success: function (data) { console.info("subscribeStepCounter_SensorJsTest001 success" + JSON.stringify(data)); - expect(typeof(data.steps)).assertEqual("number"); + expect(typeof (data.steps)).assertEqual("number"); }, - fail: function(data, code) { + fail: function (data, code) { console.error('subscribeStepCounter_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data); expect(code).assertEqual(1001); }, - }); - setTimeout(()=>{ + }); + setTimeout(() => { try { sensor.unsubscribeStepCounter(); } catch (error) { console.info('subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error ' + error); } - setTimeout(()=>{ + setTimeout(() => { expect(true).assertTrue(); done(); }, 500); @@ -90,7 +91,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeStepCounter_SensorJsTest002", 0, function (done) { - console.info('----------------------subscribeStepCounter_SensorJsTest002---------------------------'); + console.info('----------------------subscribeStepCounter_SensorJsTest002---------------------------'); try { sensor.subscribeStepCounter({ success: function (data) { @@ -117,7 +118,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeStepCounter_SensorJsTest003", 0, function (done) { - console.info('----------------------subscribeStepCounter_SensorJsTest003---------------------------'); + console.info('----------------------subscribeStepCounter_SensorJsTest003---------------------------'); try { sensor.subscribeStepCounter({ success: function (data) { @@ -128,7 +129,8 @@ describe("SensorJsTest", function () { console.error('subscribeStepCounter_SensorJsTest003 failed. Code: ' + code + '; Data: ' + data); expect(code).assertEqual(1001); }, - }, function () {}, 25); + }, function () { + }, 25); } catch (error) { errMessage = error.toString().slice(19, 56); console.info('subscribeStepCounter_SensorJsTest003 error:' + error); @@ -198,7 +200,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeStepCounter_SensorJsTest007", 0, function (done) { - console.info('----------------------subscribeStepCounter_SensorJsTest007---------------------------'); + console.info('----------------------subscribeStepCounter_SensorJsTest007---------------------------'); sensor.subscribeStepCounter({ success: function (data) { console.info("subscribeStepCounter_SensorJsTest007 success:" + JSON.stringify(data)); @@ -219,7 +221,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - setTimeout(() => { try { sensor.unsubscribeStepCounter(); @@ -244,7 +245,7 @@ describe("SensorJsTest", function () { try { sensor.unsubscribeStepCounter(); } catch (error) { - errMessage = error.toString().slice(21,45); + errMessage = error.toString().slice(21, 45); console.info('subscribeStepCounter_SensorJsTest008 error:' + error); expect(errMessage).assertEqual(errMessages[1]); done(); @@ -258,7 +259,7 @@ describe("SensorJsTest", function () { * @tc.require: SR000H0ALK, AR000H0ALM */ it("subscribeStepCounter_SensorJsTest009", 0, function (done) { - console.info('----------------------subscribeStepCounter_SensorJsTest009---------------------------'); + console.info('----------------------subscribeStepCounter_SensorJsTest009---------------------------'); sensor.subscribeStepCounter({ success: function (data) { console.info("subscribeStepCounter_SensorJsTest009 success:" + JSON.stringify(data)); @@ -269,7 +270,6 @@ describe("SensorJsTest", function () { expect(code).assertEqual(1001); }, }); - try { sensor.unsubscribeStepCounter(); } catch (error) {