提交 39705b4e 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 f6f68614
{
"app": {
"bundleName": "ohos.acts.location.geolocation.function",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.location.geolocation.function",
"name": ".MyApplication",
"mainAbility": "ohos.acts.location.geolocation.function.MainAbility",
"deviceType": [
{
"app": {
"bundleName": "ohos.acts.location.geolocation.function",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.location.geolocation.function",
"name": ".MyApplication",
"mainAbility": "ohos.acts.location.geolocation.function.MainAbility",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "ohos.acts.location.geolocation.function.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.ACCESS_LOCATION",
"reason":"need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.LOCATION_IN_BACKGROUND",
"reason":"need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "ohos.acts.location.geolocation.function.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.ACCESS_LOCATION",
"reason":"need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.APPROXIMATELY_LOCATION",
"reason":"need use ohos.permission.APPROXIMATELY_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.LOCATION_IN_BACKGROUND",
"reason":"need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
......@@ -119,7 +119,7 @@ describe('geolocationTest_geo1', function () {
expect(true).assertEqual(JSON.stringify(data) != null);
done();
}
done()
done();
})
});
......@@ -132,14 +132,18 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Geo_0200', 0, async function (done) {
await geolocation.isGeoServiceAvailable().then((result) => {
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." + JSON.stringify(error));
expect().assertFail();
});
try {
await geolocation.isGeoServiceAvailable().then((result) => {
console.info('[lbs_js] isGeoServiceAvailable 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." + JSON.stringify(error));
expect().assertFail();
});
} catch (error) {
console.info("[lbs_js] isGeoServiceAvailable error." + JSON.stringify(error));
}
done();
})
......@@ -161,7 +165,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) != null);
}
resolve()
resolve();
});
})
await promise.then(done)
......@@ -231,40 +235,63 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_Geo_0600', 0, async function (done) {
let reverseGeocodeRequest1 = { "latitude": 90, "longitude": 121.62771, "maxItems": 1 };
await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
try {
await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => {
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." + JSON.stringify(error));
expect(true).assertEqual(JSON.stringify(error) != null);
console.info('[lbs_js] not support now');
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != 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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
try {
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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let reverseGeocodeRequest3 = { "latitude": -90, "longitude": 121.62771, "maxItems": 1 };
await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
try {
await geolocation.getAddressesFromLocation(reverseGeocodeRequest3).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != 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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
done()
try {
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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done();
})
/**
......@@ -277,40 +304,60 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_Geo_0700', 0, async function (done) {
let reverseGeocodeRequest = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 };
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
try {
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != 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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
try {
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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let reverseGeocodeRequest2 = { "latitude": 31.265496, "longitude": 180, "maxItems": 1 };
await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
try {
await geolocation.getAddressesFromLocation(reverseGeocodeRequest2).then((data) => {
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." + JSON.stringify(error));
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != 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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
done()
try {
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." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null);
});
} catch (error) {
console.info("[lbs_js] getAddressesFromLocation message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done();
})
/**
......@@ -429,7 +476,6 @@ describe('geolocationTest_geo1', function () {
*/
it('SUB_HSS_LocationSystem_Geo_1100', 0, async function (done) {
try {
let geocodeRequest = { "description": "", "maxItems": 1 };
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result));
......@@ -566,7 +612,7 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
done()
done();
})
/**
......@@ -595,7 +641,7 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null);
});
done()
done();
})
/**
......@@ -772,7 +818,7 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done()
done();
})
/**
......@@ -949,3 +995,5 @@ describe('geolocationTest_geo1', function () {
})
})
......@@ -14,7 +14,6 @@
*/
import geolocation from '@ohos.geolocation';
import geolocationm from '@ohos.geoLocationManager';
import geolocations from '@system.geolocation';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
......@@ -120,7 +119,7 @@ describe('geolocationTest_4', function () {
* @tc.type Function
* @tc.level since 9
*/
it('SUB_HSS_LocationSystem_CountryCode_0200', 0, async function (done) {
it('SUB_HSS_LocationSystem_CountryCode_0200', 0, async function (done) {
function getCountryCodeCallback() {
return new Promise((resolve, reject) => {
geolocationm.getCountryCode((err,data) => {
......@@ -128,7 +127,7 @@ describe('geolocationTest_4', function () {
return console.info("getCountryCode callback err: " + JSON.stringify(err));
} else {
console.info("getCountryCode callback success"+ JSON.stringify(data));
expect(true).assertEqual(data != null);
expect(true).assertEqual(data != null);
}
resolve();
})
......@@ -146,7 +145,7 @@ describe('geolocationTest_4', function () {
* @tc.level since 9
*/
it('SUB_HSS_LocationSystem_CountryCode_0300', 0, async function (done) {
console.info("[lbs_js]countryCodeChange");
console.info("[lbs_js] countryCodeChange");
geolocationm.on('countryCodeChange', function (data) {
console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) );
});
......@@ -165,6 +164,3 @@ describe('geolocationTest_4', function () {
})
})
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import geolocationm from '@ohos.geoLocationManager';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
console.info('[lbs_js]sleep function');
}
async function changedLocationMode(){
let result1 = geolocationm.isLocationEnabled();
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1));
if(!result1){
await geolocationm.requestEnableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
}).catch((error) => {
console.info("[lbs_js] promise then error." + JSON.stringify(error));
expect().assertFail();
});
}
let result2 = geolocationm.isLocationEnabled();
console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2));
}
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("====>testgetuserid get AccountManager finish====");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("====>testgetuserid localId obtained by process:" + 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 CountryCodeType = {
COUNTRY_CODE_FROM_LOCALE : 1,
COUNTRY_CODE_FROM_SIM:2,
COUNTRY_CODE_FROM_LOCATION:3,
COUNTRY_CODE_FROM_NETWORK:4,
}
describe('geolocationTest_6', function () {
beforeAll(async function (done) {
console.info('beforeAll case');
await applyPermission();
done();
})
beforeEach(async function (done) {
console.info('beforeEach case');
await changedLocationMode();
done();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0400
* @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information
* @tc.type Function
* @tc.level since 9
*/
it('SUB_HSS_LocationSystem_CountryCode_0400', 0, async function (done) {
await geolocationm.getCountryCode().then((result) => {
console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result));
console.info("[lbs_js] country :" + result.country);
console.info("[lbs_js] type: " + result.type);
expect(true).assertTrue(JSON.stringify(result)==CountryCodeType.COUNTRY_CODE_FROM_LOCALE);
expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_SIM);
expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_LOCATION);
expect(true).assertTrue(JSON.stringify(result)!=CountryCodeType.COUNTRY_CODE_FROM_NETWORK);
}).catch((error) => {
console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error));
expect().assertFail();
});
done();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0500
* @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information
* @tc.type Function
* @tc.level since 9
*/
it('SUB_HSS_LocationSystem_CountryCode_0500', 0, async function (done) {
function getCountryCodeCallback() {
return new Promise((resolve, reject) => {
geolocationm.getCountryCode((err,data) => {
if (err) {
return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err));
} else {
console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data));
expect(true).assertEqual(data != null);
}
resolve();
})
})
}
await getCountryCodeCallback();
done();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0600
* @tc.name getCountryCode_on_off
* @tc.desc The interception country code is changed.
* @tc.type Function
* @tc.level since 9
*/
it('SUB_HSS_LocationSystem_CountryCode_0600', 0, async function (done) {
console.info("[lbs_js] countryCodeChange");
geolocationm.on('countryCodeChange', function (data) {
console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) );
});
await geolocationm.getCountryCode().then((result) => {
console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result));
expect(true).assertTrue(JSON.stringify(result)!=null);
}).catch((error) => {
console.info("[lbs_js] getCountryCode promise then error." + JSON.stringify(error));
expect().assertFail();
});
geolocationm.off('countryCodeChange', function (data) {
console.info('[lbs_js] countryCodeChange' + JSON.stringify(data));
done();
})
done();
})
})
......@@ -14,6 +14,9 @@
*/
require('./GeocoderTest.test.js')
require('./GeocoderMTest.test.js')
require('./GetCountryCode.test.js')
require('./SystemLocation.test.js')
require('./GetCountryCodeM.test.js')
require('./LocationTest.test.js')
require('./LocationMTest.test.js')
require('./SystemLocation.test.js')
......@@ -127,12 +127,12 @@ describe('geolocationTest_geo3', function () {
console.info("[lbs_js] getLocationSwitchState callback data: " + JSON.stringify(data));
expect(data).assertTrue();
}
done()
})
done();
});
/**
* @tc.number LocSwitch_0400
* @tc.number SUB_HSS_LocationSystem_LocSwitch_0400
* @tc.name Test requestrequestEnableLocation api.
* @tc.desc Enabling the Location Service Function for a Third-Party Application -Promise Mode
* @tc.size MEDIUM
......@@ -164,7 +164,7 @@ describe('geolocationTest_geo3', function () {
}
geolocation.on('locationServiceState', locationServiceState);
geolocation.off('locationServiceState', locationServiceState);
expect(true).assertTrue();
expect(true).assertTrue();
done();
})
......@@ -193,7 +193,7 @@ describe('geolocationTest_geo3', function () {
});
})
}
console.info('getCurrentLocationCallback start');
console.info('getCurrentLocationCallback start');
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result));
expect(true).assertEqual(result != null);
......@@ -493,11 +493,9 @@ describe('geolocationTest_geo3', function () {
expect(true).assertEqual(JSON.stringify(error) != null);
done();
})
done()
done();
})
/**
* @tc.number SUB_HSS_SendCommand_0100
* @tc.name Test sendCommand
......@@ -508,14 +506,20 @@ describe('geolocationTest_geo3', function () {
*/
it('SUB_HSS_SendCommand_0100', 0, async function (done) {
let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
await geolocation.sendCommand(requestInfo, (err, result) => {
if (err) {
console.info('sendcommand callback err:' + JSON.stringify(err));
expect(true).assertEqual(JSON.stringify(err) != null);
done();
}
console.info('sendcommand callback result:' + JSON.stringify(result));
});
try {
await geolocation.sendCommand(requestInfo, (err, result) => {
if (err) {
console.info('sendcommand callback err:' + JSON.stringify(err));
expect(true).assertEqual(JSON.stringify(err) != null);
done();
}
console.info('sendcommand callback result:' + JSON.stringify(result));
});
} catch (error) {
console.info('sendcommand callback err:' + JSON.stringify(error));
expect(true).assertEqual(JSON.stringify(error) != null);
}
done();
})
/**
......@@ -528,14 +532,21 @@ describe('geolocationTest_geo3', function () {
*/
it('SUB_HSS_SendCommand_0200', 0, async function (done) {
let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
geolocation.sendCommand(requestInfo).then((result) => {
console.info('sendCommand promise result:' + result);
done();
}).catch(error => {
try {
geolocation.sendCommand(requestInfo).then((result) => {
console.info('sendCommand promise result:' + result);
done();
}).catch(error => {
console.info('sendcommand promise err:' + JSON.stringify(error));
expect(true).assertEqual(JSON.stringify(error) != null);
done();
})
} catch (error) {
console.info('sendcommand promise err:' + JSON.stringify(error));
expect(true).assertEqual(JSON.stringify(error) != null);
done();
})
}
done();
})
/**
......@@ -1249,3 +1260,5 @@ describe('geolocationTest_geo3', function () {
})
})
......@@ -146,7 +146,7 @@ describe('geolocationTest_geo2', function () {
expect().assertFail();
},
});
geolocation.unsubscribe();
geolocations.unsubscribe();
console.info("[lbs_js] unsubscribe called")
done();
})
......@@ -196,3 +196,4 @@ describe('geolocationTest_geo2', function () {
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册