提交 fa43cbd5 编写于 作者: Q q00313334

add location user grant

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