LocationMTest.test.js 70.0 KB
Newer Older
Q
quanli 已提交
1
/*
Q
quanli 已提交
2
 * Copyright (C) 2022 Huawei Device Co., Ltd.
Q
quanli 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import geolocation from '@ohos.geolocation';
import geolocationm from '@ohos.geoLocationManager';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'

let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
    TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
    DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305}
let LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203}
let LocationPrivacyType = {
    OTHERS : 0,
    STARTUP: 1,
    CORE_LOCATION : 2
}

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function changedLocationMode(){
    let result1 = geolocationm.isLocationEnabled();
    console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1));
    if(!result1){
        await geolocation.requestEnableLocation().then(async(result) => {
Q
quanli 已提交
42
            ;
Q
quanli 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
            console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
        }).catch((error) => {
            console.info("[lbs_js] promise then error." + JSON.stringify(error));
            expect().assertFail();
        });
    }
    let result2 = geolocationm.isLocationEnabled();
    console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2));
}

async function enableLocationSwitch(){
    function enableLocationSwitchCallback(){
        return new Promise((resolve, reject)=>{
            geolocation.requestEnableLocation((err, data) => {
                if (err) {
                    console.info('[lbs_js]  requestEnableLocation callback err is : ' + err );
                }else {
                    console.info("[lbs_js] requestEnableLocation callback data: " + data);
                    expect(data).assertTrue();
                }
            });
        })
    }
    await enableLocationSwitchCallback();
    done();
}


async function applyPermission() {
    let osAccountManager = osaccount.getAccountManager();
    console.info("=== getAccountManager finish");
    let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
    console.info("LocalId is :" + localId);
    let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
    let atManager = abilityAccessCtrl.createAtManager();
    if (atManager != null) {
        let tokenID = appInfo.accessTokenId;
        console.info('[permission] case accessTokenID is ' + tokenID);
        let permissionName1 = 'ohos.permission.LOCATION';
        let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND';
Q
quanli 已提交
83
        let permissionName3 = 'ohos.permission.APPROXIMATELY_LOCATION';
Q
quanli 已提交
84 85 86 87 88 89 90 91 92 93
        await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
            console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
        }).catch((err) => {
            console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
        });
        await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
            console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
        }).catch((err) => {
            console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
        });
Q
quanli 已提交
94 95 96 97 98
        await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
            console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
        }).catch((err) => {
            console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
        });
Q
quanli 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    } else {
        console.info('[permission] case apply permission failed, createAtManager failed');
    }
}


export default function geolocationTest_geo7() {


    describe('geolocationTest_geo7', function () {
        beforeAll(async function (done) {
            console.info('beforeAll case');
            await applyPermission();
            done();
        })
    
        beforeEach(function () {
            console.info('beforeEach case');
        })
        afterEach(function () {
        })


Q
quanli 已提交
122

Q
quanli 已提交
123 124 125 126 127 128 129 130 131 132 133
    /**
     * @tc.number SUB_HSS_LocationSystem_LocSwitch_0600
     * @tc.name Test requestrequestEnableLocation api
     * @tc.desc Enabling the Location Service Function for a Third-Party App - Callback
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
     it('SUB_HSS_LocationSystem_LocSwitch_0600', 0, function () {
        try {
            let state = geolocationm.isLocationEnabled();
Q
quanli 已提交
134 135
            console.info('[lbs_js] getLocationSwitchState06 result: ' + JSON.stringify(state));
            expect(true).assertEqual(state);
Q
quanli 已提交
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
        } catch (error) {
            console.info("[lbs_js] getLocationSwitchState06 try err." + JSON.stringify(error));
            expect().assertFail();
        }
    });

    /**
     * @tc.number SUB_HSS_LocationSystem_LocSwitch_0700
     * @tc.name Test locationServiceState api .
     * @tc.desc Subscribe to the location service status change.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocSwitch_0700', 0, async function (done) {
        console.log('[lbs_js] just for overwriting,locationServiceState test need system api ');
        var locationServiceState = (state) => {
            console.log('[lbs_js] locationServiceState: state: ' + JSON.stringify(state));
        }
        try {
            geolocationm.on('locationEnabledChange', locationServiceState);
Q
quanli 已提交
157

Q
quanli 已提交
158 159
        } catch (error) {
            console.info("[lbs_js] locationServiceStateOn07 try err." + JSON.stringify(error));
Q
quanli 已提交
160
            expect().assertFail();
Q
quanli 已提交
161 162 163 164 165
        }
        try {
            geolocationm.off('locationEnabledChange', locationServiceState);
        } catch (error) {
            console.info("[lbs_js] locationServiceStateOff07 try err." + JSON.stringify(error));
Q
quanli 已提交
166
            expect().assertFail();
Q
quanli 已提交
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
        }
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1500
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_1500', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            geolocationm.getCurrentLocation(currentLocationRequest, (err, result) => {
                if (err) {
                    console.info("[lbs_js] getCurrentLocation15 callback err:  " + JSON.stringify(err));
Q
quanli 已提交
185
                    expect(err.code).assertEqual(3301200);
Q
quanli 已提交
186 187 188 189 190 191 192 193 194
                    console.info('[lbs_js] getCurrentLocationCallback reject after');
                    done();
                } else {
                    console.info("[lbs_js] getCurrentLocation15 callback result:" + JSON.stringify(result));
                    expect(true).assertEqual(result != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation15 callback try err." + JSON.stringify(error));
Q
quanli 已提交
195
            expect(true).assertFalse();
Q
quanli 已提交
196
        }
Q
quanli 已提交
197
        await sleep(1000);
Q
quanli 已提交
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1600
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_1600', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation16 promise result ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation16 promise err:' + JSON.stringify(error));
Q
quanli 已提交
216
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
217 218 219
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation16 promise try err." + JSON.stringify(error));
Q
quanli 已提交
220
            expect(true).assertFalse();
Q
quanli 已提交
221
        }
Q
quanli 已提交
222
        await sleep(1000);
Q
quanli 已提交
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1700
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the track tracing scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
     it('SUB_HSS_LocationSystem_SingleLoc_1700', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info("[lbs_js] getCurrentLocation callback17, result:" + JSON.stringify(result));
                expect(true).assertEqual(result != null);
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation callback17:' + JSON.stringify(error));
Q
quanli 已提交
242
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
243 244 245
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation callback17 try err." + JSON.stringify(error));
Q
quanli 已提交
246
            expect(true).assertFalse();
Q
quanli 已提交
247
        }
Q
quanli 已提交
248
        await sleep(1000);
Q
quanli 已提交
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1800
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set a car-sharing scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_1800', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation18 promise result ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation18 promise err:' + JSON.stringify(error));
Q
quanli 已提交
267
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
268 269 270
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error));
Q
quanli 已提交
271
            expect(true).assertFalse();
Q
quanli 已提交
272
        }
Q
quanli 已提交
273
        await sleep(1000);
Q
quanli 已提交
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1900
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the life service scenario..
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_1900', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation19 promise result:' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation19 promise err:' + JSON.stringify(error));
Q
quanli 已提交
292
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
293 294 295
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation18 promise try err." + JSON.stringify(error));
Q
quanli 已提交
296
            expect(true).assertFalse();
Q
quanli 已提交
297
        }
Q
quanli 已提交
298
        await sleep(1000);
Q
quanli 已提交
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2000
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario
     *           and set the scenario with no power consumption.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2000', 0, async function (done) {
        let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 };
        let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
Q
quanli 已提交
315
            await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => {
Q
quanli 已提交
316 317 318
                console.info('[lbs_js] getCurrentLocation1901 promise result:' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation1901 promise err:' + JSON.stringify(error));
Q
quanli 已提交
319
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
320 321 322
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation1901 promise try err." + JSON.stringify(error));
Q
quanli 已提交
323
            expect(true).assertFalse();
Q
quanli 已提交
324
        }
Q
quanli 已提交
325
        await sleep(1000);
Q
quanli 已提交
326 327 328 329 330
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest2).then((result) => {
                console.info('[lbs_js] getCurrentLocation1902 promise result:' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation1902 promise err:' + JSON.stringify(error));
Q
quanli 已提交
331
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
332 333 334
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation1902 promise try err." + JSON.stringify(error));
Q
quanli 已提交
335
            expect(true).assertFalse();
Q
quanli 已提交
336
        }
Q
quanli 已提交
337
        await sleep(1000);
Q
quanli 已提交
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2100
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request with the parameter set to high-precision priority location request.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2100', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation21 promise result ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation21 promise err:' + JSON.stringify(error));
Q
quanli 已提交
356
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
357 358 359
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation21 promise try err." + JSON.stringify(error));
Q
quanli 已提交
360
            expect(true).assertFalse();
Q
quanli 已提交
361
        }
Q
quanli 已提交
362
        await sleep(1000);
Q
quanli 已提交
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2200
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request with parameters set to fast location and priority location request.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2200', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation22 promise result:' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation22 promise err:' + JSON.stringify(error));
Q
quanli 已提交
381
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
382 383 384
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation22 promise try err." + JSON.stringify(error));
Q
quanli 已提交
385
            expect(true).assertFalse();
Q
quanli 已提交
386
        }
Q
quanli 已提交
387
        await sleep(1000);
Q
quanli 已提交
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2300
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request with parameters set to low power consumption.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2300', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result23:' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err23:' + JSON.stringify(error));
Q
quanli 已提交
406
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
407 408 409
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation23 promise try err." + JSON.stringify(error));
Q
quanli 已提交
410
            expect(true).assertFalse();
Q
quanli 已提交
411
        }
Q
quanli 已提交
412
        await sleep(1000);
Q
quanli 已提交
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2400
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request and set the location reporting precision.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2400', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 5 };
        let currentLocationRequest1 = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 2 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result241 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err241:' + JSON.stringify(error));
Q
quanli 已提交
432
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
433 434 435
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation241 promise try err." + JSON.stringify(error));
Q
quanli 已提交
436
            expect(true).assertFalse();
Q
quanli 已提交
437
        }
Q
quanli 已提交
438
        await sleep(1000);
Q
quanli 已提交
439 440 441 442 443
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result242 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err242:' + JSON.stringify(error));
Q
quanli 已提交
444
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
445 446 447
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation242 promise try err." + JSON.stringify(error));
Q
quanli 已提交
448
            expect(true).assertFalse();
Q
quanli 已提交
449
        }
Q
quanli 已提交
450
        await sleep(1000);
Q
quanli 已提交
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_2500
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request for specific configuration
     *          and set the reporting precision of abnormal location.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_SingleLoc_2500', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result251 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err251:' + JSON.stringify(error));
Q
quanli 已提交
471
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
472 473 474
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation251 promise try err." + JSON.stringify(error));
Q
quanli 已提交
475
            expect(true).assertFalse();
Q
quanli 已提交
476
        }
Q
quanli 已提交
477
        await sleep(1000);
Q
quanli 已提交
478 479 480 481 482
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result252 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err252:' + JSON.stringify(error));
Q
quanli 已提交
483
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
484 485 486
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation252 promise try err." + JSON.stringify(error));
Q
quanli 已提交
487
            expect(true).assertFalse();
Q
quanli 已提交
488
        }
Q
quanli 已提交
489
        await sleep(1000);
Q
quanli 已提交
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_SingleLoc_2600
    * @tc.name Test getCurrentLocation
    * @tc.desc Initiate a single location request and set the location timeout interval.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_SingleLoc_2600', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result261 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err261:' + JSON.stringify(error));
Q
quanli 已提交
509
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
510 511 512
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation261 promise try err." + JSON.stringify(error));
Q
quanli 已提交
513
            expect(true).assertFalse();
Q
quanli 已提交
514
        }
Q
quanli 已提交
515
        await sleep(1000);
Q
quanli 已提交
516 517 518 519 520
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result262 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err262:' + JSON.stringify(error));
Q
quanli 已提交
521
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
522 523 524
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation262 promise try err." + JSON.stringify(error));
Q
quanli 已提交
525
            expect(true).assertFalse();
Q
quanli 已提交
526
        }
Q
quanli 已提交
527
        await sleep(1000);
Q
quanli 已提交
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_SingleLoc_2700
    * @tc.name Test getCurrentLocation
    * @tc.desc Initiate a specified single location request and set the exception location timeout interval.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_SingleLoc_2700', 0, async function (done) {
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 };
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result271 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err271:' + JSON.stringify(error));
Q
quanli 已提交
547
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
548 549 550
            });
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation271 promise try err." + JSON.stringify(error));
Q
quanli 已提交
551
            expect(true).assertFalse();
Q
quanli 已提交
552
        }
Q
quanli 已提交
553
        await sleep(1000);
Q
quanli 已提交
554 555 556 557 558
        try {
            await geolocationm.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result272 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation promise err272:' + JSON.stringify(error));
Q
quanli 已提交
559
                expect(error.code).assertEqual(3301200);
Q
quanli 已提交
560 561 562
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation272 promise try err." + JSON.stringify(error));
Q
quanli 已提交
563
            expect(true).assertFalse();
Q
quanli 已提交
564
        }
Q
quanli 已提交
565
        await sleep(1000);
Q
quanli 已提交
566 567 568 569 570 571 572 573 574 575 576 577
        done();
    })

    /**
     * @tc.number SUB_HSS_SendCommand_0300
     * @tc.name Test sendCommand
     * @tc.desc Test sendCommand api .
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_SendCommand_0300', 0, async function (done) {
Q
quanli 已提交
578
        let requestInfo = { 'scenario': 0x301, 'command': "command_1" };
Q
quanli 已提交
579 580 581 582
        try {
            await geolocationm.sendCommand(requestInfo, (err, result) => {
                if (err) {
                    console.info('sendcommand callback err:' + JSON.stringify(err));
Q
quanli 已提交
583 584
                    console.info('sendcommand not support');
                    expect(err.code).assertEqual(801);
Q
quanli 已提交
585 586 587 588 589 590
                    done();
                }
                console.info('sendcommand callback result:' + JSON.stringify(result));
            });
        } catch (error) {
            console.info('sendcommand callback err:' + JSON.stringify(error));
Q
quanli 已提交
591
            expect(true).assertFalse();
Q
quanli 已提交
592
        }
Q
quanli 已提交
593
        await sleep(1000);
Q
quanli 已提交
594 595 596 597 598 599 600 601 602 603 604 605
        done();
    })

    /**
     * @tc.number SUB_HSS_SendCommand_0400
     * @tc.name Test sendCommand
     * @tc.desc Test sendCommand1 api .
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_SendCommand_0400', 0, async function (done) {
Q
quanli 已提交
606
        let requestInfo = { 'scenario': 0x301, 'command': "command_1" };
Q
quanli 已提交
607 608
        try {
            geolocationm.sendCommand(requestInfo).then((result) => {
Q
quanli 已提交
609
                console.info('[lbs_js] sendCommand promise result:' + result);
Q
quanli 已提交
610 611
                done();
            }).catch(error => {
Q
quanli 已提交
612 613 614
                console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error));
                console.info('[lbs_js] not support now');
                expect(error.code).assertEqual(801);
Q
quanli 已提交
615 616 617
                done();
            })
        } catch (error) {
Q
quanli 已提交
618 619
            console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error));
            expect(true).assertFalse();
Q
quanli 已提交
620
        }
Q
quanli 已提交
621
        await sleep(1000);
Q
quanli 已提交
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1600
     * @tc.name Test locationChange
     * @tc.desc Initiate a request for continuous positioning in a specified scenario and set the navigation scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_1600', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.info('[lbs_js] locationChanger16 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn16 try err." + JSON.stringify(error));
Q
quanli 已提交
645
            expect(true).assertFalse();
Q
quanli 已提交
646 647 648 649 650
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff16 try err." + JSON.stringify(error));
Q
quanli 已提交
651
            expect(true).assertFalse();
Q
quanli 已提交
652
        }
Q
quanli 已提交
653
        await sleep(1000);
Q
quanli 已提交
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1700
     * @tc.name Test locationChange
     * @tc.desc Initiate a request for continuous positioning in a specified scenario and set a track tracing scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_1700', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x302, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.info('[lbs_js] locationChanger17 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn17 try err." + JSON.stringify(error));
Q
quanli 已提交
677
            expect(true).assertFalse();
Q
quanli 已提交
678 679 680 681 682
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff17 try err." + JSON.stringify(error));
Q
quanli 已提交
683
            expect(true).assertFalse();
Q
quanli 已提交
684
        }
Q
quanli 已提交
685
        await sleep(1500);
Q
quanli 已提交
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1800
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario and set a car-sharing scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_1800', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":5,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.info('[lbs_js] locationChanger18 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn18 try err." + JSON.stringify(error));
Q
quanli 已提交
709
            expect(true).assertFalse();
Q
quanli 已提交
710 711 712 713 714
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff18 try err." + JSON.stringify(error));
Q
quanli 已提交
715
            expect(true).assertFalse();
Q
quanli 已提交
716
        }
Q
quanli 已提交
717
        await sleep(1500);
Q
quanli 已提交
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1900
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario and set a life service scenario.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_1900', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.info('[lbs_js] locationChanger19 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn19 try err." + JSON.stringify(error));
Q
quanli 已提交
741
            expect(true).assertFalse();
Q
quanli 已提交
742 743 744 745 746
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff19 try err." + JSON.stringify(error));
Q
quanli 已提交
747
            expect(true).assertFalse();
Q
quanli 已提交
748
        }
Q
quanli 已提交
749
        await sleep(1500);
Q
quanli 已提交
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_2000
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario
     *          and set the scenario with no power consumption.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2000', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x305, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange1 = (location) => {
            console.log('[lbs_js] locationChanger201 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange1 !=null);
        };
        var locationChange2 = (location) => {
            console.log('[lbs_js] locationChanger202 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange2 !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn201 try err." + JSON.stringify(error));
Q
quanli 已提交
778
            expect(true).assertFalse();
Q
quanli 已提交
779 780 781 782 783
        }
        try {
            geolocationm.on('locationChange', requestInfo, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn202 try err." + JSON.stringify(error));
Q
quanli 已提交
784
            expect(true).assertFalse();
Q
quanli 已提交
785 786 787 788 789
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff201 try err." + JSON.stringify(error));
Q
quanli 已提交
790
            expect(true).assertFalse();
Q
quanli 已提交
791 792 793 794 795
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff202 try err." + JSON.stringify(error));
Q
quanli 已提交
796
            expect(true).assertFalse();
Q
quanli 已提交
797
        }
Q
quanli 已提交
798
        await sleep(1500);
Q
quanli 已提交
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_2100
     * @tc.name Test locationChange
     * @tc.desc Initiate a specified continuous positioning request and
     *          set the parameter to high-precision priority positioning request.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2100', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x201, "scenario":0x300, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger21 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn21 try err." + JSON.stringify(error));
Q
quanli 已提交
823
            expect(true).assertFalse();
Q
quanli 已提交
824 825 826 827 828
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff21 try err." + JSON.stringify(error));
Q
quanli 已提交
829
            expect(true).assertFalse();
Q
quanli 已提交
830
        }
Q
quanli 已提交
831
        await sleep(1500);
Q
quanli 已提交
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_2200
     * @tc.name Test locationChange
     * @tc.desc Initiate a specified continuous positioning request with the parameter
     *          set to fast positioning and priority positioning request.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2200', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x203, "scenario":0x300, "timeInterval":5,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger22 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn22 try err." + JSON.stringify(error));
Q
quanli 已提交
856
            expect(true).assertFalse();
Q
quanli 已提交
857 858 859 860 861
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff22 try err." + JSON.stringify(error));
Q
quanli 已提交
862
            expect(true).assertFalse();
Q
quanli 已提交
863
        }
Q
quanli 已提交
864
        await sleep(1500);
Q
quanli 已提交
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_2300
     * @tc.name Test locationChange
     * @tc.desc Initiate a specified continuous positioning request with the parameter
     *          set to low power consumption type.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2300', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x202, "scenario":0x300, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10}
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger23 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn23 try err." + JSON.stringify(error));
Q
quanli 已提交
889
            expect(true).assertFalse();
Q
quanli 已提交
890 891 892 893 894
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff23 try err." + JSON.stringify(error));
Q
quanli 已提交
895
            expect(true).assertFalse();
Q
quanli 已提交
896
        }
Q
quanli 已提交
897
        await sleep(1500);
Q
quanli 已提交
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_2400
     * @tc.name Test locationChange
     * @tc.desc Initiate a specified continuous location request and set the reporting interval.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2400', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":3,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger24 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn24 try err." + JSON.stringify(error));
Q
quanli 已提交
921
            expect(true).assertFalse();
Q
quanli 已提交
922 923 924 925 926
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff24 try err." + JSON.stringify(error));
Q
quanli 已提交
927
            expect(true).assertFalse();
Q
quanli 已提交
928
        }
Q
quanli 已提交
929
        await sleep(1500);
Q
quanli 已提交
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1100
     * @tc.name Test locationChange
     * @tc.desc Initiate a specified continuous location request and set the location reporting interval.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LocRequest_2500', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger25 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn25 try err." + JSON.stringify(error));
Q
quanli 已提交
953
            expect(true).assertFalse();
Q
quanli 已提交
954 955 956 957 958
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff25 try err." + JSON.stringify(error));
Q
quanli 已提交
959
            expect(true).assertFalse();
Q
quanli 已提交
960
        }
Q
quanli 已提交
961
        await sleep(1500);
Q
quanli 已提交
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_LocRequest_2600
    * @tc.name Test locationChange
    * @tc.desc Initiate a specified continuous location request and set the interval for reporting exceptions.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_LocRequest_2600', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('[lbs_js] locationChanger26 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn26 try err." + JSON.stringify(error));
Q
quanli 已提交
985
            expect(true).assertFalse();
Q
quanli 已提交
986 987 988 989 990
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff26 try err." + JSON.stringify(error));
Q
quanli 已提交
991
            expect(true).assertFalse();
Q
quanli 已提交
992
        }
Q
quanli 已提交
993
        await sleep(1500);
Q
quanli 已提交
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_LocRequest_2700
    * @tc.name Test locationChange
    * @tc.desc Initiate a specified continuous location request and set the interval for reporting abnormal locations.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_LocRequest_2700', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        let requestInfo2 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange1 = (location) => {
            console.log('[lbs_js] locationChanger271 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange1 !=null);
        };
        var locationChange2 = (location) => {
            console.log('[lbs_js] locationChanger272 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange2 !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn271 try err." + JSON.stringify(error));
Q
quanli 已提交
1023
            expect(true).assertFalse();
Q
quanli 已提交
1024 1025 1026 1027 1028
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff271 try err." + JSON.stringify(error));
Q
quanli 已提交
1029
            expect(true).assertFalse();
Q
quanli 已提交
1030
        }
Q
quanli 已提交
1031
        await sleep(1500);
Q
quanli 已提交
1032 1033 1034 1035
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn272 try err." + JSON.stringify(error));
Q
quanli 已提交
1036
           expect(true).assertFalse();
Q
quanli 已提交
1037 1038 1039 1040 1041
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff272 try err." + JSON.stringify(error));
Q
quanli 已提交
1042
            expect(true).assertFalse();
Q
quanli 已提交
1043
        }
Q
quanli 已提交
1044
        await sleep(1500);
Q
quanli 已提交
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_LocRequest_2800
    * @tc.name Test locationChange
    * @tc.desc Initiate a specified continuous positioning request and set the positioning reporting precision.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_LocRequest_2800', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 5};
        let requestInfo2 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 2};
        var locationChange1 = (location) => {
            console.log('[lbs_js] locationChanger281 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange1 !=null);
        };
        var locationChange2 = (location) => {
            console.log('[lbs_js] locationChanger282 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange2 !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn281 try err." + JSON.stringify(error));
Q
quanli 已提交
1074
            expect(true).assertFalse();
Q
quanli 已提交
1075 1076 1077 1078 1079
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff281 try err." + JSON.stringify(error));
Q
quanli 已提交
1080
            expect(true).assertFalse();
Q
quanli 已提交
1081
        }
Q
quanli 已提交
1082
        await sleep(1500);
Q
quanli 已提交
1083 1084 1085 1086
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn282 try err." + JSON.stringify(error));
Q
quanli 已提交
1087
            expect(true).assertFalse();
Q
quanli 已提交
1088 1089 1090 1091 1092
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff282 try err." + JSON.stringify(error));
Q
quanli 已提交
1093
            expect(true).assertFalse();
Q
quanli 已提交
1094
        }
Q
quanli 已提交
1095
        await sleep(1500);
Q
quanli 已提交
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_LocRequest_2900
    * @tc.name Test locationChange
    * @tc.desc Initiate a specified continuous location request and set the reporting precision of abnormal location.
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 2
    */
    it('SUB_HSS_LocationSystem_LocRequest_2900', 0, async function (done) {
        enableLocationSwitch();
        let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        let requestInfo2 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": -1};
        var locationChange1 = (location) => {
            console.log('[lbs_js] locationChanger291 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange1 !=null);
        };
        var locationChange2 = (location) => {
            console.log('[lbs_js] locationChanger292 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange2 !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn291 try err." + JSON.stringify(error));
Q
quanli 已提交
1125
            expect(true).assertFalse();
Q
quanli 已提交
1126 1127 1128 1129 1130
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff291 try err." + JSON.stringify(error));
Q
quanli 已提交
1131
            expect(true).assertFalse();
Q
quanli 已提交
1132
        }
Q
quanli 已提交
1133
        await sleep(1500);
Q
quanli 已提交
1134 1135 1136 1137
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn292 try err." + JSON.stringify(error));
Q
quanli 已提交
1138
            expect(true).assertFalse();
Q
quanli 已提交
1139 1140 1141 1142 1143
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff292 try err." + JSON.stringify(error));
Q
quanli 已提交
1144
            expect(true).assertFalse();
Q
quanli 已提交
1145
        }
Q
quanli 已提交
1146
        await sleep(1500);
Q
quanli 已提交
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_LastLoc_0300
     * @tc.name Test getLastLocation
     * @tc.desc Obtain the last location after a single location.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_LastLoc_0300', 0, async function(done) {
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.info('[lbs_js] LastlocationChanger1: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1170
            expect(true).assertFalse();
Q
quanli 已提交
1171 1172 1173 1174 1175
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1176
            expect(true).assertFalse();
Q
quanli 已提交
1177
        }
Q
quanli 已提交
1178
        await sleep(1500);
Q
quanli 已提交
1179
        try {
Q
quanli 已提交
1180 1181
            let last =geolocationm.getLastLocation();
            console.info('[lbs_js] getLastLocation latitude: ' + last.latitude +
Q
quanli 已提交
1182 1183 1184 1185 1186
            ' longitude: ' + last.longitude +' altitude: ' + last.altitude
            +' accuracy: ' + last.accuracy+' speed: ' + last.speed +
            'timeStamp: ' + last.timeStamp+'direction:' + last.direction+' timeSinceBoot: '
            + last.timeSinceBoot +'additions: ' + last.additions+' additionSize' + last.additionSize
            + 'isFromMock' +last.isFromMock);
Q
quanli 已提交
1187

Q
quanli 已提交
1188 1189 1190
            expect(true).assertEqual(JSON.stringify(last) != null);
        } catch (error) {
            console.info("[lbs_js] getLastLocation error:"+ error)
Q
quanli 已提交
1191
            expect(error.code).assertEqual("3301200");
Q
quanli 已提交
1192
        }
Q
quanli 已提交
1193
        await sleep(1500);
Q
quanli 已提交
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Gnss_0300
     * @tc.name Test gnssStatusChange
     * @tc.desc Monitoring Satellite Information Reporting
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Gnss_0300', 0, async function (done) {
        await changedLocationMode();
        var gnssStatusCb = (satelliteStatusInfo) => {
            console.info('[lbs_js] gnssStatusChange1: ' + satelliteStatusInfo);
            expect(true).assertEqual(satelliteStatusInfo != null)
            console.info('[lbs_js] SatelliteStatusInfo satellitesNumber: ' + data[0].satellitesNumber +
            'satelliteIds' + data[0].satelliteIds +'carrierToNoiseDensitys'+ data[0].carrierToNoiseDensitys
            +'altitudes' + data[0].altitudes+' azimuths: ' + data[0].azimuths +
            'carrierFrequencies: ' + data[0].carrierFrequencies);
        }
        try {
            geolocationm.on('satelliteStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] satelliteStatusOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1219
            expect(true).assertFalse();
Q
quanli 已提交
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
        }
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('[lbs_js] gnsslocationChanger3: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1232
            expect(true).assertFalse();
Q
quanli 已提交
1233 1234 1235 1236 1237
        }
        try {
            geolocationm.off('satelliteStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] satelliteStatusOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1238
            expect(true).assertFalse();
Q
quanli 已提交
1239 1240 1241 1242 1243
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1244
            expect(true).assertFalse();
Q
quanli 已提交
1245
        }
Q
quanli 已提交
1246
        await sleep(1000);
Q
quanli 已提交
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Gnss_0400
     * @tc.name Test nmeaMessageChange
     * @tc.desc Monitoring NMEA Information Reporting
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
     it('SUB_HSS_LocationSystem_Gnss_0400', 0, async function (done) {
        await changedLocationMode();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var nmeaCb = (str) => {
            console.log('[lbs_js] nmeaMessage: ' + str);
        }
        var locationChange = (location) => {
            console.log('[lbs_js] gnsslocationChanger4 data:' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
        try {
            geolocationm.on('nmeaMessage', nmeaCb);
        } catch (error) {
            console.info("nmea on err:" + JSON.stringify(error));
Q
quanli 已提交
1273
            expect(true).assertFalse();
Q
quanli 已提交
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284
        }
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn04 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocationm.off('nmeaMessage', nmeaCb);
        } catch (error) { 
            console.info("nmea off err:" + JSON.stringify(error));
Q
quanli 已提交
1285
            expect(true).assertFalse();
Q
quanli 已提交
1286 1287 1288 1289 1290
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1291
            expect(true).assertFalse();
Q
quanli 已提交
1292
        }
Q
quanli 已提交
1293
        await sleep(1000);
Q
quanli 已提交
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_0700
     * @tc.name Test cachedGnssLocationsReporting
     * @tc.desc Setting the Gnss Batching Reporting Interval
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_0700', 0, async function (done) {
        var cachedLocationsCb1 = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting7:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest1 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest1, cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn071 try err." + JSON.stringify(error));
Q
quanli 已提交
1315
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1316 1317 1318 1319 1320
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff071 try err." + JSON.stringify(error));
Q
quanli 已提交
1321 1322
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1323
        }
Q
quanli 已提交
1324
        await sleep(1500);
Q
quanli 已提交
1325 1326 1327 1328 1329 1330 1331 1332 1333
        var cachedLocationsCb2 = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting7:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest2 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest2, cachedLocationsCb2);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn072 try err." + JSON.stringify(error));
Q
quanli 已提交
1334 1335
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1336 1337 1338 1339 1340
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff072 try err." + JSON.stringify(error));
Q
quanli 已提交
1341 1342
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1343
        }
Q
quanli 已提交
1344
        await sleep(1500);
Q
quanli 已提交
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_0800
     * @tc.name Test cachedGnssLocationsReporting
     * @tc.desc Setting the Gnss Batching Cache Queue to Be Reported When the Gnss Batching Cache Queue Is Full
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_0800', 0, async function (done) {
        var cachedLocationsCb = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting8:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn08 try err." + JSON.stringify(error));
Q
quanli 已提交
1366 1367
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1368 1369 1370 1371 1372
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff08 try err." + JSON.stringify(error));
Q
quanli 已提交
1373 1374
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1375
        }
Q
quanli 已提交
1376
        await sleep(1500);
Q
quanli 已提交
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_0900
     * @tc.name Test getCachedGnssLocationsSize
     * @tc.desc Obtains the number of GNSS data records in the batching process.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_0900', 0, async function (done) {
        var cachedLocationsCb = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting9:locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn09 try err." + JSON.stringify(error));
Q
quanli 已提交
1398 1399
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1400 1401 1402 1403 1404
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff09 try err." + JSON.stringify(error));
Q
quanli 已提交
1405 1406
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1407
        }
Q
quanli 已提交
1408
        await sleep(1500);
Q
quanli 已提交
1409 1410 1411 1412
        try {
            geolocationm.getCachedGnssLocationsSize((err, data) => {
                if (err) {
                    console.info('[lbs_js] getCachedGnssLocationsSize09 callback err:' + JSON.stringify(err));
Q
quanli 已提交
1413 1414
                    console.info('[lbs_js] not support now');
                    expect(err.code).assertEqual(801);
Q
quanli 已提交
1415 1416 1417 1418 1419 1420 1421
                }else {
                    console.info("[lbs_js] getCachedGnssLocationsSize09 callback data:" + JSON.stringify(data));
                    expect(true).assertEqual(data != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] getCachedGnssLocationsSize09 callback try err." + JSON.stringify(error));
Q
quanli 已提交
1422 1423
            expect(true).assertFalse();

Q
quanli 已提交
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446
        }
        await sleep(1000);
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_1000
     * @tc.name Test getCachedGnssLocationsSize
     * @tc.desc Obtains the number of GNSS data records in the batching process.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_1000', 0, async function (done) {
        var cachedLocationsCb = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting10:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn10 try err." + JSON.stringify(error));
Q
quanli 已提交
1447 1448
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1449 1450 1451 1452 1453
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff10 try err." + JSON.stringify(error));
Q
quanli 已提交
1454 1455
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1456
        }
Q
quanli 已提交
1457
        await sleep(1000);
Q
quanli 已提交
1458 1459 1460 1461 1462 1463
        try {
            await geolocationm.getCachedGnssLocationsSize().then( (result) => {
                console.info('[lbs_js] getCachedGnssLocationsSiz promise '+ JSON.stringify(result));
                expect(true).assertEqual(result != null);
            }).catch((error) => {
                console.info("[lbs_js] promise then error." + JSON.stringify(error));
Q
quanli 已提交
1464 1465
                console.info('[lbs_js] not support now');
            expect(error.code).assertEqual(801);
Q
quanli 已提交
1466 1467 1468
            });
        } catch (error) {
            console.info("[lbs_js] getCachedGnssLocationsSize promise try err." + JSON.stringify(error));
Q
quanli 已提交
1469
            expect(true).assertFalse();
Q
quanli 已提交
1470
        }
Q
quanli 已提交
1471
        await sleep(1500);
Q
quanli 已提交
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_1100
     * @tc.name Test flushCachedGnssLocations
     * @tc.desc Obtains the GNSS data of the current batching.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_1100', 0, async function (done) {
        var cachedLocationsCb = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting11:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error));
Q
quanli 已提交
1493 1494
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1495 1496 1497 1498 1499
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error));
Q
quanli 已提交
1500 1501
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1502
        }
Q
quanli 已提交
1503
        await sleep(1000);
Q
quanli 已提交
1504 1505 1506 1507
        try {
            geolocationm.flushCachedGnssLocations((err, data) => {
                if (err) {
                    console.info('[lbs_js] flushCachedGnssLocations11 callback err is : ' + JSON.stringify(err));
Q
quanli 已提交
1508 1509
                    console.info('[lbs_js] not support now');
                    expect(err.code).assertEqual(801);
Q
quanli 已提交
1510 1511 1512 1513 1514 1515 1516
                }else {
                    console.info("[lbs_js] flushCachedGnssLocations11 callback data is: " + JSON.stringify(data));
                    expect(true).assertEqual(data != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] flushCachedGnssLocations11 callback try err." + JSON.stringify(error));
Q
quanli 已提交
1517
            expect(true).assertFalse();
Q
quanli 已提交
1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
        }
        await sleep(1000);
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_Batching_1200
     * @tc.name Test flushCachedGnssLocations
     * @tc.desc Obtain the GNSS data of the current batching.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
    it('SUB_HSS_LocationSystem_Batching_1200', 0, async function (done) {
        var cachedLocationsCb = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting12:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error));
Q
quanli 已提交
1541 1542
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1543 1544 1545 1546 1547
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error));
Q
quanli 已提交
1548 1549
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1550
        }
Q
quanli 已提交
1551
        await sleep(1000);
Q
quanli 已提交
1552 1553 1554 1555 1556 1557
        try {
            await geolocationm.flushCachedGnssLocations().then( (result) => {
                console.info('[lbs_js] flushCachedGnssLocations promise '+ JSON.stringify(result));
                expect(true).assertEqual(result != null);
            }).catch((error) => {
                console.info("[lbs_js] promise then error." + JSON.stringify(error));
Q
quanli 已提交
1558 1559
                console.info('[lbs_js] not support now');
                expect(error.code).assertEqual(801);
Q
quanli 已提交
1560 1561 1562
            });
        } catch (error) {
            console.info("[lbs_js] flushCachedGnssLocations11 promise try err." + JSON.stringify(error));
Q
quanli 已提交
1563
            expect(true).assertFalse();
Q
quanli 已提交
1564
        }
Q
quanli 已提交
1565
        await sleep(1000);
Q
quanli 已提交
1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
        done();
    })

    /**
    * @tc.number SUB_HSS_LocationSystem_GeoFence_0200
    * @tc.name Test fenceStatusChange
    * @tc.desc Gnss fence function test
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 1
    */
    it('SUB_HSS_LocationSystem_GeoFence_0200', 0, async function (done) {
        await changedLocationMode();
        let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
        let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence};
        try {
            geolocationm.on('gnssFenceStatusChange', geofenceRequest,
                (want) => {
                    if(err){
                        return console.info("fenceStatusChange2 on callback err:" + err);
                    }
                    console.info("[lbs_js] fenceStatusChange2 callback result:" + JSON.stringify(want));
                    expect(true).assertEqual(want !=null);
                });
        } catch (error) {
            console.info("[lbs_js] FenceStatusOn2 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1592 1593
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605
        }
        try {
            geolocationm.off('gnssFenceStatusChange',geofenceRequest,
                (want) => {
                    if(err){
                        return console.info("fenceStatusChange2 callback err:" + err);
                    }
                    console.info("[lbs_js] off fenceStatusChange2 callback result:" + JSON.stringify(want));
                    expect(true).assertEqual(want !=null);
                });
        } catch (error) {
            console.info("[lbs_js] FenceStatusOff2 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1606 1607
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
        }
        await sleep(1000);
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_GeoFence_0300
     * @tc.name Test fenceStatusChange
     * @tc.desc Test the function of locating the validity period of the fence.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 1
     */
    it('SUB_HSS_LocationSystem_GeoFence_0300', 0, async function (done) {
        await changedLocationMode();
        let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
        let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence};
        try {
            geolocationm.on('gnssFenceStatusChange', geofenceRequest,
                (want) => {
                    if(err){
                        return console.info("[lbs_js] fenceStatusChange3 on callback err: " + err);
Q
quanli 已提交
1630 1631
                        console.info("[lbs_js] fenceStatusChange not support ");
                        expect(err.code).assertEqual(801);
Q
quanli 已提交
1632 1633 1634 1635 1636 1637
                    }
                    console.info("[lbs_js] fenceStatusChange3 callback result: " + JSON.stringify(want));
                    expect(true).assertEqual(want !=null);
                });
        } catch (error) {
            console.info("[lbs_js] FenceStatusOn3 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1638 1639
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651
        }
        try {
            geolocationm.off('gnssFenceStatusChange',geofenceRequest,
                (want) => {
                    if(err){
                        return console.info("fenceStatusChange3 callback  err:" + err);
                    }
                    console.info("[lbs_js] off fenceStatusChange3 callback result:" + JSON.stringify(want));
                    expect(true).assertEqual(want !=null);
                });
        } catch (error) {
            console.info("[lbs_js] FenceStatusOff3 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1652 1653
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1654 1655 1656 1657 1658 1659 1660 1661
        }
        await sleep(1000);
        done();
    })

    })
}