提交 9734f4c4 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 810d8b44
......@@ -18,7 +18,6 @@ import { LocationEventListener } from '@ohos.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
......@@ -35,28 +34,28 @@ function sleep(ms) {
}
async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result);
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + result);
console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
console.info("[lbs_js] promise then error." + JSON.stringify(error));
expect().assertFail();
});
}
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
});
}
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
console.debug("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
......@@ -65,14 +64,14 @@ async function applyPermission() {
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);
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
......@@ -80,29 +79,19 @@ async function applyPermission() {
}
describe('geolocationTest_geo1', function () {
let data = {
title: "",
locationChange: null,
locatlocationServiceState: null
}
console.log('#start AccessTokenTests#');
beforeAll(async function (done) {
await applyPermission();
setTimeout(function () {
this.locationChange = (err, location) => {
console.log(' locationChange: ' + err + " data: " + JSON.stringify(location));
};
this.locationServiceState = (err, state) => {
console.log('locationServiceState: ' + err + " data: " + state);
};
done();
},3000);
console.info('beforeAll case');
await applyPermission();
done();
})
beforeEach(async function () {
await changedLocationMode();
beforeEach(async function (done) {
console.info('beforeEach case');
await changedLocationMode();
done();
})
afterEach(function () {
})
......@@ -118,11 +107,13 @@ describe('geolocationTest_geo1', function () {
it('SUB_HSS_LocationSystem_Geo_0001', 0, async function (done) {
geolocation.isGeoServiceAvailable(async(err, data) => {
if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + err );
console.info('[lbs_js] getGeoServiceState err is : ' + JSON.stringify(err) );
}else {
console.info('[lbs_js] isGeoServiceAvailable callback result: ' + data);
expect(data).assertTrue();
console.info('[lbs_js] isGeoServiceAvailable callback result: ' + JSON.stringify(data));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(data)!=null);
done();
}
done()
})
......@@ -138,10 +129,11 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_Geo_0002', 0, async function (done) {
await geolocation.isGeoServiceAvailable().then( (result) => {
console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + result);
expect(result).assertTrue();
console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + JSON.stringify(result));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(result)!=null);
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
console.info("[lbs_js] promise then error." + JSON.stringify(error));
expect().assertFail();
});
done();
......@@ -160,7 +152,7 @@ describe('geolocationTest_geo1', function () {
let promise = new Promise((resolve,reject) => {
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) {
console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err);
console.info('[lbs_js] getAddressesFromLocation callback err is : ' + JSON.stringify(err));
}else {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null);
......@@ -183,15 +175,21 @@ describe('geolocationTest_geo1', function () {
let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation04 promise: ' + JSON.stringify(data));
console.info('addressUrl: ' + data[0].addressUrl + data[0].administrativeArea + data[0].countryCode
+ data[0].countryName+ data[0].descriptions+ data[0].descriptionsSize +data[0].latitude
+ data[0].locale+ data[0].locality+ data[0].longitude+ data[0].phoneNumber+ data[0].placeName
+ data[0].postalCode+ data[0].premises+ data[0].roadName+ data[0].subAdministrativeArea
+ data[0].subLocality+ data[0].subRoadName);
console.info('addressUrl: ' + JSON.stringify(data)[0].addressUrl
+ JSON.stringify(data)[0].administrativeArea + JSON.stringify(data)[0].countryCode
+ JSON.stringify(data)[0].countryName+ JSON.stringify(data)[0].descriptions
+ JSON.stringify(data)[0].descriptionsSize +data[0].latitude
+ JSON.stringify(data)[0].locale+ JSON.stringify(data)[0].locality
+ JSON.stringify(data)[0].longitude+ JSON.stringify(data)[0].phoneNumber
+ JSON.stringify(data)[0].placeName
+ JSON.stringify(data)[0].postalCode+ JSON.stringify(data)[0].premises
+ JSON.stringify(data)[0].roadName+ JSON.stringify(data)[0].subAdministrativeArea
+ JSON.stringify(data)[0].subLocality+ JSON.stringify(data)[0].subRoadName);
done();
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
done();
});
})
......@@ -211,8 +209,9 @@ describe('geolocationTest_geo1', function () {
expect(true).assertEqual((JSON.stringify(data)) !=null);
done();
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
done();
});
})
......@@ -231,15 +230,16 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] getAddressesFromLocation0601 promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0601 promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation0601 promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let reverseGeocodeRequest2 = {"latitude": 90.1, "longitude": 121.62771, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => {
console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data));
expect(data.length).assertEqual(0);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0602 promise then error." + error.message);
console.info("[lbs_js] getAddressesFromLocation0602 promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let reverseGeocodeRequest3 = {"latitude": -90, "longitude": 121.62771, "maxItems": 1};
......@@ -247,15 +247,16 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] getAddressesFromLocation0603 promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0603 promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation0603 promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let reverseGeocodeRequest4 = {"latitude": -90.1, "longitude": 121.62771, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest4).then((data) => {
console.info('[lbs_js] getAddressesFromLocation0604 promise: ' + JSON.stringify(data));
expect(data.length).assertEqual(0);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0604 promise then error." + error);
console.info("[lbs_js] getAddressesFromLocation0604 promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
done()
......@@ -275,15 +276,16 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] getAddressesFromLocation0701 promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0701 promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation0701 promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let reverseGeocodeRequest1 = {"latitude": 31.265496, "longitude": -180.1, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => {
console.info('[lbs_js] getAddressesFromLocation0702 promise: ' + JSON.stringify(data));
expect(data.length).assertEqual(0);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0702 promise then error." + error.message);
console.info("[lbs_js] getAddressesFromLocation0702 promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let reverseGeocodeRequest2 = {"latitude": 31.265496, "longitude": 180, "maxItems": 1};
......@@ -291,15 +293,16 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] getAddressesFromLocation0703 promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0703 promise then error." + error.message);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocation0703 promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let reverseGeocodeRequest3 = {"latitude": 31.265496, "longitude": 180.1, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => {
console.info('[lbs_js] getAddressesFromLocation0704 promise: ' + JSON.stringify(data));
expect(data.length).assertEqual(0);
}).catch(error => {
console.info("[lbs_js] getAddressesFromLocation0704 promise then error." + error.message);
console.info("[lbs_js] getAddressesFromLocation0704 promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
done()
......@@ -320,28 +323,28 @@ describe('geolocationTest_geo1', function () {
if(err){
switch(err){
case 101:
console.info("INPUT_PARAMS_ERROR: "+ err);
console.info("INPUT_PARAMS_ERROR: "+ JSON.stringify(err));
break;
case 102:
console.info("REVERSE_GEOCODE_ERROR: "+ err);
console.info("REVERSE_GEOCODE_ERROR: "+ JSON.stringify(err));
break;
case 103:
console.info("GEOCODE_ERROR: "+ err);
console.info("GEOCODE_ERROR: "+ JSON.stringify(err));
break;
case 104:
console.info("LOCATOR_ERROR: "+ err);
console.info("LOCATOR_ERROR: "+ JSON.stringify(err));
break;
case 105:
console.info("LOCATION_SWITCH_ERROR: "+ err);
console.info("LOCATION_SWITCH_ERROR: "+ JSON.stringify(err));
break;
case 106:
console.info("LAST_KNOWN_LOCATION_ERROR: "+ err);
console.info("LAST_KNOWN_LOCATION_ERROR: "+ JSON.stringify(err));
break;
case 107:
console.info("LOCATION_REQUEST_TIMEOUT_ERROR: "+ err);
console.info("LOCATION_REQUEST_TIMEOUT_ERROR: "+ JSON.stringify(err));
break;
default:
console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + err);
console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + JSON.stringify(err));
}
}else {
console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data));
......@@ -365,8 +368,8 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName09 promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName09 promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
done();
})
......@@ -385,8 +388,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation m callback data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName m promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName m promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -405,16 +409,18 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest1 = {"description": null, "maxItems": 1};
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -434,8 +440,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -455,7 +462,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(result.length==0).assertTrue();
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let geocodeRequest1 = {"description": null, "maxItems": 1, "minLatitude":331.3082812847 ,
......@@ -464,7 +471,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(result.length==0).assertTrue();
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
done();
......@@ -485,8 +492,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(result.length>=0).assertTrue();
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done()
})
......@@ -506,8 +514,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(result.length>=0).assertTrue();
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done()
})
......@@ -527,8 +536,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect(true).assertEqual((JSON.stringify(error)) ==null);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest2 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":90 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
......@@ -536,8 +546,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect(true).assertEqual((JSON.stringify(error)) ==null);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest3 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":-90.1 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
......@@ -545,16 +556,17 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) ==null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let geocodeRequest4 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":90.1 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
await geolocation.getAddressesFromLocationName(geocodeRequest4).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) ==null);
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let geocodeRequest5 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 ,
......@@ -563,8 +575,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect(true).assertEqual((JSON.stringify(error)) ==null);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest6 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 ,
"minLongitude":121.5782001832,"maxLatitude":90,"maxLongitude":121.8026736943};
......@@ -572,8 +585,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect(true).assertEqual((JSON.stringify(error)) ==null);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest7 ={"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 ,
"minLongitude":121.5782001832,"maxLatitude":-90.1,"maxLongitude":121.8026736943};
......@@ -581,7 +595,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) ==null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
let geocodeRequest8 ={"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 ,
......@@ -590,7 +604,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) ==null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) !=null);
});
done()
......@@ -611,8 +625,9 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect(error==null).assertTrue();
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
let geocodeRequest2 ={"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
"minLongitude":180,"maxLatitude":39.95,"maxLongitude":116.45};
......@@ -620,7 +635,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest3 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -629,7 +644,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest4 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -638,7 +653,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest5 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -647,7 +662,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest6 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -656,7 +671,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest7 ={"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -665,7 +680,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
let geocodeRequest8 ={"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
......@@ -674,7 +689,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length!=0).assertTrue();
});
done()
......@@ -691,10 +706,10 @@ describe('geolocationTest_geo1', function () {
it('SUB_HSS_LocationSystem_LocSwitch_0001', 0, async function (done) {
geolocation.isLocationEnabled(async(err, data) => {
if (err) {
console.info('[lbs_js] getLocationSwitchState err is : ' + err );
console.info('[lbs_js] getLocationSwitchState err is : ' + JSON.stringify(err) );
}else {
console.info('[lbs_js] getLocationSwitchState callback data1: ' + data);
console.info('[lbs_js] getLocationSwitchState callback data1: ' + JSON.stringify(data));
expect(data).assertTrue();
}
done()
......@@ -711,7 +726,7 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_LocSwitch_0002', 0, async function (done) {
await geolocation.isLocationEnabled().then((result) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_00021 result: ' + result);
console.info('[lbs_js] getLocationSwitchStateLocSwitch_00021 result: ' + JSON.stringify(result));
expect(result).assertTrue();
}).catch((error) => {
expect().assertFail();
......@@ -730,10 +745,10 @@ describe('geolocationTest_geo1', function () {
it('SUB_HSS_LocationSystem_LocSwitch_0003', 0, async function (done) {
geolocation.isLocationEnabled(async(err, data) => {
if (err) {
console.info('[lbs_js] getLocationSwitchState callback err is : ' + err );
console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err) );
}else {
console.info("[lbs_js] getLocationSwitchState callback data: " + data);
console.info("[lbs_js] getLocationSwitchState callback data: " + JSON.stringify(data));
expect(data).assertTrue();
}
done()
......@@ -750,7 +765,7 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_LocSwitch_0004', 0, async function (done) {
await geolocation.isLocationEnabled().then((result1) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + result1);
console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1));
expect(result1).assertTrue();
}).catch((error) => {
expect().assertFail();
......@@ -769,27 +784,22 @@ describe('geolocationTest_geo1', function () {
it('SUB_HSS_LocationSystem_LocSwitch_0005', 0, async function (done) {
geolocation.on('locationServiceState',
(result) => {
if(err){
return console.info("locationServiceState on callback err: " + err);
}
console.info("locationServiceState on result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
geolocation.requestEnableLocation((err, data) => {
if (err) {
console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
console.info('[lbs_js] requestEnableLocation callback err is : ' + JSON.stringify(err) );
}else {
console.info("[lbs_js] requestEnableLocation callback data: " + data);
console.info("[lbs_js] requestEnableLocation callback data: " + JSON.stringify(data));
expect(data).assertTrue();
}
done()
});
geolocation.off('locationServiceState',
(result) => {
if(err){
return console.info("locationServiceState off callback err: " + err);
}
console.info("locationServiceState off callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
......@@ -808,14 +818,14 @@ describe('geolocationTest_geo1', function () {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.requestEnableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
console.info('[lbs_js] requestEnableLocation callback err is : ' + JSON.stringify(err) );
}
console.info("[lbs_js] requestEnableLocation callback data: " + data);
console.info("[lbs_js] requestEnableLocation callback data: " + JSON.stringify(data));
expect(data).assertTrue();
geolocation.getCurrentLocation(currentLocationRequest,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -859,7 +869,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
expect(true).assertEqual(resultLength >= 0);
......@@ -880,7 +890,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -902,7 +912,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -925,11 +935,11 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
console.info("getCurrentLocation callback1 err: " + JSON.stringify(err))
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
return console.info("getCurrentLocation callback2 err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -958,7 +968,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -981,7 +991,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1004,7 +1014,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1027,7 +1037,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1050,7 +1060,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1073,7 +1083,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1096,7 +1106,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1119,7 +1129,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1142,7 +1152,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1166,11 +1176,11 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
console.info("getCurrentLocation callback1 err: " + JSON.stringify(err))
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
return console.info("getCurrentLocation callback2 err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1199,7 +1209,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1222,7 +1232,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1245,7 +1255,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1268,7 +1278,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1291,7 +1301,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1315,11 +1325,11 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
console.info("getCurrentLocation callback1 err: " + JSON.stringify(err))
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
return console.info("getCurrentLocation callback2 err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1348,7 +1358,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1371,7 +1381,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1394,7 +1404,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1417,7 +1427,7 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
return console.info("getCurrentLocation callback err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1441,11 +1451,11 @@ describe('geolocationTest_geo1', function () {
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
console.info("getCurrentLocation callback1 err: " + JSON.stringify(err))
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
return console.info("getCurrentLocation callback2 err: " + JSON.stringify(err))
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
......@@ -1475,10 +1485,10 @@ describe('geolocationTest_geo1', function () {
it('SUB_HSS_LocationSystem_LastLocation_0001', 0, async function (done) {
geolocation.getLastLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] getLastLocation callback err is : ' + err );
console.info('[lbs_js] getLastLocation callback err is : ' + JSON.stringify(err) );
}else {
console.info('[lbs_js] getLastLocation callback result: ' + data);
expect(data).assertTrue();
console.info('[lbs_js] getLastLocation callback result: ' + JSON.stringify(data));
expect(true).assertEqual(JSON.stringify(data)!=null);
}
done()
})
......@@ -1493,15 +1503,14 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_LastLocation_0002', 0, async function (done) {
setTimeout(async ()=>{
await geolocation.getLastLocation().then((result) => {
console.info('[lbs_js] getLastLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info('[lbs_js] getLastLocation promise then err: ' + result);
expect().assertFail();
});
},2000);
await geolocation.getLastLocation().then((result) => {
console.info('[lbs_js] getLastLocation promise result: ' + JSON.stringify(result));
expect(result).assertTrue();
}).catch((error) => {
console.info('[lbs_js] getLastLocation promise then err: ' + JSON.stringify(result));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -1515,15 +1524,14 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_SingleLoc_0028', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
setTimeout(async ()=>{
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
},2000);
done();
})
......@@ -1537,15 +1545,14 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_SingleLoc_0029', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0301, "timeoutMs": 10, "maxAccuracy": 0 };
setTimeout(async ()=>{
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
},2000);
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -1559,15 +1566,14 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_SingleLoc_0030', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0302, "timeoutMs": 10, "maxAccuracy": 0 };
setTimeout(async ()=>{
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getCurrentLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
},2000);
done();
})
......@@ -1580,17 +1586,15 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0031', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0303, "timeoutMs": 10, "maxAccuracy": 0 };
setTimeout(async ()=>{
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
},2000);
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
done();
})
......@@ -1604,20 +1608,62 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_SingleLoc_0032', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0304, "timeoutMs": 10, "maxAccuracy": 0 };
setTimeout(async ()=>{
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
console.info("[lbs_js] getCurrentLocation promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error)!=null);
});
},2000);
done();
})
/**
* @tc.number SingleLoc_0032
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0032
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_SendCommand_callback', 0, async function (done) {
let requestInfo = {'scenairo':0x301,'command':"command_1"};
await geolocation.sendCommand(requestInfo,(err,result) =>{
if(err){
console.info('sendcommand callback err:'+err);
expect(true).assertEqual(JSON.stringify(err)!=null);
done();
}
console.info('sendcommand callback result:' +result);
});
})
/**
* @tc.number SingleLoc_0032
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0032
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_SendCommand_promise', 0, async function (done) {
let requestInfo = {'scenairo':0x301,'command':"command_1"};
await geolocation.sendCommand(requestInfo).then((result) =>{
console.info('sendCommand promise result:'+result);
done();
}).catch(error=>{
console.info('sendcommand promise err:'+err);
expect(true).assertEqual(JSON.stringify(err)!=null);
done();
})
})
})
......@@ -17,7 +17,6 @@ import geolocations from '@system.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
function sleep(ms) {
......@@ -26,48 +25,48 @@ function sleep(ms) {
async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
}
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
});
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + JSON.stringify(error));
expect().assertFail();
});
}
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
});
}
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
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');
}
let osAccountManager = osaccount.getAccountManager();
console.debug("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
describe('geolocationTest_geo2', function () {
......@@ -201,14 +200,8 @@ describe('geolocationTest_geo2', function () {
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_0005', 0, async function (done) {
geolocation.unsubscribe(
(result) => {
if(err){
return console.info("unsubscribe err: " + err);
}
console.info("unsubscribe result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
geolocation.unsubscribe();
console.info("[lbs_js] unsubscribe called")
done();
})
......
......@@ -35,48 +35,48 @@ function sleep(ms) {
async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
}
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] check LocationSwitchState result: ' + result);
});
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
if(!result){
await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + JSON.stringify(error));
expect().assertFail();
});
}
});
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result));
});
}
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info('[permission] getAccountManager call end');
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
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');
}
let osAccountManager = osaccount.getAccountManager();
console.debug("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
describe('geolocationTest_geo3', function () {
......@@ -1045,6 +1045,8 @@ describe('geolocationTest_geo3', function () {
geolocation.getCachedGnssLocationsSize((err, data) => {
if (err) {
console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + err);
expect(true).assertTrue(err != null);
done();
}else {
console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data != null);
......@@ -1094,7 +1096,8 @@ describe('geolocationTest_geo3', function () {
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
expect(true).assertTrue(error != null);
done();
done();
});
})
......@@ -1114,6 +1117,8 @@ describe('geolocationTest_geo3', function () {
(result) => {
if(err){
return console.info("oncachedGnssLocationsReporting callback err: " + err);
expect(true).assertTrue(err != null);
done();
}
console.info("cachedGnssLocationsReporting result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
......@@ -1136,6 +1141,8 @@ describe('geolocationTest_geo3', function () {
geolocation.flushCachedGnssLocations((err, data) => {
if (err) {
console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + err);
expect(true).assertTrue(err != null);
done();
}else {
console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data);
......@@ -1185,7 +1192,7 @@ describe('geolocationTest_geo3', function () {
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
expect(true).assertTrue(error != null);
done();
});
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册