LocationTest.test.js 73.3 KB
Newer Older
Q
q00313334 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * 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.
 */

import geolocation from '@ohos.geolocation';
import { LocationEventListener } from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
20
import osaccount from '@ohos.account.osAccount'
Q
quanli 已提交
21
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
Q
q00313334 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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(){
    await geolocation.isLocationEnabled().then(async(result) => {
Q
quanli 已提交
38 39 40
        console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
        if(!result){
            await geolocation.requestEnableLocation().then(async(result) => {
Q
quanli 已提交
41
                await sleep(3000);
Q
quanli 已提交
42 43 44 45 46 47 48 49
                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();
            });
        }
    });
    await geolocation.isLocationEnabled().then(async(result) => {
Q
quanli 已提交
50
        console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result));
Q
quanli 已提交
51
    });
Q
q00313334 已提交
52 53
}

Q
quanli 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
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();

}


Q
q00313334 已提交
73
async function applyPermission() {
Q
quanli 已提交
74
    let osAccountManager = osaccount.getAccountManager();
Q
quanli 已提交
75
    console.info("=== getAccountManager finish");
Q
quanli 已提交
76
    let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
Q
quanli 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    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';
        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));
        });
    } else {
        console.info('[permission] case apply permission failed, createAtManager failed');
    }
Q
q00313334 已提交
98 99
}

Q
quanli 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113
export default function geolocationTest_geo3() {

    describe('geolocationTest_geo3', function () {
        beforeAll(async function (done) {
            console.info('beforeAll case');
            await applyPermission();
            done();
        })
    
        beforeEach(function () {
            console.info('beforeEach case');
        })
        afterEach(function () {
        })
Q
q00313334 已提交
114 115 116


    /**
Q
quanli 已提交
117 118 119
     * @tc.number SUB_HSS_LocationSystem_LocSwitch_0300
     * @tc.name Test requestrequestEnableLocation api
     * @tc.desc Enabling the Location Service Function for a Third-Party App - Callback
Q
q00313334 已提交
120 121 122 123
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
     it('SUB_HSS_LocationSystem_LocSwitch_0300', 0, async function (done) {
        try {
            geolocation.isLocationEnabled(async (err, data) => {
                if (err) {
                    console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err));
    
                } else {
                    console.info("[lbs_js] getLocationSwitchState callback data: " + JSON.stringify(data));
                    expect(data).assertTrue();
                }
            })
        } catch (error) {
            console.info("[lbs_js] getLocationSwitchState callback try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        await sleep(1000);
Q
quanli 已提交
140
        done();
Q
quanli 已提交
141
    });
Q
q00313334 已提交
142 143

    /**
Q
quanli 已提交
144
     * @tc.number SUB_HSS_LocationSystem_LocSwitch_0400
Q
quanli 已提交
145 146
     * @tc.name Test requestrequestEnableLocation api.
     * @tc.desc Enabling the Location Service Function for a Third-Party Application -Promise Mode
Q
q00313334 已提交
147 148 149 150
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
151
    it('SUB_HSS_LocationSystem_LocSwitch_0400', 0, async function (done) {
Q
quanli 已提交
152 153 154 155 156 157 158 159 160 161
        try {
            await geolocation.isLocationEnabled().then((result1) => {
                console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1));
                expect(result1).assertTrue();
            }).catch((error) => {
                console.info("[lbs_js] getLocationSwitchStateLocSwitch_0004 err." + JSON.stringify(error));
                expect().assertFail();
            });
        } catch (error) {
            console.info("[lbs_js] getLocationSwitchState callback try err." + JSON.stringify(error));
Q
quanli 已提交
162
            expect().assertFail();
Q
quanli 已提交
163
        }
Q
quanli 已提交
164 165
        done();
    });
Q
q00313334 已提交
166 167

    /**
Q
quanli 已提交
168 169 170
     * @tc.number SUB_HSS_LocationSystem_LocSwitch_0500
     * @tc.name Test locationServiceState api .
     * @tc.desc Subscribe to the location service status change.
Q
q00313334 已提交
171 172 173 174
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
175
    it('SUB_HSS_LocationSystem_LocSwitch_0500', 0, async function (done) {
Q
quanli 已提交
176
        console.log('just for overwriting,locationServiceState test need system api');
Q
quanli 已提交
177 178 179
        var locationServiceState = (state) => {
            console.log('locationServiceState: state: ' + JSON.stringify(state));
        }
Q
quanli 已提交
180 181 182 183 184 185 186 187 188 189 190 191
        try {
            geolocation.on('locationServiceState', locationServiceState);
        } catch (error) {
            console.info("[lbs_js] locationServiceStateOn05 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationServiceState', locationServiceState);
        } catch (error) {
            console.info("[lbs_js] locationServiceStateOff05 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
192
        done();
Q
q00313334 已提交
193 194 195
    })

    /**
Q
quanli 已提交
196
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_0100
Q
quanli 已提交
197 198
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario..
Q
q00313334 已提交
199 200 201 202
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
203
    it('SUB_HSS_LocationSystem_SingleLoc_0100', 0, async function (done) {
Q
quanli 已提交
204
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 };
Q
quanli 已提交
205 206 207 208 209 210 211 212 213 214 215 216 217
        try {
            geolocation.getCurrentLocation(currentLocationRequest, (err, result) => {
                if (err) {
                    console.info("[lbs_js] getCurrentLocation callback err:  " + JSON.stringify(err));
                    expect(true).assertEqual(err != null);
                    console.info('[lbs_js] getCurrentLocationCallback reject after')
                } else {
                    console.info("[lbs_js] getCurrentLocation callback, result:  " + JSON.stringify(result));
                    expect(true).assertEqual(result != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation callback try err." + JSON.stringify(error));
Q
quanli 已提交
218
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
219 220
        }
        await sleep(1000);
Q
quanli 已提交
221
        done();
Q
q00313334 已提交
222 223 224
    })

    /**
Q
quanli 已提交
225
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_0200
Q
quanli 已提交
226 227
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario..
Q
q00313334 已提交
228 229 230 231
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
232
    it('SUB_HSS_LocationSystem_SingleLoc_0200', 0, async function (done) {
Q
quanli 已提交
233
        let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 };
Q
quanli 已提交
234 235 236 237 238 239 240 241 242
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result ' + JSON.stringify(result));
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation_0002 promise err:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise try err." + JSON.stringify(error));
Q
quanli 已提交
243
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
244
        }
Q
quanli 已提交
245
        done();
Q
q00313334 已提交
246 247 248
    })

    /**
Q
quanli 已提交
249
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_0300
Q
quanli 已提交
250 251
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the track tracing scenario.
Q
q00313334 已提交
252 253 254 255
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
256
    it('SUB_HSS_LocationSystem_SingleLoc_0300', 0, async function (done) {
Q
quanli 已提交
257
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 };
Q
quanli 已提交
258 259 260 261 262 263 264
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info("[lbs_js] getCurrentLocation callback_0003, result:  " + JSON.stringify(result));
                expect(true).assertEqual(result != null);
            }).catch(error => {
                console.info('[lbs_js] getCurrentLocation callback_0003:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
265
            })
Q
quanli 已提交
266 267
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation callback03 try err." + JSON.stringify(error));
Q
quanli 已提交
268
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
269
        }
Q
quanli 已提交
270
        done();
Q
q00313334 已提交
271 272 273
    })

    /**
Q
quanli 已提交
274
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_0400
Q
quanli 已提交
275 276
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set a car-sharing scenario.
Q
q00313334 已提交
277 278 279 280
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
281
    it('SUB_HSS_LocationSystem_SingleLoc_0400', 0, async function (done) {
Q
quanli 已提交
282
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 };
Q
quanli 已提交
283 284 285 286 287 288 289 290 291
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result004 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err004:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise04 try err." + JSON.stringify(error));
Q
quanli 已提交
292
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
293
        }
Q
quanli 已提交
294
        done();
Q
q00313334 已提交
295 296 297
    })

    /**
Q
quanli 已提交
298
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_0500
Q
quanli 已提交
299 300
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request in a specified scenario and set the life service scenario..
Q
q00313334 已提交
301 302 303 304
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
305
    it('SUB_HSS_LocationSystem_SingleLoc_0500', 0, async function (done) {
Q
quanli 已提交
306
        let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 };
Q
quanli 已提交
307 308 309 310 311 312 313 314 315
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result005 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err005:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise05 try err." + JSON.stringify(error));
Q
quanli 已提交
316
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
317
        }
Q
quanli 已提交
318
        done();
Q
q00313334 已提交
319 320 321
    })

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

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

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

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

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

    /**
Q
quanli 已提交
467
     * @tc.number SUB_HSS_LocationSystem_SingleLoc_1100
Q
quanli 已提交
468 469 470
     * @tc.name Test getCurrentLocation
     * @tc.desc Initiate a single location request for specific configuration
     *          and set the reporting precision of abnormal location.
Q
q00313334 已提交
471 472 473 474
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
475
    it('SUB_HSS_LocationSystem_SingleLoc_1100', 0, async function (done) {
Q
quanli 已提交
476 477
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 };
Q
quanli 已提交
478 479 480 481 482 483 484 485 486
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result011 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err011:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise111 try err." + JSON.stringify(error));
Q
quanli 已提交
487
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
488 489 490 491 492 493 494 495 496 497
        }
        try {
            await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result0112 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err0112:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise112 try err." + JSON.stringify(error));
Q
quanli 已提交
498
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
499
        }
Q
q00313334 已提交
500 501 502 503
        done();
    })

    /**
Q
quanli 已提交
504
    * @tc.number SUB_HSS_LocationSystem_SingleLoc_1200
Q
quanli 已提交
505 506 507 508 509 510
    * @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
    */
Q
quanli 已提交
511
    it('SUB_HSS_LocationSystem_SingleLoc_1200', 0, async function (done) {
Q
quanli 已提交
512 513
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
Q
quanli 已提交
514 515 516 517 518 519 520 521 522
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result012 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err012:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise121 try err." + JSON.stringify(error));
Q
quanli 已提交
523
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
524 525 526 527 528 529 530 531 532 533
        }
        try {
            await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result0122 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err0122:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise122 try err." + JSON.stringify(error));
Q
quanli 已提交
534
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
535
        }
Q
q00313334 已提交
536 537 538 539
        done();
    })

    /**
Q
quanli 已提交
540
    * @tc.number SUB_HSS_LocationSystem_SingleLoc_1300
Q
quanli 已提交
541 542 543 544 545 546
    * @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
    */
Q
quanli 已提交
547
    it('SUB_HSS_LocationSystem_SingleLoc_1300', 0, async function (done) {
Q
quanli 已提交
548 549
        let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 };
        let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 };
Q
quanli 已提交
550 551 552 553 554 555 556 557 558
        try {
            await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result131 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err131:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            });
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise131 try err." + JSON.stringify(error));
Q
quanli 已提交
559
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
560 561 562 563 564 565 566 567 568 569
        }
        try {
            await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => {
                console.info('[lbs_js] getCurrentLocation promise result132 ' + JSON.stringify(result));
            }).catch(error => {
                console.info('getCurrentLocation promise err132:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
            })
        } catch (error) {
            console.info("[lbs_js] getCurrentLocation promise132 try err." + JSON.stringify(error));
Q
quanli 已提交
570
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
571
        }
Q
quanli 已提交
572
        done();
Q
quanli 已提交
573 574 575
    })

    /**
Q
quanli 已提交
576
     * @tc.number SUB_HSS_SendCommand_0100
Q
quanli 已提交
577 578 579
     * @tc.name Test sendCommand
     * @tc.desc Test sendCommand api .
     * @tc.size MEDIUM
Q
q00313334 已提交
580
     * @tc.type Function
Q
quanli 已提交
581
     * @tc.level Level 2
Q
q00313334 已提交
582
     */
Q
quanli 已提交
583
    it('SUB_HSS_SendCommand_0100', 0, async function (done) {
Q
quanli 已提交
584
        let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
Q
quanli 已提交
585 586 587 588 589 590 591 592 593 594 595 596 597 598
        try {
            await geolocation.sendCommand(requestInfo, (err, result) => {
                if (err) {
                    console.info('sendcommand callback err:' + JSON.stringify(err));
                    expect(true).assertEqual(JSON.stringify(err) != null);
                    done();
                }
                console.info('sendcommand callback result:' + JSON.stringify(result));
            });
        } catch (error) {
            console.info('sendcommand callback err:' + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        done();
Q
quanli 已提交
599 600 601
    })

    /**
Q
quanli 已提交
602
     * @tc.number SUB_HSS_SendCommand_0200
Q
quanli 已提交
603 604 605 606 607 608
     * @tc.name Test sendCommand
     * @tc.desc Test sendCommand1 api .
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
609
    it('SUB_HSS_SendCommand_0200', 0, async function (done) {
Q
quanli 已提交
610
        let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
Q
quanli 已提交
611 612 613 614 615 616 617 618 619 620
        try {
            geolocation.sendCommand(requestInfo).then((result) => {
                console.info('sendCommand promise result:' + result);
                done();
            }).catch(error => {
                console.info('sendcommand promise err:' + JSON.stringify(error));
                expect(true).assertEqual(JSON.stringify(error) != null);
                done();
            })
        } catch (error) {
Q
quanli 已提交
621 622
            console.info('sendcommand promise err:' + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
623 624 625
        }
        done();

Q
quanli 已提交
626 627 628
    })

    /**
Q
quanli 已提交
629
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0100
Q
quanli 已提交
630 631 632 633 634 635
     * @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
     */
Q
quanli 已提交
636
    it('SUB_HSS_LocationSystem_LocRequest_0100', 0, async function (done) {
Q
quanli 已提交
637 638 639 640 641 642 643
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
644 645 646 647 648 649 650 651 652 653 654 655
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn01 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff01 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
q00313334 已提交
656 657 658 659
        done();
    })

    /**
Q
quanli 已提交
660
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0200
Q
quanli 已提交
661 662
     * @tc.name Test locationChange
     * @tc.desc Initiate a request for continuous positioning in a specified scenario and set a track tracing scenario.
Q
q00313334 已提交
663 664
     * @tc.size MEDIUM
     * @tc.type Function
Q
quanli 已提交
665
     * @tc.level Level 2
Q
q00313334 已提交
666
     */
Q
quanli 已提交
667
    it('SUB_HSS_LocationSystem_LocRequest_0200', 0, async function (done) {
Q
quanli 已提交
668 669 670 671 672 673 674
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x302, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
675 676 677 678 679 680 681 682 683 684 685 686
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn02 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff02 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
q00313334 已提交
687 688 689 690
        done();
    })

    /**
Q
quanli 已提交
691
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0300
Q
quanli 已提交
692 693
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario and set a car-sharing scenario.
Q
q00313334 已提交
694 695
     * @tc.size MEDIUM
     * @tc.type Function
Q
quanli 已提交
696
     * @tc.level Level 2
Q
q00313334 已提交
697
     */
Q
quanli 已提交
698
    it('SUB_HSS_LocationSystem_LocRequest_0300', 0, async function (done) {
Q
quanli 已提交
699 700 701 702 703 704 705
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":5,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
706 707 708 709 710 711 712 713 714 715 716 717
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn03 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff03 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
q00313334 已提交
718 719 720 721
        done();
    })

    /**
Q
quanli 已提交
722
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0400
Q
quanli 已提交
723 724
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario and set a life service scenario.
Q
q00313334 已提交
725 726
     * @tc.size MEDIUM
     * @tc.type Function
Q
quanli 已提交
727
     * @tc.level Level 2
Q
q00313334 已提交
728
     */
Q
quanli 已提交
729
    it('SUB_HSS_LocationSystem_LocRequest_0400', 0, async function (done) {
Q
quanli 已提交
730 731 732 733 734 735 736
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
737 738 739 740 741 742 743 744 745 746 747 748
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn04 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff04 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
q00313334 已提交
749 750 751 752
        done();
    })

    /**
Q
quanli 已提交
753
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0500
Q
quanli 已提交
754 755 756
     * @tc.name Test locationChange
     * @tc.desc Initiate a continuous location request in a specified scenario
     *          and set the scenario with no power consumption.
Q
q00313334 已提交
757 758 759 760
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
761
    it('SUB_HSS_LocationSystem_LocRequest_0500', 0, async function (done) {
Q
quanli 已提交
762 763 764 765 766
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x305, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange1 = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
767
            expect(true).assertEqual(locationChange1 !=null);
Q
quanli 已提交
768 769 770
        };
        var locationChange2 = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
771
            expect(true).assertEqual(locationChange2 !=null);
Q
quanli 已提交
772
        };
Q
quanli 已提交
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796
        try {
            geolocation.on('locationChange', requestInfo, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn051 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.on('locationChange', requestInfo, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn052 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff051 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff052 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
797 798 799 800
        done();
    })

    /**
Q
quanli 已提交
801
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0700
Q
quanli 已提交
802 803 804 805 806 807 808
     * @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
     */
Q
quanli 已提交
809
    it('SUB_HSS_LocationSystem_LocRequest_0700', 0, async function (done) {
Q
quanli 已提交
810 811 812 813 814 815 816
        enableLocationSwitch();
        let requestInfo = {"priority":0x201, "scenario":0x300, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
817 818 819 820 821 822 823 824 825 826 827 828
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn07 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff07 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
829 830 831 832
        done();
    })

    /**
Q
quanli 已提交
833
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0800
Q
quanli 已提交
834 835 836 837 838 839 840
     * @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
     */
Q
quanli 已提交
841
    it('SUB_HSS_LocationSystem_LocRequest_0800', 0, async function (done) {
Q
quanli 已提交
842 843 844 845 846 847 848
        enableLocationSwitch();
        let requestInfo = {"priority":0x203, "scenario":0x300, "timeInterval":5,
            "distanceInterval": 5, "maxAccuracy": 10};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
849 850 851 852 853 854 855 856 857 858 859 860
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn08 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff08 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
861 862 863 864
        done();
    })

    /**
Q
quanli 已提交
865
     * @tc.number SUB_HSS_LocationSystem_LocRequest_0900
Q
quanli 已提交
866 867 868 869 870 871 872
     * @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
     */
Q
quanli 已提交
873
    it('SUB_HSS_LocationSystem_LocRequest_0900', 0, async function (done) {
Q
quanli 已提交
874 875 876 877 878 879 880
        enableLocationSwitch();
        let requestInfo = {"priority":0x202, "scenario":0x300, "timeInterval":1,
            "distanceInterval": 5, "maxAccuracy": 10}
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
881 882 883 884 885 886 887 888 889 890 891 892
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn09 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff09 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
893 894 895 896
        done();
    })

    /**
Q
quanli 已提交
897
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1000
Q
quanli 已提交
898 899 900 901 902 903
     * @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
     */
Q
quanli 已提交
904
    it('SUB_HSS_LocationSystem_LocRequest_1000', 0, async function (done) {
Q
quanli 已提交
905 906 907 908 909 910 911
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":3,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
912 913 914 915 916 917 918 919 920 921 922 923
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn10 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff10 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
924 925 926 927
        done();
    })

    /**
Q
quanli 已提交
928
     * @tc.number SUB_HSS_LocationSystem_LocRequest_1100
Q
quanli 已提交
929 930 931 932 933 934
     * @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
     */
Q
quanli 已提交
935
    it('SUB_HSS_LocationSystem_LocRequest_1100', 0, async function (done) {
Q
quanli 已提交
936
        enableLocationSwitch();
Q
q00313334 已提交
937
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
Q
quanli 已提交
938 939 940 941
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
Q
q00313334 已提交
942
        };
Q
quanli 已提交
943 944 945 946 947 948 949 950 951 952 953 954
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn11 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff11 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
q00313334 已提交
955 956 957 958
        done();
    })

    /**
Q
quanli 已提交
959
    * @tc.number SUB_HSS_LocationSystem_LocRequest_1200
Q
quanli 已提交
960 961 962 963 964 965
    * @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
    */
Q
quanli 已提交
966
    it('SUB_HSS_LocationSystem_LocRequest_1200', 0, async function (done) {
Q
quanli 已提交
967 968 969 970 971 972 973
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
974 975 976 977 978 979 980 981 982 983 984 985
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn12 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff12 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
986 987 988 989
        done();
    })

    /**
Q
quanli 已提交
990
    * @tc.number SUB_HSS_LocationSystem_LocRequest_1300
Q
quanli 已提交
991 992 993 994 995 996
    * @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
    */
Q
quanli 已提交
997
    it('SUB_HSS_LocationSystem_LocRequest_1300', 0, async function (done) {
Q
quanli 已提交
998 999 1000 1001 1002 1003 1004
        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('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1005
            expect(true).assertEqual(locationChange1 !=null);
Q
quanli 已提交
1006 1007 1008
        };
        var locationChange2 = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1009
            expect(true).assertEqual(locationChange2 !=null);
Q
quanli 已提交
1010
        };
Q
quanli 已提交
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
        try {
            geolocation.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn131 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff131 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn132 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff132 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1035 1036 1037 1038
        done();
    })

    /**
Q
quanli 已提交
1039
    * @tc.number SUB_HSS_LocationSystem_LocRequest_1400
Q
quanli 已提交
1040 1041 1042 1043 1044 1045
    * @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
    */
Q
quanli 已提交
1046
    it('SUB_HSS_LocationSystem_LocRequest_1400', 0, async function (done) {
Q
quanli 已提交
1047 1048 1049 1050 1051 1052 1053
        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('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1054
            expect(true).assertEqual(locationChange1 !=null);
Q
quanli 已提交
1055 1056 1057
        };
        var locationChange2 = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1058
            expect(true).assertEqual(locationChange2 !=null);
Q
quanli 已提交
1059
        };
Q
quanli 已提交
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
        try {
            geolocation.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn141 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff141 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn142 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff142 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1084 1085 1086 1087
        done();
    })

    /**
Q
quanli 已提交
1088
    * @tc.number SUB_HSS_LocationSystem_LocRequest_1500
Q
quanli 已提交
1089 1090 1091 1092 1093 1094
    * @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
    */
Q
quanli 已提交
1095
    it('SUB_HSS_LocationSystem_LocRequest_1500', 0, async function (done) {
Q
quanli 已提交
1096 1097 1098 1099 1100 1101 1102
        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('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1103
            expect(true).assertEqual(locationChange1 !=null);
Q
quanli 已提交
1104 1105 1106
        };
        var locationChange2 = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
Q
quanli 已提交
1107
            expect(true).assertEqual(locationChange2 !=null);
Q
quanli 已提交
1108
        };
Q
quanli 已提交
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
        try {
            geolocation.on('locationChange', requestInfo1, locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn151 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange1);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff151 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.on('locationChange', requestInfo2, locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn152 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange2);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff152 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1133 1134 1135 1136
        done();
    })

    /**
Q
quanli 已提交
1137
     * @tc.number SUB_HSS_LocationSystem_LastLoc_0100
Q
quanli 已提交
1138 1139
     * @tc.name Test getLastLocation
     * @tc.desc Obtain the last location after a single location.
Q
q00313334 已提交
1140 1141 1142 1143
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1144
    it('SUB_HSS_LocationSystem_LastLoc_0100', 0, async function(done) {
Q
quanli 已提交
1145 1146 1147 1148 1149 1150 1151
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1164 1165 1166 1167 1168 1169 1170
        await geolocation.getLastLocation().then((result) => {
            console.info('[lbs_js] getLastLocation promise result: ' + JSON.stringify(result));
            expect(true).assertEqual(JSON.stringify(result) != null);
            console.info('[lbs_js] getLastLocation latitude: ' + result.latitude +
            ' longitude: ' + result.longitude +' altitude: ' + result.altitude
            +' accuracy: ' + result.accuracy+' speed: ' + result.speed +
            'timeStamp: ' + result.timeStamp+'direction:' + result.direction+' timeSinceBoot: '
1171
            + result.timeSinceBoot +'additions: ' + result.additions+' additionSize' + result.additionSize
Q
quanli 已提交
1172
            + 'isFromMock' +result.isFromMock);
Q
quanli 已提交
1173 1174 1175 1176 1177 1178 1179 1180 1181
        }).catch((error) => {
            console.info("[lbs_js] getLastLocation promise then error:" + JSON.stringify(error));
            console.info('[lbs_js] not support now');
            expect(true).assertEqual(JSON.stringify(error) != null);
        });
        done();
    })

    /**
Q
quanli 已提交
1182
     * @tc.number SUB_HSS_LocationSystem_LastLoc_0200
Q
quanli 已提交
1183 1184 1185 1186 1187 1188
     * @tc.name Test getLastLocation
     * @tc.desc Obtain the last location after continuous positioning.
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1189
    it('SUB_HSS_LocationSystem_LastLoc_0200', 0, async function (done) {
Q
quanli 已提交
1190 1191 1192 1193 1194 1195 1196
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
        };
Q
quanli 已提交
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
1208
        }
Q
quanli 已提交
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
        try {
            geolocation.getLastLocation((err, data) => {
                if (err) {
                    console.info('[lbs_js] getLastLocation2 callback err:' + JSON.stringify(err));
                    expect(true).assertEqual(err !=null);
                } else {
                    console.info('[lbs_js] getLastLocation2 callback result:' + JSON.stringify(data));
                    expect(true).assertEqual(data !=null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] getLastLocation2 callback try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        await sleep(1000);
Q
quanli 已提交
1224 1225 1226 1227
        done();
    })

    /**
Q
quanli 已提交
1228
     * @tc.number SUB_HSS_LocationSystem_Gnss_0100
Q
quanli 已提交
1229 1230 1231 1232 1233 1234
     * @tc.name Test gnssStatusChange
     * @tc.desc Monitoring Satellite Information Reporting
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1235
    it('SUB_HSS_LocationSystem_Gnss_0100', 0, async function (done) {
Q
quanli 已提交
1236 1237 1238 1239 1240 1241 1242 1243 1244
        await changedLocationMode();
        var gnssStatusCb = (satelliteStatusInfo) => {
            console.info('gnssStatusChange: ' + 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 已提交
1245 1246 1247 1248 1249 1250
        try {
            geolocation.on('gnssStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] gnssStatusChangeOn1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1251 1252 1253 1254 1255 1256
        enableLocationSwitch();
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
Q
q00313334 已提交
1257
        };
Q
quanli 已提交
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('gnssStatusChange', gnssStatusCb);
        } catch (error) {
            console.info("[lbs_js] gnssStatusChangeOff1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1276
        done();
Q
q00313334 已提交
1277 1278 1279
    })

    /**
Q
quanli 已提交
1280
     * @tc.number SUB_HSS_LocationSystem_Gnss_0200
Q
quanli 已提交
1281 1282
     * @tc.name Test nmeaMessageChange
     * @tc.desc Monitoring NMEA Information Reporting
Q
q00313334 已提交
1283 1284 1285 1286
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1287
    it('SUB_HSS_LocationSystem_Gnss_0200', 0, async function (done) {
Q
q00313334 已提交
1288
        await changedLocationMode();
Q
quanli 已提交
1289 1290 1291 1292 1293 1294 1295 1296
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
        var nmeaCb = (str) => {
            console.log('nmeaMessageChange: ' + str);
        }
        var locationChange = (location) => {
            console.log('locationChanger: data: ' + JSON.stringify(location));
            expect(true).assertEqual(locationChange !=null);
Q
q00313334 已提交
1297
        };
Q
quanli 已提交
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
        try {
            geolocation.on('nmeaMessageChange', nmeaCb);
        } catch (error) {
            console.info("[lbs_js] nmeaChangeOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.on('locationChange', requestInfo, locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('nmeaMessageChange', nmeaCb);
        } catch (error) {
            console.info("[lbs_js] nmeaChangeOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('locationChange', locationChange);
        } catch (error) {
            console.info("[lbs_js] locationChangeOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1322 1323 1324 1325
        done();
    })

    /**
Q
quanli 已提交
1326
     * @tc.number SUB_HSS_LocationSystem_Batching_0100
Q
quanli 已提交
1327 1328 1329 1330 1331 1332
     * @tc.name Test cachedGnssLocationsReporting
     * @tc.desc Setting the Gnss Batching Reporting Interval
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1333
    it('SUB_HSS_LocationSystem_Batching_0100', 0, async function (done) {
Q
quanli 已提交
1334 1335 1336 1337 1338
        var cachedLocationsCb1 = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest1 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false};
Q
quanli 已提交
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest1, cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn11 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff11 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1351 1352 1353 1354 1355
        var cachedLocationsCb2 = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest2 = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': false};
Q
quanli 已提交
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest2, cachedLocationsCb2);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn12 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb1);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff12 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1368 1369 1370 1371
        done();
    })

    /**
Q
quanli 已提交
1372
     * @tc.number SUB_HSS_LocationSystem_Batching_0200
Q
quanli 已提交
1373 1374 1375 1376 1377 1378
     * @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
     */
Q
quanli 已提交
1379
    it('SUB_HSS_LocationSystem_Batching_0200', 0, async function (done) {
Q
quanli 已提交
1380 1381 1382 1383 1384 1385 1386
        var cachedLocationsCb = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
Q
quanli 已提交
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1399 1400 1401 1402
        done();
    })

    /**
Q
quanli 已提交
1403
     * @tc.number SUB_HSS_LocationSystem_Batching_0300
Q
quanli 已提交
1404 1405 1406 1407 1408 1409
     * @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
     */
Q
quanli 已提交
1410
    it('SUB_HSS_LocationSystem_Batching_0300', 0, async function (done) {
Q
quanli 已提交
1411 1412 1413 1414 1415 1416 1417
        var cachedLocationsCb = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
Q
quanli 已提交
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
1429
        }
Q
quanli 已提交
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444
        try {
            geolocation.getCachedGnssLocationsSize((err, data) => {
                if (err) {
                    console.info('[lbs_js]  getCachedGnssLocationsSize callback err:' + JSON.stringify(err));
                    expect(true).assertEqual(err != null);
                }else {
                    console.info("[lbs_js] getCachedGnssLocationsSize callback data is:" + JSON.stringify(data));
                    expect(true).assertEqual(data != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] getCachedGnssLocationsS callback try err:" + JSON.stringify(data));
            expect(true).assertEqual(data != null);
        }
        await sleep(1000);
Q
quanli 已提交
1445
        done();
Q
q00313334 已提交
1446 1447 1448
    })

    /**
Q
quanli 已提交
1449
     * @tc.number SUB_HSS_LocationSystem_Batching_0400
Q
quanli 已提交
1450 1451
     * @tc.name Test getCachedGnssLocationsSize
     * @tc.desc Obtains the number of GNSS data records in the batching process.
Q
q00313334 已提交
1452 1453 1454 1455
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1456
    it('SUB_HSS_LocationSystem_Batching_0400', 0, async function (done) {
Q
quanli 已提交
1457 1458 1459 1460 1461 1462 1463
        var cachedLocationsCb = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
Q
quanli 已提交
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            await geolocation.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));
                expect(true).assertEqual(error != null);
            });
        } catch (error) {
            console.info("[lbs_js] getCachedGnssLocationsS promise try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        done();
Q
q00313334 已提交
1489 1490 1491
    })

    /**
Q
quanli 已提交
1492
     * @tc.number SUB_HSS_LocationSystem_Batching_0500
Q
quanli 已提交
1493 1494
     * @tc.name Test flushCachedGnssLocations
     * @tc.desc Obtains the GNSS data of the current batching.
Q
q00313334 已提交
1495 1496 1497 1498
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1499
    it('SUB_HSS_LocationSystem_Batching_0500', 0, async function (done) {
Q
quanli 已提交
1500 1501 1502 1503 1504 1505 1506
        var cachedLocationsCb = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
Q
quanli 已提交
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
Q
quanli 已提交
1518
        }
Q
quanli 已提交
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
        try {
            geolocation.flushCachedGnssLocations((err, data) => {
                if (err) {
                    console.info('[lbs_js]  flushCachedGnssLocations callback err:' + JSON.stringify(err));
                    expect(true).assertEqual(err != null);
                }else {
                    console.info("[lbs_js] flushCachedGnssLocations callback data:" + JSON.stringify(data));
                    expect(true).assertEqual(data != null);
                }
            });
        } catch (error) {
            console.info("[lbs_js] flushCachedGnssLoc callback try err: " + JSON.stringify(data));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        await sleep(1000);
Q
quanli 已提交
1534
        done();
Q
q00313334 已提交
1535 1536 1537
    })

    /**
Q
quanli 已提交
1538
     * @tc.number SUB_HSS_LocationSystem_Batching_0600
Q
quanli 已提交
1539 1540
     * @tc.name Test flushCachedGnssLocations
     * @tc.desc Obtain the GNSS data of the current batching.
Q
q00313334 已提交
1541 1542 1543 1544
     * @tc.size MEDIUM
     * @tc.type Function
     * @tc.level Level 2
     */
Q
quanli 已提交
1545
    it('SUB_HSS_LocationSystem_Batching_0600', 0, async function (done) {
Q
quanli 已提交
1546 1547 1548 1549 1550 1551 1552
        var cachedLocationsCb = (locations) => {
            console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
            expect(true).assertEqual(locations !=null);
        }
        var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true};
        let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
            "distanceInterval": 0, "maxAccuracy": 0};
Q
quanli 已提交
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
        try {
            geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOn2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
            await geolocation.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));
                expect(true).assertEqual(error != null);
            });
        } catch (error) {
            console.info("[lbs_js] cachedGnssOff2 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1577
        done();
Q
q00313334 已提交
1578
    })
1579

Q
quanli 已提交
1580
    /**
Q
quanli 已提交
1581
    * @tc.number SUB_HSS_LocationSystem_GeoFence_0100
Q
quanli 已提交
1582 1583 1584 1585 1586 1587
    * @tc.name Test fenceStatusChange
    * @tc.desc Gnss fence function test
    * @tc.size MEDIUM
    * @tc.type Function
    * @tc.level Level 1
    */
Q
quanli 已提交
1588
    it('SUB_HSS_LocationSystem_GeoFence_0100', 0, async function (done) {
Q
quanli 已提交
1589 1590 1591
        await changedLocationMode();
        let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
        let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence};
Q
quanli 已提交
1592 1593 1594 1595
        let want = (wantAgent) => {
            console.log('wantAgent: ' + JSON.stringify(wantAgent));
        };
        try {
Q
quanli 已提交
1596 1597 1598
            geolocation.on('fenceStatusChange', geofenceRequest,
                (want) => {
                    if(err){
Q
quanli 已提交
1599
                        return console.info("[lbs_js] fenceStatusChangeOn callback err:" + err);
Q
quanli 已提交
1600
                    }
Q
quanli 已提交
1601
                    console.info("[lbs_js] fenceStatusChange callback result:  " + JSON.stringify(want));
Q
quanli 已提交
1602 1603 1604
                    expect(true).assertEqual(want !=null);
                    done();
                });
Q
quanli 已提交
1605 1606 1607 1608 1609
        } catch (error) {
            console.info("[lbs_js] fenceStatusChangeOn1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
Q
quanli 已提交
1610 1611 1612
            geolocation.off('fenceStatusChange',geofenceRequest,
                (want) => {
                    if(err){
Q
quanli 已提交
1613
                        return console.info("[lbs_js] fenceStatusChange callback err:" + err);
Q
quanli 已提交
1614
                    }
Q
quanli 已提交
1615
                    console.info("[lbs_js] off fenceStatusChange callback result:" + JSON.stringify(want));
Q
quanli 已提交
1616 1617
                    expect(true).assertEqual(want !=null);
                });
Q
quanli 已提交
1618 1619 1620 1621 1622
        } catch (error) {
            console.info("[lbs_js] fenceStatusChangeOff1 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        await sleep(1000);
Q
quanli 已提交
1623 1624
        done();
    })
Q
quanli 已提交
1625

Q
quanli 已提交
1626
    /**
Q
quanli 已提交
1627
     * @tc.number SUB_HSS_LocationSystem_GeoFence_0500
Q
quanli 已提交
1628 1629 1630 1631 1632 1633
     * @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
     */
Q
quanli 已提交
1634
    it('SUB_HSS_LocationSystem_GeoFence_0500', 0, async function (done) {
Q
quanli 已提交
1635 1636 1637
        await changedLocationMode();
        let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
        let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence};
Q
quanli 已提交
1638
        try {
Q
quanli 已提交
1639 1640 1641
            geolocation.on('fenceStatusChange', geofenceRequest,
                (want) => {
                    if(err){
Q
quanli 已提交
1642
                        return console.info("[lbs_js] fenceStatusChangeOn callback err:" + err);
Q
quanli 已提交
1643
                    }
Q
quanli 已提交
1644
                    console.info("[lbs_js] fenceStatusChange callback, result:  " + JSON.stringify(want));
Q
quanli 已提交
1645 1646 1647
                    expect(true).assertEqual(want !=null);
                    done();
                });
Q
quanli 已提交
1648 1649 1650 1651 1652
        } catch (error) {
            console.info("[lbs_js] fenceStatusChangeOn5 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
        try {
Q
quanli 已提交
1653 1654 1655
            geolocation.off('fenceStatusChange',geofenceRequest,
                (want) => {
                    if(err){
Q
quanli 已提交
1656
                        return console.info("[lbs_js] fenceStatusChange callback err:" + err);
Q
quanli 已提交
1657
                    }
Q
quanli 已提交
1658
                    console.info("[lbs_js] fenceStatusChangeOff callback result:" + JSON.stringify(want));
Q
quanli 已提交
1659 1660
                    expect(true).assertEqual(want !=null);
                });
Q
quanli 已提交
1661 1662 1663 1664
        } catch (error) {
            console.info("[lbs_js] fenceStatusChangeOff5 try err." + JSON.stringify(error));
            expect(true).assertEqual(JSON.stringify(error) != null);
        }
Q
quanli 已提交
1665 1666
        done();
    })
Q
quanli 已提交
1667 1668 1669

    })
}
Q
quanli 已提交
1670

Q
quanli 已提交
1671 1672