Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b4ee85cf
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看板
提交
b4ee85cf
编写于
7月 07, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
15d905f0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
318 addition
and
245 deletion
+318
-245
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+245
-191
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
...ion_standard/src/main/js/default/test/Geolocation.test.js
+45
-42
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+28
-12
未找到文件。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
b4ee85cf
...
@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
...
@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
import
{
LocationEventListener
}
from
'
@ohos.geolocation
'
;
import
{
LocationEventListener
}
from
'
@ohos.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
LocationRequestScenario
=
{
UNSET
:
0x300
,
NAVIGATION
:
0x301
,
let
LocationRequestScenario
=
{
UNSET
:
0x300
,
NAVIGATION
:
0x301
,
TRAJECTORY_TRACKING
:
0x302
,
CAR_HAILING
:
0x303
,
TRAJECTORY_TRACKING
:
0x302
,
CAR_HAILING
:
0x303
,
...
@@ -33,22 +34,29 @@ function sleep(ms) {
...
@@ -33,22 +34,29 @@ function sleep(ms) {
}
}
async
function
changedLocationMode
(){
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
result
);
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
)
);
if
(
!
result
){
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
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
();
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
expect
().
assertFail
();
});
});
}
}
})
});
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
});
}
}
async
function
applyPermission
()
{
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
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
let
tokenID
=
appInfo
.
accessTokenId
;
...
@@ -56,14 +64,14 @@ async function applyPermission() {
...
@@ -56,14 +64,14 @@ async function applyPermission() {
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
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
)
=>
{
}).
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
)
=>
{
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
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
)
);
});
});
}
else
{
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
...
@@ -71,29 +79,19 @@ async function applyPermission() {
...
@@ -71,29 +79,19 @@ async function applyPermission() {
}
}
describe
(
'
geolocationTest_geo1
'
,
function
()
{
describe
(
'
geolocationTest_geo1
'
,
function
()
{
let
data
=
{
title
:
""
,
locationChange
:
null
,
locatlocationServiceState
:
null
}
console
.
log
(
'
#start AccessTokenTests#
'
);
console
.
log
(
'
#start AccessTokenTests#
'
);
beforeAll
(
async
function
(
done
)
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
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
();
done
();
},
3000
);
console
.
info
(
'
beforeAll case
'
);
})
})
beforeEach
(
async
function
()
{
beforeEach
(
async
function
(
done
)
{
await
changedLocationMode
();
console
.
info
(
'
beforeEach case
'
);
console
.
info
(
'
beforeEach case
'
);
await
changedLocationMode
();
done
();
})
})
afterEach
(
function
()
{
afterEach
(
function
()
{
})
})
...
@@ -109,11 +107,13 @@ describe('geolocationTest_geo1', function () {
...
@@ -109,11 +107,13 @@ describe('geolocationTest_geo1', function () {
it
(
'
SUB_HSS_LocationSystem_Geo_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_Geo_0001
'
,
0
,
async
function
(
done
)
{
geolocation
.
isGeoServiceAvailable
(
async
(
err
,
data
)
=>
{
geolocation
.
isGeoServiceAvailable
(
async
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getGeoServiceState err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getGeoServiceState err is :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable callback result:
'
+
data
);
console
.
info
(
'
[lbs_js] isGeoServiceAvailable callback result:
'
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
data
)
!=
null
);
done
();
}
}
done
()
done
()
})
})
...
@@ -129,10 +129,11 @@ describe('geolocationTest_geo1', function () {
...
@@ -129,10 +129,11 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_Geo_0002
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_Geo_0002
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
isGeoServiceAvailable
().
then
(
(
result
)
=>
{
await
geolocation
.
isGeoServiceAvailable
().
then
(
(
result
)
=>
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable1 promise result:
'
+
result
);
console
.
info
(
'
[lbs_js] isGeoServiceAvailable1 promise result:
'
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
expect
().
assertFail
();
});
});
done
();
done
();
...
@@ -151,7 +152,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -151,7 +152,7 @@ describe('geolocationTest_geo1', function () {
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
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 :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation 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
);
...
@@ -174,15 +175,21 @@ describe('geolocationTest_geo1', function () {
...
@@ -174,15 +175,21 @@ describe('geolocationTest_geo1', function () {
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation04 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation04 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
addressUrl:
'
+
data
[
0
].
addressUrl
+
data
[
0
].
administrativeArea
+
data
[
0
].
countryCode
console
.
info
(
'
addressUrl:
'
+
JSON
.
stringify
(
data
)[
0
].
addressUrl
+
data
[
0
].
countryName
+
data
[
0
].
descriptions
+
data
[
0
].
descriptionsSize
+
data
[
0
].
latitude
+
JSON
.
stringify
(
data
)[
0
].
administrativeArea
+
JSON
.
stringify
(
data
)[
0
].
countryCode
+
data
[
0
].
locale
+
data
[
0
].
locality
+
data
[
0
].
longitude
+
data
[
0
].
phoneNumber
+
data
[
0
].
placeName
+
JSON
.
stringify
(
data
)[
0
].
countryName
+
JSON
.
stringify
(
data
)[
0
].
descriptions
+
data
[
0
].
postalCode
+
data
[
0
].
premises
+
data
[
0
].
roadName
+
data
[
0
].
subAdministrativeArea
+
JSON
.
stringify
(
data
)[
0
].
descriptionsSize
+
data
[
0
].
latitude
+
data
[
0
].
subLocality
+
data
[
0
].
subRoadName
);
+
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
();
done
();
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
done
();
});
});
})
})
...
@@ -202,8 +209,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -202,8 +209,9 @@ describe('geolocationTest_geo1', function () {
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
done
();
done
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
done
();
});
});
})
})
...
@@ -222,15 +230,16 @@ describe('geolocationTest_geo1', function () {
...
@@ -222,15 +230,16 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] getAddressesFromLocation0601 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0601 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0601 promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation0601 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
-
90
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
-
90
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
...
@@ -238,15 +247,16 @@ describe('geolocationTest_geo1', function () {
...
@@ -238,15 +247,16 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] getAddressesFromLocation0603 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0603 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0603 promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation0603 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
reverseGeocodeRequest4
=
{
"
latitude
"
:
-
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest4
=
{
"
latitude
"
:
-
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest4
).
then
((
data
)
=>
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest4
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0604 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0604 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
done
()
done
()
...
@@ -266,15 +276,16 @@ describe('geolocationTest_geo1', function () {
...
@@ -266,15 +276,16 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] getAddressesFromLocation0701 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0701 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0701 promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation0701 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
reverseGeocodeRequest1
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
-
180.1
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest1
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
-
180.1
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0702 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0702 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180
,
"
maxItems
"
:
1
};
...
@@ -282,15 +293,16 @@ describe('geolocationTest_geo1', function () {
...
@@ -282,15 +293,16 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] getAddressesFromLocation0703 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0703 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0703 promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation0703 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180.1
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180.1
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0704 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] getAddressesFromLocation0704 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
done
()
done
()
...
@@ -311,28 +323,28 @@ describe('geolocationTest_geo1', function () {
...
@@ -311,28 +323,28 @@ describe('geolocationTest_geo1', function () {
if
(
err
){
if
(
err
){
switch
(
err
){
switch
(
err
){
case
101
:
case
101
:
console
.
info
(
"
INPUT_PARAMS_ERROR:
"
+
err
);
console
.
info
(
"
INPUT_PARAMS_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
102
:
case
102
:
console
.
info
(
"
REVERSE_GEOCODE_ERROR:
"
+
err
);
console
.
info
(
"
REVERSE_GEOCODE_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
103
:
case
103
:
console
.
info
(
"
GEOCODE_ERROR:
"
+
err
);
console
.
info
(
"
GEOCODE_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
104
:
case
104
:
console
.
info
(
"
LOCATOR_ERROR:
"
+
err
);
console
.
info
(
"
LOCATOR_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
105
:
case
105
:
console
.
info
(
"
LOCATION_SWITCH_ERROR:
"
+
err
);
console
.
info
(
"
LOCATION_SWITCH_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
106
:
case
106
:
console
.
info
(
"
LAST_KNOWN_LOCATION_ERROR:
"
+
err
);
console
.
info
(
"
LAST_KNOWN_LOCATION_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
case
107
:
case
107
:
console
.
info
(
"
LOCATION_REQUEST_TIMEOUT_ERROR:
"
+
err
);
console
.
info
(
"
LOCATION_REQUEST_TIMEOUT_ERROR:
"
+
JSON
.
stringify
(
err
)
);
break
;
break
;
default
:
default
:
console
.
info
(
'
[lbs_js] getAddressesFromLocationName callback err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getAddressesFromLocationName callback err is :
'
+
JSON
.
stringify
(
err
)
);
}
}
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName08 callback data is:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[lbs_js] getAddressesFromLocationName08 callback data is:
"
+
JSON
.
stringify
(
data
));
...
@@ -356,7 +368,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -356,7 +368,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName09 promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName09 promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
expect
().
assertFail
();
});
});
done
();
done
();
...
@@ -376,8 +388,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -376,8 +388,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation m callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation m callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName m promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName m promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
done
();
done
();
})
})
...
@@ -396,16 +409,18 @@ describe('geolocationTest_geo1', function () {
...
@@ -396,16 +409,18 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest1
=
{
"
description
"
:
null
,
"
maxItems
"
:
1
};
let
geocodeRequest1
=
{
"
description
"
:
null
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest1
).
then
((
result
)
=>
{
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest1
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
done
();
done
();
})
})
...
@@ -425,8 +440,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -425,8 +440,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
done
();
done
();
})
})
...
@@ -446,7 +462,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -446,7 +462,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
result
.
length
==
0
).
assertTrue
();
expect
(
result
.
length
==
0
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
geocodeRequest1
=
{
"
description
"
:
null
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
331.3082812847
,
let
geocodeRequest1
=
{
"
description
"
:
null
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
331.3082812847
,
...
@@ -455,7 +471,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -455,7 +471,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
result
.
length
==
0
).
assertTrue
();
expect
(
result
.
length
==
0
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
done
();
done
();
...
@@ -476,8 +492,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -476,8 +492,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
result
.
length
>=
0
).
assertTrue
();
expect
(
result
.
length
>=
0
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
done
()
done
()
})
})
...
@@ -497,8 +514,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -497,8 +514,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
result
.
length
>=
0
).
assertTrue
();
expect
(
result
.
length
>=
0
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
done
()
done
()
})
})
...
@@ -518,8 +536,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -518,8 +536,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise1:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise1:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
);
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest2
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
90
,
let
geocodeRequest2
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
90
,
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
...
@@ -527,8 +546,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -527,8 +546,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise2:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
);
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest3
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
-
90.1
,
let
geocodeRequest3
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
-
90.1
,
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
...
@@ -536,16 +556,17 @@ describe('geolocationTest_geo1', function () {
...
@@ -536,16 +556,17 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise3:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise3:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
}).
catch
((
error
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
geocodeRequest4
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
90.1
,
let
geocodeRequest4
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
90.1
,
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
31.1537977881
,
"
maxLongitude
"
:
121.8026736943
};
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest4
).
then
((
result
)
=>
{
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest4
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise4:
"
+
JSON
.
stringify
(
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
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
geocodeRequest5
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
let
geocodeRequest5
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
...
@@ -554,8 +575,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -554,8 +575,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise5:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise5:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
);
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest6
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
let
geocodeRequest6
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
90
,
"
maxLongitude
"
:
121.8026736943
};
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
90
,
"
maxLongitude
"
:
121.8026736943
};
...
@@ -563,8 +585,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -563,8 +585,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise6:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise6:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
);
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest7
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
let
geocodeRequest7
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
-
90.1
,
"
maxLongitude
"
:
121.8026736943
};
"
minLongitude
"
:
121.5782001832
,
"
maxLatitude
"
:
-
90.1
,
"
maxLongitude
"
:
121.8026736943
};
...
@@ -572,7 +595,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -572,7 +595,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise7:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise7:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
}).
catch
((
error
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
let
geocodeRequest8
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
let
geocodeRequest8
=
{
"
description
"
:
"
上海金穗路1800号
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
31.3082812847
,
...
@@ -581,7 +604,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -581,7 +604,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise8:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise8:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
==
null
);
}).
catch
((
error
)
=>
{
}).
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
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
});
done
()
done
()
...
@@ -602,8 +625,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -602,8 +625,9 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise1:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise1:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
error
==
null
).
assertTrue
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
let
geocodeRequest2
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest2
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
"
minLongitude
"
:
180
,
"
maxLatitude
"
:
39.95
,
"
maxLongitude
"
:
116.45
};
"
minLongitude
"
:
180
,
"
maxLatitude
"
:
39.95
,
"
maxLongitude
"
:
116.45
};
...
@@ -611,7 +635,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -611,7 +635,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise2:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest3
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest3
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -620,7 +644,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -620,7 +644,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise3:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise3:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest4
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest4
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -629,7 +653,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -629,7 +653,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise4:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise4:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest5
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest5
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -638,7 +662,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -638,7 +662,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise5:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise5:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest6
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest6
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -647,7 +671,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -647,7 +671,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise6:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise6:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest7
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest7
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -656,7 +680,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -656,7 +680,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise7:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise7:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
let
geocodeRequest8
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
let
geocodeRequest8
=
{
"
description
"
:
"
北京天安门
"
,
"
maxItems
"
:
1
,
"
minLatitude
"
:
39.85
,
...
@@ -665,7 +689,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -665,7 +689,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise8:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js]getAddressesFromLocation promise8:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
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
();
expect
(
error
.
length
!=
0
).
assertTrue
();
});
});
done
()
done
()
...
@@ -682,10 +706,10 @@ describe('geolocationTest_geo1', function () {
...
@@ -682,10 +706,10 @@ describe('geolocationTest_geo1', function () {
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0001
'
,
0
,
async
function
(
done
)
{
geolocation
.
isLocationEnabled
(
async
(
err
,
data
)
=>
{
geolocation
.
isLocationEnabled
(
async
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getLocationSwitchState err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getLocationSwitchState err is :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
'
[lbs_js] getLocationSwitchState callback data1:
'
+
data
);
console
.
info
(
'
[lbs_js] getLocationSwitchState callback data1:
'
+
JSON
.
stringify
(
data
)
);
expect
(
data
).
assertTrue
();
expect
(
data
).
assertTrue
();
}
}
done
()
done
()
...
@@ -702,7 +726,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -702,7 +726,7 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0002
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0002
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
isLocationEnabled
().
then
((
result
)
=>
{
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
();
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
expect
().
assertFail
();
expect
().
assertFail
();
...
@@ -721,10 +745,10 @@ describe('geolocationTest_geo1', function () {
...
@@ -721,10 +745,10 @@ describe('geolocationTest_geo1', function () {
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0003
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0003
'
,
0
,
async
function
(
done
)
{
geolocation
.
isLocationEnabled
(
async
(
err
,
data
)
=>
{
geolocation
.
isLocationEnabled
(
async
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getLocationSwitchState callback err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getLocationSwitchState callback err is :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] getLocationSwitchState callback data:
"
+
data
);
console
.
info
(
"
[lbs_js] getLocationSwitchState callback data:
"
+
JSON
.
stringify
(
data
)
);
expect
(
data
).
assertTrue
();
expect
(
data
).
assertTrue
();
}
}
done
()
done
()
...
@@ -741,7 +765,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -741,7 +765,7 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0004
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0004
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
isLocationEnabled
().
then
((
result1
)
=>
{
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
();
expect
(
result1
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
expect
().
assertFail
();
expect
().
assertFail
();
...
@@ -760,27 +784,22 @@ describe('geolocationTest_geo1', function () {
...
@@ -760,27 +784,22 @@ describe('geolocationTest_geo1', function () {
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0005
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocSwitch_0005
'
,
0
,
async
function
(
done
)
{
geolocation
.
on
(
'
locationServiceState
'
,
geolocation
.
on
(
'
locationServiceState
'
,
(
result
)
=>
{
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
locationServiceState on callback err:
"
+
err
);
}
console
.
info
(
"
locationServiceState on result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
locationServiceState on result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
done
();
});
});
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 :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] requestEnableLocation callback data:
"
+
data
);
console
.
info
(
"
[lbs_js] requestEnableLocation callback data:
"
+
JSON
.
stringify
(
data
)
);
expect
(
data
).
assertTrue
();
expect
(
data
).
assertTrue
();
}
}
done
()
done
()
});
});
geolocation
.
off
(
'
locationServiceState
'
,
geolocation
.
off
(
'
locationServiceState
'
,
(
result
)
=>
{
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
locationServiceState off callback err:
"
+
err
);
}
console
.
info
(
"
locationServiceState off callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
locationServiceState off callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
done
();
...
@@ -799,14 +818,14 @@ describe('geolocationTest_geo1', function () {
...
@@ -799,14 +818,14 @@ describe('geolocationTest_geo1', function () {
let
currentLocationRequest
=
{
"
priority
"
:
0x200
,
"
scenario
"
:
0x301
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x200
,
"
scenario
"
:
0x301
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
geolocation
.
requestEnableLocation
(
async
(
err
,
data
)
=>
{
geolocation
.
requestEnableLocation
(
async
(
err
,
data
)
=>
{
if
(
err
)
{
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
();
expect
(
data
).
assertTrue
();
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
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
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -850,7 +869,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -850,7 +869,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
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
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
resultLength
>=
0
);
expect
(
true
).
assertEqual
(
resultLength
>=
0
);
...
@@ -871,7 +890,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -871,7 +890,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
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
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -893,7 +912,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -893,7 +912,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
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
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -916,11 +935,11 @@ describe('geolocationTest_geo1', function () {
...
@@ -916,11 +935,11 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
err
)
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
JSON
.
stringify
(
err
)
)
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -949,7 +968,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -949,7 +968,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -972,7 +991,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -972,7 +991,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -995,7 +1014,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -995,7 +1014,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1018,7 +1037,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1018,7 +1037,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1041,7 +1060,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1041,7 +1060,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1064,7 +1083,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1064,7 +1083,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1087,7 +1106,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1087,7 +1106,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1110,7 +1129,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1110,7 +1129,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1133,7 +1152,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1133,7 +1152,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1157,11 +1176,11 @@ describe('geolocationTest_geo1', function () {
...
@@ -1157,11 +1176,11 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
err
)
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
JSON
.
stringify
(
err
)
)
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1190,7 +1209,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1190,7 +1209,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1213,7 +1232,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1213,7 +1232,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1236,7 +1255,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1236,7 +1255,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1259,7 +1278,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1259,7 +1278,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1282,7 +1301,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1282,7 +1301,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1306,11 +1325,11 @@ describe('geolocationTest_geo1', function () {
...
@@ -1306,11 +1325,11 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
err
)
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
JSON
.
stringify
(
err
)
)
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1339,7 +1358,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1339,7 +1358,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1362,7 +1381,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1362,7 +1381,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1385,7 +1404,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1385,7 +1404,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1408,7 +1427,7 @@ describe('geolocationTest_geo1', function () {
...
@@ -1408,7 +1427,7 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
geolocation
.
getCurrentLocation
(
currentLocationRequest
,
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1432,11 +1451,11 @@ describe('geolocationTest_geo1', function () {
...
@@ -1432,11 +1451,11 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
geolocation
.
getCurrentLocation
(
currentLocationRequest1
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
err
)
console
.
info
(
"
getCurrentLocation callback1 err:
"
+
JSON
.
stringify
(
err
)
)
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
geolocation
.
getCurrentLocation
(
currentLocationRequest2
,
async
(
err
,
result
)
=>
{
async
(
err
,
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
err
)
return
console
.
info
(
"
getCurrentLocation callback2 err:
"
+
JSON
.
stringify
(
err
)
)
}
else
{
}
else
{
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
getCurrentLocation callback, result2:
"
+
JSON
.
stringify
(
result
));
let
resultLength
=
Object
.
keys
(
result
).
length
;
let
resultLength
=
Object
.
keys
(
result
).
length
;
...
@@ -1466,9 +1485,9 @@ describe('geolocationTest_geo1', function () {
...
@@ -1466,9 +1485,9 @@ describe('geolocationTest_geo1', function () {
it
(
'
SUB_HSS_LocationSystem_LastLocation_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LastLocation_0001
'
,
0
,
async
function
(
done
)
{
geolocation
.
getLastLocation
(
async
(
err
,
data
)
=>
{
geolocation
.
getLastLocation
(
async
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getLastLocation callback err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getLastLocation callback err is :
'
+
JSON
.
stringify
(
err
)
);
}
else
{
}
else
{
console
.
info
(
'
[lbs_js] getLastLocation callback result:
'
+
data
);
console
.
info
(
'
[lbs_js] getLastLocation callback result:
'
+
JSON
.
stringify
(
data
)
);
expect
(
data
).
assertTrue
();
expect
(
data
).
assertTrue
();
}
}
done
()
done
()
...
@@ -1484,15 +1503,14 @@ describe('geolocationTest_geo1', function () {
...
@@ -1484,15 +1503,14 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_HSS_LocationSystem_LastLocation_0002
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LastLocation_0002
'
,
0
,
async
function
(
done
)
{
setTimeout
(
async
()
=>
{
await
geolocation
.
getLastLocation
().
then
((
result
)
=>
{
await
geolocation
.
getLastLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] getLastLocation promise result:
'
+
result
);
console
.
info
(
'
[lbs_js] getLastLocation promise result:
'
+
JSON
.
stringify
(
result
)
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
[lbs_js] getLastLocation promise then err:
'
+
result
);
console
.
info
(
'
[lbs_js] getLastLocation promise then err:
'
+
JSON
.
stringify
(
result
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
},
2000
);
done
();
done
();
})
})
...
@@ -1506,15 +1524,14 @@ describe('geolocationTest_geo1', function () {
...
@@ -1506,15 +1524,14 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0028
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0028
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0300
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0300
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
setTimeout
(
async
()
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise data is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCurrentLocation promise data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
},
2000
);
done
();
done
();
})
})
...
@@ -1528,15 +1545,14 @@ describe('geolocationTest_geo1', function () {
...
@@ -1528,15 +1545,14 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0029
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0029
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0301
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0301
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
setTimeout
(
async
()
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
},
2000
);
done
();
done
();
})
})
...
@@ -1550,15 +1566,14 @@ describe('geolocationTest_geo1', function () {
...
@@ -1550,15 +1566,14 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0030
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0030
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0302
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0302
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
setTimeout
(
async
()
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
},
2000
);
done
();
done
();
})
})
...
@@ -1571,17 +1586,15 @@ describe('geolocationTest_geo1', function () {
...
@@ -1571,17 +1586,15 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0031
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0031
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0303
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0303
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
setTimeout
(
async
()
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
});
},
2000
);
done
();
done
();
})
})
...
@@ -1595,18 +1608,59 @@ describe('geolocationTest_geo1', function () {
...
@@ -1595,18 +1608,59 @@ describe('geolocationTest_geo1', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0032
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_0032
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0304
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0304
,
"
timeoutMs
"
:
10
,
"
maxAccuracy
"
:
0
};
setTimeout
(
async
()
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCurrentLocation promise result is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
error
);
console
.
info
(
"
[lbs_js] getCurrentLocation promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
done
();
})
/**
* @tc.number SingleLoc_0032
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0032
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_SendCommand_callback
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
'
scenairo
'
:
0x301
,
'
command
'
:
"
command_1
"
};
await
geolocation
.
sendCommand
(
requestInfo
,(
err
,
result
)
=>
{
if
(
err
){
console
.
info
(
'
sendcommand callback err:
'
+
err
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
done
();
}
console
.
info
(
'
sendcommand callback result:
'
+
result
);
});
});
},
2000
);
})
/**
* @tc.number SingleLoc_0032
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0032
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_SendCommand_promise
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
'
scenairo
'
:
0x301
,
'
command
'
:
"
command_1
"
};
await
geolocation
.
sendCommand
(
requestInfo
).
then
((
result
)
=>
{
console
.
info
(
'
sendCommand promise result:
'
+
result
);
done
();
done
();
}).
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
浏览文件 @
b4ee85cf
...
@@ -16,30 +16,38 @@ import geolocation from '@ohos.geolocation';
...
@@ -16,30 +16,38 @@ import geolocation from '@ohos.geolocation';
import
geolocations
from
'
@system.geolocation
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
function
sleep
(
ms
)
{
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
}
async
function
changedLocationMode
(){
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
result
);
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
)
);
if
(
!
result
){
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
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
();
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
expect
().
assertFail
();
});
});
}
}
})
});
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
});
}
}
async
function
applyPermission
()
{
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
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
let
tokenID
=
appInfo
.
accessTokenId
;
...
@@ -47,21 +55,21 @@ async function applyPermission() {
...
@@ -47,21 +55,21 @@ async function applyPermission() {
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
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
)
=>
{
}).
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
)
=>
{
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
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
)
);
});
});
}
else
{
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
}
}
describe
(
'
geolocationTest
'
,
function
()
{
describe
(
'
geolocationTest
_geo2
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
await
applyPermission
();
...
@@ -192,17 +200,12 @@ describe('geolocationTest', function () {
...
@@ -192,17 +200,12 @@ describe('geolocationTest', function () {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_HSS_LocationSystem_0005
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_0005
'
,
0
,
async
function
(
done
)
{
geolocation
.
unsubscribe
(
geolocation
.
unsubscribe
();
(
result
)
=>
{
console
.
info
(
"
[lbs_js] unsubscribe called
"
)
if
(
err
){
return
console
.
info
(
"
unsubscribe err:
"
+
err
);
}
console
.
info
(
"
unsubscribe result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
done
();
done
();
})
})
})
})
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
b4ee85cf
...
@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
...
@@ -17,6 +17,7 @@ import geolocation from '@ohos.geolocation';
import
{
LocationEventListener
}
from
'
@ohos.geolocation
'
;
import
{
LocationEventListener
}
from
'
@ohos.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
LocationRequestScenario
=
{
UNSET
:
0x300
,
NAVIGATION
:
0x301
,
let
LocationRequestScenario
=
{
UNSET
:
0x300
,
NAVIGATION
:
0x301
,
TRAJECTORY_TRACKING
:
0x302
,
CAR_HAILING
:
0x303
,
TRAJECTORY_TRACKING
:
0x302
,
CAR_HAILING
:
0x303
,
...
@@ -34,22 +35,29 @@ function sleep(ms) {
...
@@ -34,22 +35,29 @@ function sleep(ms) {
async
function
changedLocationMode
(){
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
result
);
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
)
);
if
(
!
result
){
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
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
();
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
)
);
expect
().
assertFail
();
expect
().
assertFail
();
});
});
}
}
})
});
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
});
}
}
async
function
applyPermission
()
{
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
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
let
tokenID
=
appInfo
.
accessTokenId
;
...
@@ -57,21 +65,21 @@ async function applyPermission() {
...
@@ -57,21 +65,21 @@ async function applyPermission() {
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
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
)
=>
{
}).
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
)
=>
{
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
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
)
);
});
});
}
else
{
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
}
}
describe
(
'
geolocationTest
'
,
function
()
{
describe
(
'
geolocationTest
_geo3
'
,
function
()
{
let
data
=
{
let
data
=
{
title
:
""
,
title
:
""
,
locationChange
:
null
,
locationChange
:
null
,
...
@@ -1037,6 +1045,8 @@ describe('geolocationTest', function () {
...
@@ -1037,6 +1045,8 @@ describe('geolocationTest', function () {
geolocation
.
getCachedGnssLocationsSize
((
err
,
data
)
=>
{
geolocation
.
getCachedGnssLocationsSize
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getCachedGnssLocationsSize callback err is :
'
+
err
);
console
.
info
(
'
[lbs_js] getCachedGnssLocationsSize callback err is :
'
+
err
);
expect
(
true
).
assertTrue
(
err
!=
null
);
done
();
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] getCachedGnssLocationsSize callback data is:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[lbs_js] getCachedGnssLocationsSize callback data is:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
!=
null
);
expect
(
true
).
assertTrue
(
data
!=
null
);
...
@@ -1086,7 +1096,8 @@ describe('geolocationTest', function () {
...
@@ -1086,7 +1096,8 @@ describe('geolocationTest', function () {
done
();
done
();
}).
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
(
true
).
assertTrue
(
error
!=
null
);
done
();
done
();
done
();
});
});
})
})
...
@@ -1106,6 +1117,8 @@ describe('geolocationTest', function () {
...
@@ -1106,6 +1117,8 @@ describe('geolocationTest', function () {
(
result
)
=>
{
(
result
)
=>
{
if
(
err
){
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
expect
(
true
).
assertTrue
(
err
!=
null
);
done
();
}
}
console
.
info
(
"
cachedGnssLocationsReporting result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
cachedGnssLocationsReporting result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
...
@@ -1128,6 +1141,8 @@ describe('geolocationTest', function () {
...
@@ -1128,6 +1141,8 @@ describe('geolocationTest', function () {
geolocation
.
flushCachedGnssLocations
((
err
,
data
)
=>
{
geolocation
.
flushCachedGnssLocations
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] flushCachedGnssLocations callback err is :
'
+
err
);
console
.
info
(
'
[lbs_js] flushCachedGnssLocations callback err is :
'
+
err
);
expect
(
true
).
assertTrue
(
err
!=
null
);
done
();
}
else
{
}
else
{
console
.
info
(
"
[lbs_js] flushCachedGnssLocations callback data is:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[lbs_js] flushCachedGnssLocations callback data is:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
);
expect
(
true
).
assertTrue
(
data
);
...
@@ -1177,7 +1192,7 @@ describe('geolocationTest', function () {
...
@@ -1177,7 +1192,7 @@ describe('geolocationTest', function () {
done
();
done
();
}).
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
(
true
).
assertTrue
(
error
!=
null
);
done
();
done
();
});
});
})
})
...
@@ -1185,3 +1200,4 @@ describe('geolocationTest', function () {
...
@@ -1185,3 +1200,4 @@ describe('geolocationTest', function () {
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录