1/* 2 * Copyright (C) 2022 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 */ 15 16import geolocation from '@ohos.geolocation'; 17import geolocationm from '@ohos.geoLocationManager'; 18import abilityAccessCtrl from '@ohos.abilityAccessCtrl' 19import bundle from '@ohos.bundle' 20import osaccount from '@ohos.account.osAccount' 21import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' 22 23let LocationRequestScenario = { 24 UNSET: 0x300, 25 NAVIGATION: 0x301, 26 TRAJECTORY_TRACKING: 0x302, 27 CAR_HAILING: 0x303, 28 DAILY_LIFE_SERVICE: 0x304, 29 NO_POWER: 0x305 30} 31let LocationRequestPriority = { UNSET: 0x200, ACCURACY: 0x201, LOW_POWER: 0x202, FIRST_FIX: 0x203 } 32 33let LocationPrivacyType = { 34 OTHERS: 0, 35 STARTUP: 1, 36 CORE_LOCATION: 2 37} 38 39function sleep(ms) { 40 return new Promise(resolve => setTimeout(resolve, ms)); 41} 42 43async function changedLocationMode(){ 44 let result1 = geolocationm.isLocationEnabled(); 45 console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); 46 if(!result1){ 47 await geolocation.requestEnableLocation().then(async(result) => { 48 await sleep(1000); 49 console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); 50 }).catch((error) => { 51 console.info("[lbs_js] promise then error." + JSON.stringify(error)); 52 expect().assertFail(); 53 }); 54 } 55 let result2 = geolocationm.isLocationEnabled(); 56 console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2)); 57} 58 59async function applyPermission() { 60 let osAccountManager = osaccount.getAccountManager(); 61 console.info("=== getAccountManager finish"); 62 let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); 63 console.info("LocalId is :" + localId); 64 let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); 65 let atManager = abilityAccessCtrl.createAtManager(); 66 if (atManager != null) { 67 let tokenID = appInfo.accessTokenId; 68 console.info('[permission] case accessTokenID is ' + tokenID); 69 let permissionName1 = 'ohos.permission.LOCATION'; 70 let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; 71 await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { 72 console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); 73 }).catch((err) => { 74 console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); 75 }); 76 await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { 77 console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); 78 }).catch((err) => { 79 console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); 80 }); 81 } else { 82 console.info('[permission] case apply permission failed, createAtManager failed'); 83 } 84} 85 86export default function geolocationTest_geo5() { 87 88 describe('geolocationTest_geo5', function () { 89 90 console.log('#start AccessTokenTests#'); 91 beforeAll(async function (done) { 92 console.info('beforeAll case'); 93 await applyPermission(); 94 done(); 95 }) 96 97 beforeEach(async function (done) { 98 console.info('beforeEach case'); 99 await changedLocationMode(); 100 done(); 101 }) 102 103 104 /** 105 * @tc.number SUB_HSS_LocationSystem_Geo_1900 106 * @tc.name testIsGeoServiceAvailable 107 * @tc.desc Check whether address resolution and reverse address resolution are supported. 108 * @tc.size MEDIUM 109 * @tc.type Function 110 * @tc.level Level 2 111 */ 112 it('SUB_HSS_LocationSystem_Geo_1900', 0, function () { 113 try { 114 let geocoder1 = geolocationm.isGeocoderAvailable(); 115 console.info('[lbs_js] isGeocoderAvailable result: ' + JSON.stringify(geocoder1)); 116 expect(true).assertEqual(JSON.stringify(geocoder1) != null); 117 } catch (error) { 118 console.info('[lbs_js] isGeocoderAvailable err:' + JSON.stringify(error)); 119 console.info('[lbs_js] not support now'); 120 expect(error.code).assertEqual("801"); 121 } 122 }); 123 124 /** 125 * @tc.number SUB_HSS_LocationSystem_Geo_2000 126 * @tc.name TestgetAddressesFromLocation 127 * @tc.desc Address Resolution Test. 128 * @tc.size MEDIUM 129 * @tc.type Function 130 * @tc.level Level 2 131 */ 132 it('SUB_HSS_LocationSystem_Geo_2000', 0, async function (done) { 133 let geocoder1 = geolocationm.isGeocoderAvailable(); 134 if (geocoder1) { 135 let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 1 }; 136 try { 137 geolocationm.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { 138 if (err) { 139 console.info('[lbs_js] getAddressesFromLocation4 callback err is:' + JSON.stringify(err)); 140 expect(err.code).assertEqual(3301300); 141 } else { 142 console.info("[lbs_js] getAddressesFromLocation4 callback data is:" + JSON.stringify(data)); 143 expect(true).assertEqual((JSON.stringify(data)) != null); 144 } 145 }); 146 } catch (error) { 147 console.info("[lbs_js] getAddressesFromLocation4 callback try error:"+ error); 148 expect(true).assertFalse(); 149 } 150 await sleep(2000); 151 } else { 152 console.info("[lbs_js] The geocoding service is unavailable."); 153 } 154 done(); 155 }) 156 157 158 /** 159 * @tc.number SUB_HSS_LocationSystem_Geo_2100 160 * @tc.name TestgetAddressesFromLocation 161 * @tc.desc Address Resolution Test. 162 * @tc.size MEDIUM 163 * @tc.type Function 164 * @tc.level Level 2 165 */ 166 it('SUB_HSS_LocationSystem_Geo_2100', 0, async function (done) { 167 let geocoder1 = geolocationm.isGeocoderAvailable(); 168 if (geocoder1) { 169 try { 170 let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5}; 171 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { 172 console.info('[lbs_js] getAddressesFromLocation21 promise: ' + JSON.stringify(data)); 173 if(data!="") 174 { 175 console.info('addressUrl: ' + JSON.stringify(data[0].addressUrl) 176 +',administrativeArea: '+ JSON.stringify(data[0].administrativeArea) 177 +',countryCode: '+ JSON.stringify(data[0].countryCode) 178 +'countryName: '+ JSON.stringify(data[0].countryName ) 179 +',descriptions: '+ JSON.stringify(data[0].descriptions) 180 +',descriptionsSize: '+JSON.stringify(data[0].descriptionsSize) 181 +',latitude: '+ JSON.stringify(data[0].latitude) 182 +',locale: '+ JSON.stringify(data[0].locale) 183 +',locality:'+ JSON.stringify(data[0].locality) 184 +',longitude:'+ JSON.stringify(data[0].longitude) 185 +',phoneNumber: '+ JSON.stringify(data[0].phoneNumber) 186 +',placeName:'+ JSON.stringify(data[0].placeName) 187 + ',postalCode: '+JSON.stringify(data[0].postalCode) 188 + ',premises:'+JSON.stringify(data[0].premises) 189 + ',roadName:'+JSON.stringify(data[0].roadName) 190 + ',subAdministrativeArea:'+JSON.stringify(data[0].subAdministrativeArea) 191 + ',subLocality:'+JSON.stringify(data[0].subLocality ) 192 +',subRoadName:'+ JSON.stringify(data[0].subRoadName) 193 + ',isFromMock:'+JSON.stringify(data[0].isFromMock)); 194 } 195 }).catch(error => { 196 console.info("[lbs_js] getAddressesFromLocation21 promise then error." + JSON.stringify(error)); 197 console.info('[lbs_js] not support now'); 198 expect(error.code).assertEqual(3301300); 199 }); 200 } catch (error) { 201 console.info("[lbs_js] getAddressesFromLocation21 try err." + JSON.stringify(error)); 202 expect(true).assertFalse(); 203 } 204 await sleep(1000); 205 } else { 206 console.info("[lbs_js] The geocoding service is unavailable."); 207 } 208 done(); 209 }) 210 211 /** 212 * @tc.number SUB_HSS_LocationSystem_Geo_2200 213 * @tc.name TestgetAddressesFromLocation 214 * @tc.desc Obtaining Multiple Addresses Using the Address Resolution Function. 215 * @tc.size MEDIUM 216 * @tc.type Function 217 * @tc.level Level 2 218 */ 219 it('SUB_HSS_LocationSystem_Geo_2200', 0, async function (done) { 220 let geocoder1 = geolocationm.isGeocoderAvailable(); 221 if (geocoder1) { 222 try { 223 let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 121.62771, "maxItems": 5 }; 224 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { 225 console.info('[lbs_js] getAddressesFromLocation22 promise:' + JSON.stringify(data)); 226 expect(true).assertEqual((JSON.stringify(data)) != null); 227 }).catch((error) => { 228 console.info("[lbs_js] getAddressesFromLocation22 promise then error." + JSON.stringify(error)); 229 console.info('[lbs_js] not support now'); 230 expect(error.code).assertEqual(3301300); 231 }); 232 } catch (error) { 233 console.info("[lbs_js] getAddressesFromLocation22 try err." + JSON.stringify(error)); 234 expect(true).assertFalse(); 235 } 236 await sleep(1000); 237 } else { 238 console.info("[lbs_js] The geocoding service is unavailable."); 239 } 240 done(); 241 }) 242 243 /** 244 * @tc.number SUB_HSS_LocationSystem_Geo_2300 245 * @tc.name TestgetAddressesFromLocation 246 * @tc.desc Input parameter boundary test of the address resolution function 247 * @tc.size MEDIUM 248 * @tc.type Function 249 * @tc.level Level 2 250 */ 251 it('SUB_HSS_LocationSystem_Geo_2300', 0, async function (done) { 252 let geocoder1 = geolocationm.isGeocoderAvailable(); 253 if (geocoder1) { 254 let reverseGeocodeRequest1 = { "latitude": 90, "longitude": 121.62771, "maxItems": 1 }; 255 try { 256 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { 257 console.info('[lbs_js] getAddressesFromLocation2301 promise: ' + JSON.stringify(data)); 258 expect(true).assertEqual((JSON.stringify(data)) != null); 259 }).catch(error => { 260 console.info("[lbs_js] getAddressesFromLocation2301 promise then error." + JSON.stringify(error)); 261 console.info('[lbs_js] not support now'); 262 expect(error.code).assertEqual(3301300); 263 }); 264 } catch (error) { 265 console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); 266 expect(true).assertFalse(); 267 } 268 let reverseGeocodeRequest2 = { "latitude": 90.1, "longitude": 121.62771, "maxItems": 1 }; 269 try { 270 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { 271 console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data)); 272 expect(data.length).assertEqual(0); 273 }).catch(error => { 274 console.info("[lbs_js] getAddressesFromLocation2302 promise then error." + JSON.stringify(error)); 275 expect(true).assertFalse(); 276 }); 277 } catch (error) { 278 console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); 279 expect(error.code).assertEqual("401"); 280 } 281 let reverseGeocodeRequest3 = { "latitude": -90, "longitude": 121.62771, "maxItems": 1 }; 282 try { 283 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { 284 console.info('[lbs_js] getAddressesFromLocation2303 promise: ' + JSON.stringify(data)); 285 expect(true).assertEqual((JSON.stringify(data)) != null); 286 }).catch(error => { 287 console.info("[lbs_js] getAddressesFromLocation2303 promise then error." + JSON.stringify(error)); 288 console.info('[lbs_js] not support now'); 289 expect(error.code).assertEqual(3301300); 290 }); 291 } catch (error) { 292 console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); 293 expect(true).assertFalse(); 294 } 295 let reverseGeocodeRequest4 = { "latitude": -90.1, "longitude": 121.62771, "maxItems": 1 }; 296 try { 297 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest4).then((data) => { 298 console.info('[lbs_js] getAddressesFromLocation2304 promise: ' + JSON.stringify(data)); 299 expect(true).assertEqual((JSON.stringify(data)) != null); 300 }).catch(error => { 301 console.info("[lbs_js] getAddressesFromLocation2304 promise then error." + JSON.stringify(error)); 302 expect(true).assertFalse(); 303 }); 304 } catch (error) { 305 console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error)); 306 expect(error.code).assertEqual("401"); 307 } 308 await sleep(1000); 309 } else { 310 console.info("[lbs_js] The geocoding service is unavailable."); 311 } 312 done(); 313 }) 314 315 /** 316 * @tc.number SUB_HSS_LocationSystem_Geo_2400 317 * @tc.name TestgetAddressesFromLocation 318 * @tc.desc Input parameter boundary test of the address resolution function 319 * @tc.size MEDIUM 320 * @tc.type Function 321 * @tc.level Level 2 322 */ 323 it('SUB_HSS_LocationSystem_Geo_2400', 0, async function (done) { 324 let geocoder1 = geolocationm.isGeocoderAvailable(); 325 if (geocoder1) { 326 let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 }; 327 try { 328 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { 329 console.info('[lbs_js] getAddressesFromLocation2401 promise: ' + JSON.stringify(data)); 330 expect(true).assertEqual((JSON.stringify(data)) != null); 331 }).catch(error => { 332 console.info("[lbs_js] getAddressesFromLocation2401 promise then error." + JSON.stringify(error)); 333 console.info('[lbs_js] not support now'); 334 expect(error.code).assertEqual(3301300); 335 }); 336 } catch (error) { 337 console.info("[lbs_js] getAddressesFromLocation message1." + JSON.stringify(error)); 338 expect(true).assertFalse(); 339 } 340 await sleep(1000); 341 let reverseGeocodeRequest1 = { "latitude": 31.265496, "longitude": -180.1, "maxItems": 1 }; 342 try { 343 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { 344 console.info('[lbs_js] getAddressesFromLocation2402 promise: ' + JSON.stringify(data)); 345 expect(data.length).assertEqual(0); 346 }).catch(error => { 347 console.info("[lbs_js] getAddressesFromLocation2402 promise then error." + JSON.stringify(error)); 348 expect(true).assertFalse(); 349 }); 350 } catch (error) { 351 console.info("[lbs_js] getAddressesFromLocation message2." + JSON.stringify(error)); 352 expect(error.code).assertEqual("401"); 353 } 354 await sleep(1000); 355 let reverseGeocodeRequest2 = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 }; 356 try { 357 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => { 358 console.info('[lbs_js] getAddressesFromLocation2403 promise: ' + JSON.stringify(data)); 359 expect(true).assertEqual((JSON.stringify(data)) != null); 360 }).catch(error => { 361 console.info("[lbs_js] getAddressesFromLocation2403 promise then error." + JSON.stringify(error)); 362 console.info('[lbs_js] not support now'); 363 expect(error.code).assertEqual(3301300); 364 }); 365 } catch (error) { 366 console.info("[lbs_js] getAddressesFromLocation message3." + JSON.stringify(error)); 367 expect(true).assertFalse(); 368 } 369 await sleep(1000); 370 let reverseGeocodeRequest3 = { "latitude": 31.265496, "longitude": 180.1, "maxItems": 1 }; 371 try { 372 await geolocationm.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => { 373 console.info('[lbs_js] getAddressesFromLocation2404 promise: ' + JSON.stringify(data)); 374 expect(data.length).assertEqual(0); 375 }).catch(error => { 376 console.info("[lbs_js] getAddressesFromLocation2404 promise then error." + JSON.stringify(error)); 377 expect(true).assertFalse(); 378 }); 379 } catch (error) { 380 console.info("[lbs_js] getAddressesFromLocation message4." + JSON.stringify(error)); 381 expect(error.code).assertEqual("401"); 382 } 383 await sleep(1000); 384 } else { 385 console.info("[lbs_js] The geocoding service is unavailable."); 386 } 387 done(); 388 }) 389 390 391 /** 392 * @tc.number SUB_HSS_LocationSystem_Geo_2500 393 * @tc.name TestgetAddressesFromLocation 394 * @tc.desc Reverse address resolution test. 395 * @tc.size MEDIUM 396 * @tc.type Function 397 * @tc.level Level 2 398 */ 399 it('SUB_HSS_LocationSystem_Geo_2500', 0, async function (done) { 400 let geocoder1 = geolocationm.isGeocoderAvailable(); 401 if (geocoder1) { 402 try { 403 let geocodeRequest = { 404 "description": "上海市浦东新区金穗路1800号", 405 "maxItems": 1, 406 "locale": "zh", 407 }; 408 geolocationm.getAddressesFromLocationName(geocodeRequest, (err, data) => { 409 if (err) { 410 switch (err) { 411 case 100: 412 console.info("NOT_SUPPORTED: " + JSON.stringify(err)); 413 break; 414 case 101: 415 console.info("INPUT_PARAMS_ERROR: " + JSON.stringify(err)); 416 break; 417 case 102: 418 console.info("REVERSE_GEOCODE_ERROR: " + JSON.stringify(err)); 419 break; 420 case 103: 421 console.info("GEOCODE_ERROR: " + JSON.stringify(err)); 422 break; 423 case 104: 424 console.info("LOCATOR_ERROR: " + JSON.stringify(err)); 425 break; 426 case 105: 427 console.info("LOCATION_SWITCH_ERROR: " + JSON.stringify(err)); 428 break; 429 case 106: 430 console.info("LAST_KNOWN_LOCATION_ERROR: " + JSON.stringify(err)); 431 break; 432 case 107: 433 console.info("LOCATION_REQUEST_TIMEOUT_ERROR: " + JSON.stringify(err)); 434 break; 435 case 108: 436 console.info("QUERY_COUNTRY_CODE_ERROR: " + JSON.stringify(err)); 437 break; 438 default: 439 console.info('getAddressesFromLocationName callback err: ' + JSON.stringify(err)); 440 } 441 } 442 else { 443 console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data)); 444 } 445 done(); 446 }); 447 } catch (error) { 448 console.info("[lbs_js] getAddressesFromLocationName08 message." + JSON.stringify(error.message)); 449 expect(true).assertFalse(); 450 } 451 await sleep(1000); 452 } else { 453 console.info("[lbs_js] The geocoding service is unavailable."); 454 } 455 done(); 456 }) 457 458 /** 459 * @tc.number SUB_HSS_LocationSystem_Geo_2600 460 * @tc.name TestgetAddressesFromLocation 461 * @tc.desc Reverse address resolution test. 462 * @tc.size MEDIUM 463 * @tc.type Function 464 * @tc.level Level 2 465 */ 466 it('SUB_HSS_LocationSystem_Geo_2600', 0, async function (done) { 467 let geocoder1 = geolocationm.isGeocoderAvailable(); 468 if (geocoder1) { 469 let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 3 }; 470 try { 471 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 472 console.info("[lbs_js] getAddressesFromLocation09 callback data is:" + JSON.stringify(result)); 473 expect(true).assertEqual((JSON.stringify(result)) != null); 474 }).catch((error) => { 475 console.info("[lbs_js] getAddressesFromLocationName09 promise then error." + JSON.stringify(error)); 476 console.info('[lbs_js] not support now'); 477 expect(error.code).assertEqual(3301400); 478 }); 479 } catch (error) { 480 console.info("[lbs_js] getAddressesFromLocationName26 try err." + JSON.stringify(error)); 481 expect(true).assertFalse(); 482 } 483 await sleep(1000); 484 } else { 485 console.info("[lbs_js] The geocoding service is unavailable."); 486 } 487 done(); 488 }) 489 490 /** 491 * @tc.number SUB_HSS_LocationSystem_Geo_2700 492 * @tc.name TestgetAddressesFromLocation 493 * @tc.desc Obtaining Multiple Locations Using the Reverse Address Resolution Function. 494 * @tc.size MEDIUM 495 * @tc.type Function 496 * @tc.level Level 2 497 */ 498 it('SUB_HSS_LocationSystem_Geo_2700', 0, async function (done) { 499 let geocoder1 = geolocationm.isGeocoderAvailable(); 500 if (geocoder1) { 501 try { 502 let geocodeRequest = { "description": "上海市浦东新区金穗路1800号", "maxItems": 5 }; 503 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 504 console.info("[lbs_js] getAddressesFromLocation10 promise data is:" + JSON.stringify(result)); 505 expect(true).assertEqual((JSON.stringify(result)) != null); 506 }).catch((error) => { 507 console.info("[lbs_js] getAddressesFromLocationName10 promise then error." + JSON.stringify(error)); 508 console.info('[lbs_js] not support now'); 509 expect(error.code).assertEqual(3301400); 510 }); 511 } catch (error) { 512 console.info("[lbs_js] getAddressesFromLocationName27 try err." + JSON.stringify(error)); 513 expect(true).assertFalse(); 514 } 515 await sleep(1000); 516 } else { 517 console.info("[lbs_js] The geocoding service is unavailable."); 518 } 519 done(); 520 }) 521 522 /** 523 * @tc.number SUB_HSS_LocationSystem_Geo_2800 524 * @tc.name TestgetAddressesFromLocation 525 * @tc.desc Invalid parameter input test for the reverse address resolution function. 526 * @tc.size MEDIUM 527 * @tc.type Function 528 * @tc.level Level 2 529 需要实测!!!! 530 */ 531 it('SUB_HSS_LocationSystem_Geo_2800', 0, async function (done) { 532 let geocoder1 = geolocationm.isGeocoderAvailable(); 533 if (geocoder1) { 534 try { 535 let geocodeRequest = { "description": "", "maxItems": 1 }; 536 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 537 console.info("[lbs_js] getAddressesFromLocation111 promise data is:" + JSON.stringify(result)); 538 expect(true).assertEqual((JSON.stringify(result)) != null); 539 }).catch((error) => { 540 console.info("[lbs_js] getAddressesFromLocationName111 promise then error." + JSON.stringify(error)); 541 expect(true).assertFalse(); 542 }); 543 }catch(error){ 544 console.info("[lbs_js] getAddressesFromLocationName111 message." + JSON.stringify(error.message)); 545 expect(error.code).assertEqual("401"); 546 } 547 await sleep(1000); 548 let geocodeRequest1 = { "description": null, "maxItems": 1 }; 549 try { 550 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 551 console.info("[lbs_js] getAddressesFromLocationName112 promise data is:" + JSON.stringify(result)); 552 expect(result.length == 0).assertTrue(); 553 }).catch((error) => { 554 console.info("[lbs_js] getAddressesFromLocationName112 promise then error." + JSON.stringify(error)); 555 expect(true).assertFalse(); 556 }); 557 }catch(error){ 558 console.info("[lbs_js] getAddressesFromLocationName112 message." + JSON.stringify(error.message)); 559 expect(error.code).assertEqual("401"); 560 } 561 await sleep(1000); 562 } else { 563 console.info("[lbs_js] The geocoding service is unavailable."); 564 } 565 done(); 566 }) 567 568 /** 569 * @tc.number SUB_HSS_LocationSystem_Geo_2900 570 * @tc.name TestgetAddressesFromLocation 571 * @tc.desc Test the reverse address resolution function in the specified range.. 572 * @tc.size MEDIUM 573 * @tc.type Function 574 * @tc.level Level 2 575 */ 576 it('SUB_HSS_LocationSystem_Geo_2900', 0, async function (done) { 577 let geocoder1 = geolocationm.isGeocoderAvailable(); 578 if (geocoder1) { 579 let geocodeRequest = { 580 "description": "上海金穗路1800号", 581 "maxItems": 1, 582 "minLatitude": 31.3082812847, 583 "minLongitude": 121.5782001832, 584 "maxLatitude": 31.1537977881, 585 "maxLongitude": 121.8026736943 586 }; 587 try { 588 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 589 console.info("[lbs_js] getAddressesFromLocation29 promise data is:" + JSON.stringify(result)); 590 expect(true).assertEqual((JSON.stringify(result)) != null); 591 }).catch((error) => { 592 console.info("[lbs_js] getAddressesFromLocationName29 promise then error." + JSON.stringify(error)); 593 console.info('[lbs_js] not support now'); 594 expect(error.code).assertEqual(3301400); 595 }); 596 } catch (error) { 597 console.info("[lbs_js] getAddressesFromLocationName29 try err." + JSON.stringify(error)); 598 expect(true).assertFalse(); 599 } 600 await sleep(1000); 601 } else { 602 console.info("[lbs_js] The geocoding service is unavailable."); 603 } 604 done(); 605 }) 606 607 /** 608 * @tc.number SUB_HSS_LocationSystem_Geo_3000 609 * @tc.name TestgetAddressesFromLocation 610 * @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range 611 * -Invalid location name. 612 * @tc.size MEDIUM 613 * @tc.type Function 614 * @tc.level Level 2 615 */ 616 it('SUB_HSS_LocationSystem_Geo_3000', 0, async function (done) { 617 let geocoder1 = geolocationm.isGeocoderAvailable(); 618 if (geocoder1) { 619 let geocodeRequest = { 620 "description": "", 621 "maxItems": 1, 622 "minLatitude": 331.3082812847, 623 "minLongitude": 121.5782001832, 624 "maxLatitude": 31.1537977881, 625 "maxLongitude": 121.8026736943 626 }; 627 try { 628 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 629 console.info("[lbs_js] getAddressesFromLocationName301 promise data is:" + JSON.stringify(result)); 630 expect(result.length == 0).assertTrue(); 631 }).catch((error) => { 632 console.info("[lbs_js] getAddressesFromLocationName301 promise then error." + JSON.stringify(error)); 633 expect(true).assertFalse(); 634 }); 635 }catch(error){ 636 console.info("[lbs_js] getAddressesFromLocationName301 message." + JSON.stringify(error.message)); 637 expect(error.code).assertEqual("401"); 638 } 639 await sleep(1000); 640 let geocodeRequest1 = { 641 "description": null, 642 "maxItems": 1, 643 "minLatitude": 331.3082812847, 644 "minLongitude": 121.5782001832, 645 "maxLatitude": 31.1537977881, 646 "maxLongitude": 121.8026736943 647 }; 648 try { 649 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 650 console.info("[lbs_js] getAddressesFromLocationName302 promise data is:" + JSON.stringify(result)); 651 expect(result.length == 0).assertTrue(); 652 }).catch((error) => { 653 console.info("[lbs_js] getAddressesFromLocationName302 promise then error." + JSON.stringify(error)); 654 expect(true).assertFalse(); 655 656 }); 657 }catch(error){ 658 console.info("[lbs_js] getAddressesFromLocationName302 message." + JSON.stringify(error.message)); 659 expect(error.code).assertEqual("401"); 660 } 661 await sleep(1000); 662 } else { 663 console.info("[lbs_js] The geocoding service is unavailable."); 664 } 665 done(); 666 }) 667 668 /** 669 * @tc.number SUB_HSS_LocationSystem_Geo_3100 670 * @tc.name TestgetAddressesFromLocation 671 * @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range 672 * - the address is not in the range. 673 * @tc.size MEDIUM 674 * @tc.type Function 675 * @tc.level Level 2 676 */ 677 it('SUB_HSS_LocationSystem_Geo_3100', 0, async function (done) { 678 let geocoder1 = geolocationm.isGeocoderAvailable(); 679 if (geocoder1) { 680 let geocodeRequest = { 681 "description": "北京天安门", 682 "maxItems": 1, 683 "minLatitude": 40.85, 684 "minLongitude": 116.35, 685 "maxLatitude": 40.95, 686 "maxLongitude": 116.45 687 }; 688 try { 689 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 690 console.info("[lbs_js] getAddressesFromLocationName31 promise data is:" + JSON.stringify(result)); 691 expect(result.length >= 0).assertTrue(); 692 }).catch((error) => { 693 console.info("[lbs_js] getAddressesFromLocationName31 promise then error." + JSON.stringify(error)); 694 expect(error.code).assertEqual(3301400); 695 }); 696 } catch (error) { 697 console.info("[lbs_js] getAddressesFromLocationName31 message." + JSON.stringify(error)); 698 expect(error.code).assertEqual("401"); 699 } 700 await sleep(1000); 701 } else { 702 console.info("[lbs_js] The geocoding service is unavailable."); 703 } 704 done(); 705 }) 706 707 /** 708 * @tc.number SUB_HSS_LocationSystem_Geo_3200 709 * @tc.name TestgetAddressesFromLocation 710 * @tc.desc Invalid longitude and latitude entered for the reverse address resolution 711 * function in the specified range. The longitude and latitude range boundary is inverted.. 712 * @tc.size MEDIUM 713 * @tc.type Function 714 * @tc.level Level 2 715 */ 716 it('SUB_HSS_LocationSystem_Geo_3200', 0, async function (done) { 717 let geocodeRequest = { 718 "description": "北京天安门", 719 "maxItems": 1, 720 "minLatitude": 39.95, 721 "minLongitude": 116.45, 722 "maxLatitude": 39.85, 723 "maxLongitude": 116.35 724 }; 725 let geocoder1 = geolocationm.isGeocoderAvailable(); 726 if (geocoder1) { 727 try { 728 await geolocationm.getAddressesFromLocationName(geocodeRequest).then((result) => { 729 console.info("[lbs_js] getAddressesFromLocationName32 promise data is:" + JSON.stringify(result)); 730 expect(result.length >= 0).assertTrue(); 731 }).catch((error) => { 732 console.info("[lbs_js] getAddressesFromLocationName32 promise then error." + JSON.stringify(error)); 733 console.info('[lbs_js] not support now'); 734 expect(error.code).assertEqual(3301400); 735 }); 736 } catch (error) { 737 console.info("[lbs_js] getAddressesFromLocationName32 message." + JSON.stringify(error)); 738 expect(error.code).assertEqual("401"); 739 } 740 await sleep(1000); 741 } else { 742 console.info("[lbs_js] The geocoding service is unavailable."); 743 } 744 done(); 745 }) 746 747 /** 748 * @tc.number SUB_HSS_LocationSystem_Geo_3300 749 * @tc.name TestgetAddressesFromLocation 750 * @tc.desc Input parameter boundary test for the reverse address resolution function in a specified range. 751 * @tc.size MEDIUM 752 * @tc.type Function 753 * @tc.level Level 2 754 */ 755 it('SUB_HSS_LocationSystem_Geo_3300', 0, async function (done) { 756 let geocoder1 = geolocationm.isGeocoderAvailable(); 757 if (geocoder1) { 758 let geocodeRequest1 = { 759 "description": "上海金穗路1800号", 760 "maxItems": 1, 761 "minLatitude": -90, 762 "minLongitude": 121.5782001832, 763 "maxLatitude": 31.1537977881, 764 "maxLongitude": 121.8026736943 765 }; 766 try{ 767 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 768 console.info("[lbs_js] getAddressesFromLocationName33 promise1:" + JSON.stringify(result)); 769 expect(true).assertEqual((JSON.stringify(result)) != null); 770 }).catch((error) => { 771 console.info("[lbs_js] getAddressesFromLocationName33 promise1 then error." + JSON.stringify(error)); 772 console.info('[lbs_js] not support now'); 773 expect(error.code).assertEqual(3301400); 774 }); 775 }catch(error){ 776 console.info("[lbs_js] getAddressesFromLocationName33 message1." + JSON.stringify(error.message)); 777 expect(true).assertFalse(); 778 } 779 await sleep(1000); 780 let geocodeRequest2 = { 781 "description": "上海金穗路1800号", 782 "maxItems": 1, 783 "minLatitude": 90, 784 "minLongitude": 121.5782001832, 785 "maxLatitude": 31.1537977881, 786 "maxLongitude": 121.8026736943 787 }; 788 try{ 789 await geolocationm.getAddressesFromLocationName(geocodeRequest2).then((result) => { 790 console.info("[lbs_js] getAddressesFromLocationName33 promise2: " + JSON.stringify(result)); 791 expect(true).assertEqual((JSON.stringify(result)) != null); 792 }).catch((error) => { 793 console.info("[lbs_js] getAddressesFromLocationName33 promise2 then error." + JSON.stringify(error)); 794 console.info('[lbs_js] not support now'); 795 expect(error.code).assertEqual(3301400); 796 }); 797 }catch(error){ 798 console.info("[lbs_js] getAddressesFromLocationName33 message2." + JSON.stringify(error.message)); 799 expect(true).assertFalse(); 800 } 801 await sleep(1000); 802 let geocodeRequest3 = { 803 "description": "上海金穗路1800号", 804 "maxItems": 1, 805 "minLatitude": -90.1, 806 "minLongitude": 121.5782001832, 807 "maxLatitude": 31.1537977881, 808 "maxLongitude": 121.8026736943 809 }; 810 try{ 811 await geolocationm.getAddressesFromLocationName(geocodeRequest3).then((result) => { 812 console.info("[lbs_js] getAddressesFromLocationName33 promise3: " + JSON.stringify(result)); 813 expect(true).assertEqual((JSON.stringify(result)) == null); 814 }).catch((error) => { 815 console.info("[lbs_js] getAddressesFromLocationName33 promise3 then error." + JSON.stringify(error)); 816 expect(true).assertFalse(); 817 }); 818 }catch(error){ 819 console.info("[lbs_js] getAddressesFromLocationName33 message3." + JSON.stringify(error.message)); 820 expect(error.code).assertEqual("401"); 821 } 822 await sleep(1000); 823 let geocodeRequest4 = { 824 "description": "上海金穗路1800号", 825 "maxItems": 1, 826 "minLatitude": 90.1, 827 "minLongitude": 121.5782001832, 828 "maxLatitude": 31.1537977881, 829 "maxLongitude": 121.8026736943 830 }; 831 try{ 832 await geolocationm.getAddressesFromLocationName(geocodeRequest4).then((result) => { 833 console.info("[lbs_js] getAddressesFromLocationName33 promise4: " + JSON.stringify(result)); 834 console.info('[lbs_js] not support now'); 835 expect(true).assertEqual(JSON.stringify(error) != null); 836 }).catch((error) => { 837 console.info("[lbs_js] getAddressesFromLocationName33 promise4 then error." + JSON.stringify(error)); 838 expect(true).assertFalse(); 839 }); 840 }catch(error){ 841 console.info("[lbs_js] getAddressesFromLocationName33 message4." + JSON.stringify(error.message)); 842 expect(error.code).assertEqual("401"); 843 } 844 await sleep(1000); 845 let geocodeRequest5 = { 846 "description": "上海金穗路1800号", 847 "maxItems": 1, 848 "minLatitude": 31.3082812847, 849 "minLongitude": 121.5782001832, 850 "maxLatitude": -90, 851 "maxLongitude": 121.8026736943 852 }; 853 try { 854 await geolocationm.getAddressesFromLocationName(geocodeRequest5).then((result) => { 855 console.info("[lbs_js] getAddressesFromLocationName33 promise5: " + JSON.stringify(result)); 856 expect(true).assertEqual((JSON.stringify(result)) != null); 857 }).catch((error) => { 858 console.info("[lbs_js] getAddressesFromLocationName33 promise5 then error." + JSON.stringify(error)); 859 console.info('[lbs_js] not support now'); 860 expect(error.code).assertEqual(3301400); 861 }); 862 }catch(error){ 863 console.info("[lbs_js] getAddressesFromLocationName33 message5." + JSON.stringify(error.message)); 864 expect(true).assertFalse(); 865 } 866 await sleep(1000); 867 let geocodeRequest6 = { 868 "description": "上海金穗路1800号", 869 "maxItems": 1, 870 "minLatitude": 31.3082812847, 871 "minLongitude": 121.5782001832, 872 "maxLatitude": 90, 873 "maxLongitude": 121.8026736943 874 }; 875 try{ 876 await geolocationm.getAddressesFromLocationName(geocodeRequest6).then((result) => { 877 console.info("[lbs_js] getAddressesFromLocationName33 promise6: " + JSON.stringify(result)); 878 expect(true).assertEqual((JSON.stringify(result)) != null); 879 }).catch((error) => { 880 console.info("[lbs_js] getAddressesFromLocationName33 promise6 then error." + JSON.stringify(error)); 881 console.info('[lbs_js] not support now'); 882 expect(error.code).assertEqual(3301400); 883 }); 884 }catch(error){ 885 console.info("[lbs_js] getAddressesFromLocationName33 message6." + JSON.stringify(error.message)); 886 expect(true).assertFalse(); 887 } 888 await sleep(1000); 889 let geocodeRequest7 = { 890 "description": "上海金穗路1800号", 891 "maxItems": 1, 892 "minLatitude": 31.3082812847, 893 "minLongitude": 121.5782001832, 894 "maxLatitude": -90.1, 895 "maxLongitude": 121.8026736943 896 }; 897 try{ 898 await geolocationm.getAddressesFromLocationName(geocodeRequest7).then((result) => { 899 console.info("[lbs_js] getAddressesFromLocationName33 promise7: " + JSON.stringify(result)); 900 expect(true).assertEqual((JSON.stringify(result)) == null); 901 }).catch((error) => { 902 console.info("[lbs_js] getAddressesFromLocationName33 promise7 then error." + JSON.stringify(error)); 903 expect(true).assertFalse(); 904 }); 905 }catch(error){ 906 console.info("[lbs_js] getAddressesFromLocationName33 message7." + JSON.stringify(error.message)); 907 expect(error.code).assertEqual("401"); 908 } 909 await sleep(1000); 910 let geocodeRequest8 = { 911 "description": "上海金穗路1800号", 912 "maxItems": 1, 913 "minLatitude": 31.3082812847, 914 "minLongitude": 121.5782001832, 915 "maxLatitude": 90.1, 916 "maxLongitude": 121.8026736943 917 }; 918 try{ 919 await geolocationm.getAddressesFromLocationName(geocodeRequest8).then((result) => { 920 console.info("[lbs_js] getAddressesFromLocationName33 promise8: " + JSON.stringify(result)); 921 expect(true).assertEqual((JSON.stringify(result)) == null); 922 }).catch((error) => { 923 console.info("[lbs_js] getAddressesFromLocationName33 promise8 then error." + JSON.stringify(error)); 924 expect(true).assertFalse(); 925 }); 926 }catch(error){ 927 console.info("[lbs_js] getAddressesFromLocationName33 message8." + JSON.stringify(error.message)); 928 expect(error.code).assertEqual("401"); 929 } 930 await sleep(1000); 931 } else { 932 console.info("[lbs_js] The geocoding service is unavailable."); 933 } 934 done(); 935 }) 936 937 /** 938 * @tc.number SUB_HSS_LocationSystem_Geo_3400 939 * @tc.name TestgetAddressesFromLocation 940 * @tc.desc Longitude input parameter boundary test for the reverse address resolution function in a specified range 941 * @tc.size MEDIUM 942 * @tc.type Function 943 * @tc.level Level 2 944 */ 945 it('SUB_HSS_LocationSystem_Geo_3400', 0, async function (done) { 946 let geocoder1 = geolocationm.isGeocoderAvailable(); 947 if (geocoder1) { 948 let geocodeRequest1 = { 949 "description": "北京天安门", 950 "maxItems": 1, 951 "minLatitude": 39.85, 952 "minLongitude": -180, 953 "maxLatitude": 39.95, 954 "maxLongitude": 116.45 955 }; 956 try{ 957 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 958 console.info("[lbs_js] getAddressesFromLocationName34 promise1: " + JSON.stringify(result)); 959 expect(true).assertEqual((JSON.stringify(result)) != null); 960 }).catch((error) => { 961 console.info("[lbs_js] getAddressesFromLocationName34 promise1 then error." + JSON.stringify(error)); 962 console.info('[lbs_js] not support now'); 963 expect(error.code).assertEqual(3301400); 964 }); 965 }catch(error){ 966 console.info("[lbs_js] getAddressesFromLocationName34 message1." + JSON.stringify(error.message)); 967 expect(true).assertFalse(); 968 } 969 await sleep(1000); 970 let geocodeRequest2 = { 971 "description": "北京天安门", 972 "maxItems": 1, 973 "minLatitude": 39.85, 974 "minLongitude": 180, 975 "maxLatitude": 39.95, 976 "maxLongitude": 116.45 977 }; 978 try{ 979 await geolocationm.getAddressesFromLocationName(geocodeRequest2).then((result) => { 980 console.info("[lbs_js] getAddressesFromLocationName34 promise2: " + JSON.stringify(result)); 981 expect(true).assertEqual((JSON.stringify(result)) != null); 982 }).catch((error) => { 983 console.info("[lbs_js] getAddressesFromLocationName34 promise2 then error." + JSON.stringify(error)); 984 console.info('[lbs_js] not support now'); 985 expect(error.code).assertEqual(3301400); 986 }); 987 }catch(error){ 988 console.info("[lbs_js] getAddressesFromLocationName34 message2." + JSON.stringify(error.message)); 989 expect(true).assertFalse(); 990 } 991 await sleep(1000); 992 let geocodeRequest3 = { 993 "description": "北京天安门", 994 "maxItems": 1, 995 "minLatitude": 39.85, 996 "minLongitude": -180.1, 997 "maxLatitude": 39.95, 998 "maxLongitude": 116.45 999 }; 1000 try{ 1001 await geolocationm.getAddressesFromLocationName(geocodeRequest3).then((result) => { 1002 console.info("[lbs_js] getAddressesFromLocationName34 promise3: " + JSON.stringify(result)); 1003 expect(true).assertEqual((JSON.stringify(result)) != null); 1004 }).catch((error) => { 1005 console.info("[lbs_js] getAddressesFromLocationName34 promise3 then error." + JSON.stringify(error)); 1006 expect(true).assertFalse(); 1007 }); 1008 }catch(error){ 1009 console.info("[lbs_js] getAddressesFromLocationName34 message3." + JSON.stringify(error.message)); 1010 expect(error.code).assertEqual("401"); 1011 } 1012 await sleep(1000); 1013 let geocodeRequest4 = { 1014 "description": "北京天安门", 1015 "maxItems": 1, 1016 "minLatitude": 39.85, 1017 "minLongitude": 180.1, 1018 "maxLatitude": 39.95, 1019 "maxLongitude": 116.45 1020 }; 1021 try{ 1022 await geolocationm.getAddressesFromLocationName(geocodeRequest4).then((result) => { 1023 console.info("[lbs_js] getAddressesFromLocationName34 promise4: " + JSON.stringify(result)); 1024 expect(true).assertEqual((JSON.stringify(result)) != null); 1025 }).catch((error) => { 1026 console.info("[lbs_js] getAddressesFromLocationName34 promise4 then error." + JSON.stringify(error)); 1027 expect(true).assertFalse(); 1028 }); 1029 }catch(error){ 1030 console.info("[lbs_js] getAddressesFromLocationName34 message4." + JSON.stringify(error.message)); 1031 expect(error.code).assertEqual("401"); 1032 } 1033 await sleep(1000); 1034 let geocodeRequest5 = { 1035 "description": "北京天安门", 1036 "maxItems": 1, 1037 "minLatitude": 39.85, 1038 "minLongitude": 116.35, 1039 "maxLatitude": 39.95, 1040 "maxLongitude": -180 1041 }; 1042 try{ 1043 await geolocationm.getAddressesFromLocationName(geocodeRequest5).then((result) => { 1044 console.info("[lbs_js] getAddressesFromLocationName34 promise5: " + JSON.stringify(result)); 1045 expect(true).assertEqual((JSON.stringify(result)) != null); 1046 }).catch((error) => { 1047 console.info("[lbs_js] getAddressesFromLocationName34 promise5 then error." + JSON.stringify(error)); 1048 console.info('[lbs_js] not support now'); 1049 expect(error.code).assertEqual(3301400); 1050 }); 1051 }catch(error){ 1052 console.info("[lbs_js] getAddressesFromLocationName34 message5." + JSON.stringify(error.message)); 1053 expect(true).assertFalse(); 1054 } 1055 let geocodeRequest6 = { 1056 "description": "北京天安门", 1057 "maxItems": 1, 1058 "minLatitude": 39.85, 1059 "minLongitude": 116.35, 1060 "maxLatitude": 39.95, 1061 "maxLongitude": 180 1062 }; 1063 try{ 1064 await geolocationm.getAddressesFromLocationName(geocodeRequest6).then((result) => { 1065 console.info("[lbs_js] getAddressesFromLocationName34 promise6: " + JSON.stringify(result)); 1066 expect(true).assertEqual((JSON.stringify(result)) != null); 1067 }).catch((error) => { 1068 console.info("[lbs_js] getAddressesFromLocationName34 promise6 then error." + JSON.stringify(error)); 1069 console.info('[lbs_js] not support now'); 1070 expect(error.code).assertEqual(3301400); 1071 }); 1072 }catch(error){ 1073 console.info("[lbs_js] getAddressesFromLocationName34 message6." + JSON.stringify(error.message)); 1074 expect(true).assertFalse(); 1075 } 1076 await sleep(1000); 1077 let geocodeRequest7 = { 1078 "description": "北京天安门", 1079 "maxItems": 1, 1080 "minLatitude": 39.85, 1081 "minLongitude": 116.35, 1082 "maxLatitude": 39.95, 1083 "maxLongitude": -180.1 1084 }; 1085 try{ 1086 await geolocationm.getAddressesFromLocationName(geocodeRequest7).then((result) => { 1087 console.info("[lbs_js] getAddressesFromLocationName34 promise7: " + JSON.stringify(result)); 1088 expect(true).assertEqual((JSON.stringify(result)) != null); 1089 }).catch((error) => { 1090 console.info("[lbs_js] getAddressesFromLocationName34 promise7 then error." + JSON.stringify(error)); 1091 expect(true).assertFalse(); 1092 }); 1093 }catch(error){ 1094 console.info("[lbs_js] getAddressesFromLocationName34 message7." + JSON.stringify(error.message)); 1095 expect(error.code).assertEqual("401"); 1096 } 1097 let geocodeRequest8 = { 1098 "description": "北京天安门", 1099 "maxItems": 1, 1100 "minLatitude": 39.85, 1101 "minLongitude": 116.35, 1102 "maxLatitude": 39.95, 1103 "maxLongitude": 180.1 1104 }; 1105 try{ 1106 await geolocationm.getAddressesFromLocationName(geocodeRequest8).then((result) => { 1107 console.info("[lbs_js] getAddressesFromLocationName34 promise8: " + JSON.stringify(result)); 1108 expect(true).assertEqual((JSON.stringify(result)) != null); 1109 }).catch((error) => { 1110 console.info("[lbs_js] getAddressesFromLocationName34 promise8 then error." + JSON.stringify(error)); 1111 expect(true).assertFalse(); 1112 }); 1113 }catch(error){ 1114 console.info("[lbs_js] getAddressesFromLocationName34 message8." + JSON.stringify(error.message)); 1115 expect(error.code).assertEqual("401"); 1116 } 1117 await sleep(1000); 1118 } else { 1119 console.info("[lbs_js] The geocoding service is unavailable."); 1120 } 1121 done(); 1122 }) 1123 1124 /** 1125 * @tc.number SUB_HSS_LocationSystem_Geo_3500 1126 * @tc.name TestgetAddressesFromLocation 1127 * @tc.desc Longitude input parameter boundary test for the reverse address resolution function in a specified range 1128 * @tc.size MEDIUM 1129 * @tc.type Function 1130 * @tc.level Level 2 1131 */ 1132 it('SUB_HSS_LocationSystem_Geo_3500', 0, async function (done) { 1133 let geocoder1 = geolocationm.isGeocoderAvailable(); 1134 if (geocoder1) { 1135 let geocodeRequest1 = { 1136 "description": "北京天安门", 1137 "maxItems": 1, 1138 "minLatitude": 39.85, 1139 "minLongitude": -180, 1140 "maxLatitude": 39.95, 1141 "maxLongitude": 116.45, 1142 "country": "cn" 1143 }; 1144 try{ 1145 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 1146 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3500 promise1: " + JSON.stringify(result)); 1147 expect(true).assertEqual((JSON.stringify(result)) != null); 1148 }).catch((error) => { 1149 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3500 promise1 then error." + JSON.stringify(error)); 1150 console.info('[lbs_js] not support now'); 1151 expect(error.code).assertEqual(3301400); 1152 }); 1153 }catch(error){ 1154 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3500 message1." + JSON.stringify(error.message)); 1155 expect(true).assertFalse(); 1156 } 1157 await sleep(1000); 1158 } else { 1159 console.info("[lbs_js] The geocoding service is unavailable."); 1160 } 1161 done(); 1162 }) 1163 1164 /** 1165 * @tc.number SUB_HSS_LocationSystem_Geo_3600 1166 * @tc.name TestgetAddressesFromLocation 1167 * @tc.desc Longitude input parameter boundary test for the reverse address resolution function in a specified range 1168 * @tc.size MEDIUM 1169 * @tc.type Function 1170 * @tc.level Level 2 1171 */ 1172 it('SUB_HSS_LocationSystem_Geo_3600', 0, async function (done) { 1173 let geocoder1 = geolocationm.isGeocoderAvailable(); 1174 if (geocoder1) { 1175 let geocodeRequest1 = { 1176 "description": "北京天安门", 1177 "maxItems": 1, 1178 "minLatitude": 39.85, 1179 "minLongitude": -180, 1180 "maxLatitude": 39.95, 1181 "maxLongitude": 116.45, 1182 "country": "us" 1183 }; 1184 try{ 1185 await geolocationm.getAddressesFromLocationName(geocodeRequest1).then((result) => { 1186 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3600 promise1: " + JSON.stringify(result)); 1187 expect(true).assertEqual((JSON.stringify(result)) != null); 1188 }).catch((error) => { 1189 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3600 promise1 then error." + JSON.stringify(error)); 1190 console.info('[lbs_js] not support now'); 1191 expect(error.code).assertEqual(3301400); 1192 }); 1193 }catch(error){ 1194 console.info("[lbs_js] SUB_HSS_LocationSystem_Geo_3600 message1." + JSON.stringify(error.message)); 1195 expect(true).assertFalse(); 1196 } 1197 await sleep(1000); 1198 } else { 1199 console.info("[lbs_js] The geocoding service is unavailable."); 1200 } 1201 done(); 1202 }) 1203 1204 }) 1205}