LocationMTest.test.js 70.1 KB
Newer Older
Q
quanli 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Q
quanli 已提交
16
import geolocation from '@ohos.geolocation';
Q
quanli 已提交
17 18 19 20
import geolocationm from '@ohos.geoLocationManager';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
Q
quanli 已提交
21
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
Q
quanli 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

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){
Q
quanli 已提交
41
        await geolocation.requestEnableLocation().then(async(result) => {
Q
quanli 已提交
42
            ;
Q
quanli 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55
            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)=>{
Q
quanli 已提交
56
            geolocation.requestEnableLocation((err, data) => {
Q
quanli 已提交
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
                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
    } else {
        console.info('[permission] case apply permission failed, createAtManager failed');
    }
}


Q
quanli 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
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 已提交
121

Q
quanli 已提交
122

Q
quanli 已提交
123 124 125 126 127 128 129 130
    /**
     * @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
     */
Q
quanli 已提交
131 132 133
     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
        } catch (error) {
            console.info("[lbs_js] getLocationSwitchState06 try err." + JSON.stringify(error));
            expect().assertFail();
        }
Q
quanli 已提交
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
    });

    /**
     * @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));
        }
Q
quanli 已提交
155 156
        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
        }
Q
quanli 已提交
168 169 170 171 172 173
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1500
     * @tc.name Test getCurrentLocation
Q
quanli 已提交
174
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.
Q
quanli 已提交
175 176 177 178 179 180
     * @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 };
Q
quanli 已提交
181 182 183 184
        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
        done();
    })

    /**
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1600
     * @tc.name Test getCurrentLocation
Q
quanli 已提交
204
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.
Q
quanli 已提交
205 206 207 208 209 210
     * @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 };
Q
quanli 已提交
211 212 213 214 215
        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
        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 };
Q
quanli 已提交
236 237 238 239 240 241
        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
        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 };
Q
quanli 已提交
262 263 264 265 266
        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
        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 };
Q
quanli 已提交
287 288 289 290 291
        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
        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 };
Q
quanli 已提交
314
        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
        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 };
Q
quanli 已提交
351 352 353 354 355
        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
        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 };
Q
quanli 已提交
376 377 378 379 380
        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
        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 };
Q
quanli 已提交
401 402 403 404 405
        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
        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 };
Q
quanli 已提交
427 428 429 430 431
        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
        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 };
Q
quanli 已提交
466 467 468 469 470
        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
        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 };
Q
quanli 已提交
504 505 506 507 508
        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
        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 };
Q
quanli 已提交
542 543 544 545 546
        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 615
                console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error));
                console.info('[lbs_js] not support now');
                expect(error.code).assertEqual(801);
                //expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
616 617 618
                done();
            })
        } catch (error) {
Q
quanli 已提交
619 620
            console.info('[lbs_js] sendcommand promise err:' + JSON.stringify(error));
            expect(true).assertFalse();
Q
quanli 已提交
621
        }
Q
quanli 已提交
622
        await sleep(1000);
Q
quanli 已提交
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
        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);
        };
Q
quanli 已提交
642 643 644 645
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn16 try err." + JSON.stringify(error));
Q
quanli 已提交
646
            expect(true).assertFalse();
Q
quanli 已提交
647 648 649 650 651
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff16 try err." + JSON.stringify(error));
Q
quanli 已提交
652
            expect(true).assertFalse();
Q
quanli 已提交
653
        }
Q
quanli 已提交
654
        await sleep(1000);
Q
quanli 已提交
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
        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);
        };
Q
quanli 已提交
674 675 676 677
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn17 try err." + JSON.stringify(error));
Q
quanli 已提交
678
            expect(true).assertFalse();
Q
quanli 已提交
679 680 681 682 683
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff17 try err." + JSON.stringify(error));
Q
quanli 已提交
684
            expect(true).assertFalse();
Q
quanli 已提交
685
        }
Q
quanli 已提交
686
        await sleep(1500);
Q
quanli 已提交
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
        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);
        };
Q
quanli 已提交
706 707 708 709
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn18 try err." + JSON.stringify(error));
Q
quanli 已提交
710
            expect(true).assertFalse();
Q
quanli 已提交
711 712 713 714 715
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff18 try err." + JSON.stringify(error));
Q
quanli 已提交
716
            expect(true).assertFalse();
Q
quanli 已提交
717
        }
Q
quanli 已提交
718
        await sleep(1500);
Q
quanli 已提交
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
        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);
        };
Q
quanli 已提交
738 739 740 741
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn19 try err." + JSON.stringify(error));
Q
quanli 已提交
742
            expect(true).assertFalse();
Q
quanli 已提交
743 744 745 746 747
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff19 try err." + JSON.stringify(error));
Q
quanli 已提交
748
            expect(true).assertFalse();
Q
quanli 已提交
749
        }
Q
quanli 已提交
750
        await sleep(1500);
Q
quanli 已提交
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
        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);
        };
Q
quanli 已提交
775 776 777 778
        try {
            geolocationm.on('locationChange', requestInfo, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn201 try err." + JSON.stringify(error));
Q
quanli 已提交
779
            expect(true).assertFalse();
Q
quanli 已提交
780 781 782 783 784
        }
        try {
            geolocationm.on('locationChange', requestInfo, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn202 try err." + JSON.stringify(error));
Q
quanli 已提交
785
            expect(true).assertFalse();
Q
quanli 已提交
786 787 788 789 790
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff201 try err." + JSON.stringify(error));
Q
quanli 已提交
791
            expect(true).assertFalse();
Q
quanli 已提交
792 793 794 795 796
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff202 try err." + JSON.stringify(error));
Q
quanli 已提交
797
            expect(true).assertFalse();
Q
quanli 已提交
798
        }
Q
quanli 已提交
799
        await sleep(1500);
Q
quanli 已提交
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819
        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);
        };
Q
quanli 已提交
820 821 822 823
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn21 try err." + JSON.stringify(error));
Q
quanli 已提交
824
            expect(true).assertFalse();
Q
quanli 已提交
825 826 827 828 829
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff21 try err." + JSON.stringify(error));
Q
quanli 已提交
830
            expect(true).assertFalse();
Q
quanli 已提交
831
        }
Q
quanli 已提交
832
        await sleep(1500);
Q
quanli 已提交
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
        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);
        };
Q
quanli 已提交
853 854 855 856
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn22 try err." + JSON.stringify(error));
Q
quanli 已提交
857
            expect(true).assertFalse();
Q
quanli 已提交
858 859 860 861 862
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff22 try err." + JSON.stringify(error));
Q
quanli 已提交
863
            expect(true).assertFalse();
Q
quanli 已提交
864
        }
Q
quanli 已提交
865
        await sleep(1500);
Q
quanli 已提交
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
        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);
        };
Q
quanli 已提交
886 887 888 889
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn23 try err." + JSON.stringify(error));
Q
quanli 已提交
890
            expect(true).assertFalse();
Q
quanli 已提交
891 892 893 894 895
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff23 try err." + JSON.stringify(error));
Q
quanli 已提交
896
            expect(true).assertFalse();
Q
quanli 已提交
897
        }
Q
quanli 已提交
898
        await sleep(1500);
Q
quanli 已提交
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
        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);
        };
Q
quanli 已提交
918 919 920 921
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn24 try err." + JSON.stringify(error));
Q
quanli 已提交
922
            expect(true).assertFalse();
Q
quanli 已提交
923 924 925 926 927
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff24 try err." + JSON.stringify(error));
Q
quanli 已提交
928
            expect(true).assertFalse();
Q
quanli 已提交
929
        }
Q
quanli 已提交
930
        await sleep(1500);
Q
quanli 已提交
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
        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);
        };
Q
quanli 已提交
950 951 952 953
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn25 try err." + JSON.stringify(error));
Q
quanli 已提交
954
            expect(true).assertFalse();
Q
quanli 已提交
955 956 957 958 959
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff25 try err." + JSON.stringify(error));
Q
quanli 已提交
960
            expect(true).assertFalse();
Q
quanli 已提交
961
        }
Q
quanli 已提交
962
        await sleep(1500);
Q
quanli 已提交
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
        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);
        };
Q
quanli 已提交
982 983 984 985
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn26 try err." + JSON.stringify(error));
Q
quanli 已提交
986
            expect(true).assertFalse();
Q
quanli 已提交
987 988 989 990 991
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff26 try err." + JSON.stringify(error));
Q
quanli 已提交
992
            expect(true).assertFalse();
Q
quanli 已提交
993
        }
Q
quanli 已提交
994
        await sleep(1500);
Q
quanli 已提交
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
        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) => {
Q
quanli 已提交
1017
            console.log('[lbs_js] locationChanger272 data:' + JSON.stringify(location));
Q
quanli 已提交
1018 1019
            expect(true).assertEqual(locationChange2 !=null);
        };
Q
quanli 已提交
1020 1021 1022 1023
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn271 try err." + JSON.stringify(error));
Q
quanli 已提交
1024
            expect(true).assertFalse();
Q
quanli 已提交
1025 1026 1027 1028 1029
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff271 try err." + JSON.stringify(error));
Q
quanli 已提交
1030
            expect(true).assertFalse();
Q
quanli 已提交
1031
        }
Q
quanli 已提交
1032
        await sleep(1500);
Q
quanli 已提交
1033 1034 1035 1036
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn272 try err." + JSON.stringify(error));
Q
quanli 已提交
1037
           expect(true).assertFalse();
Q
quanli 已提交
1038 1039 1040 1041 1042
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff272 try err." + JSON.stringify(error));
Q
quanli 已提交
1043
            expect(true).assertFalse();
Q
quanli 已提交
1044
        }
Q
quanli 已提交
1045
        await sleep(1500);
Q
quanli 已提交
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
        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);
        };
Q
quanli 已提交
1071 1072 1073 1074
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn281 try err." + JSON.stringify(error));
Q
quanli 已提交
1075
            expect(true).assertFalse();
Q
quanli 已提交
1076 1077 1078 1079 1080
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff281 try err." + JSON.stringify(error));
Q
quanli 已提交
1081
            expect(true).assertFalse();
Q
quanli 已提交
1082
        }
Q
quanli 已提交
1083
        await sleep(1500);
Q
quanli 已提交
1084 1085 1086 1087
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn282 try err." + JSON.stringify(error));
Q
quanli 已提交
1088
            expect(true).assertFalse();
Q
quanli 已提交
1089 1090 1091 1092 1093
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff282 try err." + JSON.stringify(error));
Q
quanli 已提交
1094
            expect(true).assertFalse();
Q
quanli 已提交
1095
        }
Q
quanli 已提交
1096
        await sleep(1500);
Q
quanli 已提交
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
        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);
        };
Q
quanli 已提交
1122 1123 1124 1125
        try {
            geolocationm.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn291 try err." + JSON.stringify(error));
Q
quanli 已提交
1126
            expect(true).assertFalse();
Q
quanli 已提交
1127 1128 1129 1130 1131
        }
        try {
            geolocationm.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff291 try err." + JSON.stringify(error));
Q
quanli 已提交
1132
            expect(true).assertFalse();
Q
quanli 已提交
1133
        }
Q
quanli 已提交
1134
        await sleep(1500);
Q
quanli 已提交
1135 1136 1137 1138
        try {
            geolocationm.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn292 try err." + JSON.stringify(error));
Q
quanli 已提交
1139
            expect(true).assertFalse();
Q
quanli 已提交
1140 1141 1142 1143 1144
        }
        try {
            geolocationm.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff292 try err." + JSON.stringify(error));
Q
quanli 已提交
1145
            expect(true).assertFalse();
Q
quanli 已提交
1146
        }
Q
quanli 已提交
1147
        await sleep(1500);
Q
quanli 已提交
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
        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);
        };
Q
quanli 已提交
1167 1168 1169 1170
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1171
            expect(true).assertFalse();
Q
quanli 已提交
1172 1173 1174 1175 1176
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1177
            expect(true).assertFalse();
Q
quanli 已提交
1178
        }
Q
quanli 已提交
1179
        await sleep(1500);
Q
quanli 已提交
1180
        try {
Q
quanli 已提交
1181 1182
            let last =geolocationm.getLastLocation();
            console.info('[lbs_js] getLastLocation latitude: ' + last.latitude +
Q
quanli 已提交
1183 1184 1185 1186 1187
            ' longitude: ' + result.longitude +' altitude: ' + result.altitude
            +' accuracy: ' + result.accuracy+' speed: ' + result.speed +
            'timeStamp: ' + result.timeStamp+'direction:' + result.direction+' timeSinceBoot: '
            + result.timeSinceBoot +'additions: ' + result.additions+' additionSize' + result.additionSize
            + 'isFromMock' +result.isFromMock);
Q
quanli 已提交
1188

Q
quanli 已提交
1189 1190 1191
            expect(true).assertEqual(JSON.stringify(last) != null);
        } catch (error) {
            console.info("[lbs_js] getLastLocation error:"+ error)
Q
quanli 已提交
1192
            expect(error.code).assertEqual("3301200");
Q
quanli 已提交
1193
        }
Q
quanli 已提交
1194
        await sleep(1500);
Q
quanli 已提交
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215
        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);
        }
Q
quanli 已提交
1216 1217 1218 1219
        try {
            geolocationm.on('satelliteStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] satelliteStatusOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1220
            expect(true).assertFalse();
Q
quanli 已提交
1221
        }
Q
quanli 已提交
1222 1223 1224 1225 1226 1227 1228
        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);
        };
Q
quanli 已提交
1229 1230 1231 1232
        try {
            geolocationm.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOn03 try err." + JSON.stringify(error));
Q
quanli 已提交
1233
            expect(true).assertFalse();
Q
quanli 已提交
1234 1235 1236 1237 1238
        }
        try {
            geolocationm.off('satelliteStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] satelliteStatusOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1239
            expect(true).assertFalse();
Q
quanli 已提交
1240 1241 1242 1243 1244
        }
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1245
            expect(true).assertFalse();
Q
quanli 已提交
1246
        }
Q
quanli 已提交
1247
        await sleep(1000);
Q
quanli 已提交
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 1273
        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 已提交
1274
            expect(true).assertFalse();
Q
quanli 已提交
1275
        }
Q
quanli 已提交
1276 1277 1278 1279 1280 1281
        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);
        }
Q
quanli 已提交
1282 1283 1284 1285
        try {
            geolocationm.off('nmeaMessage', nmeaCb);
        } catch (error) { 
            console.info("nmea off err:" + JSON.stringify(error));
Q
quanli 已提交
1286
            expect(true).assertFalse();
Q
quanli 已提交
1287
        }
Q
quanli 已提交
1288 1289 1290 1291
        try {
            geolocationm.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangerOff03 try err." + JSON.stringify(error));
Q
quanli 已提交
1292
            expect(true).assertFalse();
Q
quanli 已提交
1293
        }
Q
quanli 已提交
1294
        await sleep(1000);
Q
quanli 已提交
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311
        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};
Q
quanli 已提交
1312 1313 1314 1315
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest1, cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn071 try err." + JSON.stringify(error));
Q
quanli 已提交
1316
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1317 1318 1319 1320 1321
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff071 try err." + JSON.stringify(error));
Q
quanli 已提交
1322 1323
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1324
        }
Q
quanli 已提交
1325
        await sleep(1500);
Q
quanli 已提交
1326 1327 1328 1329 1330
        var cachedLocationsCb2 = (locations) => {
            console.log('[lbs_js] cachedGnssLocationsReporting7:locations:' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest2 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false};
Q
quanli 已提交
1331 1332 1333 1334
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest2, cachedLocationsCb2);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn072 try err." + JSON.stringify(error));
Q
quanli 已提交
1335 1336
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1337 1338 1339 1340 1341
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff072 try err." + JSON.stringify(error));
Q
quanli 已提交
1342 1343
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1344
        }
Q
quanli 已提交
1345
        await sleep(1500);
Q
quanli 已提交
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
        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};
Q
quanli 已提交
1363 1364 1365 1366
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn08 try err." + JSON.stringify(error));
Q
quanli 已提交
1367 1368
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1369 1370 1371 1372 1373
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff08 try err." + JSON.stringify(error));
Q
quanli 已提交
1374 1375
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1376
        }
Q
quanli 已提交
1377
        await sleep(1500);
Q
quanli 已提交
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
        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};
Q
quanli 已提交
1395 1396 1397 1398
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn09 try err." + JSON.stringify(error));
Q
quanli 已提交
1399 1400
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1401
        }
Q
quanli 已提交
1402 1403 1404 1405
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff09 try err." + JSON.stringify(error));
Q
quanli 已提交
1406 1407
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1408
        }
Q
quanli 已提交
1409
        await sleep(1500);
Q
quanli 已提交
1410 1411 1412 1413
        try {
            geolocationm.getCachedGnssLocationsSize((err, data) => {
                if (err) {
                    console.info('[lbs_js] getCachedGnssLocationsSize09 callback err:' + JSON.stringify(err));
Q
quanli 已提交
1414 1415
                    console.info('[lbs_js] not support now');
                    expect(err.code).assertEqual(801);
Q
quanli 已提交
1416 1417 1418 1419 1420 1421 1422
                }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 已提交
1423 1424
            expect(true).assertFalse();

Q
quanli 已提交
1425 1426
        }
        await sleep(1000);
Q
quanli 已提交
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
        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};
Q
quanli 已提交
1444 1445 1446 1447
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn10 try err." + JSON.stringify(error));
Q
quanli 已提交
1448 1449
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1450 1451 1452 1453 1454
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff10 try err." + JSON.stringify(error));
Q
quanli 已提交
1455 1456
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1457
        }
Q
quanli 已提交
1458
        await sleep(1000);
Q
quanli 已提交
1459 1460 1461 1462 1463 1464
        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 已提交
1465 1466
                console.info('[lbs_js] not support now');
            expect(error.code).assertEqual(801);
Q
quanli 已提交
1467 1468 1469
            });
        } catch (error) {
            console.info("[lbs_js] getCachedGnssLocationsSize promise try err." + JSON.stringify(error));
Q
quanli 已提交
1470
            expect(true).assertFalse();
Q
quanli 已提交
1471
        }
Q
quanli 已提交
1472
        await sleep(1500);
Q
quanli 已提交
1473
        done();
Q
quanli 已提交
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
    })

    /**
     * @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};
Q
quanli 已提交
1490 1491 1492 1493
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error));
Q
quanli 已提交
1494 1495
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1496 1497 1498 1499 1500
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error));
Q
quanli 已提交
1501 1502
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1503
        }
Q
quanli 已提交
1504
        await sleep(1000);
Q
quanli 已提交
1505 1506 1507 1508
        try {
            geolocationm.flushCachedGnssLocations((err, data) => {
                if (err) {
                    console.info('[lbs_js] flushCachedGnssLocations11 callback err is : ' + JSON.stringify(err));
Q
quanli 已提交
1509 1510
                    console.info('[lbs_js] not support now');
                    expect(err.code).assertEqual(801);
Q
quanli 已提交
1511 1512 1513 1514 1515 1516 1517
                }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 已提交
1518
            expect(true).assertFalse();
Q
quanli 已提交
1519 1520
        }
        await sleep(1000);
Q
quanli 已提交
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537
        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};
Q
quanli 已提交
1538 1539 1540 1541
        try {
            geolocationm.on('cachedGnssLocationsChange', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOn11 try err." + JSON.stringify(error));
Q
quanli 已提交
1542 1543
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1544 1545 1546 1547 1548
        }
        try {
            geolocationm.off('cachedGnssLocationsChange',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssLocOff11 try err." + JSON.stringify(error));
Q
quanli 已提交
1549 1550
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1551
        }
Q
quanli 已提交
1552
        await sleep(1000);
Q
quanli 已提交
1553 1554 1555 1556 1557 1558
        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 已提交
1559 1560
                console.info('[lbs_js] not support now');
                expect(error.code).assertEqual(801);
Q
quanli 已提交
1561 1562 1563
            });
        } catch (error) {
            console.info("[lbs_js] flushCachedGnssLocations11 promise try err." + JSON.stringify(error));
Q
quanli 已提交
1564
            expect(true).assertFalse();
Q
quanli 已提交
1565
        }
Q
quanli 已提交
1566
        await sleep(1000);
Q
quanli 已提交
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581
        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};
Q
quanli 已提交
1582
        try {
Q
quanli 已提交
1583 1584 1585 1586 1587 1588 1589 1590
            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);
                });
Q
quanli 已提交
1591 1592
        } catch (error) {
            console.info("[lbs_js] FenceStatusOn2 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1593 1594
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1595 1596
        }
        try {
Q
quanli 已提交
1597 1598 1599 1600 1601 1602 1603 1604
            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);
                });
Q
quanli 已提交
1605 1606
        } catch (error) {
            console.info("[lbs_js] FenceStatusOff2 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1607 1608
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1609 1610
        }
        await sleep(1000);
Q
quanli 已提交
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625
        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};
Q
quanli 已提交
1626
        try {
Q
quanli 已提交
1627 1628 1629 1630
            geolocationm.on('gnssFenceStatusChange', geofenceRequest,
                (want) => {
                    if(err){
                        return console.info("[lbs_js] fenceStatusChange3 on callback err: " + err);
Q
quanli 已提交
1631 1632
                        console.info("[lbs_js] fenceStatusChange not support ");
                        expect(err.code).assertEqual(801);
Q
quanli 已提交
1633 1634 1635 1636
                    }
                    console.info("[lbs_js] fenceStatusChange3 callback result: " + JSON.stringify(want));
                    expect(true).assertEqual(want !=null);
                });
Q
quanli 已提交
1637 1638
        } catch (error) {
            console.info("[lbs_js] FenceStatusOn3 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1639 1640
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1641 1642
        }
        try {
Q
quanli 已提交
1643 1644 1645 1646 1647 1648 1649 1650
            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);
                });
Q
quanli 已提交
1651 1652
        } catch (error) {
            console.info("[lbs_js] FenceStatusOff3 try error:"+ JSON.stringify(error));
Q
quanli 已提交
1653 1654
            console.info('[lbs_js] not support now');
            expect(error.code).assertEqual("801");
Q
quanli 已提交
1655 1656
        }
        await sleep(1000);
Q
quanli 已提交
1657 1658
        done();
    })
Q
quanli 已提交
1659 1660 1661 1662

    })
}