未验证 提交 62b92434 编写于 作者: O openharmony_ci 提交者: Gitee

!3441 【location】Location脚本优化。

Merge pull request !3441 from 权力/myfeature
......@@ -17,6 +17,8 @@ import geolocation from '@ohos.geolocation';
import { LocationEventListener } from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
......@@ -44,11 +46,18 @@ async function changedLocationMode(){
expect().assertFail();
});
}
})
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
});
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, 100);
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......@@ -1009,3 +1018,4 @@ describe('geolocationTest', function () {
......@@ -16,13 +16,15 @@ import geolocation from '@ohos.geolocation';
import geolocations from '@system.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function changedLocationMode(){
async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(!result){
......@@ -35,11 +37,18 @@ function sleep(ms) {
expect().assertFail();
});
}
})
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
});
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, 100);
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......@@ -206,3 +215,4 @@ describe('geolocationTest', function () {
})
......@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
import { LocationEventListener } from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
......@@ -38,18 +39,25 @@ async function changedLocationMode(){
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result:' + result);
console.info('[lbs_js] test requestEnableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
}
})
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
});
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, 100);
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......@@ -1185,3 +1193,4 @@ describe('geolocationTest', function () {
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册