1/* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import sensor from '@ohos.sensor' 16 17import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 18 19describe("SensorJsTest", function () { 20 function callback(data) { 21 console.info("callback" + JSON.stringify(data)); 22 expect(typeof(data.x)).assertEqual("number"); 23 } 24 25 function callback2() { 26 console.info("callback2" + JSON.stringify(data)); 27 expect(typeof(data.x)).assertEqual("number"); 28 } 29 30 beforeAll(function() { 31 /* 32 * @tc.setup: setup invoked before all testcases 33 */ 34 console.info('beforeAll caled') 35 }) 36 37 afterAll(function() { 38 /* 39 * @tc.teardown: teardown invoked after all testcases 40 */ 41 console.info('afterAll caled') 42 }) 43 44 beforeEach(function() { 45 /* 46 * @tc.setup: setup invoked before each testcases 47 */ 48 console.info('beforeEach caled') 49 }) 50 51 afterEach(function() { 52 /* 53 * @tc.teardown: teardown invoked after each testcases 54 */ 55 console.info('afterEach caled') 56 }) 57 58 const PARAMETER_ERROR_CODE = 401 59 const SERVICE_EXCEPTION_CODE = 14500101 60 const PARAMETER_ERROR_MSG = 'The parameter invalid.' 61 const SERVICE_EXCEPTION_MSG = 'Service exception.' 62 63 /* 64 * @tc.name:SensorJsTest_001 65 * @tc.desc:verify app info is not null 66 * @tc.type: FUNC 67 * @tc.require: Issue Number 68 */ 69 it("SensorJsTest_001", 0, async function (done) { 70 console.info('----------------------SensorJsTest_001---------------------------'); 71 sensor.on(sensor.SensorId.ACCELEROMETER, callback); 72 setTimeout(()=>{ 73 sensor.off(sensor.SensorId.ACCELEROMETER); 74 done(); 75 }, 500); 76 }) 77 78 /* 79 * @tc.name:SensorJsTest_002 80 * @tc.desc:verify app info is not null 81 * @tc.type: FUNC 82 * @tc.require: Issue Number 83 */ 84 it("SensorJsTest_002", 0, async function (done) { 85 console.info('----------------------SensorJsTest_002---------------------------'); 86 function onSensorCallback(data) { 87 console.info('SensorJsTest002 callback in'); 88 expect(false).assertTrue(); 89 done(); 90 } 91 try { 92 sensor.on(-1, onSensorCallback); 93 } catch (error) { 94 console.info(error); 95 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 96 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 97 done(); 98 } 99 }) 100 101 /* 102 * @tc.name:SensorJsTest_003 103 * @tc.desc:verify app info is not null 104 * @tc.type: FUNC 105 * @tc.require: Issue Number 106 */ 107 it("SensorJsTest_003", 0, async function (done) { 108 console.info('----------------------SensorJsTest003---------------------------'); 109 sensor.on(sensor.SensorId.ACCELEROMETER, callback, {'interval': 100000000}); 110 setTimeout(()=>{ 111 console.info('----------------------SensorJsTest_003 off in---------------------------'); 112 sensor.off(sensor.SensorId.ACCELEROMETER); 113 console.info('----------------------SensorJsTest_003 off end---------------------------'); 114 done(); 115 }, 500); 116 }) 117 118 /* 119 * @tc.name:SensorJsTest_004 120 * @tc.desc:verify app info is not null 121 * @tc.type: FUNC 122 * @tc.require: Issue Number 123 */ 124 it("SensorJsTest_004", 0, function (done) { 125 console.info('----------------------SensorJsTest_004---------------------------'); 126 function onSensorCallback(data) { 127 console.info('SensorJsTest004 callback in'); 128 expect(true).assertTrue(); 129 done(); 130 } 131 try { 132 sensor.on(sensor.SensorId.ACCELEROMETER, onSensorCallback, {'interval': 100000000}, 5); 133 } catch (error) { 134 console.info(error); 135 expect(false).assertTrue(); 136 done(); 137 } 138 setTimeout(()=>{ 139 console.info('----------------------SensorJsTest_004 off in---------------------------'); 140 sensor.off(sensor.SensorId.ACCELEROMETER); 141 console.info('----------------------SensorJsTest_004 off end---------------------------'); 142 done(); 143 }, 500); 144 }) 145 146 /* 147 * @tc.name:SensorJsTest_005 148 * @tc.desc:verify app info is not null 149 * @tc.type: FUNC 150 * @tc.require: Issue Number 151 */ 152 it("SensorJsTest_005", 0, async function (done) { 153 sensor.once(sensor.SensorId.ACCELEROMETER, callback); 154 setTimeout(()=>{ 155 expect(true).assertTrue(); 156 done(); 157 }, 500); 158 }) 159 160 /* 161 * @tc.name:SensorJsTest_006 162 * @tc.desc:verify app info is not null 163 * @tc.type: FUNC 164 * @tc.require: Issue Number 165 */ 166 it("SensorJsTest_006", 0, async function (done) { 167 function onceSensorCallback(data) { 168 console.info('SensorJsTest_006 callback in'); 169 expect(false).assertTrue(); 170 done(); 171 } 172 try { 173 sensor.once(-1, onceSensorCallback); 174 } catch (error) { 175 console.info(error); 176 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 177 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 178 done(); 179 } 180 }) 181 182 /* 183 * @tc.name:SensorJsTest_007 184 * @tc.desc:verify app info is not null 185 * @tc.type: FUNC 186 * @tc.require: Issue Number 187 */ 188 it("SensorJsTest_007", 0, function (done) { 189 function onceSensorCallback(data) { 190 console.info('SensorJsTest007 on error'); 191 expect(true).assertTrue(); 192 done(); 193 } 194 try{ 195 sensor.once(sensor.SensorId.ACCELEROMETER, onceSensorCallback, 5); 196 } catch (error) { 197 console.info(error); 198 expect(false).assertTrue(); 199 done(); 200 } 201 }) 202 203 /* 204 * @tc.name:SensorJsTest_008 205 * @tc.desc:verify app info is not null 206 * @tc.type: FUNC 207 * @tc.require: Issue Number 208 */ 209 it("SensorJsTest_008", 0, async function (done) { 210 try { 211 sensor.off(-1, callback); 212 } catch (error) { 213 console.info(error); 214 expect(error.code).assertEqual(PARAMETER_ERROR_CODE) 215 expect(error.message).assertEqual(PARAMETER_ERROR_MSG) 216 done(); 217 } 218 }) 219 220 /* 221 * @tc.name:SensorJsTest_009 222 * @tc.desc:verify app info is not null 223 * @tc.type: FUNC 224 * @tc.require: Issue Number 225 */ 226 it("SensorJsTest_009", 0, async function (done) { 227 function onSensorCallback(data) { 228 console.info('SensorJsTest_009 callback in'); 229 expect(false).assertTrue(); 230 done(); 231 } 232 sensor.on(sensor.SensorId.ACCELEROMETER, onSensorCallback); 233 sensor.off(sensor.SensorId.ACCELEROMETER, onSensorCallback); 234 setTimeout(()=>{ 235 expect(true).assertTrue(); 236 done(); 237 }, 500); 238 }) 239 240 /* 241 * @tc.name:SensorJsTest_010 242 * @tc.desc:verify app info is not null 243 * @tc.type: FUNC 244 * @tc.require: Issue Number 245 */ 246 it("SensorJsTest_010", 0, async function (done) { 247 function onSensorCallback(data) { 248 console.info('SensorJsTest010 on error'); 249 expect(false).assertTrue(); 250 done(); 251 } 252 try { 253 sensor.off(1000000, onSensorCallback); 254 } catch (error) { 255 console.info(error); 256 expect(error.code).assertEqual(PARAMETER_ERROR_CODE) 257 expect(error.message).assertEqual(PARAMETER_ERROR_MSG) 258 done(); 259 } 260 }) 261 262 /* 263 * @tc.name:SensorJsTest_011 264 * @tc.desc:verify app info is not null 265 * @tc.type: FUNC 266 * @tc.require: Issue Number 267 */ 268 it("SensorJsTest_011", 0, async function (done) { 269 sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ 270 console.info("callback: " + JSON.stringify(data)); 271 expect(typeof(data.x)).assertEqual("number"); 272 }); 273 sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ 274 console.info("callback2: " + JSON.stringify(data)); 275 expect(typeof(data.x)).assertEqual("number"); 276 }); 277 setTimeout(()=>{ 278 console.info('----------------------SensorJsTest_011 off in---------------------------'); 279 sensor.off(sensor.SensorId.ACCELEROMETER); 280 console.info('----------------------SensorJsTest_011 off end---------------------------'); 281 done(); 282 }, 1000); 283 }) 284 285 /* 286 * @tc.name:SensorJsTest_012 287 * @tc.desc:verify app info is not null 288 * @tc.type: FUNC 289 * @tc.require: Issue Number 290 */ 291 it("SensorJsTest_012", 0, function (done) { 292 try { 293 sensor.off(sensor.SensorId.ACCELEROMETER, 5); 294 } catch (error) { 295 console.info(error); 296 expect(error.code).assertEqual(PARAMETER_ERROR_CODE) 297 expect(error.message).assertEqual(PARAMETER_ERROR_MSG) 298 done(); 299 } 300 }) 301 302 /* 303 * @tc.name:SensorJsTest_013 304 * @tc.desc:verify app info is not null 305 * @tc.type: FUNC 306 * @tc.require: Issue Number 307 */ 308 it("SensorJsTest_013", 0, async function (done) { 309 console.info('----------------------SensorJsTest013---------------------------'); 310 sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ 311 console.info("callback: " + JSON.stringify(data)); 312 expect(typeof(data.x)).assertEqual("number"); 313 }, {'interval': 100000000}); 314 sensor.once(sensor.SensorId.ACCELEROMETER, (data)=>{ 315 console.info("callback2: " + JSON.stringify(data)); 316 expect(typeof(data.x)).assertEqual("number"); 317 }); 318 setTimeout(()=>{ 319 console.info('----------------------SensorJsTest_013 off in---------------------------'); 320 sensor.off(sensor.SensorId.ACCELEROMETER); 321 console.info('----------------------SensorJsTest_013 off end---------------------------'); 322 done(); 323 }, 1000); 324 }) 325 326 /* 327 * @tc.name:SensorJsTest_014 328 * @tc.desc:verify app info is not null 329 * @tc.type: FUNC 330 * @tc.require: Issue Number 331 */ 332 it("SensorJsTest_014", 0, async function (done) { 333 console.info('----------------------SensorJsTest_014---------------------------'); 334 sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ 335 console.info("callback: " + JSON.stringify(data)); 336 expect(typeof(data.x)).assertEqual("number"); 337 }, {'interval': 100000000}); 338 sensor.on(sensor.SensorId.ACCELEROMETER, (data)=>{ 339 console.info("callback2: " + JSON.stringify(data)); 340 expect(typeof(data.x)).assertEqual("number"); 341 }, {'interval': 100000000}); 342 setTimeout(()=>{ 343 console.info('----------------------SensorJsTest_014 off in---------------------------'); 344 sensor.off(sensor.SensorId.ACCELEROMETER); 345 console.info('----------------------SensorJsTest_014 off end---------------------------'); 346 done(); 347 }, 1000); 348 }) 349 350 /* 351 * @tc.name:SensorJsTest_015 352 * @tc.desc:verify app info is not null 353 * @tc.type: FUNC 354 * @tc.require: Issue Number 355 */ 356 it("SensorJsTest_015", 0, async function (done) { 357 console.info('----------------------SensorJsTest_015---------------------------'); 358 try { 359 sensor.on(); 360 } catch (error) { 361 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 362 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 363 done(); 364 } 365 try { 366 sensor.once(); 367 } catch (error) { 368 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 369 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 370 done(); 371 } 372 try { 373 sensor.off(); 374 } catch (error) { 375 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 376 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 377 done(); 378 } 379 }) 380 381 let GEOMAGNETIC_COMPONENT_YEAR_RESULT = [ 382 [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], 383 [6554.17041015625, -87.19947052001953, 54649.078125, -0.7622424364089966, 83.16046905517578, 6554.75048828125, 55040.7734375], 384 [6537.99169921875, -28.231582641601562, 54692.02734375, -0.24740631878376007, 83.18303680419922, 6538.052734375, 55081.4296875], 385 [6521.81201171875, 30.73670768737793, 54734.97265625, 0.2700277864933014, 83.20502471923828, 6521.88427734375, 55122.15625], 386 [6505.6328125, 89.70511627197266, 54777.90625, 0.7899921536445618, 83.22642517089844, 6506.2509765625, 55162.9453125]] 387 388 let GEOMAGNETIC_COMPONENT_COORDINATES_RESULT = [ 389 [6570.3935546875, -146.3289337158203, 54606.0078125, -1.2758207321166992, 83.13726043701172, 6572.02294921875, 55000.0703125], 390 [39624.28125, 109.8766098022461, -10932.4638671875, 0.15887857973575592, -15.424291610717773, 39624.43359375, 41104.921875], 391 [37636.72265625, 104.90892791748047, -10474.810546875, 0.15970633924007416, -15.552550315856934, 37636.8671875, 39067.3203125], 392 [5940.583984375, 15772.0927734375, -52480.7578125, 69.36103820800781, -72.19599914550781, 16853.765625, 55120.58984375], 393 [5744.87255859375, 14799.48046875, -49969.40234375, 68.78474426269531, -72.37483215332031, 15875.3955078125, 52430.61328125]] 394 395 let GEOMAGNETIC_COORDINATES = [[80, 0, 0], 396 [0, 120, 0], 397 [0, 120, 100000], 398 [-80, 240, 0], 399 [-80, 240, 100000]] 400 401 let timeMillis = [1580486400000, 1612108800000, 1643644800000, 1675180800000, 1706716800000] 402 403 /** 404 * test 405 * 406 * @tc.name: Sensor_GetGeomagneticField_001 407 * @tc.desc: Verification results of the incorrect parameters of the test interface. 408 * @tc.require: AR000GH2U6 409 * @tc.author: 410 */ 411 it('Sensor_GetGeomagneticField_001', 0, async function (done) { 412 console.info("---------------------------Sensor_GetGeomagneticField_001----------------------------------"); 413 let promiseArray = [] 414 for (let i = 0; i < timeMillis.length; i++) { 415 promiseArray.push(new Promise((resolve, reject) => { 416 let j = i 417 sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[j], (error, data) => { 418 if (error) { 419 console.info('Sensor_GetGeomagneticField_001 failed'); 420 expect(false).assertTrue(); 421 setTimeout(() =>{ 422 reject() 423 }, 500) 424 } else { 425 console.info('Sensor_GetGeomagneticField_001 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 426 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 427 expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][0]) 428 expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][1]) 429 expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][2]) 430 expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][3]) 431 expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][4]) 432 expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][5]) 433 expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[j][6]) 434 setTimeout(() =>{ 435 resolve() 436 }, 500) 437 } 438 }) 439 })) 440 } 441 Promise.all(promiseArray).then(done) 442 }) 443 444 /** 445 * test 446 * 447 * @tc.name: Sensor_GetGeomagneticField_002 448 * @tc.desc: Verification results of the incorrect parameters of the test interface. 449 * @tc.require: AR000GH2U6 450 * @tc.author: 451 */ 452 it('Sensor_GetGeomagneticField_002', 0, async function (done) { 453 console.info("---------------------------Sensor_GetGeomagneticField_002----------------------------------"); 454 let promiseArray = [] 455 for (let i = 0; i < GEOMAGNETIC_COORDINATES.length; i++) { 456 promiseArray.push(new Promise((resolve, reject) => { 457 let j = i 458 sensor.getGeomagneticInfo({'latitude':GEOMAGNETIC_COORDINATES[j][0], 'longitude':GEOMAGNETIC_COORDINATES[j][1], 'altitude':GEOMAGNETIC_COORDINATES[j][2]}, timeMillis[0], (error, data) => { 459 if (error) { 460 console.info('Sensor_GetGeomagneticField_002 failed'); 461 expect(false).assertTrue(); 462 setTimeout(() =>{ 463 reject() 464 }, 500) 465 } else { 466 console.info('Sensor_GetGeomagneticField_002 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 467 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 468 expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][0]) 469 expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][1]) 470 expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][2]) 471 expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][3]) 472 expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][4]) 473 expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][5]) 474 expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[j][6]) 475 setTimeout(() =>{ 476 resolve() 477 }, 500) 478 } 479 }) 480 })) 481 } 482 Promise.all(promiseArray).then(done) 483 }) 484 485 /** 486 * test 487 * 488 * @tc.name: Sensor_GetGeomagneticField_003 489 * @tc.desc: Verification results of the incorrect parameters of the test interface. 490 * @tc.require: AR000GH2U6 491 * @tc.author: 492 */ 493 it('Sensor_GetGeomagneticField_003', 0, async function (done) { 494 console.info("---------------------------Sensor_GetGeomagneticField_003----------------------------------"); 495 let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, 496 -27.667943954467773, -12.610970497131348, 28465.9765625, 32141.2109375] 497 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':0}, Number.MIN_VALUE, (error, data) => { 498 if (error) { 499 console.info('Sensor_GetGeomagneticField_003 failed'); 500 expect(false).assertTrue(); 501 } else { 502 console.info('Sensor_GetGeomagneticField_003 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 503 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 504 expect(data.x).assertEqual(geomagneticComponent[0]) 505 expect(data.y).assertEqual(geomagneticComponent[1]) 506 expect(data.z).assertEqual(geomagneticComponent[2]) 507 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 508 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 509 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 510 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 511 } 512 setTimeout(() =>{ 513 done() 514 }, 500) 515 }) 516 }) 517 518 /** 519 * test 520 * 521 * @tc.name: Sensor_GetGeomagneticField_004 522 * @tc.desc: Verification results of the incorrect parameters of the test interface. 523 * @tc.require: AR000GH2U6 524 * @tc.author: 525 */ 526 it('Sensor_GetGeomagneticField_004', 0, async function (done) { 527 console.info("---------------------------Sensor_GetGeomagneticField_004----------------------------------"); 528 let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, 3.6568238735198975, 1827.8634033203125, 56757.21484375] 529 sensor.getGeomagneticInfo({'latitude':Number.MAX_VALUE, 'longitude':0, 'altitude':0}, timeMillis[0], (error, data) => { 530 if (error) { 531 console.info('Sensor_GetGeomagneticField_004 failed'); 532 expect(false).assertTrue(); 533 } else { 534 console.info('Sensor_GetGeomagneticField_004 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 535 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 536 expect(data.x).assertEqual(geomagneticComponent[0]) 537 expect(data.y).assertEqual(geomagneticComponent[1]) 538 expect(data.z).assertEqual(geomagneticComponent[2]) 539 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 540 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 541 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 542 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 543 } 544 setTimeout(() =>{ 545 done() 546 }, 500) 547 }) 548 }) 549 550 /** 551 * test 552 * 553 * @tc.name: Sensor_GetGeomagneticField_005 554 * @tc.desc: Verification results of the incorrect parameters of the test interface. 555 * @tc.require: AR000GH2U6 556 * @tc.author: 557 */ 558 it('Sensor_GetGeomagneticField_005', 0, async function (done) { 559 console.info("---------------------------Sensor_GetGeomagneticField_005----------------------------------"); 560 let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, 3.6568238735198975, 1827.8634033203125, 56757.21484375] 561 sensor.getGeomagneticInfo({'latitude':Number.NaN, 'longitude':0, 'altitude':0}, timeMillis[0], (error, data) => { 562 if (error) { 563 console.info('Sensor_GetGeomagneticField_005 failed'); 564 expect(false).assertTrue(); 565 } else { 566 console.info('Sensor_GetGeomagneticField_005 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 567 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 568 expect(data.x).assertEqual(geomagneticComponent[0]) 569 expect(data.y).assertEqual(geomagneticComponent[1]) 570 expect(data.z).assertEqual(geomagneticComponent[2]) 571 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 572 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 573 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 574 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 575 } 576 setTimeout(() =>{ 577 done() 578 }, 500) 579 }) 580 }) 581 582 /** 583 * test 584 * 585 * @tc.name: Sensor_GetGeomagneticField_006 586 * @tc.desc: Verification results of the incorrect parameters of the test interface. 587 * @tc.require: AR000GH2U6 588 * @tc.author: 589 */ 590 it('Sensor_GetGeomagneticField_006', 0, async function (done) { 591 console.info("---------------------------Sensor_GetGeomagneticField_006----------------------------------"); 592 let geomagneticComponent = [14425.57421875, -17156.767578125, -52023.21484375, -66.69005584716797, -49.94255447387695, 22415.4375, 56646.859375] 593 sensor.getGeomagneticInfo({'latitude':Number.NEGATIVE_INFINITY, 'longitude':0, 'altitude':0}, timeMillis[0], (error, data) => { 594 if (error) { 595 console.info('Sensor_GetGeomagneticField_006 failed'); 596 expect(false).assertTrue(); 597 } else { 598 console.info('Sensor_GetGeomagneticField_006 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 599 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 600 expect(data.x).assertEqual(geomagneticComponent[0]) 601 expect(data.y).assertEqual(geomagneticComponent[1]) 602 expect(data.z).assertEqual(geomagneticComponent[2]) 603 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 604 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 605 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 606 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 607 } 608 setTimeout(() =>{ 609 done() 610 }, 500) 611 }) 612 }) 613 614 /** 615 * test 616 * 617 * @tc.name: Sensor_GetGeomagneticField_007 618 * @tc.desc: Verification results of the incorrect parameters of the test interface. 619 * @tc.require: AR000GH2U6 620 * @tc.author: 621 */ 622 it('Sensor_GetGeomagneticField_007', 0, async function (done) { 623 console.info("---------------------------Sensor_GetGeomagneticField_007----------------------------------"); 624 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.MAX_VALUE, 'altitude':0}, timeMillis[0], (error, data) => { 625 if (error) { 626 console.info('Sensor_GetGeomagneticField_007 failed'); 627 expect(false).assertTrue(); 628 } else { 629 console.info('Sensor_GetGeomagneticField_007 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 630 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 631 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue(); 632 } 633 setTimeout(() =>{ 634 done() 635 }, 500) 636 }) 637 }) 638 639 /** 640 * test 641 * 642 * @tc.name: Sensor_GetGeomagneticField_008 643 * @tc.desc: Verification results of the incorrect parameters of the test interface. 644 * @tc.require: SR000GH2A3 645 * @tc.author: 646 */ 647 it('Sensor_GetGeomagneticField_008', 0, async function (done) { 648 console.info("---------------------------Sensor_GetGeomagneticField_008----------------------------------"); 649 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0], (error, data) => { 650 if (error) { 651 console.info('Sensor_GetGeomagneticField_008 failed'); 652 expect(false).assertTrue(); 653 } else { 654 console.info('Sensor_GetGeomagneticField_008 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 655 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 656 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 657 } 658 setTimeout(() =>{ 659 done() 660 }, 500) 661 }) 662 }) 663 664 /** 665 * test 666 * 667 * @tc.name: Sensor_GetGeomagneticField_009 668 * @tc.desc: Verification results of the incorrect parameters of the test interface. 669 * @tc.require: SR000GH2A3 670 * @tc.author: 671 */ 672 it('Sensor_GetGeomagneticField_009', 0, async function (done) { 673 console.info("---------------------------Sensor_GetGeomagneticField_009----------------------------------"); 674 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0], (error, data) => { 675 if (error) { 676 console.info('Sensor_GetGeomagneticField_009 failed'); 677 expect(false).assertTrue(); 678 } else { 679 console.info('Sensor_GetGeomagneticField_009 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 680 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 681 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 682 } 683 setTimeout(() =>{ 684 done() 685 }, 500) 686 }) 687 }) 688 689 /** 690 * test 691 * 692 * @tc.name: Sensor_GetGeomagneticField_010 693 * @tc.desc: Verification results of the incorrect parameters of the test interface. 694 * @tc.require: SR000GH2A3 695 * @tc.author: 696 */ 697 it('Sensor_GetGeomagneticField_010', 0, async function (done) { 698 console.info("---------------------------Sensor_GetGeomagneticField_010----------------------------------"); 699 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0], (error, data) => { 700 if (error) { 701 console.info('Sensor_GetGeomagneticField_010 failed'); 702 expect(false).assertTrue(); 703 } else { 704 console.info('Sensor_GetGeomagneticField_010 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 705 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 706 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 707 } 708 setTimeout(() =>{ 709 done() 710 }, 500) 711 }) 712 }) 713 714 /** 715 * test 716 * 717 * @tc.name: Sensor_GetGeomagneticField_011 718 * @tc.desc: Verification results of the incorrect parameters of the test interface. 719 * @tc.require: SR000GH2A4 720 * @tc.author: 721 */ 722 it('Sensor_GetGeomagneticField_011', 0, async function (done) { 723 console.info("---------------------------Sensor_GetGeomagneticField_011----------------------------------"); 724 let geomagneticComponent = [27536.40234375, -2248.586669921875, -16022.4306640625, -30.110872268676758, -4.66834020614624, 27628.05859375, 31937.875] 725 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MIN_VALUE}, timeMillis[0], (error, data) => { 726 if (error) { 727 console.info('Sensor_GetGeomagneticField_011 failed'); 728 expect(false).assertTrue(); 729 } else { 730 console.info('Sensor_GetGeomagneticField_011 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 731 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 732 expect(data.x).assertEqual(geomagneticComponent[0]) 733 expect(data.y).assertEqual(geomagneticComponent[1]) 734 expect(data.z).assertEqual(geomagneticComponent[2]) 735 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 736 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 737 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 738 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 739 } 740 setTimeout(() =>{ 741 done() 742 }, 500) 743 }) 744 }) 745 746 /** 747 * test 748 * 749 * @tc.name: Sensor_GetGeomagneticField_012 750 * @tc.desc: Verification results of the incorrect parameters of the test interface. 751 * @tc.require: SR000GH2A4 752 * @tc.author: 753 */ 754 it('Sensor_GetGeomagneticField_012', 0, async function (done) { 755 console.info("---------------------------Sensor_GetGeomagneticField_012----------------------------------"); 756 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0], (error, data) => { 757 if (error) { 758 console.info('Sensor_GetGeomagneticField_012 failed'); 759 expect(false).assertTrue(); 760 } else { 761 console.info('Sensor_GetGeomagneticField_012 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 762 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 763 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 764 } 765 setTimeout(() =>{ 766 done() 767 }, 500) 768 }) 769 }) 770 771 /** 772 * test 773 * 774 * @tc.name: Sensor_GetGeomagneticField_013 775 * @tc.desc: Verification results of the incorrect parameters of the test interface. 776 * @tc.require: SR000GH2A4 777 * @tc.author: 778 */ 779 it('Sensor_GetGeomagneticField_013', 0, async function (done) { 780 console.info("---------------------------Sensor_GetGeomagneticField_013----------------------------------"); 781 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0], (error, data) => { 782 if (error) { 783 console.info('Sensor_GetGeomagneticField_013 failed'); 784 expect(false).assertTrue(); 785 } else { 786 console.info('Sensor_GetGeomagneticField_013 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 787 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 788 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 789 } 790 setTimeout(() =>{ 791 done() 792 }, 500) 793 }) 794 }) 795 796 /** 797 * test 798 * 799 * @tc.name: Sensor_GetGeomagneticField_014 800 * @tc.desc: Verification results of the incorrect parameters of the test interface. 801 * @tc.require: AR000GH2UB 802 * @tc.author: 803 */ 804 it('Sensor_GetGeomagneticField_014', 0, async function (done) { 805 console.info("---------------------------Sensor_GetGeomagneticField_014----------------------------------"); 806 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0], (error, data) => { 807 if (error) { 808 console.info('Sensor_GetGeomagneticField_014 failed'); 809 expect(false).assertTrue(); 810 } else { 811 console.info('Sensor_GetGeomagneticField_014 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 812 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 813 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 814 } 815 setTimeout(() =>{ 816 done() 817 }, 500) 818 }) 819 }) 820 821 /** 822 * test 823 * 824 * @tc.name: Sensor_GetGeomagneticField_015 825 * @tc.desc: Verification results of the incorrect parameters of the test interface. 826 * @tc.require: AR000GH2UB 827 * @tc.author: 828 */ 829 it('Sensor_GetGeomagneticField_015', 0, async function (done) { 830 console.info("---------------------------Sensor_GetGeomagneticField_015----------------------------------"); 831 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0], (error, data) => { 832 if (error) { 833 console.info('Sensor_GetGeomagneticField_015 once success'); 834 expect(false).assertTrue(); 835 } else { 836 console.info('Sensor_GetGeomagneticField_015 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 837 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 838 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 839 } 840 setTimeout(() =>{ 841 done() 842 }, 500) 843 }) 844 }) 845 846 /** 847 * test 848 * 849 * @tc.name: Sensor_GetGeomagneticField_016 850 * @tc.desc: Verification results of the incorrect parameters of the test interface. 851 * @tc.require: AR000GH2UB 852 * @tc.author: 853 */ 854 it('Sensor_GetGeomagneticField_016', 0, async function (done) { 855 console.info("---------------------------Sensor_GetGeomagneticField_016----------------------------------"); 856 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0], (error, data) => { 857 if (error) { 858 console.info('Sensor_GetGeomagneticField_016 failed'); 859 expect(false).assertTrue(); 860 } else { 861 console.info('Sensor_GetGeomagneticField_016 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 862 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 863 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 864 } 865 setTimeout(() =>{ 866 done() 867 }, 500) 868 }) 869 }) 870 871 /** 872 * test 873 * 874 * @tc.name: Sensor_GetGeomagneticField_017 875 * @tc.desc: Verification results of the incorrect parameters of the test interface. 876 * @tc.require: AR000GH2UB 877 * @tc.author: 878 */ 879 it('Sensor_GetGeomagneticField_017', 0, async function (done) { 880 console.info("---------------------------Sensor_GetGeomagneticField_017----------------------------------"); 881 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0], (error, data) => { 882 if (error) { 883 console.info('Sensor_GetGeomagneticField_017 failed'); 884 expect(false).assertTrue(); 885 } else { 886 console.info('Sensor_GetGeomagneticField_017 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 887 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 888 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 889 } 890 setTimeout(() =>{ 891 done() 892 }, 500) 893 }) 894 }) 895 896 /** 897 * test 898 * 899 * @tc.name: Sensor_GetGeomagneticField_018 900 * @tc.desc: Verification results of the incorrect parameters of the test interface. 901 * @tc.require: AR000GH2UB 902 * @tc.author: 903 */ 904 it('Sensor_GetGeomagneticField_018', 0, async function (done) { 905 console.info("---------------------------Sensor_GetGeomagneticField_018----------------------------------"); 906 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0], (error, data) => { 907 if (error) { 908 console.info('Sensor_GetGeomagneticField_018 failed'); 909 expect(false).assertfalse(); 910 } else { 911 console.info('Sensor_GetGeomagneticField_018 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 912 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 913 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 914 } 915 setTimeout(() =>{ 916 done() 917 }, 500) 918 }) 919 }) 920 921 /** 922 * test 923 * 924 * @tc.name: Sensor_GetGeomagneticField_019 925 * @tc.desc: Verification results of the incorrect parameters of the test interface. 926 * @tc.require: AR000GH2UB 927 * @tc.author: 928 */ 929 it('Sensor_GetGeomagneticField_019', 0, async function (done) { 930 console.info("---------------------------Sensor_GetGeomagneticField_019----------------------------------"); 931 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.MAX_VALUE, 'altitude':0}, timeMillis[0], (error, data) => { 932 if (error) { 933 console.info('Sensor_GetGeomagneticField_019 failed'); 934 expect(false).assertTrue(); 935 } else { 936 console.info('Sensor_GetGeomagneticField_019 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 937 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 938 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue(); 939 } 940 setTimeout(() =>{ 941 done() 942 }, 500) 943 }) 944 }) 945 946 /** 947 * test 948 * 949 * @tc.name: Sensor_GetGeomagneticField_020 950 * @tc.desc: Verification results of the incorrect parameters of the test interface. 951 * @tc.require: AR000GH2UB 952 * @tc.author: 953 */ 954 it('Sensor_GetGeomagneticField_020', 0, async function (done) { 955 console.info("---------------------------Sensor_GetGeomagneticField_020----------------------------------"); 956 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0], (error, data) => { 957 if (error) { 958 console.info('Sensor_GetGeomagneticField_020 failed'); 959 expect(false).assertTrue(); 960 } else { 961 console.info('Sensor_GetGeomagneticField_020 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 962 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 963 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 964 } 965 setTimeout(() =>{ 966 done() 967 }, 500) 968 }) 969 }) 970 971 /** 972 * test 973 * 974 * @tc.name: Sensor_GetGeomagneticField_021 975 * @tc.desc: Verification results of the incorrect parameters of the test interface. 976 * @tc.require: AR000GH2UB 977 * @tc.author: 978 */ 979 it('Sensor_GetGeomagneticField_021', 0, async function (done) { 980 console.info("---------------------------Sensor_GetGeomagneticField_021----------------------------------"); 981 sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0], (error, data) => { 982 if (error) { 983 console.info('Sensor_GetGeomagneticField_021 failed'); 984 expect(false).assertTrue(); 985 } else { 986 console.info('Sensor_GetGeomagneticField_021 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 987 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 988 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 989 } 990 setTimeout(() =>{ 991 done() 992 }, 500) 993 }) 994 }) 995 996 /** 997 * test 998 * 999 * @tc.name: Sensor_GetGeomagneticField_022 1000 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1001 * @tc.require: AR000GH2UB 1002 * @tc.author: 1003 */ 1004 it('Sensor_GetGeomagneticField_022', 0, async function (done) { 1005 console.info("---------------------------Sensor_GetGeomagneticField_022----------------------------------"); 1006 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0], (error, data) => { 1007 if (error) { 1008 console.info('Sensor_GetGeomagneticField_022 failed'); 1009 expect(false).assertTrue(); 1010 } else { 1011 console.info('Sensor_GetGeomagneticField_022 success x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1012 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1013 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1014 } 1015 setTimeout(() =>{ 1016 done() 1017 }, 500) 1018 }) 1019 }) 1020 1021 /** 1022 * test 1023 * 1024 * @tc.name: Sensor_GetGeomagneticField_023 1025 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1026 * @tc.require: AR000GH2UB 1027 * @tc.author: 1028 */ 1029 it('Sensor_GetGeomagneticField_023', 0, async function (done) { 1030 console.info("---------------------------Sensor_GetGeomagneticField_023----------------------------------"); 1031 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0], (error, data) => { 1032 if (error) { 1033 console.info('Sensor_GetGeomagneticField_023 once success'); 1034 expect(false).assertTrue(); 1035 } else { 1036 console.info('Sensor_GetGeomagneticField_023 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1037 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1038 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1039 } 1040 setTimeout(() =>{ 1041 done() 1042 }, 500) 1043 }) 1044 }) 1045 1046 /** 1047 * test 1048 * 1049 * @tc.name: Sensor_GetGeomagneticField_024 1050 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1051 * @tc.require: AR000GH2UB 1052 * @tc.author: 1053 */ 1054 it('Sensor_GetGeomagneticField_024', 0, async function (done) { 1055 console.info("---------------------------Sensor_GetGeomagneticField_024----------------------------------"); 1056 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0], (error, data) => { 1057 if (error) { 1058 console.info('Sensor_GetGeomagneticField_024 once success'); 1059 expect(false).assertTrue(); 1060 } else { 1061 console.info('Sensor_GetGeomagneticField_024 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1062 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1063 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1064 } 1065 setTimeout(() =>{ 1066 done() 1067 }, 500) 1068 }) 1069 }) 1070 1071 /** 1072 * test 1073 * 1074 * @tc.name: Sensor_GetGeomagneticField_025 1075 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1076 * @tc.require: AR000GH2UB 1077 * @tc.author: 1078 */ 1079 it("Sensor_GetGeomagneticField_025", 0, async function (done) { 1080 console.info("---------------------------Sensor_GetGeomagneticField_025----------------------------------"); 1081 for (var i = 0; i < timeMillis.length; i++) { 1082 await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i]).then((data) => { 1083 console.info('Sensor_GetGeomagneticField_025 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1084 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); 1085 expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) 1086 expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) 1087 expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) 1088 expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) 1089 expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) 1090 expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) 1091 expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) 1092 }).catch((error) => { 1093 console.info("promise::catch", error); 1094 }) 1095 } 1096 done() 1097 }) 1098 1099 /** 1100 * test 1101 * 1102 * @tc.name: Sensor_GetGeomagneticField_026 1103 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1104 * @tc.require: AR000GH2UD 1105 * @tc.author: 1106 */ 1107 it("Sensor_GetGeomagneticField_026", 0, async function (done) { 1108 console.info('----------------------Sensor_GetGeomagneticField_026---------------------------'); 1109 let geomagneticComponent = [27779.234375, -6214.9794921875, -14924.6611328125, -27.667943954467773, -12.610970497131348, 28465.9765625, 32141.2109375] 1110 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':0}, Number.MIN_VALUE).then((data) => { 1111 console.info('Sensor_GetGeomagneticField_026 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1112 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1113 expect(data.x).assertEqual(geomagneticComponent[0]) 1114 expect(data.y).assertEqual(geomagneticComponent[1]) 1115 expect(data.z).assertEqual(geomagneticComponent[2]) 1116 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 1117 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 1118 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 1119 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 1120 }).catch((error) => { 1121 console.info("promise::catch", error); 1122 }); 1123 done() 1124 }) 1125 1126 /** 1127 * test 1128 * 1129 * @tc.name: Sensor_GetGeomagneticField_027 1130 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1131 * @tc.require: AR000GH2UD 1132 * @tc.author: 1133 */ 1134 it("Sensor_GetGeomagneticField_027", 0, async function (done) { 1135 console.info('----------------------Sensor_GetGeomagneticField_027---------------------------'); 1136 let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, 3.6568238735198975, 1827.8634033203125, 56757.21484375] 1137 await sensor.getGeomagneticInfo({'latitude':Number.MAX_VALUE, 'longitude':0, 'altitude':0}, timeMillis[0]).then((data) => { 1138 console.info('Sensor_GetGeomagneticField_027 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1139 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1140 expect(data.x).assertEqual(geomagneticComponent[0]) 1141 expect(data.y).assertEqual(geomagneticComponent[1]) 1142 expect(data.z).assertEqual(geomagneticComponent[2]) 1143 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 1144 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 1145 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 1146 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 1147 }).catch((error) => { 1148 console.info("promise::catch", error) 1149 }); 1150 done() 1151 }) 1152 1153 /** 1154 * test 1155 * 1156 * @tc.name: Sensor_GetGeomagneticField_028 1157 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1158 * @tc.require: AR000GH2UD 1159 * @tc.author: 1160 */ 1161 it("Sensor_GetGeomagneticField_028", 0, async function (done) { 1162 console.info('----------------------Sensor_GetGeomagneticField_028---------------------------'); 1163 let geomagneticComponent = [1824.141845703125, 116.58167266845703, 56727.7734375, 88.15447235107422, 3.6568238735198975, 1827.8634033203125, 56757.21484375] 1164 await sensor.getGeomagneticInfo({'latitude':Number.NaN, 'longitude':0, 'altitude':0}, timeMillis[0]).then((data) => { 1165 console.info('Sensor_GetGeomagneticField_028 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1166 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1167 expect(data.x).assertEqual(geomagneticComponent[0]) 1168 expect(data.y).assertEqual(geomagneticComponent[1]) 1169 expect(data.z).assertEqual(geomagneticComponent[2]) 1170 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 1171 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 1172 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 1173 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 1174 }).catch((error) => { 1175 console.info("promise::catch", error) 1176 }); 1177 done() 1178 }) 1179 1180 /* 1181 * @tc.name:Sensor_GetGeomagneticField_029 1182 * @tc.desc:verify app info is not null 1183 * @tc.type: FUNC 1184 * @tc.require: Issue Number 1185 */ 1186 it("Sensor_GetGeomagneticField_029", 0, async function (done) { 1187 console.info('----------------------Sensor_GetGeomagneticField_029---------------------------'); 1188 let geomagneticComponent = [14425.57421875, -17156.767578125, -52023.21484375, -66.69005584716797, -49.94255447387695, 22415.4375, 56646.859375] 1189 await sensor.getGeomagneticInfo({'latitude':Number.NEGATIVE_INFINITY, 'longitude':0, 'altitude':0}, timeMillis[0]).then((data) => { 1190 console.info('Sensor_GetGeomagneticField_029 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1191 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1192 expect(data.x).assertEqual(geomagneticComponent[0]) 1193 expect(data.y).assertEqual(geomagneticComponent[1]) 1194 expect(data.z).assertEqual(geomagneticComponent[2]) 1195 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 1196 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 1197 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 1198 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 1199 }).catch((error) => { 1200 console.info("promise::catch", error) 1201 }); 1202 done() 1203 }) 1204 1205 /* 1206 * @tc.name:Sensor_GetGeomagneticField_030 1207 * @tc.desc:verify app info is not null 1208 * @tc.type: FUNC 1209 * @tc.require: Issue Number 1210 */ 1211 it("Sensor_GetGeomagneticField_030", 0, async function (done) { 1212 console.info('----------------------Sensor_GetGeomagneticField_030---------------------------'); 1213 let geomagneticComponent = [NaN, NaN, NaN] 1214 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.MAX_VALUE, 'altitude':0}, timeMillis[0]).then((data) => { 1215 console.info('Sensor_GetGeomagneticField_030 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1216 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1217 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1218 }).catch((error) => { 1219 console.info("promise::catch", error) 1220 }); 1221 done() 1222 }) 1223 1224 /* 1225 * @tc.name:Sensor_GetGeomagneticField_031 1226 * @tc.desc:verify app info is not null 1227 * @tc.type: FUNC 1228 * @tc.require: Issue Number 1229 */ 1230 it("Sensor_GetGeomagneticField_031", 0, async function (done) { 1231 console.info('----------------------Sensor_GetGeomagneticField_031---------------------------'); 1232 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0]).then((data) => { 1233 console.info('Sensor_GetGeomagneticField_031 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1234 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1235 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1236 }).catch((error) => { 1237 console.info("promise::catch", error) 1238 }); 1239 done() 1240 }) 1241 1242 /* 1243 * @tc.name:Sensor_GetGeomagneticField_032 1244 * @tc.desc:verify app info is not null 1245 * @tc.type: FUNC 1246 * @tc.require: Issue Number 1247 */ 1248 it("Sensor_GetGeomagneticField_032", 0, async function (done) { 1249 console.info('----------------------Sensor_GetGeomagneticField_032---------------------------'); 1250 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0]).then((data) => { 1251 console.info('Sensor_GetGeomagneticField_032 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1252 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1253 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1254 }).catch((error) => { 1255 console.info("promise::catch", error) 1256 }); 1257 done() 1258 }) 1259 1260 /* 1261 * @tc.name:Sensor_GetGeomagneticField_033 1262 * @tc.desc:verify app info is not null 1263 * @tc.type: FUNC 1264 * @tc.require: Issue Number 1265 */ 1266 it("Sensor_GetGeomagneticField_033", 0, async function (done) { 1267 console.info('----------------------Sensor_GetGeomagneticField_033---------------------------'); 1268 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0]).then((data) => { 1269 console.info('Sensor_GetGeomagneticField_033 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1270 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1271 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1272 }).catch((error) => { 1273 console.info("promise::catch", error) 1274 }); 1275 done() 1276 }) 1277 1278 /* 1279 * @tc.name:Sensor_GetGeomagneticField_034 1280 * @tc.desc:verify app info is not null 1281 * @tc.type: FUNC 1282 * @tc.require: Issue Number 1283 */ 1284 it("Sensor_GetGeomagneticField_034", 0, async function (done) { 1285 console.info('----------------------Sensor_GetGeomagneticField_034---------------------------'); 1286 let geomagneticComponent = [27536.40234375, -2248.586669921875, -16022.4306640625, -30.110872268676758, -4.66834020614624, 27628.05859375, 31937.875] 1287 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MIN_VALUE}, timeMillis[0]).then((data) => { 1288 console.info('Sensor_GetGeomagneticField_034 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1289 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1290 expect(data.x).assertEqual(geomagneticComponent[0]) 1291 expect(data.y).assertEqual(geomagneticComponent[1]) 1292 expect(data.z).assertEqual(geomagneticComponent[2]) 1293 expect(data.geomagneticDip).assertEqual(geomagneticComponent[3]) 1294 expect(data.deflectionAngle).assertEqual(geomagneticComponent[4]) 1295 expect(data.levelIntensity).assertEqual(geomagneticComponent[5]) 1296 expect(data.totalIntensity).assertEqual(geomagneticComponent[6]) 1297 }).catch((error) => { 1298 console.info("promise::catch", error) 1299 }); 1300 done() 1301 }) 1302 1303 /* 1304 * @tc.name:Sensor_GetGeomagneticField_035 1305 * @tc.desc:verify app info is not null 1306 * @tc.type: FUNC 1307 * @tc.require: Issue Number 1308 */ 1309 it("Sensor_GetGeomagneticField_035", 0, async function (done) { 1310 console.info('----------------------Sensor_GetGeomagneticField_035---------------------------start'); 1311 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0]).then((data) => { 1312 console.info('Sensor_GetGeomagneticField_035 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1313 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1314 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1315 }).catch((error) => { 1316 console.info("promise::catch", error) 1317 }); 1318 done() 1319 }) 1320 1321 /* 1322 * @tc.name:Sensor_GetGeomagneticField_036 1323 * @tc.desc:verify app info is not null 1324 * @tc.type: FUNC 1325 * @tc.require: Issue Number 1326 */ 1327 it("Sensor_GetGeomagneticField_036", 0, async function (done) { 1328 console.info('----------------------Sensor_GetGeomagneticField_036---------------------------'); 1329 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0]).then((data) => { 1330 console.info('Sensor_GetGeomagneticField_036 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1331 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1332 expect(Number.isNaN(data.x) && Number.isNaN(data.y) && Number.isNaN(data.z)).assertTrue() 1333 }).catch((error) => { 1334 console.info("promise::catch", error) 1335 }); 1336 done() 1337 }) 1338 1339 /* 1340 * @tc.name:Sensor_GetGeomagneticField_037 1341 * @tc.desc:verify app info is not null 1342 * @tc.type: FUNC 1343 * @tc.require: Issue Number 1344 */ 1345 it('Sensor_GetGeomagneticField_037', 0, async function (done) { 1346 for (var i = 0; i < timeMillis.length; i++) { 1347 console.info('----------------------Sensor_GetGeomagneticField_037---------------------------'); 1348 await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i]).then((data) => { 1349 console.info('Sensor_GetGeomagneticField_037 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1350 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); 1351 expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) 1352 expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) 1353 expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][2]) 1354 expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][3]) 1355 expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][4]) 1356 expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) 1357 expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) 1358 }).catch((error) => { 1359 console.info("promise::catch", error) 1360 }); 1361 } 1362 done() 1363 }) 1364 1365 /* 1366 * @tc.name:Sensor_GetGeomagneticField_038 1367 * @tc.desc:verify app info is not null 1368 * @tc.type: FUNC 1369 * @tc.require: Issue Number 1370 */ 1371 it("Sensor_GetGeomagneticField_038", 0, async function (done) { 1372 console.info('----------------------Sensor_GetGeomagneticField_038---------------------------'); 1373 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0]).then((data) => { 1374 console.info('Sensor_GetGeomagneticField_038 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1375 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1376 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1377 }).catch((error) => { 1378 console.info("promise::catch", error) 1379 }); 1380 done() 1381 }) 1382 1383 /* 1384 * @tc.name:Sensor_GetGeomagneticField_039 1385 * @tc.desc:verify app info is not null 1386 * @tc.type: FUNC 1387 * @tc.require: Issue Number 1388 */ 1389 it("Sensor_GetGeomagneticField_039", 0, async function (done) { 1390 console.info('----------------------Sensor_GetGeomagneticField_039---------------------------'); 1391 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0]).then((data) => { 1392 console.info('Sensor_GetGeomagneticField_039 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1393 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1394 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1395 }).catch((error) => { 1396 console.info("promise::catch", error) 1397 }); 1398 done() 1399 }) 1400 1401 /* 1402 * @tc.name:Sensor_GetGeomagneticField_040 1403 * @tc.desc:verify app info is not null 1404 * @tc.type: FUNC 1405 * @tc.require: Issue Number 1406 */ 1407 it("Sensor_GetGeomagneticField_040", 0, async function (done) { 1408 console.info('----------------------Sensor_GetGeomagneticField_040 max ---------------------------'); 1409 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0]).then((data) => { 1410 console.info('Sensor_GetGeomagneticField_040 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1411 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1412 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1413 }).catch((error) => { 1414 console.info("promise::catch", error) 1415 }); 1416 done() 1417 }) 1418 1419 /* 1420 * @tc.name:Sensor_GetGeomagneticField_041 1421 * @tc.desc:verify app info is not null 1422 * @tc.type: FUNC 1423 * @tc.require: Issue Number 1424 */ 1425 it("Sensor_GetGeomagneticField_041", 0, async function (done) { 1426 console.info('----------------------Sensor_GetGeomagneticField_041---------------------------'); 1427 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0]).then((data) => { 1428 console.info('Sensor_GetGeomagneticField_041 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1429 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1430 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1431 }).catch((error) => { 1432 console.info("promise::catch", error) 1433 }); 1434 done() 1435 }) 1436 1437 /* 1438 * @tc.name:Sensor_GetGeomagneticField_042 1439 * @tc.desc:verify app info is not null 1440 * @tc.type: FUNC 1441 * @tc.require: Issue Number 1442 */ 1443 it("Sensor_GetGeomagneticField_042", 0, async function (done) { 1444 console.info('----------------------Sensor_GetGeomagneticField_042---------------------------'); 1445 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0]).then((data) => { 1446 console.info('Sensor_GetGeomagneticField_042 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1447 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1448 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1449 }).catch((error) => { 1450 console.info("promise::catch", error) 1451 }); 1452 done() 1453 }) 1454 1455 /* 1456 * @tc.name:Sensor_GetGeomagneticField_043 1457 * @tc.desc:verify app info is not null 1458 * @tc.type: FUNC 1459 * @tc.require: Issue Number 1460 */ 1461 it('Sensor_GetGeomagneticField_043', 0, async function (done) { 1462 console.info('----------------------Sensor_GetGeomagneticField_043---------------------------'); 1463 for (var i = 0; i < GEOMAGNETIC_COORDINATES.length; i++) { 1464 await sensor.getGeomagneticInfo({'latitude':GEOMAGNETIC_COORDINATES[i][0], 'longitude':GEOMAGNETIC_COORDINATES[i][1], 'altitude':GEOMAGNETIC_COORDINATES[i][2]}, timeMillis[0]).then((data) => { 1465 console.info('Sensor_GetGeomagneticField_043 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1466 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1467 expect(data.x).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][0]) 1468 expect(data.y).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][1]) 1469 expect(data.z).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][2]) 1470 expect(data.deflectionAngle).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][3]) 1471 expect(data.geomagneticDip).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][4]) 1472 expect(data.levelIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][5]) 1473 expect(data.totalIntensity).assertEqual(GEOMAGNETIC_COMPONENT_COORDINATES_RESULT[i][6]) 1474 }).catch((error) => { 1475 console.info("promise::catch", error); 1476 }); 1477 } 1478 done() 1479 }) 1480 1481 /* 1482 * @tc.name:Sensor_GetGeomagneticField_044 1483 * @tc.desc:verify app info is not null 1484 * @tc.type: FUNC 1485 * @tc.require: Issue Number 1486 */ 1487 it("Sensor_GetGeomagneticField_044", 0, async function (done) { 1488 console.info('----------------------Sensor_GetGeomagneticField_044---------------------------'); 1489 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.MAX_VALUE, 'altitude':0}, timeMillis[0]).then((data) => { 1490 console.info('Sensor_GetGeomagneticField_044 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1491 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1492 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue(); 1493 }).catch((error) => { 1494 console.info("promise::catch", error); 1495 }); 1496 done() 1497 }) 1498 1499 /* 1500 * @tc.name:Sensor_GetGeomagneticField_045 1501 * @tc.desc:verify app info is not null 1502 * @tc.type: FUNC 1503 * @tc.require: Issue Number 1504 */ 1505 it("Sensor_GetGeomagneticField_045", 0, async function (done) { 1506 console.info('----------------------Sensor_GetGeomagneticField_045---------------------------'); 1507 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NaN, 'altitude':0}, timeMillis[0]).then((data) => { 1508 console.info('Sensor_GetGeomagneticField_045 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1509 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1510 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1511 }).catch((error) => { 1512 console.info("promise::catch", error); 1513 }); 1514 done() 1515 }) 1516 1517 /* 1518 * @tc.name:Sensor_GetGeomagneticField_046 1519 * @tc.desc:verify app info is not null 1520 * @tc.type: FUNC 1521 * @tc.require: Issue Number 1522 */ 1523 it("Sensor_GetGeomagneticField_046", 0, async function (done) { 1524 console.info('----------------------Sensor_GetGeomagneticField_046---------------------------'); 1525 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':Number.NEGATIVE_INFINITY, 'altitude':0}, timeMillis[0]).then((data) => { 1526 console.info('Sensor_GetGeomagneticField_046 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1527 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1528 expect(Number.isNaN(data.deflectionAngle) && Number.isNaN(data.geomagneticDip)).assertTrue() 1529 }).catch((error) => { 1530 console.info("promise::catch", error); 1531 }); 1532 done() 1533 }) 1534 1535 /* 1536 * @tc.name:Sensor_GetGeomagneticField_047 1537 * @tc.desc:verify app info is not null 1538 * @tc.type: FUNC 1539 * @tc.require: Issue Number 1540 */ 1541 it("Sensor_GetGeomagneticField_047", 0, async function (done) { 1542 console.info('----------------------Sensor_GetGeomagneticField_047---------------------------'); 1543 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.MAX_VALUE}, timeMillis[0]).then((data) => { 1544 console.info('Sensor_GetGeomagneticField_047 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1545 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1546 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1547 }).catch((error) => { 1548 console.info("promise::catch", error); 1549 }); 1550 done() 1551 }) 1552 1553 /* 1554 * @tc.name:Sensor_GetGeomagneticField_048 1555 * @tc.desc:verify app info is not null 1556 * @tc.type: FUNC 1557 * @tc.require: Issue Number 1558 */ 1559 it("Sensor_GetGeomagneticField_048", 0, async function (done) { 1560 console.info('----------------------Sensor_GetGeomagneticField_048---------------------------'); 1561 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NaN}, timeMillis[0]).then((data) => { 1562 console.info('Sensor_GetGeomagneticField_048 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1563 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1564 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1565 }).catch((error) => { 1566 console.info("promise::catch", error); 1567 }); 1568 done() 1569 }) 1570 1571 /* 1572 * @tc.name:Sensor_GetGeomagneticField_049 1573 * @tc.desc:verify app info is not null 1574 * @tc.type: FUNC 1575 * @tc.require: Issue Number 1576 */ 1577 it("Sensor_GetGeomagneticField_049", 0, async function (done) { 1578 console.info('----------------------Sensor_GetGeomagneticField_049---------------------------'); 1579 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0]).then((data) => { 1580 console.info('Sensor_GetGeomagneticField_049 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip 1581 + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity) 1582 expect(Number.isNaN(data.levelIntensity) && Number.isNaN(data.totalIntensity)).assertTrue() 1583 }).catch((error) => { 1584 console.info("promise::catch", error); 1585 }); 1586 done() 1587 }) 1588 1589 /* 1590 * @tc.name:Sensor_GetGeomagneticField_050 1591 * @tc.desc:verify app info is not null 1592 * @tc.type: FUNC 1593 * @tc.require: I5SWJI 1594 */ 1595 it("Sensor_GetGeomagneticField_050", 0, async function (done) { 1596 console.info('----------------------Sensor_GetGeomagneticField_050---------------------------'); 1597 try { 1598 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}).then((data) => { 1599 expect(true).assertfalse() 1600 }).catch((error) => { 1601 expect(true).assertfalse() 1602 }); 1603 done() 1604 } catch(err) { 1605 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1606 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1607 done() 1608 } 1609 }) 1610 1611 /* 1612 * @tc.name:Sensor_GetGeomagneticField_051 1613 * @tc.desc:verify app info is not null 1614 * @tc.type: FUNC 1615 * @tc.require: I5SWJI 1616 */ 1617 it("Sensor_GetGeomagneticField_051", 0, async function (done) { 1618 console.info('----------------------Sensor_GetGeomagneticField_051---------------------------'); 1619 try { 1620 await sensor.getGeomagneticInfo(-1, timeMillis[0]).then((data) => { 1621 expect(true).assertfalse() 1622 }).catch((error) => { 1623 expect(true).assertfalse() 1624 }); 1625 done() 1626 } catch(err) { 1627 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1628 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1629 done() 1630 } 1631 }) 1632 1633 /* 1634 * @tc.name:Sensor_GetGeomagneticField_052 1635 * @tc.desc:verify app info is not null 1636 * @tc.type: FUNC 1637 * @tc.require: I5SWJI 1638 */ 1639 it("Sensor_GetGeomagneticField_052", 0, async function (done) { 1640 console.info('----------------------Sensor_GetGeomagneticField_052---------------------------'); 1641 try { 1642 await sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, 'invalid').then((data) => { 1643 expect(true).assertfalse() 1644 }).catch((error) => { 1645 expect(true).assertfalse() 1646 }); 1647 done() 1648 } catch(err) { 1649 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1650 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1651 done() 1652 } 1653 }) 1654 1655 /* 1656 * @tc.name:Sensor_GetGeomagneticField_053 1657 * @tc.desc:verify app info is not null 1658 * @tc.type: FUNC 1659 * @tc.require: I5SWJI 1660 */ 1661 it("Sensor_GetGeomagneticField_053", 0, async function (done) { 1662 console.info('----------------------Sensor_GetGeomagneticField_053---------------------------'); 1663 try { 1664 await sensor.getGeomagneticInfo({'invalid':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0]).then((data) => { 1665 expect(true).assertfalse() 1666 }).catch((error) => { 1667 expect(true).assertfalse() 1668 }); 1669 done() 1670 } catch(err) { 1671 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1672 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1673 done() 1674 } 1675 }) 1676 1677 /* 1678 * @tc.name:Sensor_GetGeomagneticField_054 1679 * @tc.desc:verify app info is not null 1680 * @tc.type: FUNC 1681 * @tc.require: I5SWJI 1682 */ 1683 it("Sensor_GetGeomagneticField_054", 0, async function (done) { 1684 console.info('----------------------Sensor_GetGeomagneticField_054---------------------------'); 1685 try { 1686 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, (err, data) => { 1687 expect(false).assertTrue() 1688 setTimeout(() =>{ 1689 done() 1690 }, 500) 1691 }); 1692 } catch(err) { 1693 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1694 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1695 done() 1696 } 1697 }) 1698 1699 /* 1700 * @tc.name:Sensor_GetGeomagneticField_055 1701 * @tc.desc:verify app info is not null 1702 * @tc.type: FUNC 1703 * @tc.require: I5SWJI 1704 */ 1705 it("Sensor_GetGeomagneticField_055", 0, async function (done) { 1706 console.info('----------------------Sensor_GetGeomagneticField_055---------------------------'); 1707 try { 1708 await sensor.getGeomagneticInfo(-1, timeMillis[0], (err, data) => { 1709 expect(false).assertTrue() 1710 setTimeout(() =>{ 1711 done() 1712 }, 500) 1713 }); 1714 } catch(err) { 1715 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1716 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1717 done() 1718 } 1719 }) 1720 1721 /* 1722 * @tc.name:Sensor_GetGeomagneticField_056 1723 * @tc.desc:verify app info is not null 1724 * @tc.type: FUNC 1725 * @tc.require: I5SWJI 1726 */ 1727 it("Sensor_GetGeomagneticField_056", 0, async function (done) { 1728 console.info('----------------------Sensor_GetGeomagneticField_056---------------------------'); 1729 try { 1730 sensor.getGeomagneticInfo({'latitude':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, 'invalid', (err, data) => { 1731 expect(false).assertTrue() 1732 setTimeout(() =>{ 1733 done() 1734 }, 500) 1735 }); 1736 } catch(err) { 1737 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1738 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1739 done() 1740 } 1741 }) 1742 1743 /* 1744 * @tc.name:Sensor_GetGeomagneticField_057 1745 * @tc.desc:verify app info is not null 1746 * @tc.type: FUNC 1747 * @tc.require: I5SWJI 1748 */ 1749 it("Sensor_GetGeomagneticField_057", 0, async function (done) { 1750 console.info('----------------------Sensor_GetGeomagneticField_057---------------------------'); 1751 try { 1752 sensor.getGeomagneticInfo({'invalid':0, 'longitude':0, 'altitude':Number.NEGATIVE_INFINITY}, timeMillis[0], (err, data) => { 1753 expect(false).assertTrue() 1754 setTimeout(() =>{ 1755 done() 1756 }, 500) 1757 }); 1758 } catch(err) { 1759 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1760 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1761 done() 1762 } 1763 }) 1764 1765 var SENSOR_DATA_MATRIX = [ 1766 { 1767 "rotation": [-0.7980074882507324, 0.5486301183700562, 0.24937734007835388, -0.17277367413043976, 1768 -0.6047078967094421, 0.7774815559387207, 0.5773502588272095, 0.5773502588272095,0.5773502588272095], 1769 "inclination":[1, 0, 0, 0, 0.20444221794605255,0.9788785576820374, 0, -0.9788785576820374, 0.20444221794605255] 1770 }, 1771 { 1772 "rotation": [-0.8206444382667542, 0.3832680284976959, 0.42384934425354004, 0.021023601293563843, 1773 -0.7209705710411072,0.6926466822624207, 0.5710522532463074,0.57732754945755,0.5836028456687927], 1774 "inclination":[1, 0, 0, 0, 0.2584352493286133,0.9660285115242004, 0, -0.9660285115242004, 0.2584352493286133] 1775 }, 1776 { 1777 "rotation": [0.9583651423454285, 0.08038506656885147, -0.27399733662605286, 0.160231813788414, 1778 -0.9456362724304199, 0.2830156981945038, -0.23635157942771912, -0.3151354491710663, -0.9191450476646423], 1779 "inclination":[1, 0, 0, 0, 0.34239840507507324, 0.9395548701286316, 0, -0.9395548701286316, 0.34239840507507324] 1780 }, 1781 { 1782 "rotation":[null, null, null, null, null, null, null, null, null], 1783 "inclination":[1, 0, 0, 0, null, null, 0, null ,null] 1784 }, 1785 { 1786 "rotation":[null, null, null, null, null, null,0, 0, 0], 1787 "inclination":[1, 0, 0, 0, null, 0, 0, 0, null] 1788 } 1789 ] 1790 1791 let GET_DIRECTION = [ 1792 [ 0.38050639629364014, -0.9783217310905457, -0.6610431671142578], 1793 [-2.7610862255096436, 1.5018651485443115, 2.987273931503296], 1794 [0.32175055146217346, -1.006853699684143, -0.6857295036315918], 1795 [1.3332617282867432, -1.5440233945846558, -0.6627295017242432], 1796 [NaN, NaN, NaN], 1797 [0.7853981852531433, -0.6154797077178955, -0.7853981852531433], 1798 [0.7853981852531433, -0.7853981852531433, -0.7853981852531433], 1799 [0.785398, -0.615480, -0.785398], 1800 [0.785398, -0.785398, -0.785398] 1801 ] 1802 1803 let rotationMatrix = [ 1804 [1, 2, 3, 4, 5, 6, 7, 8, 9], 1805 [-1, -2, -3, -4, -5, -6, -7, -78, -45], 1806 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 1807 [11111111, 21111111, 31111111, 4111111, 5111111, 61111111, 71111111, 811111111, 91111111], 1808 [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN], 1809 [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], 1810 [3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39], 1811 [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], 1812 [3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39] 1813 ] 1814 1815 let gravity = [ 1816 [9, 9, 9], [91, 92, 93], [-9, -12, -35], [NaN, NaN, NaN], [3.40282e+38, 3.40282e+38, 3.40282e+38], [3.40282e+39, 3.40282e+39, 3.40282e+39] 1817 ] 1818 let geomagnetic = [ 1819 [30, 25, 41], [3, 2, 4], [-123, -456, -564], [3.40282e+38, 3.40282e+38, 3.40282e+38], [NaN, NaN, NaN] 1820 ] 1821 1822 /** 1823 * test 1824 * 1825 * @tc.name: Sensor_CreateRotationMatrix_001 1826 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1827 * @tc.require: I5SWJI 1828 * @tc.author: 1829 */ 1830 it('Sensor_CreateRotationMatrix_001', 0, async function (done) { 1831 sensor.getRotationMatrix(gravity[0], geomagnetic[0], (error,data)=>{ 1832 if (error) { 1833 console.info('Sensor_CreateRotationMatrix_001 failed'); 1834 expect(false).assertTrue(); 1835 } else { 1836 console.info("Sensor_CreateRotationMatrix_001" + JSON.stringify(data)) 1837 expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) 1838 } 1839 done() 1840 }) 1841 }) 1842 1843 /** 1844 * test 1845 * 1846 * @tc.name: Sensor_CreateRotationMatrix_002 1847 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1848 * @tc.require: I5SWJI 1849 * @tc.author: 1850 */ 1851 1852 it('Sensor_CreateRotationMatrix_002', 0, async function (done) { 1853 sensor.getRotationMatrix(gravity[2],geomagnetic[2],(error,data)=>{ 1854 if (error) { 1855 console.info('Sensor_CreateRotationMatrix_002 failed'); 1856 expect(false).assertTrue(); 1857 } else { 1858 console.info("Sensor_CreateRotationMatrix_002" + JSON.stringify(data)) 1859 expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[2])) 1860 } 1861 done() 1862 }) 1863 }) 1864 1865 /** 1866 * test 1867 * 1868 * @tc.name: Sensor_CreateRotationMatrix_003 1869 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1870 * @tc.require: I5SWJI 1871 * @tc.author: 1872 */ 1873 it('Sensor_CreateRotationMatrix_003', 0, async function (done) { 1874 sensor.getRotationMatrix(gravity[0],geomagnetic[0]).then((data) => { 1875 console.info("Sensor_CreateRotationMatrix_003" + JSON.stringify(data)) 1876 expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) 1877 done() 1878 }, (error) =>{ 1879 expect(false).assertTrue(); 1880 done() 1881 }) 1882 }) 1883 1884 /** 1885 * test 1886 * 1887 * @tc.name: Sensor_CreateRotationMatrix_004 1888 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1889 * @tc.require: I5SWJI 1890 * @tc.author: 1891 */ 1892 it('Sensor_CreateRotationMatrix_004', 0, async function (done) { 1893 sensor.getRotationMatrix(gravity[1],geomagnetic[1]).then((data) => { 1894 console.info("Sensor_CreateRotationMatrix_004" + JSON.stringify(data)) 1895 expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[1])) 1896 done() 1897 }, (error) =>{ 1898 expect(false).assertTrue(); 1899 done() 1900 }) 1901 }) 1902 1903 /** 1904 * test 1905 * 1906 * @tc.name: Sensor_CreateRotationMatrix_005 1907 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1908 * @tc.require: I5SWJI 1909 * @tc.author: 1910 */ 1911 it('Sensor_CreateRotationMatrix_005', 0, async function (done) { 1912 sensor.getRotationMatrix(gravity[2],geomagnetic[2]).then((data) => { 1913 console.info("Sensor_CreateRotationMatrix_005" + JSON.stringify(data)) 1914 expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[2])) 1915 done() 1916 }, (error) =>{ 1917 expect(false).assertTrue(); 1918 done() 1919 }) 1920 }) 1921 1922 /** 1923 * test 1924 * 1925 * @tc.name: Sensor_CreateRotationMatrix_006 1926 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1927 * @tc.require: I5SWJI 1928 * @tc.author: 1929 */ 1930 it('Sensor_CreateRotationMatrix_006', 0, async function (done) { 1931 try { 1932 sensor.getRotationMatrix() 1933 } catch (err) { 1934 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1935 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1936 done() 1937 } 1938 }) 1939 1940 /** 1941 * test 1942 * 1943 * @tc.name: Sensor_CreateRotationMatrix_007 1944 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1945 * @tc.require: I5SWJI 1946 * @tc.author: 1947 */ 1948 it('Sensor_CreateRotationMatrix_007', 0, async function (done) { 1949 try { 1950 sensor.getRotationMatrix(-1) 1951 } catch (err) { 1952 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1953 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1954 done() 1955 } 1956 }) 1957 1958 /** 1959 * test 1960 * 1961 * @tc.name: Sensor_CreateRotationMatrix_008 1962 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1963 * @tc.require: I5SWJI 1964 * @tc.author: 1965 */ 1966 it('Sensor_CreateRotationMatrix_008', 0, async function (done) { 1967 try { 1968 sensor.getRotationMatrix(gravity[2], -1) 1969 } catch (err) { 1970 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1971 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1972 done() 1973 } 1974 }) 1975 1976 /** 1977 * test 1978 * 1979 * @tc.name: Sensor_CreateRotationMatrix_009 1980 * @tc.desc: Verification results of the incorrect parameters of the test interface. 1981 * @tc.require: I5SWJI 1982 * @tc.author: 1983 */ 1984 it('Sensor_CreateRotationMatrix_009', 0, async function (done) { 1985 try { 1986 sensor.getRotationMatrix().then((data) => { 1987 expect(true).assertfalse() 1988 done() 1989 }, (error) =>{ 1990 expect(true).assertfalse() 1991 done() 1992 }) 1993 } catch (err) { 1994 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 1995 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 1996 done() 1997 } 1998 }) 1999 2000 /** 2001 * test 2002 * 2003 * @tc.name: Sensor_CreateRotationMatrix_010 2004 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2005 * @tc.require: I5SWJI 2006 * @tc.author: 2007 */ 2008 it('Sensor_CreateRotationMatrix_010', 0, async function (done) { 2009 try { 2010 sensor.getRotationMatrix(-1).then((data) => { 2011 expect(true).assertfalse() 2012 done() 2013 }, (error) =>{ 2014 expect(true).assertfalse() 2015 done() 2016 }) 2017 } catch (err) { 2018 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2019 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2020 done() 2021 } 2022 }) 2023 2024 /** 2025 * test 2026 * 2027 * @tc.name: Sensor_CreateRotationMatrix_011 2028 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2029 * @tc.require: I5SWJI 2030 * @tc.author: 2031 */ 2032 it('Sensor_CreateRotationMatrix_011', 0, async function (done) { 2033 try { 2034 sensor.getRotationMatrix(gravity[2], -1).then((data) => { 2035 expect(true).assertfalse() 2036 done() 2037 }, (error) =>{ 2038 expect(true).assertfalse() 2039 done() 2040 }) 2041 } catch (err) { 2042 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2043 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2044 done() 2045 } 2046 }) 2047 2048 let createRotationMatrixResult = [ 2049 [0.6724675297737122,-0.10471208393573761,0.7326819896697998,0.06531608104705811,0.9944750070571899, 2050 0.08217836916446686,-0.7372390031814575,-0.007406365126371384,0.6755914688110352], 2051 [1,0,0,0,1,0,0,0,1] 2052 ] 2053 /* 2054 * @tc.name: Sensor_CreateRotationMatrix_012 2055 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2056 * @tc.require: I5SWJI 2057 * @tc.author: 2058 */ 2059 it('Sensor_CreateRotationMatrix_012', 0, async function (done) { 2060 console.info("Sensor_CreateRotationMatrix_012 start"); 2061 sensor.getRotationMatrix([-0.0245, 0.402, 0.0465], (error, data) =>{ 2062 console.info("Sensor_CreateRotationMatrix_012"); 2063 if (error) { 2064 console.info('Sensor_CreateRotationMatrix_012 failed'); 2065 expect(false).assertTrue(); 2066 } else { 2067 for(var i = 0;i < data.length; i++) { 2068 console.info("Sensor_CreateRotationMatrix_012 [" + i + ") = " + data[i]); 2069 expect(data[i]).assertEqual(createRotationMatrixResult[0][i]) 2070 } 2071 } 2072 done() 2073 }) 2074 console.info(LABEL + "Sensor_CreateRotationMatrix_012 end"); 2075 }) 2076 2077 /* 2078 * tc.name: Sensor_CreateRotationMatrix_013 2079 * tc.desc: Verfication results of the incorrect parameters of test interface. 2080 * tc.require: SR000GH2A2 2081 * @tc.author: 2082 */ 2083 it('Sensor_CreateRotationMatrix_013', 0,async function (done) { 2084 console.info('Sensor_CreateRotationMatrix_013 start') 2085 sensor.getRotationMatrix([-0.0245, 0.402, 0.0465]).then((data) => { 2086 for(var i = 0;i < data.length; i++) { 2087 console.info("Sensor_CreateRotationMatrix_013 [" + i + "] : " + data[i]); 2088 expect(data[i]).assertEqual(createRotationMatrixResult[0][i]) 2089 } 2090 done() 2091 },(error) => { 2092 expect(false).assertTrue(); 2093 console.info('promise failed', error) 2094 done() 2095 }) 2096 console.info( "Sensor_CreateRotationMatrix_013 end") 2097 }) 2098 2099 /* 2100 * tc.name: Sensor_CreateRotationMatrix_014 2101 * tc.desc: Verfication results of the incorrect parameters of test interface. 2102 * tc.require: I5SWJI 2103 * @tc.author: 2104 */ 2105 it('Sensor_CreateRotationMatrix_014', 0,async function (done) { 2106 console.info('Sensor_CreateRotationMatrix_014 start') 2107 sensor.getRotationMatrix([0, 0, 0]).then((data) => { 2108 for(var i = 0;i < data.length; i++) { 2109 console.info("Sensor_CreateRotationMatrix_014 [" + i + "] : " + data[i]); 2110 expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) 2111 } 2112 done() 2113 }, (error) => { 2114 expect(false).assertTrue(); 2115 console.info('promise failed', error) 2116 done() 2117 }) 2118 console.info( "Sensor_CreateRotationMatrix_014 end") 2119 }) 2120 2121 /** 2122 * test 2123 * 2124 * @tc.name: Sensor_GetDirection_001 2125 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2126 * @tc.require: I5SWJI 2127 * @tc.author: 2128 */ 2129 it('Sensor_GetDirection_001', 0, async function (done) { 2130 sensor.getOrientation(rotationMatrix[0],(error,data)=>{ 2131 if (error) { 2132 console.info('Sensor_GetDirection_001 failed'); 2133 expect(false).assertTrue(); 2134 } else { 2135 for (var i = 1; i < data.length; i++) { 2136 console.info("Sensor_GetDirection_001" + data[i]) 2137 expect(data[i]).assertEqual(GET_DIRECTION[0][i]) 2138 } 2139 } 2140 done() 2141 }) 2142 }) 2143 2144 /** 2145 * test 2146 * 2147 * @tc.name: Sensor_GetDirection_002 2148 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2149 * @tc.require: I5SWJI 2150 * @tc.author: 2151 */ 2152 it('Sensor_GetDirection_002', 0, async function (done) { 2153 sensor.getOrientation(rotationMatrix[1],function(error,data){ 2154 if (error) { 2155 console.info('Sensor_GetDirection_002 failed'); 2156 expect(false).assertTrue(); 2157 } else { 2158 for (var i = 1; i < data.length; i++) { 2159 console.info("Sensor_GetDirection_002" + data[i]) 2160 expect(data[i]).assertEqual(GET_DIRECTION[1][i]) 2161 } 2162 } 2163 done() 2164 }) 2165 }) 2166 2167 /** 2168 * test 2169 * 2170 * @tc.name: Sensor_GetDirection_003 2171 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2172 * @tc.require: AR000GH2RN 2173 * @tc.author: 2174 */ 2175 it('Sensor_GetDirection_003', 0, async function (done) { 2176 sensor.getOrientation(rotationMatrix[0]).then((data) => { 2177 for (var i = 0; i<data.length; i++) { 2178 console.info("Sensor_GetDirection_003" + data[i]) 2179 expect(data[i]).assertEqual(GET_DIRECTION[0][i]) 2180 } 2181 done() 2182 }, (error) =>{ 2183 expect(false).assertTrue(); 2184 done() 2185 }) 2186 }) 2187 2188 /** 2189 * test 2190 * 2191 * @tc.name: Sensor_GetDirection_004 2192 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2193 * @tc.require: AR000GH2RN 2194 * @tc.author: 2195 */ 2196 it('Sensor_GetDirection_004', 0, async function (done) { 2197 sensor.getOrientation(rotationMatrix[1]).then((data) => { 2198 for (var i = 0; i<data.length; i++) { 2199 console.info("Sensor_GetDirection_004" + data[i]) 2200 expect(data[i]).assertEqual(GET_DIRECTION[1][i]) 2201 } 2202 done() 2203 }, (error) =>{ 2204 expect(false).assertTrue(); 2205 done() 2206 }) 2207 }) 2208 2209 /** 2210 * test 2211 * 2212 * @tc.name: Sensor_GetDirection_005 2213 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2214 * @tc.require: AR000GH2RN 2215 * @tc.author: 2216 */ 2217 it('Sensor_GetDirection_005', 0, async function (done) { 2218 try { 2219 sensor.getOrientation([1,2,3,1,2,3,1,2,3,0]).then((data) => { 2220 for (var i = 0; i<data.length; i++) { 2221 console.info("Sensor_GetDirection_005 failed") 2222 expect(false).assertTrue(); 2223 } 2224 done() 2225 }, (error) =>{ 2226 expect(false).assertTrue(); 2227 console.info("Sensor_GetDirection_005 success") 2228 done() 2229 }) 2230 } catch (err) { 2231 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2232 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2233 done() 2234 } 2235 }) 2236 2237 /** 2238 * test 2239 * 2240 * @tc.name: Sensor_GetDirection_006 2241 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2242 * @tc.require: I5SWJI 2243 * @tc.author: 2244 */ 2245 it('Sensor_GetDirection_006', 0, async function (done) { 2246 try { 2247 sensor.getRotationMatrix() 2248 } catch (err) { 2249 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2250 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2251 done() 2252 } 2253 }) 2254 2255 /** 2256 * test 2257 * 2258 * @tc.name: Sensor_GetDirection_007 2259 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2260 * @tc.require: I5SWJI 2261 * @tc.author: 2262 */ 2263 it('Sensor_GetDirection_007', 0, async function (done) { 2264 try { 2265 sensor.getRotationMatrix(-1) 2266 } catch (err) { 2267 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2268 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2269 done() 2270 } 2271 }) 2272 2273 /** 2274 * test 2275 * 2276 * @tc.name: Sensor_GetDirection_008 2277 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2278 * @tc.require: I5SWJI 2279 * @tc.author: 2280 */ 2281 it('Sensor_GetDirection_008', 0, async function (done) { 2282 try { 2283 sensor.getRotationMatrix(rotationMatrix[1], -1) 2284 } catch (err) { 2285 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2286 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2287 done() 2288 } 2289 }) 2290 2291 /** 2292 * test 2293 * 2294 * @tc.name: Sensor_GetDirection_009 2295 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2296 * @tc.require: I5SWJI 2297 * @tc.author: 2298 */ 2299 it('Sensor_GetDirection_009', 0, async function (done) { 2300 try { 2301 sensor.getRotationMatrix().then((data) => { 2302 expect(true).assertfalse() 2303 done() 2304 }, (error) =>{ 2305 expect(true).assertfalse() 2306 done() 2307 }) 2308 } catch (err) { 2309 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2310 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2311 done() 2312 } 2313 }) 2314 2315 /** 2316 * test 2317 * 2318 * @tc.name: Sensor_GetDirection_010 2319 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2320 * @tc.require: I5SWJI 2321 * @tc.author: 2322 */ 2323 it('Sensor_GetDirection_010', 0, async function (done) { 2324 try { 2325 sensor.getRotationMatrix(-1).then((data) => { 2326 expect(true).assertfalse() 2327 done() 2328 }, (error) =>{ 2329 expect(true).assertfalse() 2330 done() 2331 }) 2332 } catch (err) { 2333 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2334 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2335 done() 2336 } 2337 }) 2338 2339 /** 2340 * test 2341 * 2342 * @tc.name: Sensor_GetDirection_011 2343 * @tc.desc: Verification results of the incorrect parameters of the test interface. 2344 * @tc.require: I5SWJI 2345 * @tc.author: 2346 */ 2347 it('Sensor_GetDirection_011', 0, async function (done) { 2348 try { 2349 sensor.getRotationMatrix(rotationMatrix[1], -1).then((data) => { 2350 expect(true).assertfalse() 2351 done() 2352 }, (error) =>{ 2353 expect(true).assertfalse() 2354 done() 2355 }) 2356 } catch (err) { 2357 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2358 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2359 done() 2360 } 2361 }) 2362 2363 let ANGLECHANGE_9_RESULT = [ 2364 [0.7853981852531433, NaN, -0.32175055146217346], //123123123 2365 [0.7853981852531433, NaN, -0.7853981852531433], //FLOAT.MAXVALUE 2366 [0.0, -0.0, -0.0], //FLOAT.MINVALUE 2367 [0.7853981852531433, NaN, -0.7853981852531433], //FLOAT.MAXVALUE+1 2368 ]; 2369 2370 /** 2371 * test 2372 * 2373 * @tc.name: Sensor_GetAngleModify_001 2374 * @tc.desc: 2375 * @tc.require: AR000GH2SL 2376 * @tc.author: 2377 */ 2378 it('Sensor_GetAngleModify_001', 0, async function (done) { 2379 console.info("SensorJsAPI--->Sensor_GetAngleModify_001"); 2380 sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], function(error, data) { 2381 if (error) { 2382 console.info('Sensor_GetAngleModify_001 failed'); 2383 expect(false).assertTrue(); 2384 } else { 2385 for(var i = 0; i < data.length; i++) { 2386 console.info("Sensor_GetAngleModify_001 [" + i + "] = " + data[i]); 2387 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && 2388 expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); 2389 } 2390 } 2391 done() 2392 }) 2393 }) 2394 2395 /** 2396 * test 2397 * 2398 * @tc.name: Sensor_GetAngleModify_002 2399 * @tc.desc: 2400 * @tc.require: AR000GH2SL 2401 * @tc.author: 2402 */ 2403 it('Sensor_GetAngleModify_002', 0, async function (done) { 2404 console.info("Sensor_GetAngleModify_002"); 2405 sensor.getAngleVariation([3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], 2406 [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], 2407 function(error, data) { 2408 if (error) { 2409 console.info('Sensor_GetAngleModify_002 failed'); 2410 expect(false).assertTrue(); 2411 } else { 2412 for(var i = 0; i < data.length; i++) { 2413 console.info("Sensor_GetAngleModify_002 [" + i + "] = " + data[i]); 2414 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[1][0]) && expect(Number.isNaN(data[1])).assertTrue() && 2415 expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[1][2]); 2416 } 2417 } 2418 done() 2419 }) 2420 }) 2421 2422 /** 2423 * test 2424 * 2425 * @tc.name: Sensor_GetAngleModify_003 2426 * @tc.desc: 2427 * @tc.require: AR000GH2SL 2428 * @tc.author: 2429 */ 2430 it('Sensor_GetAngleModify_003', 0, async function (done) { 2431 console.info("Sensor_GetAngleModify_003 in"); 2432 sensor.getAngleVariation([1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38], 2433 [1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38], 2434 function(error, data) { 2435 if (error) { 2436 console.info('Sensor_GetAngleModify_003 failed'); 2437 expect(false).assertTrue(); 2438 } else { 2439 for(var i = 0; i < data.length; i++) { 2440 console.info("Sensor_GetAngleModify_003 [" + i + "] = " + data[i]); 2441 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[2][0]) 2442 && expect(data[1]).assertEqual(ANGLECHANGE_9_RESULT[2][1]) 2443 && expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[2][2]); 2444 } 2445 } 2446 done() 2447 }); 2448 }) 2449 2450 /** 2451 * test 2452 * 2453 * @tc.name: Sensor_GetAngleModify_004 2454 * @tc.desc: 2455 * @tc.require: AR000GH2SL 2456 * @tc.author: 2457 */ 2458 it('Sensor_GetAngleModify_004', 0, async function (done) { 2459 console.info("Sensor_GetAngleModify_004"); 2460 sensor.getAngleVariation([3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1], 2461 [3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1, 3.40282e+38+1], 2462 function(error, data) { 2463 if (error) { 2464 console.info('Sensor_GetAngleModify_004 failed'); 2465 expect(false).assertTrue(); 2466 } else { 2467 for(var i = 0; i < data.length; i++) { 2468 console.info("Sensor_GetAngleModify_004 [" + i + "] = " + data[i]); 2469 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[3][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[3][2]); 2470 } 2471 } 2472 done() 2473 }); 2474 }) 2475 2476 /** 2477 * test 2478 * 2479 * @tc.name: Sensor_GetAngleModify_005 2480 * @tc.desc: 2481 * @tc.require: AR000GH2SL 2482 * @tc.author: 2483 */ 2484 it('Sensor_GetAngleModify_005', 0, async function (done) { 2485 console.info("Sensor_GetAngleModify_005 in"); 2486 sensor.getAngleVariation([0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0], 2487 [0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0], 2488 function(error, data) { 2489 if (error) { 2490 console.info('Sensor_GetAngleModify_005 failed'); 2491 expect(false).assertTrue(); 2492 } else { 2493 for(var i = 0; i < data.length; i++) { 2494 console.info("Sensor_GetAngleModify_005 [" + i + "] = " + data[i]); 2495 expect(Number.isNaN(data[0]) && Number.isNaN(data[1]) && Number.isNaN(data[2])).assertTrue(); 2496 } 2497 } 2498 done() 2499 }); 2500 }) 2501 2502 /** 2503 * test 2504 * 2505 * @tc.name: Sensor_GetAngleModify_006 2506 * @tc.desc: 2507 * @tc.require: AR000GH2SL 2508 * @tc.author: 2509 */ 2510 it('Sensor_GetAngleModify_006', 0, async function (done) { 2511 console.info("Sensor_GetAngleModify_006 in"); 2512 sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2]).then((data) => { 2513 for(var i = 0; i < data.length; i++) { 2514 console.info("Sensor_GetAngleModify_006 [" + i + "] = " + data[i]); 2515 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && 2516 expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); 2517 } 2518 done(); 2519 }, (error) =>{ 2520 expect(false).assertTrue(); 2521 done() 2522 }) 2523 }) 2524 2525 /** 2526 * test 2527 * 2528 * @tc.name: Sensor_GetAngleModify_007 2529 * @tc.desc: 2530 * @tc.require: AR000GH2SL 2531 * @tc.author: 2532 */ 2533 it('Sensor_GetAngleModify_007', 0, async function (done) { 2534 console.info("Sensor_GetAngleModify_007 in"); 2535 sensor.getAngleVariation([3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], 2536 [3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38]).then((data) => { 2537 for(var i = 0; i < data.length; i++) { 2538 console.info("Sensor_GetAngleModify_007 [" + i + "] = " + data[i]); 2539 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[1][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[1][2]); 2540 } 2541 done() 2542 }, (error) =>{ 2543 expect(false).assertTrue(); 2544 done() 2545 }) 2546 }) 2547 2548 /** 2549 * test 2550 * 2551 * @tc.name: Sensor_GetAngleModify_008 2552 * @tc.desc: 2553 * @tc.require: AR000GH2SL 2554 * @tc.author: 2555 */ 2556 it('Sensor_GetAngleModify_008', 0, async function (done) { 2557 console.info("Sensor_GetAngleModify_008 in"); 2558 sensor.getAngleVariation([1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38], 2559 [1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38, 1.17549e-38]).then((data) => { 2560 for(var i = 0; i < data.length; i++) { 2561 console.info("Sensor_GetAngleModify_008 [" + i + "] = " + data[i]); 2562 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[2][0]) 2563 && expect(data[1]).assertEqual(ANGLECHANGE_9_RESULT[2][1]) 2564 && expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[2][2]); 2565 } 2566 done() 2567 }, (error) =>{ 2568 expect(false).assertTrue(); 2569 done() 2570 }) 2571 }) 2572 2573 /** 2574 * test 2575 * 2576 * @tc.name: Sensor_GetAngleModify_009 2577 * @tc.desc: 2578 * @tc.require: AR000GH2SL 2579 * @tc.author: 2580 */ 2581 it('Sensor_GetAngleModify_009', 0, async function (done) { 2582 console.info("Sensor_GetAngleModify_009 in"); 2583 sensor.getAngleVariation([3.40282e+38 + 1,3.40282e+38 + 1,3.40282e+38 + 1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1], 2584 [3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1,3.40282e+38+1]) 2585 .then((data) => { 2586 for(var i = 0; i < data.length; i++) { 2587 console.info("Sensor_GetAngleModify_009 [" + i + "] = " + data[i]); 2588 expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[3][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[3][2]); 2589 } 2590 done() 2591 }, (error) =>{ 2592 expect(false).assertTrue(); 2593 done() 2594 }) 2595 }) 2596 2597 /** 2598 * test 2599 * 2600 * @tc.name: Sensor_GetAngleModify_010 2601 * @tc.desc: 2602 * @tc.require: AR000GH2SL 2603 * @tc.author: 2604 */ 2605 it('Sensor_GetAngleModify_010', 0, async function (done) { 2606 console.info("Sensor_GetAngleModify_010 in"); 2607 sensor.getAngleVariation([0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0], 2608 [0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0]).then((data) => { 2609 for(var i = 0; i < data.length; i++) { 2610 console.info("Sensor_GetAngleModify_010 [" + i + "] = " + data[i]); 2611 expect(Number.isNaN(data[0]) && Number.isNaN(data[1]) && Number.isNaN(data[2])).assertTrue(); 2612 } 2613 done() 2614 }, (error) =>{ 2615 expect(false).assertTrue(); 2616 done() 2617 }) 2618 }) 2619 2620 /* 2621 * @tc.name:Sensor_GetAngleModify_011 2622 * @tc.desc:verify app info is not null 2623 * @tc.type: FUNC 2624 * @tc.require: I5SWJI 2625 */ 2626 it("Sensor_GetAngleModify_011", 0, async function (done) { 2627 console.info('----------------------Sensor_GetAngleModify_011---------------------------'); 2628 try { 2629 await sensor.getAngleVariation([1,2,3,1,2,3,1,2,3]).then((data) => { 2630 expect(true).assertfalse() 2631 }).catch((error) => { 2632 expect(true).assertfalse() 2633 }); 2634 done() 2635 } catch(err) { 2636 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2637 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2638 done() 2639 } 2640 }) 2641 2642 /* 2643 * @tc.name:Sensor_GetAngleModify_012 2644 * @tc.desc:verify app info is not null 2645 * @tc.type: FUNC 2646 * @tc.require: I5SWJI 2647 */ 2648 it("Sensor_GetAngleModify_012", 0, async function (done) { 2649 console.info('----------------------Sensor_GetAngleModify_012---------------------------'); 2650 try { 2651 await sensor.getAngleVariation(-1, [2,2,2,2,2,2,2,2,2]).then((data) => { 2652 expect(true).assertfalse() 2653 }).catch((error) => { 2654 expect(true).assertfalse() 2655 }); 2656 done() 2657 } catch(err) { 2658 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2659 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2660 done() 2661 } 2662 }) 2663 2664 /* 2665 * @tc.name:Sensor_GetAngleModify_013 2666 * @tc.desc:verify app info is not null 2667 * @tc.type: FUNC 2668 * @tc.require: I5SWJI 2669 */ 2670 it("Sensor_GetAngleModify_013", 0, async function (done) { 2671 console.info('----------------------Sensor_GetAngleModify_013---------------------------'); 2672 try { 2673 await sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], 'invalid').then((data) => { 2674 expect(true).assertfalse() 2675 }).catch((error) => { 2676 expect(true).assertfalse() 2677 }); 2678 done() 2679 } catch(err) { 2680 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2681 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2682 done() 2683 } 2684 }) 2685 2686 /* 2687 * @tc.name:Sensor_GetAngleModify_014 2688 * @tc.desc:verify app info is not null 2689 * @tc.type: FUNC 2690 * @tc.require: I5SWJI 2691 */ 2692 it("Sensor_GetAngleModify_014", 0, async function (done) { 2693 console.info('----------------------Sensor_GetAngleModify_014---------------------------'); 2694 try { 2695 sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], (err, data) => { 2696 expect(false).assertTrue() 2697 setTimeout(() =>{ 2698 done() 2699 }, 500) 2700 }); 2701 } catch(err) { 2702 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2703 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2704 done() 2705 } 2706 }) 2707 2708 /* 2709 * @tc.name:Sensor_GetAngleModify_015 2710 * @tc.desc:verify app info is not null 2711 * @tc.type: FUNC 2712 * @tc.require: I5SWJI 2713 */ 2714 it("Sensor_GetAngleModify_015", 0, async function (done) { 2715 console.info('----------------------Sensor_GetAngleModify_015---------------------------'); 2716 try { 2717 await sensor.getAngleVariation(-1, [2,2,2,2,2,2,2,2,2], (err, data) => { 2718 expect(false).assertTrue() 2719 setTimeout(() =>{ 2720 done() 2721 }, 500) 2722 }); 2723 } catch(err) { 2724 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2725 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2726 done() 2727 } 2728 }) 2729 2730 /* 2731 * @tc.name:Sensor_GetAngleModify_016 2732 * @tc.desc:verify app info is not null 2733 * @tc.type: FUNC 2734 * @tc.require: I5SWJI 2735 */ 2736 it("Sensor_GetAngleModify_016", 0, async function (done) { 2737 console.info('----------------------Sensor_GetAngleModify_016---------------------------'); 2738 try { 2739 sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], 'invalid', (err, data) => { 2740 expect(false).assertTrue() 2741 setTimeout(() =>{ 2742 done() 2743 }, 500) 2744 }); 2745 } catch(err) { 2746 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2747 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2748 done() 2749 } 2750 }) 2751 2752 var result = [ 2753 [0.7441122531890869, 0.5199999809265137, -0.335999995470047, -0.25099998712539673], 2754 [0, 3.402820018375656e+38, 3.402820018375656e+38, 3.402820018375656e+38], 2755 [1, 0, 0, 0], 2756 [0.7183529734611511, -0.32499998807907104, -0.5619999766349792, -0.25], 2757 [0, 0, 0, 0] 2758 ] 2759 2760 /* 2761 * @tc.name: Sensor_CreateQuaterniont_001 2762 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2763 * @tc.require: AR000GH2RP 2764 * @tc.author: 2765 */ 2766 it('Sensor_CreateQuaterniont_001', 0,async function (done) { 2767 console.info('Sensor_CreateQuaterniont_001 start') 2768 sensor.getQuaternion([0.52, -0.336, -0.251], (error, data) =>{ 2769 console.info('Sensor_CreateQuaterniont_001' + 'lengh:' + data.length); 2770 if (error) { 2771 console.info('Sensor_CreateQuaterniont_001 failed'); 2772 expect(false).assertTrue(); 2773 } else { 2774 for (var i = 0; i < data.length; i++) { 2775 console.info("data[" + i + "]: " + data[i]) 2776 expect(data[i]).assertEqual(result[0][i]) 2777 } 2778 } 2779 done() 2780 }) 2781 }) 2782 2783 /* 2784 * @tc.name: Sensor_CreateQuaterniont_002 2785 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2786 * @tc.require: AR000GH2RP 2787 * @tc.author: 2788 */ 2789 it('Sensor_CreateQuaterniont_002', 0,async function (done) { 2790 console.info('Sensor_CreateQuaterniont_002 start') 2791 sensor.getQuaternion([3.40282e+38, 3.40282e+38, 3.40282e+38], (error, data) =>{ 2792 if (error) { 2793 console.info('Sensor_CreateQuaterniont_002 failed'); 2794 expect(false).assertTrue(); 2795 } else { 2796 for (var i = 0; i < data.length; i++) { 2797 console.info("data[" + i + "]: " + data[i]) 2798 expect(data[i]).assertEqual(result[1][i]) 2799 } 2800 } 2801 done() 2802 }) 2803 }) 2804 2805 /* 2806 * @tc.name: Sensor_CreateQuaterniont_003 2807 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2808 * @tc.require: AR000GH2RP 2809 * @tc.author: 2810 */ 2811 it('Sensor_CreateQuaterniont_003', 0,async function (done) { 2812 console.info('Sensor_CreateQuaterniont_003 start') 2813 sensor.getQuaternion([0, 0, 0], (error, data) =>{ 2814 if (error) { 2815 console.info('Sensor_CreateQuaterniont_003 failed'); 2816 expect(false).assertTrue(); 2817 } else { 2818 for (var i = 0; i < data.length; i++) { 2819 console.info("data[" + i + "]: " + data[i]) 2820 expect(data[i]).assertEqual(result[2][i]) 2821 } 2822 } 2823 done() 2824 }) 2825 console.info("Sensor_CreateQuaterniont_003 end") 2826 }) 2827 2828 /* 2829 * @tc.name: Sensor_CreateQuaterniont_004 2830 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2831 * @tc.require: AR000GH2RP 2832 * @tc.author: 2833 */ 2834 it('Sensor_CreateQuaterniont_004', 0,async function (done) { 2835 console.info('Sensor_CreateQuaterniont_004 start') 2836 sensor.getQuaternion([-0.325, -0.562, -0.25], (error, data) =>{ 2837 if (error) { 2838 console.info('Sensor_CreateQuaterniont_004 failed'); 2839 expect(false).assertTrue(); 2840 } else { 2841 for (var i = 0; i < data.length; i++) { 2842 console.info("data[" + i + "]: " + data[i]) 2843 expect(data[i]).assertEqual(result[3][i]) 2844 } 2845 } 2846 done() 2847 }) 2848 console.info("Sensor_CreateQuaterniont_004 end") 2849 }) 2850 2851 /* 2852 * @tc.name: Sensor_CreateQuaterniont_005 2853 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2854 * @tc.require: AR000GH2RP 2855 * @tc.author: 2856 */ 2857 it('Sensor_CreateQuaterniont_005', 0,async function (done) { 2858 console.info('Sensor_CreateQuaterniont_005 start') 2859 try { 2860 sensor.getQuaternion([0.25, 0.14], (error, data) =>{ 2861 if (error) { 2862 expect(false).assertTrue(); 2863 } else { 2864 expect(false).assertTrue(); 2865 } 2866 done() 2867 }) 2868 } catch (err) { 2869 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2870 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2871 done() 2872 } 2873 console.info("Sensor_CreateQuaterniont_005 end") 2874 }) 2875 2876 /* 2877 * @tc.name: Sensor_CreateQuaterniont_006 2878 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2879 * @tc.require: AR000GH2RP 2880 * @tc.author: 2881 */ 2882 it('Sensor_CreateQuaterniont_006', 0,async function (done) { 2883 console.info('Sensor_CreateQuaterniont_006 start') 2884 sensor.getQuaternion([0.52, -0.336, -0.251]).then((data) => { 2885 console.info('Sensor_CreateQuaterniont_006'); 2886 for (var i = 0; i < data.length; i++) { 2887 console.info("data[" + i + "]: " + data[i]); 2888 expect(data[i]).assertEqual(result[0][i]) 2889 } 2890 done() 2891 }, (error) => { 2892 expect(false).assertTrue(); 2893 console.info('promise failed') 2894 done() 2895 }) 2896 console.info("Sensor_CreateQuaterniont_006 end") 2897 }) 2898 2899 /* 2900 * @tc.name: Sensor_CreateQuaterniont_007 2901 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2902 * @tc.require: AR000GH2RP 2903 * @tc.author: 2904 */ 2905 it('Sensor_CreateQuaterniont_007', 0,async function (done) { 2906 console.info('Sensor_CreateQuaterniont_007 start') 2907 try { 2908 sensor.getQuaternion([0, 0]).then((data) => { 2909 console.info('Sensor_CreateQuaterniont_007'); 2910 expect(false).assertTrue(); 2911 done() 2912 }, (error) => { 2913 expect(false).assertTrue(); 2914 console.info('promise failed') 2915 done() 2916 }) 2917 } catch (err) { 2918 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2919 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2920 done() 2921 } 2922 console.info("Sensor_CreateQuaterniont_007 end") 2923 }) 2924 2925 /* 2926 * @tc.name: Sensor_CreateQuaterniont_008 2927 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2928 * @tc.require: AR000GH2RP 2929 * @tc.author: 2930 */ 2931 it('Sensor_CreateQuaterniont_008', 0,async function (done) { 2932 console.info('Sensor_CreateQuaterniont_008 start') 2933 sensor.getQuaternion([0, 0, 0]).then((data) => { 2934 console.info('Sensor_CreateQuaterniont_008'); 2935 for (var i = 0; i < data.length; i++) { 2936 console.info("data[" + i + "]: " + data[i]); 2937 expect(data[i]).assertEqual(result[2][i]) 2938 } 2939 done() 2940 }, (error) => { 2941 expect(false).assertTrue(); 2942 console.info('promise failed') 2943 done() 2944 }) 2945 console.info("Sensor_CreateQuaterniont_008 end") 2946 }) 2947 2948 /* 2949 * @tc.name: Sensor_CreateQuaterniont_009 2950 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2951 * @tc.require: AR000GH2RP 2952 * @tc.author: 2953 */ 2954 it('Sensor_CreateQuaterniont_009', 0,async function (done) { 2955 console.info('Sensor_CreateQuaterniont_009 start') 2956 sensor.getQuaternion([-0.325, -0.562, -0.25]).then((data) => { 2957 console.info('Sensor_CreateQuaterniont_009'); 2958 for (var i = 0; i < data.length; i++) { 2959 console.info("data[" + i + "]: " + data[i]); 2960 expect(data[i]).assertEqual(result[3][i]) 2961 } 2962 done() 2963 },(error) => { 2964 expect(false).assertTrue(); 2965 console.info('promise failed') 2966 done() 2967 }) 2968 }) 2969 2970 /* 2971 * @tc.name: Sensor_CreateQuaterniont_010 2972 * @tc.desc: Verfication results of the incorrect parameters of test interface. 2973 * @tc.require: AR000GH2RP 2974 * @tc.author: 2975 */ 2976 it('Sensor_CreateQuaterniont_010', 0,async function (done) { 2977 console.info('Sensor_CreateQuaterniont_010 start') 2978 try { 2979 sensor.getQuaternion([0.25, 0.14]).then((data) => { 2980 console.info('Sensor_CreateQuaterniont_010'); 2981 expect(false).assertTrue(); 2982 done() 2983 },(error) => { 2984 expect(false).assertTrue(); 2985 console.info('promise failed') 2986 done() 2987 }) 2988 } catch (err) { 2989 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 2990 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 2991 done() 2992 } 2993 }) 2994 2995 /* 2996 * test 2997 * 2998 * @tc.name: Sensor_CreateQuaterniont_011 2999 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3000 * @tc.require: I5SWJI 3001 * @tc.author: 3002 */ 3003 it('Sensor_CreateQuaterniont_011', 0, async function (done) { 3004 try { 3005 sensor.createQuaternion() 3006 } catch (err) { 3007 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3008 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3009 done() 3010 } 3011 }) 3012 3013 /* 3014 * test 3015 * 3016 * @tc.name: Sensor_CreateQuaterniont_012 3017 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3018 * @tc.require: I5SWJI 3019 * @tc.author: 3020 */ 3021 it('Sensor_CreateQuaterniont_012', 0, async function (done) { 3022 try { 3023 sensor.createQuaternion(-1) 3024 } catch (err) { 3025 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3026 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3027 done() 3028 } 3029 }) 3030 3031 /* 3032 * test 3033 * 3034 * @tc.name: Sensor_CreateQuaterniont_013 3035 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3036 * @tc.require: I5SWJI 3037 * @tc.author: 3038 */ 3039 it('Sensor_CreateQuaterniont_013', 0, async function (done) { 3040 try { 3041 sensor.createQuaternion([0.52, -0.336, -0.251], -1) 3042 } catch (err) { 3043 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3044 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3045 done() 3046 } 3047 }) 3048 3049 /* 3050 * test 3051 * 3052 * @tc.name: Sensor_CreateQuaterniont_014 3053 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3054 * @tc.require: I5SWJI 3055 * @tc.author: 3056 */ 3057 it('Sensor_CreateQuaterniont_014', 0, async function (done) { 3058 try { 3059 sensor.createQuaternion().then((data) => { 3060 expect(true).assertfalse() 3061 done() 3062 }, (error) =>{ 3063 expect(false).assertfalse() 3064 done() 3065 }) 3066 } catch (err) { 3067 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3068 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3069 done() 3070 } 3071 }) 3072 3073 /* 3074 * test 3075 * 3076 * @tc.name: Sensor_CreateQuaterniont_015 3077 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3078 * @tc.require: I5SWJI 3079 * @tc.author: 3080 */ 3081 it('Sensor_CreateQuaterniont_015', 0, async function (done) { 3082 try { 3083 sensor.createQuaternion(-1).then((data) => { 3084 expect(true).assertfalse() 3085 done() 3086 }, (error) =>{ 3087 expect(false).assertfalse() 3088 done() 3089 }) 3090 } catch (err) { 3091 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3092 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3093 done() 3094 } 3095 }) 3096 3097 /* 3098 * test 3099 * 3100 * @tc.name: Sensor_CreateQuaterniont_016 3101 * @tc.desc: Verification results of the incorrect parameters of the test interface. 3102 * @tc.require: I5SWJI 3103 * @tc.author: 3104 */ 3105 it('Sensor_CreateQuaterniont_016', 0, async function (done) { 3106 try { 3107 sensor.createQuaternion([0.52, -0.336, -0.251], -1).then((data) => { 3108 expect(true).assertfalse() 3109 done() 3110 }, (error) =>{ 3111 expect(false).assertfalse() 3112 done() 3113 }) 3114 } catch (err) { 3115 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3116 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3117 done() 3118 } 3119 }) 3120 3121 var getGeomagneticDipResult = [ 0.8760581016540527, 0.862170, -Infinity, 44330] 3122 3123 /* 3124 * @tc.name: Sensor_GetGeomagneticDip_001 3125 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3126 * @tc.require: AR000GH2OG 3127 * @tc.author: 3128 */ 3129 it('Sensor_GetGeomagneticDip_001', 0, async function (done) { 3130 console.info('Sensor_GetGeomagneticDip_001 start') 3131 sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], (error, data) => { 3132 if (error) { 3133 console.info('Sensor_GetGeomagneticDip_001 failed'); 3134 expect(false).assertTrue(); 3135 } else { 3136 console.info("Sensor_GetGeomagneticDip_001" + data) 3137 expect(data).assertEqual(getGeomagneticDipResult[0]) 3138 } 3139 done() 3140 console.info('Sensor_GetGeomagneticDip_001' + 'lengh:' + data.length); 3141 }) 3142 console.info("Sensor_GetGeomagneticDip_001 end") 3143 }) 3144 3145 /* 3146 * @tc.name: Sensor_GetGeomagneticDip_002 3147 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3148 * @tc.require: AR000GH2OG 3149 * @tc.author: 3150 */ 3151 it('Sensor_GetGeomagneticDip_002', 0, async function (done) { 3152 console.info('Sensor_GetGeomagneticDip_002 start') 3153 try { 3154 sensor.getInclination([1, 2, 3, 4], (error,data) => { 3155 if (error) { 3156 expect(false).assertTrue(); 3157 } else { 3158 expect(false).assertTrue(); 3159 } 3160 done() 3161 }) 3162 } catch (err) { 3163 expect(err.code).assertEqual(PARAMETER_ERROR_CODE) 3164 expect(err.message).assertEqual(PARAMETER_ERROR_MSG) 3165 done() 3166 } 3167 console.info("Sensor_GetGeomagneticDip_002 end") 3168 }) 3169 3170 /* 3171 * @tc.name: Sensor_GetGeomagneticDip_003 3172 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3173 * @tc.require: I5SWJI 3174 * @tc.author: 3175 */ 3176 it('Sensor_GetGeomagneticDip_003', 0, async function (done) { 3177 console.info('Sensor_GetGeomagneticDip_003 start') 3178 try { 3179 sensor.getInclination() 3180 } catch(error) { 3181 console.info(error); 3182 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3183 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3184 done(); 3185 } 3186 console.info("Sensor_GetGeomagneticDip_003 end") 3187 }) 3188 3189 /* 3190 * @tc.name: Sensor_GetGeomagneticDip_004 3191 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3192 * @tc.require: I5SWJI 3193 * @tc.author: 3194 */ 3195 it('Sensor_GetGeomagneticDip_004', 0, async function (done) { 3196 console.info('Sensor_GetGeomagneticDip_004 start') 3197 try { 3198 sensor.getInclination(-1, (error, data) => { 3199 if (error) { 3200 console.info('Sensor_GetGeomagneticDip_004 failed'); 3201 expect(false).assertTrue(); 3202 } else { 3203 console.info("Sensor_GetGeomagneticDip_004" + data) 3204 expect(data).assertEqual(getGeomagneticDipResult[0]) 3205 } 3206 done() 3207 console.info('Sensor_GetGeomagneticDip_004' + 'lengh:' + data.length); 3208 }) 3209 } catch(error) { 3210 console.info(error); 3211 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3212 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3213 done(); 3214 } 3215 console.info("Sensor_GetGeomagneticDip_004 end") 3216 }) 3217 3218 /* 3219 * @tc.name: Sensor_GetGeomagneticDip_005 3220 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3221 * @tc.require: I5SWJI 3222 * @tc.author: 3223 */ 3224 it('Sensor_GetGeomagneticDip_005', 0, async function (done) { 3225 console.info('Sensor_GetGeomagneticDip_005 start') 3226 try { 3227 sensor.getInclination().then((data)=>{ 3228 console.info("Sensor_GetGeomagneticDip_005" + data) 3229 expect(true).assertfalse() 3230 done() 3231 }, (error)=>{ 3232 expect(true).assertfalse() 3233 done() 3234 }) 3235 } catch(error) { 3236 console.info(error); 3237 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3238 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3239 done(); 3240 } 3241 console.info("Sensor_GetGeomagneticDip_005 end") 3242 }) 3243 3244 /* 3245 * @tc.name: Sensor_GetGeomagneticDip_006 3246 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3247 * @tc.require: I5SWJI 3248 * @tc.author: 3249 */ 3250 it('Sensor_GetGeomagneticDip_006', 0, async function (done) { 3251 console.info('Sensor_GetGeomagneticDip_006 start') 3252 try { 3253 sensor.getInclination(-1).then((data)=>{ 3254 console.info("Sensor_GetGeomagneticDip_006" + data) 3255 expect(true).assertfalse() 3256 done() 3257 }, (error)=>{ 3258 expect(true).assertfalse() 3259 done() 3260 }) 3261 } catch(error) { 3262 console.info(error); 3263 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3264 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3265 done(); 3266 } 3267 console.info("Sensor_GetGeomagneticDip_006 end") 3268 }) 3269 3270 /* 3271 * @tc.name: Sensor_GetAltitude_001 3272 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3273 * @tc.require: AR000GH2OG 3274 * @tc.author: 3275 */ 3276 it('Sensor_GetAltitude_001', 0, async function (done) { 3277 console.info('Sensor_GetAltitude_001 start') 3278 sensor.getDeviceAltitude(0, 100, (error, data) => { 3279 if (error) { 3280 console.info('Sensor_GetAltitude_001 failed'); 3281 expect(false).assertTrue(); 3282 } else { 3283 console.info("Sensor_GetAltitude_001" + data) 3284 expect(data).assertEqual(getGeomagneticDipResult[2]) 3285 } 3286 done() 3287 console.info("Sensor_GetAltitude_001 end") 3288 }) 3289 }) 3290 3291 /* 3292 * @tc.name: Sensor_GetAltitude_002 3293 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3294 * @tc.require: AR000GH2OG 3295 * @tc.author: 3296 */ 3297 it('Sensor_GetAltitude_002', 0, async function (done) { 3298 console.info('Sensor_GetAltitude_002 start') 3299 sensor.getDeviceAltitude(5, 0, (error, data) => { 3300 if (error) { 3301 console.info('Sensor_GetAltitude_002 failed'); 3302 expect(false).assertTrue(); 3303 } else { 3304 console.info("Sensor_GetAltitude_002" + data) 3305 expect(data).assertEqual(getGeomagneticDipResult[3]) 3306 } 3307 done() 3308 }) 3309 console.info("Sensor_GetAltitude_002 end") 3310 }) 3311 3312 /* 3313 * @tc.name: Sensor_GetAltitude_003 3314 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3315 * @tc.require: AR000GH2OG 3316 * @tc.author: 3317 */ 3318 it('Sensor_GetAltitude_003', 0, async function (done) { 3319 sensor.getDeviceAltitude(0, 100).then((data)=>{ 3320 console.info("Sensor_GetAltitude_003" + data) 3321 expect(data).assertEqual(getGeomagneticDipResult[2]) 3322 done() 3323 }, (error)=>{ 3324 console.info('Sensor_GetAltitude_003 failed'); 3325 expect(false).assertTrue(); 3326 done() 3327 }); 3328 }) 3329 3330 /* 3331 * @tc.name: Sensor_GetAltitude_004 3332 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3333 * @tc.require: AR000GH2OG 3334 * @tc.author: 3335 */ 3336 it('Sensor_GetAltitude_004', 0, async function (done) { 3337 sensor.getDeviceAltitude(5, 0).then((data)=>{ 3338 console.info("Sensor_GetAltitude_004" + data) 3339 expect(data).assertEqual(getGeomagneticDipResult[3]) 3340 done() 3341 }, (error)=>{ 3342 console.info('Sensor_GetAltitude_004 failed'); 3343 expect(false).assertTrue(); 3344 done() 3345 }); 3346 }) 3347 3348 /* 3349 * @tc.name: Sensor_GetAltitude_005 3350 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3351 * @tc.require: I5SWJI 3352 * @tc.author: 3353 */ 3354 it('Sensor_GetAltitude_005', 0, async function (done) { 3355 console.info('Sensor_GetAltitude_005 start') 3356 try { 3357 sensor.getDeviceAltitude() 3358 } catch(error) { 3359 console.info(error); 3360 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3361 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3362 done(); 3363 } 3364 console.info("Sensor_GetAltitude_005 end") 3365 }) 3366 3367 /* 3368 * @tc.name: Sensor_GetAltitude_006 3369 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3370 * @tc.require: I5SWJI 3371 * @tc.author: 3372 */ 3373 it('Sensor_GetAltitude_006', 0, async function (done) { 3374 console.info('Sensor_GetAltitude_006 start') 3375 try { 3376 sensor.getDeviceAltitude("invalid", 0, (error, data) => { 3377 if (error) { 3378 console.info('Sensor_GetAltitude_006 failed'); 3379 expect(false).assertTrue(); 3380 } else { 3381 console.info("Sensor_GetAltitude_006" + data) 3382 expect(data).assertEqual(getGeomagneticDipResult[0]) 3383 } 3384 done() 3385 console.info('Sensor_GetAltitude_006' + 'lengh:' + data.length); 3386 }) 3387 } catch(error) { 3388 console.info(error); 3389 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3390 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3391 done(); 3392 } 3393 console.info("Sensor_GetGeomagneticDip_004 end") 3394 }) 3395 3396 /* 3397 * @tc.name: Sensor_GetAltitude_007 3398 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3399 * @tc.require: I5SWJI 3400 * @tc.author: 3401 */ 3402 it('Sensor_GetAltitude_007', 0, async function (done) { 3403 console.info('Sensor_GetAltitude_007 start') 3404 try { 3405 sensor.getDeviceAltitude().then((data)=>{ 3406 console.info("Sensor_GetAltitude_007" + data) 3407 expect(true).assertfalse() 3408 done() 3409 }, (error)=>{ 3410 expect(true).assertfalse() 3411 done() 3412 }) 3413 } catch(error) { 3414 console.info(error); 3415 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3416 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3417 done(); 3418 } 3419 console.info("Sensor_GetAltitude_007 end") 3420 }) 3421 3422 /* 3423 * @tc.name: Sensor_GetAltitude_008 3424 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3425 * @tc.require: I5SWJI 3426 * @tc.author: 3427 */ 3428 it('Sensor_GetAltitude_008', 0, async function (done) { 3429 console.info('Sensor_GetAltitude_008 start') 3430 try { 3431 sensor.getDeviceAltitude("invalid", 0).then((data)=>{ 3432 console.info("Sensor_GetAltitude_008" + data) 3433 expect(true).assertfalse() 3434 done() 3435 }, (error)=>{ 3436 expect(true).assertfalse() 3437 done() 3438 }) 3439 } catch(error) { 3440 console.info(error); 3441 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3442 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3443 done(); 3444 } 3445 console.info("Sensor_GetAltitude_008 end") 3446 }) 3447 3448 let transformCoordinateSystemResult = [ 3449 [1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000], 3450 [340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 3451 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 3452 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000, 340282001837565600000000000000000000000.000000], 3453 [Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity]] 3454 3455 /* 3456 * @tc.name: Sensor_TransformCoordinateSystem_001 3457 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3458 * @tc.require: AR000GH2TR 3459 * @tc.author: 3460 */ 3461 it('Sensor_TransformCoordinateSystem_001', 0, async function (done) { 3462 console.info("---------------------------Sensor_TransformCoordinateSystem_001----------------------------------"); 3463 sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, (error, data) => { 3464 if (error) { 3465 console.info('Sensor_TransformCoordinateSystem_001 failed'); 3466 expect(false).assertTrue(); 3467 } else { 3468 console.info("Sensor_TransformCoordinateSystem_001 " + JSON.stringify(data)); 3469 expect(JSON.stringify(data)).assertEqual(JSON.stringify(transformCoordinateSystemResult[0])) 3470 } 3471 done() 3472 }) 3473 }) 3474 3475 /* 3476 * @tc.name: Sensor_TransformCoordinateSystem_002 3477 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3478 * @tc.require: AR000GH2TR 3479 * @tc.author: 3480 */ 3481 it('Sensor_TransformCoordinateSystem_002', 0, async function (done) { 3482 console.info("---------------------------Sensor_TransformCoordinateSystem_002----------------------------------"); 3483 sensor.transformRotationMatrix([3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38, 3.40282e+38], {'x':1, 'y':2}, (error, data) => { 3484 if (error) { 3485 console.info('Sensor_TransformCoordinateSystem_002 failed'); 3486 expect(false).assertTrue(); 3487 } else { 3488 console.info("Sensor_TransformCoordinateSystem_002 " + JSON.stringify(data)); 3489 expect(JSON.stringify(data)).assertEqual(JSON.stringify(transformCoordinateSystemResult[1])) 3490 } 3491 done() 3492 }) 3493 }) 3494 3495 /* 3496 * @tc.name: Sensor_TransformCoordinateSystem_003 3497 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3498 * @tc.require: AR000GH2TR 3499 * @tc.author: 3500 */ 3501 it("Sensor_TransformCoordinateSystem_003", 0, async function (done) { 3502 console.info("---------------------------Sensor_TransformCoordinateSystem_003----------------------------------"); 3503 sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}).then((data) => { 3504 for (var i = 0; i < data.length; i++) { 3505 console.info("Sensor_TransformCoordinateSystem_003 data[ " + i + "] = " + data[i]); 3506 expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); 3507 } 3508 done() 3509 }, (error)=>{ 3510 console.info('Sensor_TransformCoordinateSystem_003 failed'); 3511 expect(false).assertTrue(); 3512 done() 3513 }); 3514 }) 3515 3516 /* 3517 * @tc.name: Sensor_TransformCoordinateSystem_004 3518 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3519 * @tc.require: AR000GH2TR 3520 * @tc.author: 3521 */ 3522 it("Sensor_TransformCoordinateSystem_004", 0, async function (done) { 3523 console.info("---------------------------Sensor_TransformCoordinateSystem_004----------------------------------"); 3524 sensor.transformRotationMatrix([3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39, 3.40282e+39], {'x':1, 'y':3}).then((data) => { 3525 for (var i = 0; i < data.length; i++) { 3526 console.info("Sensor_TransformCoordinateSystem_004 data[ " + i + "] = " + data[i]); 3527 expect(data[i]).assertEqual(transformCoordinateSystemResult[2][i]); 3528 } 3529 done() 3530 }, (error)=>{ 3531 console.info('Sensor_TransformCoordinateSystem_004 failed'); 3532 expect(false).assertTrue(); 3533 done() 3534 }); 3535 }) 3536 3537 /* 3538 * @tc.name: Sensor_TransformCoordinateSystem_005 3539 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3540 * @tc.require: I5SWJI 3541 * @tc.author: 3542 */ 3543 it('Sensor_TransformCoordinateSystem_005', 0, async function (done) { 3544 console.info('Sensor_TransformCoordinateSystem_005 start') 3545 try { 3546 sensor.transformRotationMatrix() 3547 } catch(error) { 3548 console.info(error); 3549 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3550 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3551 done(); 3552 } 3553 console.info("Sensor_TransformCoordinateSystem_005 end") 3554 }) 3555 3556 /* 3557 * @tc.name: Sensor_TransformCoordinateSystem_006 3558 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3559 * @tc.require: I5SWJI 3560 * @tc.author: 3561 */ 3562 it('Sensor_TransformCoordinateSystem_006', 0, async function (done) { 3563 console.info('Sensor_TransformCoordinateSystem_006 start') 3564 try { 3565 sensor.transformRotationMatrix("invalid", 0, (error, data) => { 3566 if (error) { 3567 console.info('Sensor_TransformCoordinateSystem_006 failed'); 3568 expect(false).assertTrue(); 3569 } else { 3570 console.info("Sensor_TransformCoordinateSystem_006" + data) 3571 expect(data).assertEqual(getGeomagneticDipResult[0]) 3572 } 3573 done() 3574 }) 3575 } catch(error) { 3576 console.info(error); 3577 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3578 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3579 done(); 3580 } 3581 console.info("Sensor_GetGeomagneticDip_004 end") 3582 }) 3583 3584 /* 3585 * @tc.name: Sensor_TransformCoordinateSystem_007 3586 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3587 * @tc.require: I5SWJI 3588 * @tc.author: 3589 */ 3590 it('Sensor_TransformCoordinateSystem_007', 0, async function (done) { 3591 console.info('Sensor_TransformCoordinateSystem_007 start') 3592 try { 3593 sensor.transformRotationMatrix().then((data)=>{ 3594 console.info("Sensor_TransformCoordinateSystem_007" + data) 3595 expect(true).assertfalse() 3596 done() 3597 }, (error)=>{ 3598 expect(true).assertfalse() 3599 done() 3600 }) 3601 } catch(error) { 3602 console.info(error); 3603 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3604 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3605 done(); 3606 } 3607 console.info("Sensor_TransformCoordinateSystem_007 end") 3608 }) 3609 3610 /* 3611 * @tc.name: Sensor_TransformCoordinateSystem_008 3612 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3613 * @tc.require: I5SWJI 3614 * @tc.author: 3615 */ 3616 it('Sensor_TransformCoordinateSystem_008', 0, async function (done) { 3617 console.info('Sensor_TransformCoordinateSystem_008 start') 3618 try { 3619 sensor.transformRotationMatrix("invalid", 0).then((data)=>{ 3620 console.info("Sensor_TransformCoordinateSystem_008" + data) 3621 expect(true).assertfalse() 3622 done() 3623 }, (error)=>{ 3624 expect(true).assertfalse() 3625 done() 3626 }) 3627 } catch(error) { 3628 console.info(error); 3629 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3630 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3631 done(); 3632 } 3633 console.info("Sensor_TransformCoordinateSystem_008 end") 3634 }) 3635 3636 /* 3637 * @tc.name: Sensor_TransformCoordinateSystem_009 3638 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3639 * @tc.require: I5SWJI 3640 * @tc.author: 3641 */ 3642 it('Sensor_TransformCoordinateSystem_009', 0, async function (done) { 3643 console.info('Sensor_TransformCoordinateSystem_008 start') 3644 try { 3645 sensor.transformRotationMatrix([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], {'x':1, 'y':1}).then((data)=>{ 3646 console.info("Sensor_TransformCoordinateSystem_009" + data) 3647 expect(true).assertfalse() 3648 done() 3649 }, (error)=>{ 3650 expect(true).assertfalse() 3651 done() 3652 }) 3653 } catch(error) { 3654 console.info(error); 3655 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3656 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3657 done(); 3658 } 3659 console.info("Sensor_TransformCoordinateSystem_009 end") 3660 }) 3661 3662 /* 3663 * @tc.name: Sensor_TransformCoordinateSystem_010 3664 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3665 * @tc.require: I5SWJI 3666 * @tc.author: 3667 */ 3668 it('Sensor_TransformCoordinateSystem_010', 0, async function (done) { 3669 console.info('Sensor_TransformCoordinateSystem_010 start') 3670 try { 3671 sensor.transformRotationMatrix([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], {'x':1, 'y':1}, (error, data) => { 3672 if (error) { 3673 console.info('Sensor_TransformCoordinateSystem_010 failed'); 3674 expect(false).assertTrue(); 3675 } else { 3676 console.info("Sensor_TransformCoordinateSystem_010" + data) 3677 expect(data).assertEqual(getGeomagneticDipResult[0]) 3678 } 3679 done() 3680 }) 3681 } catch(error) { 3682 console.info(error); 3683 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3684 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3685 done(); 3686 } 3687 console.info("Sensor_TransformCoordinateSystem_010 end") 3688 }) 3689 3690 /* 3691 * @tc.name: Sensor_GetSensorList_001 3692 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3693 * @tc.require: AR000GH2TR 3694 * @tc.author: 3695 */ 3696 it("Sensor_GetSensorList_001", 0, async function (done) { 3697 console.info("---------------------------Sensor_GetSensorList_001----------------------------------"); 3698 sensor.getSensorList().then((data) => { 3699 console.info("---------------------------Sensor_GetSensorList_001 callback in-----------" + data.length); 3700 for (var i = 0; i < data.length; i++) { 3701 console.info("Sensor_GetSensorList_001 " + JSON.stringify(data[i])); 3702 } 3703 expect(true).assertTrue(); 3704 done(); 3705 }, (error)=>{ 3706 console.info('Sensor_GetSensorList_001 failed'); 3707 expect(false).assertTrue(); 3708 done(); 3709 }); 3710 }) 3711 3712 /* 3713 * @tc.name: Sensor_GetSensorList_002 3714 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3715 * @tc.require: AR000GH2TR 3716 * @tc.author: 3717 */ 3718 it("Sensor_GetSensorList_002", 0, async function (done) { 3719 console.info("---------------------------Sensor_GetSensorList_002----------------------------------"); 3720 sensor.getSensorList((error, data) => { 3721 if (error) { 3722 console.info('Sensor_GetSensorList_002 failed'); 3723 expect(false).assertTrue(); 3724 } else { 3725 console.info("---------------------------Sensor_GetSensorList_002 callback in-----------" + data.length); 3726 for (var i = 0; i < data.length; i++) { 3727 console.info("Sensor_GetSensorList_002 " + JSON.stringify(data[i])); 3728 } 3729 expect(true).assertTrue(); 3730 } 3731 done(); 3732 }); 3733 }) 3734 3735 /* 3736 * @tc.name: Sensor_GetSensorList_003 3737 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3738 * @tc.require: AR000GH2TR 3739 * @tc.author: 3740 */ 3741 it("Sensor_GetSensorList_003", 0, async function (done) { 3742 console.info("---------------------------Sensor_GetSensorList_003----------------------------------"); 3743 try { 3744 sensor.getSensorList(-1); 3745 } catch(error) { 3746 console.info(error); 3747 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3748 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3749 done(); 3750 } 3751 }) 3752 3753 /* 3754 * @tc.name: Sensor_GetSensorList_004 3755 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3756 * @tc.require: AR000GH2TR 3757 * @tc.author: 3758 */ 3759 it("Sensor_GetSensorList_004", 0, async function (done) { 3760 console.info("---------------------------Sensor_GetSensorList_004----------------------------------"); 3761 try { 3762 sensor.getSensorList(-1).then(data => { 3763 console.info("Sensor_GetSingleSensor_003 " + JSON.stringify(data)); 3764 expect(false).assertTrue(); 3765 done(); 3766 }), (error => { 3767 console.info(error); 3768 expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE); 3769 expect(error.code).assertEqual(SERVICE_EXCEPTION_MSG); 3770 done(); 3771 }); 3772 } catch(error) { 3773 console.info(error); 3774 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3775 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3776 done(); 3777 } 3778 }) 3779 3780 /* 3781 * @tc.name: Sensor_GetSingleSensor_001 3782 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3783 * @tc.require: AR000GH2TR 3784 * @tc.author: 3785 */ 3786 it("Sensor_GetSingleSensor_001", 0, async function (done) { 3787 console.info("---------------------------Sensor_GetSingleSensor_001----------------------------------"); 3788 sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (error, data) => { 3789 if (error) { 3790 console.info('Sensor_GetSingleSensor_001 failed'); 3791 expect(false).assertTrue(); 3792 } else { 3793 console.info("---------------------------Sensor_GetSingleSensor_001 callback in-----------" + data.length); 3794 console.info("Sensor_GetSingleSensor_001 " + JSON.stringify(data)); 3795 expect(true).assertTrue(); 3796 } 3797 done(); 3798 }); 3799 }) 3800 3801 /* 3802 * @tc.name: Sensor_GetSingleSensor_002 3803 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3804 * @tc.require: AR000GH2TR 3805 * @tc.author: 3806 */ 3807 it("Sensor_GetSingleSensor_002", 0, async function (done) { 3808 console.info("---------------------------Sensor_GetSingleSensor_002----------------------------------"); 3809 try { 3810 sensor.getSingleSensor(-1, (error, data) => { 3811 if (error) { 3812 console.info('Sensor_GetSingleSensor_002 failed'); 3813 expect(true).assertTrue(); 3814 } else { 3815 console.info("---------------------------Sensor_GetSingleSensor_002 callback in-----------" + data.length); 3816 console.info("Sensor_GetSingleSensor_002 " + JSON.stringify(data)); 3817 expect(false).assertTrue(); 3818 } 3819 done(); 3820 }); 3821 } catch(error) { 3822 console.info(error); 3823 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3824 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3825 done(); 3826 } 3827 }) 3828 3829 /* 3830 * @tc.name: Sensor_GetSingleSensor_003 3831 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3832 * @tc.require: AR000GH2TR 3833 * @tc.author: 3834 */ 3835 it("Sensor_GetSingleSensor_003", 0, async function (done) { 3836 console.info("---------------------------SensorJsTest_114----------------------------------"); 3837 sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => { 3838 console.info("Sensor_GetSingleSensor_003 " + JSON.stringify(data)); 3839 expect(true).assertTrue(); 3840 done(); 3841 }, (error)=>{ 3842 console.info('Sensor_GetSingleSensor_003 failed'); 3843 expect(false).assertTrue(); 3844 done(); 3845 }); 3846 }) 3847 3848 /* 3849 * @tc.name: Sensor_GetSingleSensor_004 3850 * @tc.desc: Verfication results of the incorrect parameters of test interface. 3851 * @tc.require: AR000GH2TR 3852 * @tc.author: 3853 */ 3854 it("Sensor_GetSingleSensor_004", 0, async function (done) { 3855 console.info("---------------------------Sensor_GetSingleSensor_004----------------------------------"); 3856 try { 3857 sensor.getSingleSensor(-1).then((data) => { 3858 console.info("Sensor_GetSingleSensor_004 " + JSON.stringify(data)); 3859 expect(false).assertTrue(); 3860 done(); 3861 }, (error)=>{ 3862 console.info('Sensor_GetSingleSensor_004 success'); 3863 expect(true).assertTrue(); 3864 done(); 3865 }); 3866 } catch(error) { 3867 console.info(error); 3868 expect(error.code).assertEqual(PARAMETER_ERROR_CODE); 3869 expect(error.message).assertEqual(PARAMETER_ERROR_MSG); 3870 done(); 3871 } 3872 }) 3873 3874 /* 3875 * @tc.name:Sensor_SubscribeAccelerometer_001 3876 * @tc.desc:verify app info is not null 3877 * @tc.type: FUNC 3878 * @tc.require: AR000GH2TR 3879 */ 3880 it("Sensor_SubscribeAccelerometer_001", 0, async function (done) { 3881 console.info('----------------------Sensor_SubscribeAccelerometer_001---------------------------'); 3882 sensor.subscribeAccelerometer({ 3883 interval: 'normal', 3884 success: function(data) { 3885 expect(typeof(data.x)).assertEqual("number"); 3886 expect(typeof(data.y)).assertEqual("number"); 3887 expect(typeof(data.z)).assertEqual("number"); 3888 console.info("SensorJsTest001 success" + JSON.stringify(data)); 3889 }, 3890 fail: function(data, code) { 3891 expect(false).assertTrue(); 3892 console.error('Subscription failed. Code: ' + code + '; Data: ' + data); 3893 }, 3894 }); 3895 setTimeout(()=>{ 3896 try { 3897 sensor.unsubscribeAccelerometer(); 3898 } catch (error) { 3899 console.info('SensorJsTest001 unsubscribe failed' + error); 3900 expect(false).assertTrue(); 3901 } 3902 setTimeout(()=>{ 3903 expect(true).assertTrue(); 3904 done(); 3905 }, 500); 3906 }, 1000); 3907 }) 3908 3909 /* 3910 * @tc.name:Sensor_SubscribeAccelerometer_002 3911 * @tc.desc:verify app info is not null 3912 * @tc.type: FUNC 3913 * @tc.require: AR000GH2TR 3914 */ 3915 it("Sensor_SubscribeAccelerometer_002", 0, async function (done) { 3916 console.info('----------------------Sensor_SubscribeAccelerometer_002---------------------------'); 3917 sensor.subscribeAccelerometer({ 3918 interval: 'xxx', 3919 success: function(data) { 3920 expect(false).assertTrue(); 3921 console.info("Sensor_SubscribeAccelerometer_002 success" + JSON.stringify(data)); 3922 done(); 3923 }, 3924 fail: function(data, code) { 3925 expect(true).assertTrue(); 3926 console.error('Sensor_SubscribeAccelerometer_002 Subscription failed. Code: ' + code + '; Data: ' + data); 3927 done(); 3928 }, 3929 }); 3930 }) 3931 3932 /* 3933 * @tc.name:Sensor_SubscribeAccelerometer_003 3934 * @tc.desc:verify app info is not null 3935 * @tc.type: FUNC 3936 * @tc.require: AR000GH2TR 3937 */ 3938 it("Sensor_SubscribeAccelerometer_003", 0, async function (done) { 3939 console.info('----------------------Sensor_SubscribeAccelerometer_003---------------------------'); 3940 try { 3941 sensor.subscribeAccelerometer({ 3942 interval: 'xxx', 3943 success: function(data) { 3944 expect(false).assertTrue(); 3945 console.info("Sensor_SubscribeAccelerometer_003 success" + JSON.stringify(data)); 3946 } 3947 }); 3948 } catch (error) { 3949 console.info('Sensor_SubscribeAccelerometer_003 Subscription failed' + error); 3950 expect(false).assertTrue(); 3951 } 3952 setTimeout(()=>{ 3953 expect(true).assertTrue(); 3954 done(); 3955 }, 500); 3956 }) 3957 3958 /* 3959 * @tc.name:Sensor_SubscribeAccelerometer_004 3960 * @tc.desc:verify app info is not null 3961 * @tc.type: FUNC 3962 * @tc.require: AR000GH2TR 3963 */ 3964 it("Sensor_SubscribeAccelerometer_004", 0, async function (done) { 3965 console.info('----------------------Sensor_SubscribeAccelerometer_004---------------------------'); 3966 try { 3967 sensor.subscribeAccelerometer({ 3968 interval: 'normal', 3969 }); 3970 } catch (error) { 3971 console.info('Sensor_SubscribeAccelerometer_004 Subscription failed' + error); 3972 expect(false).assertTrue(); 3973 } 3974 setTimeout(()=>{ 3975 expect(true).assertTrue(); 3976 done(); 3977 }, 500); 3978 }) 3979 3980 /* 3981 * @tc.name:Sensor_UnsubscribeAccelerometer_001 3982 * @tc.desc:verify app info is not null 3983 * @tc.type: FUNC 3984 * @tc.require: AR000GH2TR 3985 */ 3986 it("Sensor_UnsubscribeAccelerometer_001", 0, async function (done) { 3987 console.info('----------------------Sensor_UnsubscribeAccelerometer_001---------------------------'); 3988 try { 3989 sensor.unsubscribeAccelerometer(); 3990 } catch (error) { 3991 console.info(error); 3992 expect(false).assertTrue(); 3993 } 3994 setTimeout(()=>{ 3995 expect(true).assertTrue(); 3996 done(); 3997 }, 500); 3998 }) 3999 4000 /* 4001 * @tc.name:Sensor_UnsubscribeAccelerometer_002 4002 * @tc.desc:verify app info is not null 4003 * @tc.type: FUNC 4004 * @tc.require: AR000GH2TR 4005 */ 4006 it("Sensor_UnsubscribeAccelerometer_002", 0, async function (done) { 4007 console.info('----------------------Sensor_UnsubscribeAccelerometer_002---------------------------'); 4008 try { 4009 sensor.unsubscribeAccelerometer('xxx'); 4010 } catch (error) { 4011 console.info(error); 4012 expect(false).assertTrue(); 4013 } 4014 setTimeout(()=>{ 4015 expect(true).assertTrue(); 4016 done(); 4017 }, 500); 4018 }) 4019}) 4020