Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
40bba722
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40bba722
编写于
7月 07, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
8dc8a202
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
312 addition
and
301 deletion
+312
-301
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+223
-212
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
...ion_standard/src/main/js/default/test/Geolocation.test.js
+41
-48
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+48
-41
未找到文件。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
40bba722
...
...
@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
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
,
...
...
@@ -33,25 +34,29 @@ 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 LocationSwitchStatu result:
'
+
result
);
console
.
info
(
'
[lbs_js]
getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
)
);
});
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
100
);
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
;
...
...
@@ -59,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
'
);
...
...
@@ -74,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
()
{
})
...
...
@@ -112,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
()
})
...
...
@@ -132,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
();
...
...
@@ -154,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
);
...
...
@@ -177,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
();
});
})
...
...
@@ -205,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
();
});
})
...
...
@@ -225,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
};
...
...
@@ -241,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
()
...
...
@@ -269,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
};
...
...
@@ -285,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
()
...
...
@@ -314,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
));
...
...
@@ -359,7 +368,7 @@ 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
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName09 promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
});
done
();
...
...
@@ -379,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
();
})
...
...
@@ -399,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
();
})
...
...
@@ -428,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
();
})
...
...
@@ -449,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
,
...
...
@@ -458,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
();
...
...
@@ -479,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
()
})
...
...
@@ -500,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
()
})
...
...
@@ -521,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
};
...
...
@@ -530,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
};
...
...
@@ -539,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
,
...
...
@@ -557,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
};
...
...
@@ -566,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
};
...
...
@@ -575,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
,
...
...
@@ -584,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
()
...
...
@@ -605,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
};
...
...
@@ -614,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
,
...
...
@@ -623,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
,
...
...
@@ -632,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
,
...
...
@@ -641,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
,
...
...
@@ -650,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
,
...
...
@@ -659,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
,
...
...
@@ -668,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
()
...
...
@@ -685,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
()
...
...
@@ -705,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
();
...
...
@@ -724,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
()
...
...
@@ -744,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
();
...
...
@@ -763,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
();
...
...
@@ -802,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
;
...
...
@@ -853,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
);
...
...
@@ -874,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
;
...
...
@@ -896,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
;
...
...
@@ -919,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
;
...
...
@@ -952,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
;
...
...
@@ -975,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
;
...
...
@@ -998,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
;
...
...
@@ -1021,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
;
...
...
@@ -1044,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
;
...
...
@@ -1067,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
;
...
...
@@ -1090,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
;
...
...
@@ -1113,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
;
...
...
@@ -1136,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
;
...
...
@@ -1160,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
;
...
...
@@ -1193,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
;
...
...
@@ -1216,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
;
...
...
@@ -1239,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
;
...
...
@@ -1262,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
;
...
...
@@ -1285,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
;
...
...
@@ -1309,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
;
...
...
@@ -1342,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
;
...
...
@@ -1365,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
;
...
...
@@ -1388,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
;
...
...
@@ -1411,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
;
...
...
@@ -1435,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
;
...
...
@@ -1469,9 +1485,9 @@ 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
);
console
.
info
(
'
[lbs_js] getLastLocation callback result:
'
+
JSON
.
stringify
(
data
)
);
expect
(
data
).
assertTrue
();
}
done
()
...
...
@@ -1487,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
();
})
...
...
@@ -1509,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
();
})
...
...
@@ -1531,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
();
})
...
...
@@ -1553,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
();
})
...
...
@@ -1574,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
();
})
...
...
@@ -1598,58 +1608,59 @@ 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 S
endCommand
* @tc.name SUB_HSS_Location
_SendCommand_callback
* @tc.desc Test
sendCommand
api .
* @tc.number S
ingleLoc_0032
* @tc.name SUB_HSS_Location
System_SingleLoc_0032
* @tc.desc Test
getCurrentLocation
api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_Location
_SendCommand_callback
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
"
scenario
"
:
0x301
,
"
command
"
:
"
command_1
"
};
geolocation
.
sendCommand
(
requestInfo
,(
err
,
result
)
=>
{
it
(
'
SUB_HSS
_SendCommand_callback
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
'
scenairo
'
:
0x301
,
'
command
'
:
"
command_1
"
};
await
geolocation
.
sendCommand
(
requestInfo
,(
err
,
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
[lbs_js] sendCommand callback err
"
+
err
);
console
.
info
(
'
sendcommand callback err:
'
+
err
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
done
();
}
console
.
info
(
'
[LBS_js] sendCommand callback result:
'
+
result
)
})
done
();
console
.
info
(
'
sendcommand callback result:
'
+
result
);
});
})
/**
* @tc.number S
endCommand
* @tc.name SUB_HSS_Location
_SendCommand_promise
* @tc.desc Test
sendCommand
api .
/**
* @tc.number S
ingleLoc_0032
* @tc.name SUB_HSS_Location
System_SingleLoc_0032
* @tc.desc Test
getCurrentLocation
api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_Location
_SendCommand_promise
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
"
scenario
"
:
0x301
,
"
command
"
:
"
command_1
"
};
geolocation
.
sendCommand
(
requestInfo
).
then
((
result
)
=>
{
console
.
info
(
'
[LBS_js] sendCommand promise result:
'
+
result
);
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
(
"
[lbs_js] sendCommand promise err:
"
+
err
);
expect
.
assertFail
();
}).
catch
(
error
=>
{
console
.
info
(
'
sendcommand promise err:
'
+
err
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
done
();
})
})
})
...
...
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
浏览文件 @
40bba722
...
...
@@ -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
();
})
...
...
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
40bba722
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录