提交 fa43cbd5 编写于 作者: Q q00313334

add location user grant

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 5477de5d
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.location.geolocation", "package": "ohos.acts.location.geolocation.function",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": "ohos.acts.location.geolocation.function.MainAbility", "mainAbility": "ohos.acts.location.geolocation.function.MainAbility",
"deviceType": [ "deviceType": [
...@@ -48,14 +48,34 @@ ...@@ -48,14 +48,34 @@
], ],
"defPermissions": [ "defPermissions": [
{ {
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "ACCESS_LOCATION label",
"description": "ACCESS_LOCATION description"
},
{
"availableScope": [], "availableScope": [],
"grantMode": "system_grant", "grantMode": "system_grant",
"name": "ohos.permission.ACCESS_LOCATION" "name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": false,
"label": "MANAGE_SECURE_SETTINGS label",
"description": "MANAGE_SECURE_SETTINGS description"
}, },
{ {
"availableScope": [], "availableScope": [],
"grantMode": "system_grant", "grantMode": "user_grant",
"name": "ohos.permission.LOCATION" "name": "ohos.permission.LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "LOCATION label",
"description": "LOCATION description"
} }
], ],
"reqPermissions": [ "reqPermissions": [
...@@ -89,10 +109,9 @@ ...@@ -89,10 +109,9 @@
"when": "inuse" "when": "inuse"
} }
}, },
{
{ "name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"usedScene": { "usedScene": {
"ability": [ "ability": [
"ohos.acts.location.geolocation.function.MainAbility" "ohos.acts.location.geolocation.function.MainAbility"
...@@ -100,25 +119,19 @@ ...@@ -100,25 +119,19 @@
"when": "inuse" "when": "inuse"
} }
}, },
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{ {
"name":"ohos.permission.GET_WIFI_LOCAL_MAC", "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason":"need use ohos.permission.GET_WIFI_LOCAL_MAC", "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
}, },
{ {
"name":"ohos.permission.GET_WIFI_INFO_INTERNAL", "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
"reason":"need use ohos.permission.GET_WIFI_INFO_INTERNAL", },
"usedScene": { {
"ability": [ "name": "ohos.permission.GET_BUNDLE_INFO"
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
} }
], ],
"js": [ "js": [
......
...@@ -14,12 +14,13 @@ ...@@ -14,12 +14,13 @@
*/ */
import geolocation from '@ohos.geolocation'; import geolocation from '@ohos.geolocation';
import wantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305} DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305}
let LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203} let LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203}
let LocationPrivacyType = { let LocationPrivacyType = {
...@@ -28,19 +29,44 @@ let LocationPrivacyType = { ...@@ -28,19 +29,44 @@ let LocationPrivacyType = {
CORE_LOCATION : 2 CORE_LOCATION : 2
} }
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, 100);
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 :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
describe('geolocationTest', function () { describe('geolocationTest', function () {
beforeAll(function () { console.log('#start AccessTokenTests#');
console.info('beforeAll called') beforeAll(async function () {
await applyPermission();
console.info('beforeAll case');
}) })
beforeEach(function () { beforeEach(function () {
console.info('beforeEach called') sleep(3000);
console.info('beforeEach case');
}) })
afterEach(function () { afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
}) })
/** /**
...@@ -60,8 +86,8 @@ describe('geolocationTest', function () { ...@@ -60,8 +86,8 @@ describe('geolocationTest', function () {
expect().assertFail(); expect().assertFail();
}) })
done() done()
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001
* @tc.name testisLocationEnabled promise * @tc.name testisLocationEnabled promise
...@@ -70,28 +96,23 @@ describe('geolocationTest', function () { ...@@ -70,28 +96,23 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isLocationEnabled_promise_test_001', 0, async function (done) { it('geolocation_isLocationEnabled_promise_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
await geolocation.isLocationEnabled().then((result) => { await geolocation.isLocationEnabled().then((result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result); console.info('[lbs_js] getLocationSwitchState result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
expect().assertFail(); expect().assertFail();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback * @tc.name testgetAddressesFromLocationName callback
...@@ -101,16 +122,13 @@ describe('geolocationTest', function () { ...@@ -101,16 +122,13 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1, let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1,
"locale": "zh",description:"",maxItems:"",minLatitude:"", "locale": "zh",description:"",maxItems:"",minLatitude:"",
minLongitude:"",maxLatitude:"",maxLongitude:""}; minLongitude:"",maxLatitude:"",maxLongitude:""};
...@@ -144,14 +162,12 @@ describe('geolocationTest', function () { ...@@ -144,14 +162,12 @@ describe('geolocationTest', function () {
}else { }else {
console.info("[lbs_js] getAddressesFromLocationName callback data is: " + JSON.stringify(data)); console.info("[lbs_js] getAddressesFromLocationName callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info("[lbs_js] getAddressesFromLocationName callback exit .");
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001
* @tc.name testgetAddressesFromLocation callback * @tc.name testgetAddressesFromLocation callback
...@@ -161,7 +177,6 @@ describe('geolocationTest', function () { ...@@ -161,7 +177,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocation_callback_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocation_callback_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
...@@ -169,7 +184,6 @@ describe('geolocationTest', function () { ...@@ -169,7 +184,6 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1,"locale": "zh"}; let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1,"locale": "zh"};
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) { if (err) {
...@@ -181,12 +195,11 @@ describe('geolocationTest', function () { ...@@ -181,12 +195,11 @@ describe('geolocationTest', function () {
' administrativeArea: ' + data[0].administrativeArea +' countryCode: ' + data[0].countryCode ' administrativeArea: ' + data[0].administrativeArea +' countryCode: ' + data[0].countryCode
+' countryName: ' + data[0].countryName+' descriptions: ' + data[0].descriptions+ +' countryName: ' + data[0].countryName+' descriptions: ' + data[0].descriptions+
'descriptionsSize: ' + data[0].descriptionsSize+'latitude:' + data[0].latitude+' locale: ' 'descriptionsSize: ' + data[0].descriptionsSize+'latitude:' + data[0].latitude+' locale: '
+ data[0].locale +'locality' + data[0].locality+'longitude:' + data[0].longitude+'phoneNumber:' + data[0].locale +'locality: ' + data[0].locality+' longitude:' + data[0].longitude+'phoneNumber:'
+ data[0].phoneNumber+' placeName: ' + data[0].placeName+' postalCode: ' + data[0].postalCode + data[0].phoneNumber+' placeName: ' + data[0].placeName+' postalCode: ' + data[0].postalCode
+' premises: ' + data[0].premises+'roadName: ' + data[0].roadName +' subAdministrativeArea: ' +' premises: ' + data[0].premises+'roadName: ' + data[0].roadName +' subAdministrativeArea: '
+ data[0].subAdministrativeArea+' subLocality: ' + data[0].subLocality + data[0].subAdministrativeArea+' subLocality: ' + data[0].subLocality
+' subRoadName: ' + data[0].subRoadName); +' subRoadName: ' + data[0].subRoadName);
} }
done(); done();
}); });
...@@ -208,11 +221,9 @@ describe('geolocationTest', function () { ...@@ -208,11 +221,9 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
await geolocation.isGeoServiceAvailable().then( (result) => { await geolocation.isGeoServiceAvailable().then( (result) => {
console.info('[lbs_js] isGeoServiceAvailable result: ' + result); console.info('[lbs_js] isGeoServiceAvailable result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
...@@ -236,26 +247,22 @@ describe('geolocationTest', function () { ...@@ -236,26 +247,22 @@ describe('geolocationTest', function () {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] enableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
resolve() resolve()
}); });
}) })
let promiseTwo = new Promise((resolve, reject) => { let promiseTwo = new Promise((resolve, reject) => {
geolocation.isLocationEnabled((err, data) => { geolocation.isLocationEnabled((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLocationSwitchState : ' + err); console.info('[lbs_js] getLocationSwitchState : ' + err);
}else { }else {
console.info("[lbs_js] getLocationSwitchState data: " + data); console.info("[lbs_js] getLocationSwitchState data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
resolve() resolve()
}); });
}) })
await promiseOne.then(()=>{ await promiseOne.then(()=>{
return promiseTwo return promiseTwo
}).then(done) }).then(done)
...@@ -269,22 +276,18 @@ describe('geolocationTest', function () { ...@@ -269,22 +276,18 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocationName_promise_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocationName_promise_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1}; let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null); expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error); console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail(); expect().assertFail();
...@@ -292,7 +295,6 @@ describe('geolocationTest', function () { ...@@ -292,7 +295,6 @@ describe('geolocationTest', function () {
done(); done();
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testrequestEnableLocation callback * @tc.name testrequestEnableLocation callback
...@@ -314,14 +316,13 @@ describe('geolocationTest', function () { ...@@ -314,14 +316,13 @@ describe('geolocationTest', function () {
console.info('[lbs_js] requestEnableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] requestEnableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001
* @tc.name testdisableLocation callback * @tc.name testdisableLocation callback
* @tc.desc Test disableLocation api . * @tc.desc Test disableLocation api .
...@@ -329,15 +330,13 @@ describe('geolocationTest', function () { ...@@ -329,15 +330,13 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_disableLocation_callback_test_001', 0, async function (done) { it('geolocation_disableLocation_callback_test_001', 0, async function (done) {
geolocation.disableLocation((err, data) => { geolocation.disableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] disableLocation callback err is : ' + err ); console.info('[lbs_js] disableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] disableLocation callback data: " + data); console.info("[lbs_js] disableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
}); });
...@@ -355,13 +354,11 @@ describe('geolocationTest', function () { ...@@ -355,13 +354,11 @@ describe('geolocationTest', function () {
await geolocation.disableLocation().then((data) => { await geolocation.disableLocation().then((data) => {
console.info('[lbs_js] disableLocation data: ' + data); console.info('[lbs_js] disableLocation data: ' + data);
expect(data).assertTrue(); expect(data).assertTrue();
done(); done();
}); });
}) })
/**
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testEnableLocation callback * @tc.name testEnableLocation callback
* @tc.desc Test enableLocation api . * @tc.desc Test enableLocation api .
...@@ -369,8 +366,7 @@ describe('geolocationTest', function () { ...@@ -369,8 +366,7 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_enableLocation_callback_test_001', 0, async function (done) { it('geolocation_enableLocation_callback_test_001', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] enableLocation callback err is : ' + err );
...@@ -382,7 +378,7 @@ describe('geolocationTest', function () { ...@@ -382,7 +378,7 @@ describe('geolocationTest', function () {
}); });
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001
* @tc.name testrequestEnableLocation promise * @tc.name testrequestEnableLocation promise
* @tc.desc Test requestEnableLocation api . * @tc.desc Test requestEnableLocation api .
...@@ -390,7 +386,7 @@ describe('geolocationTest', function () { ...@@ -390,7 +386,7 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_requestEnableLocation_promise_test_001', 0, async function(done) { it('geolocation_requestEnableLocation_promise_test_001', 0, async function(done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
...@@ -406,7 +402,7 @@ describe('geolocationTest', function () { ...@@ -406,7 +402,7 @@ describe('geolocationTest', function () {
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
}) })
/** /**
...@@ -428,8 +424,7 @@ describe('geolocationTest', function () { ...@@ -428,8 +424,7 @@ describe('geolocationTest', function () {
let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null); expect(true).assertEqual((JSON.stringify(data)) !=null);
done(); done();
}).catch(error => { }).catch(error => {
console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message); console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message);
...@@ -462,7 +457,8 @@ describe('geolocationTest', function () { ...@@ -462,7 +457,8 @@ describe('geolocationTest', function () {
return console.info("getCurrentLocation callback err: " + err) return console.info("getCurrentLocation callback err: " + err)
} }
console.info("getCurrentLocation callback, result: " + JSON.stringify(result)); console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result != null); let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}); });
done() done()
}) })
...@@ -488,20 +484,48 @@ describe('geolocationTest', function () { ...@@ -488,20 +484,48 @@ describe('geolocationTest', function () {
return console.info("getCurrentLocation callback err: " + err) return console.info("getCurrentLocation callback err: " + err)
} }
console.info("getCurrentLocation callback, result: " + JSON.stringify(result)); console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result != null); let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}); });
done() done()
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name getLastLocation promise
* @tc.desc Test getLastLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_getCurrentLocation_promise_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let currentLocationRequest = { "priority": 0x203, "scenario": 0x301,
"timeoutMs": 5, "maxAccuracy": 0 };
try {
geolocation.getCurrentLocation(currentLocationRequest).then( (result) => {
console.info('[lbs_js]getCurrentLocation promise result '+ JSON.stringify(result));
});
}catch(e) {
console.info('[lbs_js] getCurrentLocation promise err is : ' +JSON.stringify(e));
}
done();
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback * @tc.desc Test getLastLocation api .
* @tc.desc Test getAddressesFromLocationName api .
* @tc.author * @tc.author
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getLastLocation_callback_test_001', 0, async function (done) { it('geolocation_getLastLocation_callback_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
...@@ -510,18 +534,18 @@ describe('geolocationTest', function () { ...@@ -510,18 +534,18 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
geolocation.getLastLocation((err, data) => { await geolocation.getLastLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLastLocation callback err is : ' + err); console.info('[lbs_js] getLastLocation callback err is : ' + err);
}else { }else {
console.info("[lbs_js] getLastLocation callback data is: " + JSON.stringify(data)); console.info("[lbs_js] getLastLocation callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null); let resultLength = Object.keys(data).length;
expect(true).assertEqual(resultLength >= 0);
console.info('[lbs_js] getLastLocation latitude: ' + data[0].latitude + console.info('[lbs_js] getLastLocation latitude: ' + data[0].latitude +
' longitude: ' + data[0].longitude +' altitude: ' + data[0].altitude ' longitude: ' + data[0].longitude +' altitude: ' + data[0].altitude
+' accuracy: ' + data[0].accuracy+' speed: ' + data[0].speed + +' accuracy: ' + data[0].accuracy+' speed: ' + data[0].speed +
'timeStamp: ' + data[0].timeStamp+'direction:' + data[0].direction+' timeSinceBoot: ' 'timeStamp: ' + data[0].timeStamp+'direction:' + data[0].direction+' timeSinceBoot: '
+ data[0].timeSinceBoot +'additions: ' + data[0].additions+' additionSize' + data[0].additionSize); + data[0].timeSinceBoot +'additions' + data[0].additions+'additionSize' + data[0].additionSize);
} }
}); });
done(); done();
...@@ -545,11 +569,12 @@ describe('geolocationTest', function () { ...@@ -545,11 +569,12 @@ describe('geolocationTest', function () {
}); });
geolocation.getLastLocation().then( (result) => { geolocation.getLastLocation().then( (result) => {
console.info('[lbs_js] getLastLocation promise result '+ JSON.stringify(result)); console.info('[lbs_js] getLastLocation promise result '+ JSON.stringify(result));
expect(true).assertEqual(result != null); let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
done(); done();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect(true).assertEqual(error != null);
done(); done();
}); });
}) })
...@@ -570,30 +595,26 @@ describe('geolocationTest', function () { ...@@ -570,30 +595,26 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
geolocation.isGeoServiceAvailable((err, data) => { geolocation.isGeoServiceAvailable((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + err ); console.info('[lbs_js] getGeoServiceState err is : ' + err );
return return
}else { }else {
console.info('[lbs_js] isGeoServiceAvailable result: ' + data); console.info('[lbs_js] isGeoServiceAvailable result: ' + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
}); });
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback * @tc.name testgetCachedGnssLocationsSize callback
* @tc.desc Test getAddressesFromLocationName api . * @tc.desc Test getCachedGnssLocationsSize api .
* @tc.author
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getCachedGnssLocationsSize_callback_test_001', 0, async function (done) { it('geolocation_getCachedGnssLocationsSize_callback_test_001', 0, async function (done) {
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
...@@ -615,8 +636,8 @@ describe('geolocationTest', function () { ...@@ -615,8 +636,8 @@ describe('geolocationTest', function () {
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testisGeoServiceAvailable promise * @tc.name testgetCachedGnssLocationsSize promise
* @tc.desc Test isGeoServiceAvailable api . * @tc.desc Test getCachedGnssLocationsSize api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -629,9 +650,8 @@ describe('geolocationTest', function () { ...@@ -629,9 +650,8 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
geolocation.getCachedGnssLocationsSize().then( (result) => { geolocation.getCachedGnssLocationsSize().then( (result) => {
console.info('[lbs_js] getCachedGnssLocationsSiz '+ JSON.stringify(result)); console.info('[lbs_js] getCachedGnssLocationsSiz promise '+ JSON.stringify(result));
expect(true).assertTrue(result != null); expect(true).assertTrue(result != null);
done(); done();
}).catch((error) => { }).catch((error) => {
...@@ -643,8 +663,8 @@ describe('geolocationTest', function () { ...@@ -643,8 +663,8 @@ describe('geolocationTest', function () {
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback * @tc.name testflushCachedGnssLocations callback
* @tc.desc Test getAddressesFromLocationName api . * @tc.desc Test flushCachedGnssLocations api .
* @tc.author * @tc.author
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
...@@ -662,17 +682,17 @@ describe('geolocationTest', function () { ...@@ -662,17 +682,17 @@ describe('geolocationTest', function () {
if (err) { if (err) {
console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + err); console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + err);
}else { }else {
console.info("[lbs_js] flushCachedGnssLocations callback: " + JSON.stringify(data)); console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data); expect(true).assertTrue(data);
} }
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testisGeoServiceAvailable promise * @tc.name testflushCachedGnssLocations promise
* @tc.desc Test isGeoServiceAvailable api . * @tc.desc Test flushCachedGnssLocations api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -698,8 +718,8 @@ describe('geolocationTest', function () { ...@@ -698,8 +718,8 @@ describe('geolocationTest', function () {
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
* @tc.name testGetCurrentlocation callback * @tc.name testgnssStatusChange callback
* @tc.desc Test GetCurrentlocation api . * @tc.desc Test gnssStatusChange api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -709,10 +729,9 @@ describe('geolocationTest', function () { ...@@ -709,10 +729,9 @@ describe('geolocationTest', function () {
await geolocation.on('gnssStatusChange', function (data) { await geolocation.on('gnssStatusChange', function (data) {
console.info('[lbs_js] gnssStatusChangestart' +JSON.stringify(data) ); console.info('[lbs_js] gnssStatusChangestart' +JSON.stringify(data) );
expect(true).assertEqual((JSON.stringify(data)) !=null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info('[lbs_js] SatelliteStatusInfo satellitesNumber' + data[0].satellitesNumber console.info('[lbs_js] SatelliteStatusInfo satellitesNumber: ' + data[0].satellitesNumber +
+ 'satelliteIds ' + data[0].satelliteIds +' carrierToNoiseDensitys'+ 'satelliteIds' + data[0].satelliteIds +'carrierToNoiseDensitys'+ data[0].carrierToNoiseDensitys
data[0].carrierToNoiseDensitys +'altitudes' + data[0].altitudes+' azimuths: ' + data[0].azimuths +
+' altitudes: ' + data[0].altitudes+' azimuths: ' + data[0].azimuths +
'carrierFrequencies: ' + data[0].carrierFrequencies); 'carrierFrequencies: ' + data[0].carrierFrequencies);
}); });
}catch(e) { }catch(e) {
...@@ -730,8 +749,8 @@ describe('geolocationTest', function () { ...@@ -730,8 +749,8 @@ describe('geolocationTest', function () {
/** /**
* @tc.number nmeaMessageChange_test_0001 * @tc.number nmeaMessageChange_test_0001
* @tc.name testGetCurrentlocation callback * @tc.name testnmeaMessageChange callback
* @tc.desc Test GetCurrentlocation api . * @tc.desc Test nmeaMessageChange api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -753,25 +772,6 @@ describe('geolocationTest', function () { ...@@ -753,25 +772,6 @@ describe('geolocationTest', function () {
} }
done(); done();
}) })
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test setLocationPrivacyConfirmStatus callback
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_setLocationPrivacyConfirmStatus_callback_test_001', 0, async function (done) {
let reqType = 1;
let isConfirmed = true;
console.info('[lbs_js] setLocationPrivacyConfirmStatus callback test start ...');
geolocation.setLocationPrivacyConfirmStatus(reqType, isConfirmed, (err,resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done()
});
})
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
...@@ -781,10 +781,10 @@ describe('geolocationTest', function () { ...@@ -781,10 +781,10 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isLocationPrivacyConfirmed_callback_test_001', 0, async function (done) { it('geolocation_LocationPrivacyConfirmed_callback_test_001', 0, async function (done) {
let reqType = 1; let reqType = 1;
let value = true; let value = true;
geolocation.setLocationPrivacyConfirmStatus(reqType, value, (err, resp)=>{ await geolocation.setLocationPrivacyConfirmStatus(reqType, value, (err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
}); });
...@@ -804,8 +804,8 @@ describe('geolocationTest', function () { ...@@ -804,8 +804,8 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_setLocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) { it('geolocation_LocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) {
let reqType = 1; let reqType =1;
let value = true; let value = true;
let type = "STARTUP"; let type = "STARTUP";
...@@ -818,30 +818,164 @@ describe('geolocationTest', function () { ...@@ -818,30 +818,164 @@ describe('geolocationTest', function () {
if(type == "CORE_LOCATION"){ if(type == "CORE_LOCATION"){
reqType = 2; reqType = 2;
} }
console.info('LBS setLocationPrivacyConfirmStatus promise test start ...') await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => { console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done();
})
})
/**
* @tc.number geolocation_setLocationPrivacyConfirmStatus_promise_test_002
* @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_LocationPrivacyConfirmStatus_promise_test_002', 0, async function (done) {
let reqType =1;
let value = false;
let type = "STARTUP";
if(type == "OTHERS"){
reqType = 0;
}
if(type == "STARTUP"){
reqType = 1;
}
if(type == "CORE_LOCATION"){
reqType = 2;
}
await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
})
})
/**
* @tc.number geolocation_setLocationPrivacyConfirmStatus_promise_test_003
* @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_LocationPrivacyConfirmStatus_promise_test_003', 0, async function (done) {
let reqType =0;
let value = false;
let type = "STARTUP";
if(type == "OTHERS"){
reqType = 0;
}
if(type == "STARTUP"){
reqType = 1;
}
if(type == "CORE_LOCATION"){
reqType = 2;
}
await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
})
})
/**
* @tc.number geolocation_setLocationPrivacyConfirmStatus_promise_test_004
* @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_LocationPrivacyConfirmStatus_promise_test_004', 0, async function (done) {
let reqType =2;
let value = false;
let type = "STARTUP";
if(type == "OTHERS"){
reqType = 0;
}
if(type == "STARTUP"){
reqType = 1;
}
if(type == "CORE_LOCATION"){
reqType = 2;
}
await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue(); expect(resp).assertTrue();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done(); done();
}) })
}) })
/** /**
* @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001 * @tc.number geolocation_LocationPrivacyConfirmStatus_promise_test_005
* @tc.name Test isLocationPrivacyConfirmed promise * @tc.name Test isLocationPrivacyConfirmed promise
* @tc.desc Test isLocationPrivacyConfirmed api . * @tc.desc Test isLocationPrivacyConfirmed api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isLocationPrivacyConfirmed_promise_test_001', 0, async function (done) { it('geolocation_LocationPrivacyConfirmStatus_promise_test_005', 0, async function (done) {
let reqType = 1; let reqType = 1;
let value = true; let value = true;
geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => { await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue(); expect(resp).assertTrue();
}) })
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done();
})
})
/**
* @tc.number geolocation_LocationPrivacyConfirmStatus_promise_test_006
* @tc.name Test isLocationPrivacyConfirmed promise
* @tc.desc Test isLocationPrivacyConfirmed api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_LocationPrivacyConfirmStatus_promise_test_006', 0, async function (done) {
let reqType =0;
let value = true;
let type = "OTHERS";
if(type == "OTHERS"){
reqType = 0;
}
if(type == "STARTUP"){
reqType = 1;
}
if(type == "CORE_LOCATION"){
reqType = 2;
}
await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
})
console.info('LBS isLocationPrivacyConfirmed promise test start ...'); console.info('LBS isLocationPrivacyConfirmed promise test start ...');
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => { geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp)) console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
...@@ -850,6 +984,39 @@ describe('geolocationTest', function () { ...@@ -850,6 +984,39 @@ describe('geolocationTest', function () {
}) })
}) })
/**
* @tc.number geolocation_LocationPrivacyConfirmStatus_promise_test_007
* @tc.name Test isLocationPrivacyConfirmed promise
* @tc.desc Test isLocationPrivacyConfirmed api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_LocationPrivacyConfirmStatus_promise_test_007', 0, async function (done) {
let reqType =2;
let value = true;
let type = "CORE_LOCATION";
if(type == "OTHERS"){
reqType = 0;
}
if(type == "STARTUP"){
reqType = 1;
}
if(type == "CORE_LOCATION"){
reqType = 2;
}
await geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done();
})
})
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise * @tc.name testlocationChangeOn promise
...@@ -859,7 +1026,6 @@ describe('geolocationTest', function () { ...@@ -859,7 +1026,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_locationChange_On_test_001', 0, async function (done) { it('geolocation_locationChange_On_test_001', 0, async function (done) {
let requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5, let requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
let locationChange = (location) => { let locationChange = (location) => {
...@@ -889,57 +1055,55 @@ describe('geolocationTest', function () { ...@@ -889,57 +1055,55 @@ describe('geolocationTest', function () {
if(err){ if(err){
return console.info("onLocationChange callback err: " + err); return console.info("onLocationChange callback err: " + err);
} }
console.info("offLocationChange callback, result: " + JSON.stringify(locationChange)); console.info("offLocationChange callback " + JSON.stringify(locationChange));
expect(true).assertEqual(locationChange !=null); expect(true).assertEqual(locationChange !=null);
done(); done();
}); });
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise * @tc.name testlocationChangeOn promise
* @tc.desc Test fenceStatusChange api . * @tc.desc Test locationChangeOn api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_fenceStatusChange_On_test_001', 0, async function (done) { it('geolocation_fenceStatusChange_On_test_001', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] enableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
}); });
let geofence = {"latitude":31.12,"longitude":121.11, "radius":1,"expiration":""}; let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
let geofenceRequest = { "priority":0x203, "scenario":0x300,"geofence":geofence}; let geofenceRequest = {"priority":0x0203, "scenario":0x0300, "geofence": geofence};
let want = (wantAgent)=>{ let want = (wantAgent) => {
console.log('wantAgent:'+ JSON.stringify(wantAgent)); console.log('wantAgent: ' + JSON.stringify(wantAgent));
}; };
await geolocation.on('fenceStatusChange',geofenceRequest, await geolocation.on('fenceStatusChange', geofenceRequest,
want => { (want) => {
if(err){ if(err){
return console.info("fenceStatusChange callback err: " + err); return console.info("fenceStatusChange on callback err: " + err);
} }
console.info("offfenceStatusChange callback: " + JSON.stringify(want)); console.info("fenceStatusChange callback, result: " + JSON.stringify(want));
expect(true).assertEqual(want !=null); expect(true).assertEqual(want !=null);
done(); done();
}); });
await geolocation.off('fenceStatusChange',geofenceRequest, await geolocation.off('fenceStatusChange',geofenceRequest,
want => { (want) => {
if(err){ if(err){
return console.info("fenceStatusChange callback err: " + err); return console.info("fenceStatusChange callback err: " + err);
} }
console.info("offfenceStatusChange callback: " + JSON.stringify(want)); console.info("offfenceStatusChange callback, result: " + JSON.stringify(want));
expect(true).assertEqual(want !=null); expect(true).assertEqual(want !=null);
done(); done();
}); });
})
})
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise * @tc.name testlocationChangeOn promise
...@@ -948,42 +1112,38 @@ describe('geolocationTest', function () { ...@@ -948,42 +1112,38 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_cachedGnssLocationsReporting_On_test_001', 0, async function (done) { it('geolocation_cachedGnssLocationsReporting_On_test_001', 0, async function (done) {
let request = {"reportingPeriodSec": 0, "wakeUpCacheQueueFull": true};
let request = {"reportingPeriodSec": 0, "wakeUpCacheQueueFull": true}; await geolocation.on('cachedGnssLocationsReporting',request,
await geolocation.on('cachedGnssLocationsReporting',request,
result => {
if(err){
return console.info("oncachedGnssLocationsReporting callback err: " + err);
}
console.info("cachedGnssLocationsReporting result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
console.info('LBS enableLocation callback test start ...');
geolocation.enableLocation((err, data) => {
if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
console.info("[lbs_js] enableLocation callback exit .");
}
done()
});
await geolocation.off('cachedGnssLocationsReporting',request,
result => { result => {
if(err){ if(err){
return console.info("cachedGnssLocationsReporting callback err: " + err); return console.info("oncachedGnssLocationsReporting callback err: " + err);
} }
console.info("offcachedGnssLocationsReporting callback, result: " + JSON.stringify(locationChange)); console.info("cachedGnssLocationsReporting result: " + JSON.stringify(result));
expect(true).assertEqual(locationChange !=null); expect(true).assertEqual(result !=null);
done(); done();
}); });
console.info('LBS enableLocation callback test start ...');
}) geolocation.enableLocation((err, data) => {
if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
console.info("[lbs_js] enableLocation callback exit .");
}
done()
});
await geolocation.off('cachedGnssLocationsReporting',request,
(result) => {
if(err){
return console.info("cachedGnssLocationsReporting callback err: " + err);
}
console.info("offcachedGnssLocationsReporting callback " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
})
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
...@@ -993,16 +1153,12 @@ describe('geolocationTest', function () { ...@@ -993,16 +1153,12 @@ describe('geolocationTest', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_OnLocationServiceState_test_001', 0, async function (done) { it('geolocation_OnLocationServiceState_test_001', 0, async function (done) {
await geolocation.on('locationServiceState', result => { await geolocation.on('locationServiceState', result => {
console.info("onlocationServiceState callback, result: " + JSON.stringify(result)); console.info("onlocationServiceState callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); done();
}); });
console.info('LBS enableLocation callback test start ...');
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] enableLocation callback err is : ' + err );
...@@ -1014,8 +1170,7 @@ describe('geolocationTest', function () { ...@@ -1014,8 +1170,7 @@ describe('geolocationTest', function () {
}); });
}) })
/**
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
* @tc.name testOnLocationServiceState * @tc.name testOnLocationServiceState
* @tc.desc Test offLocationServiceState api . * @tc.desc Test offLocationServiceState api .
...@@ -1046,10 +1201,5 @@ describe('geolocationTest', function () { ...@@ -1046,10 +1201,5 @@ describe('geolocationTest', function () {
done(); done();
}); });
}) })
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册