提交 3c69456c 编写于 作者: Q q00313334 提交者: 权力
上级 ccf63ad2
...@@ -69,6 +69,7 @@ describe('bluetoothhostTest', function() { ...@@ -69,6 +69,7 @@ describe('bluetoothhostTest', function() {
let sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
...@@ -77,9 +78,10 @@ describe('bluetoothhostTest', function() { ...@@ -77,9 +78,10 @@ describe('bluetoothhostTest', function() {
await sleep(3000); await sleep(3000);
break; break;
case 2: case 2:
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
......
...@@ -135,6 +135,7 @@ describe('bluetoothhostTest', function() { ...@@ -135,6 +135,7 @@ describe('bluetoothhostTest', function() {
let sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
...@@ -143,9 +144,10 @@ describe('bluetoothhostTest', function() { ...@@ -143,9 +144,10 @@ describe('bluetoothhostTest', function() {
await sleep(3000); await sleep(3000);
break; break;
case 2: case 2:
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
......
...@@ -62,6 +62,7 @@ describe('bluetoothhostTest', function() { ...@@ -62,6 +62,7 @@ describe('bluetoothhostTest', function() {
let sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
...@@ -70,9 +71,10 @@ describe('bluetoothhostTest', function() { ...@@ -70,9 +71,10 @@ describe('bluetoothhostTest', function() {
await sleep(3000); await sleep(3000);
break; break;
case 2: case 2:
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
break; break;
......
...@@ -4,17 +4,19 @@ ...@@ -4,17 +4,19 @@
"vendor": "acts", "vendor": "acts",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5 "target": 5,
"releaseType": "Beta1"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.location.geolocation.function", "package": "ohos.acts.location.geolocation",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": "ohos.acts.location.geolocation.function.MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
...@@ -25,7 +27,6 @@ ...@@ -25,7 +27,6 @@
}, },
"abilities": [ "abilities": [
{ {
"visible": true,
"skills": [ "skills": [
{ {
"entities": [ "entities": [
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
] ]
} }
], ],
"visible": true,
"name": "ohos.acts.location.geolocation.function.MainAbility", "name": "ohos.acts.location.geolocation.function.MainAbility",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:mainability_description",
...@@ -44,6 +46,81 @@ ...@@ -44,6 +46,81 @@
"launchType": "standard" "launchType": "standard"
} }
], ],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.ACCESS_LOCATION"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.LOCATION"
}
],
"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.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"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.GET_WIFI_INFO_INTERNAL",
"reason":"need use ohos.permission.GET_WIFI_INFO_INTERNAL",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
}
],
"js": [ "js": [
{ {
"pages": [ "pages": [
......
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -14,14 +14,19 @@ ...@@ -14,14 +14,19 @@
*/ */
import geolocation from '@ohos.geolocation'; import geolocation from '@ohos.geolocation';
import { LocationEventListener } from '@ohos.geolocation';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 ,
TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303,
DAILY_LIFE_SERIVICE : 0x304 ,NO_POWER : 0x305} DAILY_LIFE_SERIVICE : 0x304 ,NO_POWER : 0x305}
var LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203} let LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203}
let LocationPrivacyType = {
OTHERS : 0,
STARTUP: 1,
CORE_LOCATION : 2
}
describe('geolocationTest', function () { describe('geolocationTest', function () {
beforeAll(function () { beforeAll(function () {
...@@ -36,206 +41,178 @@ describe('geolocationTest', function () { ...@@ -36,206 +41,178 @@ describe('geolocationTest', function () {
}) })
afterAll(function () { afterAll(function () {
console.info('afterAll called') console.info('afterAll called')
}) })
/** /**
* @tc.number geolocation_enableLocation_promise_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_PROMISE_0001
* @tc.name testenableLocation promise * @tc.name testenableLocation promise
* @tc.desc Test enableLocation api . * @tc.desc Test enableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_enableLocation_promise_test_001', 0, async function (done) { it('geolocation_enableLocation_promise_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}) })
done() done()
}) })
/** /**
* @tc.number geolocation_isLocationEnabled_promise_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001
* @tc.name testisLocationEnabled promise * @tc.name testisLocationEnabled promise
* @tc.desc Test isLocationEnabled api . * @tc.desc Test isLocationEnabled api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isLocationEnabled_promise_test_001', 0, async function (done) { it('geolocation_isLocationEnabled_promise_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
console.info('[lbs_js] LBS getLocationSwitchState promise test start ...');
await geolocation.isLocationEnabled().then((result) => { await geolocation.isLocationEnabled().then((result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result); console.info('[lbs_js] getLocationSwitchState result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] getLocationSwitchState promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error.");
expect().assertFail(); expect().assertFail();
}); });
done(); done();
}) })
/** /**
* @tc.number geolocation_getAddressesFromLocationName_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback * @tc.name testgetAddressesFromLocationName callback
* @tc.desc Test getAddressesFromLocationName api . * @tc.desc Test getAddressesFromLocationName api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
console.info('LBS getAddressesFromLocationName callback test start ...'); let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1,
var geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "locale": "zh",description:"",maxItems:"",minLatitude:"",
"maxItems": 1,"locale":"zh",minLatitude:"",minLongitude:"", minLongitude:"",maxLatitude:"",maxLongitude:""};
maxLatitude:"",maxLongitude:""}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
geolocation.getAddressesFromLocationName(geocodeRequest, if(err){
(err, data) => {
if (err) {
switch(err){ switch(err){
case 101: case "101":
console.info("INPUT_PARAMS_ERROR:" + err); console.info("INPUT_PARAMS_ERROR: "+ err);
break; break;
case 102: case "102":
console.info("REVERSE_GEOCODE_ERROR:" + err); console.info("REVERSE_GEOCODE_ERROR: "+ err);
break; break;
case 103: case "103":
console.info("GEOCODE_ERROR:" + err); console.info("GEOCODE_ERROR: "+ err);
break; break;
case 104: case "104":
console.info("LOCATOR_ERROR:" + err); console.info("LOCATOR_ERROR: "+ err);
break;
case 105:
console.info("LOCATIOR_SWITCH_ERROR:" + err);
break; break;
case 106: case "105":
console.info("LAST_KNOWN_LOCATION_ERROR:" + err); console.info("LOCATION_SWITCH_ERROR: "+ err);
break; break;
case 107: case "106":
console.info("LOCATION_REUEST_TIMEOUT_ERROR:" + err); console.info("LAST_KNOWN_LOCATION_ERROR: "+ err);
break; break;
default: case "107":
console.info('[lbs_js]LocationName callback err:' + err); console.info("LOCATION_REQUEST_TIMEOUT_ERROR: "+ err);
} break;
default:
console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + err);
}
}else { }else {
console.info("[lbs_js]LocationName callback data" + JSON.stringify(data)); console.info("[lbs_js] getAddressesFromLocationName callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) != null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info("[lbs_js] getAddressesFromLocationName callback exit.");
} }
done(); done();
}); });
}) })
/** /**
* @tc.number geolocation_getAddressesFromLocation_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001
* @tc.name testgetAddressesFromLocation callback * @tc.name testgetAddressesFromLocation callback
* @tc.desc Test getAddressesFromLocation api . * @tc.desc Test getAddressesFromLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocation_callback_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocation_callback_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
console.info('LBS getAddressesFromLocation callback test start ...'); let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1,"locale": "zh"};
var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11,
"maxItems": 1,"locale": "zh"};
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err); console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err);
}else { }else {
console.info("[lbs_js] Location callback data is: " + JSON.stringify(data)); console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info('[lbs_js] Location addressUrl: ' + data[0].addressUrl); console.info('[lbs_js] getAddressesFromLocation addressUrl: ' + data[0].addressUrl +
console.info('[lbs_js] Location administrativeArea: ' + data[0].administrativeArea); ' administrativeArea: ' + data[0].administrativeArea +' countryCode: ' + data[0].countryCode
console.info('[lbs_js] Location countryCode: ' + data[0].countryCode); +' countryName: ' + data[0].countryName+' descriptions: ' + data[0].descriptions+
console.info('[lbs_js] Location countryName: ' + data[0].countryName); 'descriptionsSize: ' + data[0].descriptionsSize+'latitude:' + data[0].latitude+' locale: '
console.info('[lbs_js] Location descriptions: ' + data[0].descriptions); + data[0].locale +'locality' + data[0].locality+'longitude:' + data[0].longitude+'phoneNumber:'
console.info('[lbs_js] Location descriptionsSize: ' + data[0].descriptionsSize); + data[0].phoneNumber+' placeName: ' + data[0].placeName+' postalCode: ' + data[0].postalCode
console.info('[lbs_js] Location latitude: ' + data[0].latitude); +' premises: ' + data[0].premises+'roadName: ' + data[0].roadName +' subAdministrativeArea: '
console.info('[lbs_js] Location locale: ' + data[0].locale); + data[0].subAdministrativeArea+' subLocality: ' + data[0].subLocality
console.info('[lbs_js] Location locality: ' + data[0].locality); +' subRoadName: ' + data[0].subRoadName);
console.info('[lbs_js] Location longitude: ' + data[0].longitude);
console.info('[lbs_js] Location phoneNumber: ' + data[0].phoneNumber);
console.info('[lbs_js] Location placeName: ' + data[0].placeName);
console.info('[lbs_js] FromLocation postalCode: ' + data[0].postalCode);
console.info('[lbs_js] Location premises: ' + data[0].premises);
console.info('[lbs_js] Location roadName: ' + data[0].roadName);
console.info('[lbs_js] getAddressesFromLocation subAdministrativeArea:'
+ data[0].subAdministrativeArea);
console.info('[lbs_js] Location subLocality: ' + data[0].subLocality);
console.info('[lbs_js] Location subRoadName: ' + data[0].subRoadName);
console.info("[lbs_js] Location callback exit .");
} }
done(); done();
}); });
}) })
/** /**
* @tc.number geolocation_isGeoServiceAvailable_promise_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testisGeoServiceAvailable promise * @tc.name testisGeoServiceAvailable promise
* @tc.desc Test isGeoServiceAvailable api . * @tc.desc Test isGeoServiceAvailable api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isGeoServiceAvailable_promise_test_001', 0, async function (done) { it('geolocation_isGeoServiceAvailable_promise_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
console.info('LBS getGeoServiceState promise test start ...');
await geolocation.isGeoServiceAvailable().then( (result) => { await geolocation.isGeoServiceAvailable().then( (result) => {
console.info('[lbs_js] isGeoServiceAvailable result: ' + result); console.info('[lbs_js] isGeoServiceAvailable result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] getGeoServiceState promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
...@@ -244,16 +221,15 @@ describe('geolocationTest', function () { ...@@ -244,16 +221,15 @@ describe('geolocationTest', function () {
}) })
/** /**
* @tc.number geolocation_isLocationEnabled_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_CALLBACK_0001
* @tc.name testisLocationEnabled callback * @tc.name testisLocationEnabled callback
* @tc.desc Test isLocationEnabled api . * @tc.desc Test isLocationEnabled api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_isLocationEnabled_callback_test_001', 0, async function (done) { it('geolocation_isLocationEnabled_callback_test_001', 0, async function (done) {
console.info('LBS enableLocation callback test start ...');
let promiseOne = new Promise((resolve, reject) => { let promiseOne = new Promise((resolve, reject) => {
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
...@@ -261,21 +237,20 @@ describe('geolocationTest', function () { ...@@ -261,21 +237,20 @@ describe('geolocationTest', function () {
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
console.info("[lbs_js] enableLocation callback exit .");
} }
resolve() resolve()
}); });
}) })
let promiseTwo = new Promise((resolve, reject) => { let promiseTwo = new Promise((resolve, reject) => {
console.info('LBS getLocationSwitchState callback test start ...');
geolocation.isLocationEnabled((err, data) => { geolocation.isLocationEnabled((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLocationSwitchState : ' + err); console.info('[lbs_js] getLocationSwitchState : ' + err);
}else { }else {
console.info("[lbs_js] getLocationSwitchState data: " + data); console.info("[lbs_js] getLocationSwitchState data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
console.info("[lbs_js] getLocationSwitchState callback exit .");
} }
resolve() resolve()
}); });
...@@ -287,165 +262,174 @@ describe('geolocationTest', function () { ...@@ -287,165 +262,174 @@ describe('geolocationTest', function () {
}) })
/** /**
* @tc.number geolocation_getAddressesFromLocationName_promise_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_PROMISE_0001
* @tc.name testgetAddressesFromLocationName promise * @tc.name testgetAddressesFromLocationName promise
* @tc.desc Test getAddressesFromLocationName api . * @tc.desc Test getAddressesFromLocationName api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_getAddressesFromLocationName_promise_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocationName_promise_test_001', 0, async function (done) {
console.info('LBS enableLocation promise test start ...');
await geolocation.enableLocation().then((result) => { await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result); console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
console.info("[lbs_js] enableLocation promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
console.info('LBS getAddressesFromLocationName promise test start ...'); let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1};
var geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation callback data is:" console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
+ JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null); expect(true).assertEqual((JSON.stringify(result)) !=null);
console.info("[lbs_js] getAddressesFromLocationName promise.");
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + error); console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
expect().assertFail(); expect().assertFail();
}); });
done(); done();
}) })
/** /**
* @tc.number geolocation_requestEnableLocation_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testrequestEnableLocation callback * @tc.name testrequestEnableLocation callback
* @tc.desc Test requestEnableLocation api . * @tc.desc Test requestEnableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_requestEnableLocation_callback_test_001', 0, async function (done) { it('geolocation_requestEnableLocation_callback_test_001', 0, async function (done) {
console.info('LBS requestEnableLocation callback test start ...'); 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();
});
geolocation.requestEnableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] requestEnableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] requestEnableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
console.info("[lbs_js] requestEnableLocation callback exit .");
} }
done(); done();
}); });
}) })
/**
/** * @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001
* @tc.number geolocation_requestEnableLocation_promise_test_001 * @tc.name testdisableLocation callback
* @tc.name testrequestEnableLocation promise * @tc.desc Test disableLocation api .
* @tc.desc Test requestEnableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_requestEnableLocation_promise_test_001', 0, async function (done) { it('geolocation_disableLocation_callback_test_001', 0, async function (done) {
console.info('LBS requestEnableLocation promise test start ...');
await geolocation.requestEnableLocation().then((result) => { geolocation.disableLocation((err, data) => {
console.info('[lbs_js] requestEnableLocation result: ' + result); if (err) {
expect(result).assertTrue(); console.info('[lbs_js] disableLocation callback err is : ' + err );
console.info("[lbs_js] requestEnableLocation promise."); }else {
}).catch((error) => { console.info("[lbs_js] disableLocation callback data: " + data);
console.info("[lbs_js] promise then error." + error.message); expect(data).assertTrue();
expect().assertFail();
}
done()
}); });
done() })
})
/** @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_PROMISE_0001
* @tc.name testdisableLocation promise
* @tc.desc Test disableLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_disableLocation_promise_test_001', 0, async function (done) {
console.info('[lbs_js]LBS disableLocation promise test start ...');
await geolocation.disableLocation().then((data) => {
console.info('[lbs_js] disableLocation data: ' + data);
expect(data).assertTrue();
done();
});
})
/** /**
* @tc.number geolocation_enableLocation_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testEnableLocation callback * @tc.name testEnableLocation callback
* @tc.desc Test enableLocation api . * @tc.desc Test enableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_enableLocation_callback_test_001', 0, async function (done) { it('geolocation_enableLocation_callback_test_001', 0, async function (done) {
console.info('LBS enableLocation callback test start ...');
geolocation.enableLocation((err, data) => { geolocation.enableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] enableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
console.info("[lbs_js] enableLocation callback exit .");
} }
done() done()
}); });
}) })
/** /**
* @tc.number geolocation_disableLocation_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001
* @tc.name testdisableLocation callback * @tc.name testrequestEnableLocation promise
* @tc.desc Test disableLocation api . * @tc.desc Test requestEnableLocation api .
* @tc.author wangsilu wwx1075324 * @tc.size MEDIUM
* @tc.size MEDIUM * @tc.type Function
* @tc.type Function * @tc.level Level 2
* @tc.level Level 2 */
*/ it('geolocation_requestEnableLocation_promise_test_001', 0, async function(done) {
it('geolocation_disableLocation_callback_test_001', 0, async function (done) { await geolocation.enableLocation().then((result) => {
console.info('LBS disableLocation callback test start ...'); console.info('[lbs_js] testenableLocation result: ' + result);
geolocation.disableLocation((err, data) => { expect(result).assertTrue();
if (err) { }).catch((error) => {
console.info('[lbs_js] disableLocation callback err is : ' + err ); console.info("[lbs_js] promise then error." + error.message);
}else { expect().assertFail();
console.info("[lbs_js] disableLocation callback data: " + data);
expect(data).assertTrue();
console.info("[lbs_js] disableLocation callback exit .");
}
done()
}); });
await geolocation.requestEnableLocation()
.then((result) => {
console.info('[lbs_js] requestEnableLocation result: ' + result);
expect(result).assertTrue();
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
}) })
/** @tc.number geolocation_disableLocation_promise_test_001
* @tc.name testdisableLocation promise
* @tc.desc Test disableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_disableLocation_promise_test_001', 0, async function (done) {
console.info('[lbs_js]LBS disableLocation promise test start ...');
geolocation.disableLocation().then((data) => {
console.info('[lbs_js] disableLocation data: ' + data);
expect(data).assertTrue();
console.info("[lbs_js] disableLocation promise exit");
done();
});
})
/** /**
* @tc.number geolocation_getAddressesFromLocation_promise_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_PROMISE_0001
* @tc.name testgetAddressesFromLocation promise * @tc.name testgetAddressesFromLocation promise
* @tc.desc Test getAddressesFromLocation api . * @tc.desc Test getAddressesFromLocation api .
* @tc.author wangsilu wwx1075324 * @tc.size MEDIUM
* @tc.size MEDIUM * @tc.type Function
* @tc.type Function * @tc.level Level 2
* @tc.level Level 2 */
*/
it('geolocation_getAddressesFromLocation_promise_test_001', 0, async function (done) { it('geolocation_getAddressesFromLocation_promise_test_001', 0, async function (done) {
console.info('LBS getAddressesFromLocation promise test start ...'); await geolocation.enableLocation().then((result) => {
var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data));
expect(true).assertEqual((JSON.stringify(data)) !=null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info("[lbs_js] getAddressesFromLocation promise exit.");
done(); done();
}).catch(error => { }).catch(error => {
console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message); console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message);
...@@ -454,298 +438,373 @@ describe('geolocationTest', function () { ...@@ -454,298 +438,373 @@ describe('geolocationTest', function () {
}); });
}) })
/** /**
* @tc.number geolocation_GetCurrentlocation_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
* @tc.name testGetCurrentlocation callback * @tc.name testGetCurrentlocation callback
* @tc.desc Test GetCurrentlocation api . * @tc.desc Test GetCurrentlocation api .
* @tc.author wangsilu wwx1075324 * @tc.size MEDIUM
* @tc.size MEDIUM * @tc.type Function
* @tc.type Function * @tc.level Level 2
* @tc.level Level 2 */
*/
it('geolocation_GetCurrentlocation_callback_test_001', 0, async function(done) { it('geolocation_GetCurrentlocation_callback_test_001', 0, async function(done) {
var locationEventListener = new LocationEventListener(); await geolocation.enableLocation().then((result) => {
var requestInfo = { "priority": 0x0203, "scenario": 0x0300, "timeInterval": 5 console.info('[lbs_js] testenableLocation result: ' + result);
, "distanceInterval": 0, "maxAccuracy": 0 }; expect(result).assertTrue();
locationEventListener.getCurrentLocation(requestInfo, result => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let currentLocationRequest = { "priority": 0x203, "scenario": 0x300,
"timeoutMs": 5, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}
console.info("getCurrentLocation callback, result: " + JSON.stringify(result)); console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result != null); expect(true).assertEqual(result != null);
done()
}); });
done()
}) })
/** /**
* @tc.number geolocation_isGeoServiceAvailable_callback_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
* @tc.name testisGeoServiceAvailable callback * @tc.name testGetCurrentlocation callback
* @tc.desc Test isGeoServiceAvailable api . * @tc.desc Test GetCurrentlocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_isGeoServiceAvailable_callback_test_001', 0, async function (done) {
console.info('LBS enableLocation callback test start ...');
let promiseOne = new Promise((resolve, reject) => {
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 .");
}
resolve()
});
})
console.info('LBS getGeoServiceState callback test start ...')
let promiseTwo = new Promise((resolve, reject) => {
geolocation.isGeoServiceAvailable((err, data) => {
if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + err );
}else {
console.info('[lbs_js] isGeoServiceAvailable result: ' + data);
expect(data).assertTrue();
console.info("[lbs_js] getGeoServiceState callback exit .");
}
resolve()
});
})
await promiseOne.then(()=>{
return promiseTwo
}).then(done)
})
/**
* @tc.number geolocation_locationChange_On_test_002
* @tc.name testlocationChangeOn promise
* @tc.desc Test locationChangeOn api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_locationChange_On_test_002', 0, async function (done) {
var locationEventListener = new LocationEventListener();
console.info('LBS locationChange_On callback test start ...');
var requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5,
"distanceInterval": 0, "maxAccuracy": 0};
await locationEventListener.on('locationChange',requestInfo, result => {
console.info("onLocationChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
console.info("[lbs_js] onLocationChange latitude: " + result.latitude);
console.info("[lbs_js] onLocationChange longitude: " + result.longitude);
console.info("[lbs_js] onLocationChange altitude: " + result.altitude);
console.info("[lbs_js] onLocationChange accuracy: " + result.accuracy);
console.info("[lbs_js] onLocationChange speed: " + result.speed);
console.info("[lbs_js] onLocationChange timeStamp: " + result.timeStamp);
console.info("[lbs_js] onLocationChange direction: " + result.direction);
console.info("[lbs_js] onLocationChange additions: " + result.additions);
console.info("[lbs_js] onLocationChange additionSize: " + result.additionSize);
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()
});
})
/**
* @tc.number geolocation_OnLocationServiceState_test_001
* @tc.name testOnLocationServiceState
* @tc.desc Test OnLocationServiceState api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_OnLocationServiceState_test_001', 0, async function (done) { it('geolocation_GetCurrentlocation_callback_test_002', 0, async function(done) {
var locationEventListener = new LocationEventListener(); await geolocation.enableLocation().then((result) => {
console.info('LBS OnLocationServiceState test start ...'); console.info('[lbs_js] testenableLocation result: ' + result);
await locationEventListener.on('locationServiceState', result => { expect(result).assertTrue();
console.info("onlocationServiceState callback, result: " + JSON.stringify(result)); }).catch((error) => {
expect(true).assertEqual(result !=null); console.info("[lbs_js] promise then error." + error.message);
done(); expect().assertFail();
}); });
console.info('LBS enableLocation callback test start ...'); await geolocation.getCurrentLocation((err, result) => {
geolocation.enableLocation((err, data) => { if (err){
if (err) { return console.info("getCurrentLocation callback err: " + 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() console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
}); expect(true).assertEqual(result != null);
}) });
done()
})
/** /**
* @tc.number geolocation_offLocationServiceState_test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testoffLocationServiceState * @tc.name testgetAddressesFromLocationName callback
* @tc.desc Test offLocationServiceState api . * @tc.desc Test getAddressesFromLocationName api .
* @tc.author wangsilu wwx1075324 * @tc.author
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_offLocationServiceState_test_001', 0, async function (done) { it('geolocation_getLastLocation_callback_test_001', 0, async function (done) {
var locationEventListener = new LocationEventListener(); await geolocation.enableLocation().then((result) => {
console.info('LBS OnLocationServiceState test start ...'); console.info('[lbs_js] testenableLocation result: ' + result);
await locationEventListener.on('locationServiceState', result => { expect(result).assertTrue();
console.info("onlocationServiceState callback, result:" + JSON.stringify(result)); }).catch((error) => {
expect(true).assertEqual(result !=null); console.info("[lbs_js] promise then error." + error.message);
done(); expect().assertFail();
});
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()
});
console.info('LBS disableLocation callback test start ...');
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();
console.info("[lbs_js] disableLocation callback exit .");
}
done()
}); });
console.info('LBS offLocationServiceState test start ...');
locationEventListener.off('locationServiceState', result => {
console.info("offlocationServiceState callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
})
/**
* @tc.number geolocation_getLastLocation_callback__test_001
* @tc.name testgetLastLocation callback
* @tc.desc Test getLastLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_getLastLocation_callback__test_001', 0, async function (done) {
console.info('LBS getLastLocation test start ...');
geolocation.getLastLocation((err, data) => { geolocation.getLastLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLastLocation callback err is : ' + err ); console.info('[lbs_js] getLastLocation callback err is : ' + err);
}else { }else {
console.info("[lbs_js] getLastLocation callback data: " + JSON.stringify(data)); console.info("[lbs_js] getLastLocation callback data is: " + JSON.stringify(data));
expect(data).assertTrue(data != null); expect(true).assertEqual((JSON.stringify(data)) !=null);
console.info("[lbs_js] getLastLocation callback exit ."); 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);
} }
}); });
done(); done();
}) })
/** /**
* @tc.number geolocation_locationChange_Off_test_002 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testlocationChangeOff promise * @tc.name getLastLocation promise
* @tc.desc Test locationChangeoff api . * @tc.desc Test getLastLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_locationChange_Off_test_002', 0, async function(done) { it('geolocation_getLastLocation_promise_test_001', 0, async function (done) {
var locationEventListener = new LocationEventListener(); await geolocation.enableLocation().then((result) => {
console.info('LBS locationChange_On callback test start ...'); console.info('[lbs_js] testenableLocation result: ' + result);
var requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5 expect(result).assertTrue();
, "distanceInterval": 0, "maxAccuracy": 0}; }).catch((error) => {
locationEventListener.on('locationChange',requestInfo, result => { console.info("[lbs_js] promise then error." + error.message);
console.info("onLocationChange callback, result: " + JSON.stringify(result)); expect().assertFail();
expect(true).assertEqual(result !=null); });
done(); geolocation.getLastLocation().then( (result) => {
}); console.info('[lbs_js] getLastLocation promise result '+ JSON.stringify(result));
expect(true).assertEqual(result != null);
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
done();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_CALLBACK_0001
* @tc.name testisGeoServiceAvailable callback
* @tc.desc Test isGeoServiceAvailable api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_isGeoServiceAvailable_callback_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();
});
console.info('LBS enableLocation callback test start ...'); geolocation.isGeoServiceAvailable((err, data) => {
geolocation.enableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] getGeoServiceState err is : ' + err );
return
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info('[lbs_js] isGeoServiceAvailable result: ' + data);
expect(data).assertTrue(); expect(data).assertTrue();
console.info("[lbs_js] enableLocation callback exit .");
} }
done() 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.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);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
geolocation.getCachedGnssLocationsSize((err, data) => {
if (err) {
console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + err);
}else {
console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data != null);
}
});
done();
})
console.info('LBS disableLocation callback test start ...'); /**
geolocation.disableLocation((err, data) => { * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testisGeoServiceAvailable promise
* @tc.desc Test isGeoServiceAvailable api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_getCachedGnssLocationsSize_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();
});
geolocation.getCachedGnssLocationsSize().then( (result) => {
console.info('[lbs_js] getCachedGnssLocationsSiz '+ JSON.stringify(result));
expect(true).assertTrue(result != null);
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
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.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_flushCachedGnssLocations_callback_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();
});
geolocation.flushCachedGnssLocations((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] disableLocation callback err is : ' + err ); console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + err);
}else { }else {
console.info("[lbs_js] disableLocation callback data: " + data); console.info("[lbs_js] flushCachedGnssLocations callback: " + JSON.stringify(data));
expect(data).assertTrue(); expect(true).assertTrue(data);
console.info("[lbs_js] disableLocation callback exit .");
} }
done()
}); });
done();
})
console.info('LBS locationChange_Off test2 start ...'); /**
locationEventListener.off('locationChange', result => { * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
console.info("[lbs_js] offlocationChange callback result " + JSON.stringify(result)); * @tc.name testisGeoServiceAvailable promise
expect(true).assertEqual(result != null); * @tc.desc Test isGeoServiceAvailable api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_flushCachedGnssLocations_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();
});
geolocation.flushCachedGnssLocations().then( (result) => {
console.info('[lbs_js] flushCachedGnssLocations_ '+ JSON.stringify(result));
expect(true).assertTrue(result);
done();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
done(); done();
}); });
}) })
/** /**
* @tc.number geolocation_getLastLocation_promise__test_001 * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
* @tc.name testgetLastLocation promise * @tc.name testGetCurrentlocation callback
* @tc.desc Test getLastLocation api . * @tc.desc Test GetCurrentlocation api .
* @tc.author wangsilu wwx1075324 * @tc.size MEDIUM
* @tc.size MEDIUM * @tc.type Function
* @tc.type Function * @tc.level Level 2
* @tc.level Level 2 */
*/ it('geolocation_gnssStatusChangeon_test_0001', 0, async function (done) {
it('geolocation_getLastLocation_promise__test_001', 0, async function (done) { try {
console.info('LBS getLastLocation test start ...'); await geolocation.on('gnssStatusChange', function (data) {
geolocation.getLastLocation().then((result) => { console.info('[lbs_js] gnssStatusChangestart' +JSON.stringify(data) );
console.info("[lbs_js] getLastLocation promise data: " + JSON.stringify(result)); expect(true).assertEqual((JSON.stringify(data)) !=null);
expect(data).assertTrue(data != null); console.info('[lbs_js] SatelliteStatusInfo satellitesNumber' + data[0].satellitesNumber
console.info("[lbs_js] getLastLocation promise exit ."); + 'satelliteIds ' + data[0].satelliteIds +' carrierToNoiseDensitys'+
done(); data[0].carrierToNoiseDensitys
}).catch(error => { +' altitudes: ' + data[0].altitudes+' azimuths: ' + data[0].azimuths +
console.info('[lbs_js] getLastLocation promise err is : ' + err ); 'carrierFrequencies: ' + data[0].carrierFrequencies);
expect().assertFail(); });
done(); }catch(e) {
expect(null).assertFail();
}); }
}) try {
await geolocation.off('gnssStatusChange', function (data) {
console.info("[lbs_js] gnssStatusChange off data:" + JSON.stringify(data));
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/** /**
* @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001 * @tc.number nmeaMessageChange_test_0001
* @tc.name testGetCurrentlocation callback
* @tc.desc Test GetCurrentlocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_nmeaMessageChangeon_test_0001', 0, async function (done) {
try {
await geolocation.on('nmeaMessageChange', function (data) {
console.info('[lbs_js] nmeaMessageChange' +JSON.stringify(data) );
});
}catch(e) {
expect(null).assertFail();
}
try {
await geolocation.off('nmeaMessageChange', function (data) {
console.info("[lbs_js] nmeaMessageChange off data:" + JSON.stringify(data));
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test setLocationPrivacyConfirmStatus callback
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_setLocationPrivacyConfirmStatus_callback_test_001', 0, async function (done) {
let reqType = 1;
let isConfirmed = true;
console.info('[lbs_js] setLocationPrivacyConfirmStatus callback test start ...');
geolocation.setLocationPrivacyConfirmStatus(reqType, isConfirmed, (err,resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test isLocationPrivacyConfirmed callback
* @tc.desc Test isLocationPrivacyConfirmed api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_isLocationPrivacyConfirmed_callback_test_001', 0, async function (done) {
let reqType = 1;
let value = true;
geolocation.setLocationPrivacyConfirmStatus(reqType, value, (err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
});
console.info('[lbs_js] isLocationPrivacyConfirmed callback test start ...');
geolocation.isLocationPrivacyConfirmed(reqType ,(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name Test setLocationPrivacyConfirmStatus promise * @tc.name Test setLocationPrivacyConfirmStatus promise
* @tc.desc Test setLocationPrivacyConfirmStatus api . * @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('geolocation_setLocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) { it('geolocation_setLocationPrivacyConfirmStatus_promise_test_001', 0, async function (done) {
let reqType = 1; let reqType = 1;
let value = true; let value = true;
let type = "STARTUP"; let type = "STARTUP";
...@@ -771,7 +830,6 @@ describe('geolocationTest', function () { ...@@ -771,7 +830,6 @@ describe('geolocationTest', function () {
* @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001 * @tc.number geolocation_isLocationPrivacyConfirmed_promise_test_001
* @tc.name Test isLocationPrivacyConfirmed promise * @tc.name Test isLocationPrivacyConfirmed promise
* @tc.desc Test isLocationPrivacyConfirmed api . * @tc.desc Test isLocationPrivacyConfirmed api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -779,7 +837,6 @@ describe('geolocationTest', function () { ...@@ -779,7 +837,6 @@ describe('geolocationTest', function () {
it('geolocation_isLocationPrivacyConfirmed_promise_test_001', 0, async function (done) { it('geolocation_isLocationPrivacyConfirmed_promise_test_001', 0, async function (done) {
let reqType = 1; let reqType = 1;
let value = true; let value = true;
console.info('LBS setLocationPrivacyConfirmStatus promise test start ...')
geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => { geolocation.setLocationPrivacyConfirmStatus(reqType,value).then((resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp)) console.log("[lbs_js] setLocationPrivacyConfirmStatus current type is "+ JSON.stringify(resp))
expect(resp).assertTrue(); expect(resp).assertTrue();
...@@ -789,11 +846,166 @@ describe('geolocationTest', function () { ...@@ -789,11 +846,166 @@ describe('geolocationTest', function () {
geolocation.isLocationPrivacyConfirmed(reqType).then(resp => { geolocation.isLocationPrivacyConfirmed(reqType).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp)) console.log("[lbs_js] isLocationPrivacyConfirmed current type is "+ JSON.stringify(resp))
expect(resp).assertTrue(); expect(resp).assertTrue();
console.info("[lbs_js] isLocationPrivacyConfirmed callback exit .");
done(); done();
}) })
}) })
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise
* @tc.desc Test locationChangeOn api .
* @tc.size MEDIUM
* @tc.type 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) => {
console.log('locationChanger: ' + JSON.stringify(location));
};
await geolocation.on('locationChange',requestInfo,
locationChange => {
if(err){
return console.info("onLocationChange callback err: " + err);
}
console.info("onLocationChange callback, result: " + JSON.stringify(locationChange));
expect(true).assertEqual(locationChange !=null);
done();
});
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('locationChange',requestInfo,
locationChange => {
if(err){
return console.info("onLocationChange callback err: " + err);
}
console.info("offLocationChange callback, result: " + JSON.stringify(locationChange));
expect(true).assertEqual(locationChange !=null);
done();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise
* @tc.desc Test cachedGnssLocationsReporting api .
* @tc.size MEDIUM
* @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,
result => {
if(err){
return console.info("cachedGnssLocationsReporting callback err: " + err);
}
console.info("offcachedGnssLocationsReporting callback, result: " + JSON.stringify(locationChange));
expect(true).assertEqual(locationChange !=null);
done();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
* @tc.name testOnLocationServiceState
* @tc.desc Test OnLocationServiceState api .
* @tc.size MEDIUM
* @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 );
}else {
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
}
done()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
* @tc.name testOnLocationServiceState
* @tc.desc Test offLocationServiceState api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('geolocation_offLocationServiceState_test_001', 0, async function (done) {
geolocation.on('locationServiceState', async result => {
console.info("locationServiceState callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
geolocation.off('locationServiceState', result => {
console.info("offlocationServiceState callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
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();
}
done();
});
})
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册