提交 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": [
...@@ -49,13 +49,33 @@ ...@@ -49,13 +49,33 @@
"defPermissions": [ "defPermissions": [
{ {
"availableScope": [], "availableScope": [],
"grantMode": "system_grant", "grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION" "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.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": [],
"grantMode": "user_grant",
"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.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": { "usedScene": {
"ability": [ "ability": [
"ohos.acts.location.geolocation.function.MainAbility" "ohos.acts.location.geolocation.function.MainAbility"
...@@ -101,24 +120,18 @@ ...@@ -101,24 +120,18 @@
} }
}, },
{ {
"name":"ohos.permission.GET_WIFI_LOCAL_MAC", "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason":"need use ohos.permission.GET_WIFI_LOCAL_MAC", "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
}, },
{ {
"name":"ohos.permission.GET_WIFI_INFO_INTERNAL", "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason":"need use ohos.permission.GET_WIFI_INFO_INTERNAL", "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
"usedScene": { },
"ability": [ {
"ohos.acts.location.geolocation.function.MainAbility" "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
], },
"when": "inuse" {
} "name": "ohos.permission.GET_BUNDLE_INFO"
} }
], ],
"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')
}) })
/** /**
...@@ -71,27 +97,22 @@ describe('geolocationTest', function () { ...@@ -71,27 +97,22 @@ describe('geolocationTest', 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();
...@@ -237,12 +248,10 @@ describe('geolocationTest', function () { ...@@ -237,12 +248,10 @@ describe('geolocationTest', function () {
}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) {
...@@ -250,12 +259,10 @@ describe('geolocationTest', function () { ...@@ -250,12 +259,10 @@ describe('geolocationTest', function () {
}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)
...@@ -270,21 +277,17 @@ describe('geolocationTest', function () { ...@@ -270,21 +277,17 @@ describe('geolocationTest', 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
...@@ -315,7 +317,6 @@ describe('geolocationTest', function () { ...@@ -315,7 +317,6 @@ describe('geolocationTest', function () {
}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();
}); });
...@@ -330,14 +331,12 @@ describe('geolocationTest', function () { ...@@ -330,14 +331,12 @@ describe('geolocationTest', 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,12 +354,10 @@ describe('geolocationTest', function () { ...@@ -355,12 +354,10 @@ 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
...@@ -370,7 +367,6 @@ describe('geolocationTest', function () { ...@@ -370,7 +367,6 @@ describe('geolocationTest', 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 );
...@@ -429,7 +425,6 @@ describe('geolocationTest', function () { ...@@ -429,7 +425,6 @@ describe('geolocationTest', function () {
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,15 +484,43 @@ describe('geolocationTest', function () { ...@@ -488,15 +484,43 @@ 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
...@@ -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,7 +595,6 @@ describe('geolocationTest', function () { ...@@ -570,7 +595,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();
}); });
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 );
...@@ -578,18 +602,15 @@ describe('geolocationTest', function () { ...@@ -578,18 +602,15 @@ describe('geolocationTest', function () {
}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
...@@ -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,7 +682,7 @@ describe('geolocationTest', function () { ...@@ -662,7 +682,7 @@ 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);
} }
}); });
...@@ -671,8 +691,8 @@ describe('geolocationTest', function () { ...@@ -671,8 +691,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 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
...@@ -756,18 +775,22 @@ describe('geolocationTest', function () { ...@@ -756,18 +775,22 @@ describe('geolocationTest', function () {
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test setLocationPrivacyConfirmStatus callback * @tc.name Test isLocationPrivacyConfirmed callback
* @tc.desc Test setLocationPrivacyConfirmStatus 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_setLocationPrivacyConfirmStatus_callback_test_001', 0, async function (done) { it('geolocation_LocationPrivacyConfirmed_callback_test_001', 0, async function (done) {
let reqType = 1; let reqType = 1;
let isConfirmed = true; let value = true;
console.info('[lbs_js] setLocationPrivacyConfirmStatus callback test start ...'); await geolocation.setLocationPrivacyConfirmStatus(reqType, value, (err, resp)=>{
geolocation.setLocationPrivacyConfirmStatus(reqType, isConfirmed, (err,resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
});
console.info('[lbs_js] isLocationPrivacyConfirmed callback test start ...');
geolocation.isLocationPrivacyConfirmed(reqType ,(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue(); expect(resp).assertTrue();
done() done()
}); });
...@@ -775,38 +798,114 @@ describe('geolocationTest', function () { ...@@ -775,38 +798,114 @@ describe('geolocationTest', function () {
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test isLocationPrivacyConfirmed callback * @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test isLocationPrivacyConfirmed api . * @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @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_LocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) {
let reqType = 1; let reqType =1;
let value = true; let value = true;
geolocation.setLocationPrivacyConfirmStatus(reqType, value, (err, resp)=>{ 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();
})
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done();
})
})
console.info('[lbs_js] isLocationPrivacyConfirmed callback test start ...'); /**
geolocation.isLocationPrivacyConfirmed(reqType ,(err,resp) => { * @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)) 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(); expect(resp).assertTrue();
done() })
}); geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
})
}) })
/** /**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002 * @tc.number geolocation_setLocationPrivacyConfirmStatus_promise_test_004
* @tc.name Test setLocationPrivacyConfirmStatus promise * @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test setLocationPrivacyConfirmStatus api . * @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @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_004', 0, async function (done) {
let reqType = 1; let reqType =2;
let value = true; let value = false;
let type = "STARTUP"; let type = "STARTUP";
if(type == "OTHERS"){ if(type == "OTHERS"){
...@@ -818,30 +917,65 @@ describe('geolocationTest', function () { ...@@ -818,30 +917,65 @@ 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)) 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,17 +1055,16 @@ describe('geolocationTest', function () { ...@@ -889,17 +1055,16 @@ 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
...@@ -914,30 +1079,29 @@ describe('geolocationTest', function () { ...@@ -914,30 +1079,29 @@ describe('geolocationTest', function () {
} }
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();
}); });
}) })
/** /**
...@@ -949,9 +1113,7 @@ describe('geolocationTest', function () { ...@@ -949,9 +1113,7 @@ describe('geolocationTest', 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 => { result => {
if(err){ if(err){
...@@ -961,7 +1123,6 @@ describe('geolocationTest', function () { ...@@ -961,7 +1123,6 @@ describe('geolocationTest', function () {
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); done();
}); });
console.info('LBS enableLocation callback test start ...'); console.info('LBS enableLocation callback test start ...');
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
...@@ -974,15 +1135,14 @@ describe('geolocationTest', function () { ...@@ -974,15 +1135,14 @@ describe('geolocationTest', function () {
done() done()
}); });
await geolocation.off('cachedGnssLocationsReporting',request, await geolocation.off('cachedGnssLocationsReporting',request,
result => { (result) => {
if(err){ if(err){
return console.info("cachedGnssLocationsReporting callback err: " + err); return console.info("cachedGnssLocationsReporting callback err: " + err);
} }
console.info("offcachedGnssLocationsReporting callback, result: " + JSON.stringify(locationChange)); console.info("offcachedGnssLocationsReporting callback " + JSON.stringify(result));
expect(true).assertEqual(locationChange !=null); expect(true).assertEqual(result !=null);
done(); done();
}); });
}) })
/** /**
...@@ -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,7 +1170,6 @@ describe('geolocationTest', function () { ...@@ -1014,7 +1170,6 @@ 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
...@@ -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.
先完成此消息的编辑!
想要评论请 注册