Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
cf0c3439
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看板
提交
cf0c3439
编写于
7月 22, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
2b69936d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
496 addition
and
141 deletion
+496
-141
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+16
-10
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+2
-0
location/geolocation_standard/src/main/js/default/test/LocationMock.test.js
...on_standard/src/main/js/default/test/LocationMock.test.js
+360
-0
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+118
-131
未找到文件。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
cf0c3439
...
...
@@ -322,26 +322,32 @@ describe('geolocationTest_geo1', function () {
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
){
switch
(
err
){
case
100
:
console
.
info
(
"
NOT_SUPPORTED
"
+
JSON
.
stringify
(
err
));
break
;
case
101
:
console
.
info
(
"
INPUT_PARAMS_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
INPUT_PARAMS_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
102
:
console
.
info
(
"
REVERSE_GEOCODE_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
REVERSE_GEOCODE_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
103
:
console
.
info
(
"
GEOCODE_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
GEOCODE_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
104
:
console
.
info
(
"
LOCATOR_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
LOCATOR_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
105
:
console
.
info
(
"
LOCATION_SWITCH_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
LOCATION_SWITCH_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
106
:
console
.
info
(
"
LAST_KNOWN_LOCATION_ERROR
:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
LAST_KNOWN_LOCATION_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
107
:
console
.
info
(
"
LOCATION_REQUEST_TIMEOUT_ERROR:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
LOCATION_REQUEST_TIMEOUT_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
case
108
:
console
.
info
(
"
QUERY_COUNTRY_CODE_ERROR
"
+
JSON
.
stringify
(
err
));
break
;
default
:
console
.
info
(
'
[lbs_js] getAddressesFromLocationName callback err is :
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1507,7 +1513,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] getLastLocation promise result:
'
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
info
(
'
[lbs_js] getLastLocation promise
then err:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[lbs_js] getLastLocation promise
result:
'
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
...
...
@@ -1653,8 +1659,8 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
sendCommand promise result:
'
+
result
);
done
();
}).
catch
(
error
=>
{
console
.
info
(
'
sendcommand promise err:
'
+
err
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
console
.
info
(
'
sendcommand promise err:
'
+
err
or
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
or
)
!=
null
);
done
();
})
})
...
...
location/geolocation_standard/src/main/js/default/test/List.test.js
浏览文件 @
cf0c3439
...
...
@@ -16,3 +16,5 @@
require
(
'
./GeocoderTest.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
require
(
'
./Geolocation.test.js
'
)
require
(
'
./LocationMock.test.js
'
)
location/geolocation_standard/src/main/js/default/test/LocationMock.test.js
0 → 100644
浏览文件 @
cf0c3439
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
console
.
info
(
'
[lbs_js]sleep function
'
);
}
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
console
.
info
(
'
[lbs_js] test requestEnableLocation promise result:
'
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
}
});
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] check LocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
});
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
debug
(
"
====>testgetuserid get AccountManager finish====
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
====>testgetuserid localId obtained by process:
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
describe
(
'
geolocationTest_4
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach case
'
);
await
changedLocationMode
();
done
();
})
afterEach
(
function
()
{
})
/**
* @tc.number enableLocationMock_callback
* @tc.name enableLocationMock_callback
* @tc.desc Test enableLocationMock api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
enableLocationMock_callback
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]enableLocationMock
"
);
let
locationRequestScenario1
=
{
"
scenario
"
:
0x0301
}
function
enableLocationMockPromise
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
enableLocationMock
(
locationRequestScenario1
,(
err
)
=>
{
if
(
err
){
return
console
.
info
(
"
enableLocationMock callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
enableLocationMock callback success!
"
);
}
resolve
();
})
})
}
await
enableLocationMockPromise
()
done
()
})
/**
* @tc.number disableLocationMock
* @tc.name disableLocationMock_callback
* @tc.desc Test disableLocationMock api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
disableLocationMock_callback
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]disableLocationMock
"
);
let
locationRequestScenario1
=
{
"
scenario
"
:
0x0301
}
function
disableLocationMockPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
disableLocationMock
(
locationRequestScenario1
,
(
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
disableLocationMockPromise callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
disableLocationMockPromise callback success
"
);
}
resolve
();
})
})
}
await
disableLocationMockPromise
()
done
()
})
/**
* @tc.number getCountryCode
* @tc.name getCountryCode_promise
* @tc.desc Test getCountryCode api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
getCountryCode_promise
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] country :
"
+
JSON
.
stringify
(
result
).
country
);
console
.
info
(
"
[lbs_js] type:
"
+
JSON
.
stringify
(
result
).
type
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
done
();
})
/**
* @tc.number getCountryCode
* @tc.name getCountryCode_callback
* @tc.desc Test getCountryCode api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
getCountryCode_callback
'
,
0
,
async
function
(
done
)
{
function
getCountryCodePromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
getCountryCode
((
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getCountryCode callback success
"
);
}
resolve
();
})
})
}
await
getCountryCodePromise
();
done
();
})
/**
* @tc.number getCountryCode
* @tc.name getCountryCode_on_off
* @tc.desc Test getCountryCode api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
getCountryCode_on_off
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]countryCodeChange
"
);
geolocation
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
});
await
geolocation
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
geolocation
.
off
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
));
done
();
})
done
();
})
/**
* @tc.number setReverseGeocodingMockInfo
* @tc.name setReverseGeocodingMockInfo_callback
* @tc.desc Test setReverseGeocodingMockInfo api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
setReverseGeocodingMockInfo_callback
'
,
0
,
async
function
(
done
)
{
function
enableReverseGeocodingMockPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
enableReverseGeocodingMock
(
(
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
enableReverseGeocodingMock callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
enableReverseGeocodingMock callback success
"
);
}
resolve
();
})
})
}
await
enableReverseGeocodingMockPromise
();
var
locations
=
[
{
"
location
"
:
{
"
locale
"
:
"
shanghai
"
,
"
latitude
"
:
30.12
,
"
longitude
"
:
120.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
shanghai
"
,
"
latitude
"
:
30.12
,
"
longitude
"
:
120.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
beijing
"
,
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
beijing
"
,
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
shenzhen
"
,
"
latitude
"
:
32.12
,
"
longitude
"
:
122.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
shenzhen
"
,
"
latitude
"
:
32.12
,
"
longitude
"
:
122.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
wuhan
"
,
"
latitude
"
:
33.12
,
"
longitude
"
:
123.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
wuhan
"
,
"
latitude
"
:
33.12
,
"
longitude
"
:
123.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
chengdu
"
,
"
latitude
"
:
34.12
,
"
longitude
"
:
124.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
chengdu
"
,
"
latitude
"
:
34.12
,
"
longitude
"
:
124.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
];
function
setReverseGeocodingMockInfoPromise
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
setReverseGeocodingMockInfo
(
locations
,(
err
)
=>
{
if
(
err
){
console
.
info
(
"
[lbs_js]setReverseGeocodingMockInfo callback err:
"
+
JSON
.
stringify
(
err
)
);
}
else
{
console
.
info
(
"
[lbs_js]setReverseGeocodingMockInfo callback called
"
);
}
resolve
();
});
})
}
await
setReverseGeocodingMockInfoPromise
();
function
disableReverseGeocodingMockPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
disableReverseGeocodingMock
((
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
disableReverseGeocodingMock callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[lbs_js] disableReverseGeocodingMock promise called
"
);
}
resolve
();
})
})
}
await
disableReverseGeocodingMockPromise
()
done
();
})
/**
* @tc.number setReverseGeocodingMockInfo
* @tc.name setReverseGeocodingMockInfo_promise
* @tc.desc Test setReverseGeocodingMockInfo api .
* @tc.type Function
* @tc.level since 9
*/
it
(
'
setReverseGeocodingMockInfo_promise
'
,
0
,
async
function
(
done
)
{
function
enableReverseGeocodingMockPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
enableReverseGeocodingMock
(
(
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
enableReverseGeocodingMock callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
enableReverseGeocodingMock callback success
"
);
}
resolve
();
})
})
}
await
enableReverseGeocodingMockPromise
();
var
locations
=
[
{
"
location
"
:
{
"
locale
"
:
"
shanghai
"
,
"
latitude
"
:
30.12
,
"
longitude
"
:
120.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
shanghai
"
,
"
latitude
"
:
30.12
,
"
longitude
"
:
120.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
beijing
"
,
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
beijing
"
,
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
shenzhen
"
,
"
latitude
"
:
32.12
,
"
longitude
"
:
122.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
shenzhen
"
,
"
latitude
"
:
32.12
,
"
longitude
"
:
122.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
wuhan
"
,
"
latitude
"
:
33.12
,
"
longitude
"
:
123.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
wuhan
"
,
"
latitude
"
:
33.12
,
"
longitude
"
:
123.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
{
"
location
"
:
{
"
locale
"
:
"
chengdu
"
,
"
latitude
"
:
34.12
,
"
longitude
"
:
124.11
,
"
maxItems
"
:
1
},
"
geoAddress
"
:
{
"
locale
"
:
"
chengdu
"
,
"
latitude
"
:
34.12
,
"
longitude
"
:
124.11
,
"
maxItems
"
:
1
,
"
isFromMock
"
:
true
}},
];
geolocation
.
setReverseGeocodingMockInfo
(
locations
).
then
(()
=>
{
console
.
info
(
"
[lbs_js] setReverseGeocodingMockInfo promise called
"
);
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation05 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
done
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
});
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] setReverseGeocodingMockInfo promise result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
})
function
disableReverseGeocodingMockPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
disableReverseGeocodingMock
((
err
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
disableReverseGeocodingMock callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[lbs_js] disableReverseGeocodingMock promise called
"
);
}
resolve
();
})
})
}
await
disableReverseGeocodingMockPromise
()
done
();
})
})
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
cf0c3439
...
...
@@ -38,7 +38,7 @@ async function changedLocationMode(){
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
//
await sleep(3000);
console
.
info
(
'
[lbs_js] test requestEnableLocation promise result:
'
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
...
...
@@ -55,7 +55,7 @@ async function changedLocationMode(){
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
debug
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
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
();
...
...
@@ -88,15 +88,15 @@ describe('geolocationTest_geo3', function () {
console
.
log
(
'
#start AccessTokenTests#
'
);
beforeAll
(
async
function
(
done
)
{
await
applyPermission
();
setTimeout
(
function
()
{
this
.
locationChange
=
(
err
,
location
)
=>
{
setTimeout
(
function
()
{
this
.
locationChange
=
(
err
,
location
)
=>
{
console
.
log
(
'
locationChange:
'
+
err
+
"
data:
"
+
JSON
.
stringify
(
location
));
};
this
.
locationServiceState
=
(
err
,
state
)
=>
{
};
this
.
locationServiceState
=
(
err
,
state
)
=>
{
console
.
log
(
'
locationServiceState:
'
+
err
+
"
data:
"
+
state
);
};
done
();
},
3000
);
};
done
();
},
3000
);
console
.
info
(
'
beforeAll case
'
);
})
...
...
@@ -449,7 +449,7 @@ describe('geolocationTest_geo3', function () {
let
locationChange
=
(
location
)
=>
{
console
.
log
(
'
locationChanger:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
async
(
locationChange
)
=>
{
if
(
err
){
return
console
.
info
(
"
onLocationChange callback err:
"
+
err
);
...
...
@@ -723,25 +723,11 @@ describe('geolocationTest_geo3', function () {
*/
it
(
'
SUB_HSS_LocationSystem_Gnss_0001
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
try
{
geolocation
.
on
(
'
gnssStatusChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] gnssStatusChangestart
'
+
JSON
.
stringify
(
data
)
);
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
console
.
info
(
'
[lbs_js] SatelliteStatusInfo satellitesNumber:
'
+
data
[
0
].
satellitesNumber
+
'
satelliteIds
'
+
data
[
0
].
satelliteIds
+
'
carrierToNoiseDensitys
'
+
data
[
0
].
carrierToNoiseDensitys
+
'
altitudes
'
+
data
[
0
].
altitudes
+
'
azimuths:
'
+
data
[
0
].
azimuths
+
'
carrierFrequencies:
'
+
data
[
0
].
carrierFrequencies
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
try
{
geolocation
.
off
(
'
gnssStatusChange
'
,
function
(
data
)
{
console
.
info
(
"
[lbs_js] gnssStatusChange off data:
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
var
gnssStatusCb
=
(
satelliteStatusInfo
)
=>
{
console
.
log
(
'
gnssStatusChange:
'
+
satelliteStatusInfo
);
}
geolocation
.
on
(
'
gnssStatusChange
'
,
gnssStatusCb
);
geolocation
.
off
(
'
gnssStatusChange
'
,
gnssStatusCb
);
done
();
})
...
...
@@ -755,20 +741,11 @@ describe('geolocationTest_geo3', function () {
*/
it
(
'
SUB_HSS_LocationSystem_Gnss_0002
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
try
{
geolocation
.
on
(
'
nmeaMessageChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] nmeaMessageChange
'
+
JSON
.
stringify
(
data
)
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
try
{
geolocation
.
off
(
'
nmeaMessageChange
'
,
function
(
data
)
{
console
.
info
(
"
[lbs_js] nmeaMessageChange off data:
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
var
nmeaCb
=
(
str
)
=>
{
console
.
log
(
'
nmeaMessageChange:
'
+
str
);
}
geolocation
.
on
(
'
nmeaMessageChange
'
,
nmeaCb
);
geolocation
.
off
(
'
nmeaMessageChange
'
,
nmeaCb
);
done
();
})
...
...
@@ -784,26 +761,28 @@ describe('geolocationTest_geo3', function () {
await
changedLocationMode
();
let
geofence
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
radius
"
:
1
,
"
expiration
"
:
""
};
let
geofenceRequest
=
{
"
priority
"
:
0x200
,
"
scenario
"
:
0x301
,
"
geofence
"
:
geofence
};
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
offfenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
setTimeout
(
async
()
=>
{
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
off fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
},
1000
);
done
();
})
...
...
@@ -819,25 +798,28 @@ describe('geolocationTest_geo3', function () {
await
changedLocationMode
();
let
geofence
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
radius
"
:
1
,
"
expiration
"
:
""
};
let
geofenceRequest
=
{
"
priority
"
:
0x200
,
"
scenario
"
:
0x304
,
"
geofence
"
:
geofence
};
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
off fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
setTimeout
(
async
()
=>
{
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
off fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
},
1000
);
done
();
})
...
...
@@ -853,26 +835,28 @@ describe('geolocationTest_geo3', function () {
await
changedLocationMode
();
let
geofence
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
radius
"
:
1
,
"
expiration
"
:
""
};
let
geofenceRequest
=
{
"
priority
"
:
0x203
,
"
scenario
"
:
0x300
,
"
geofence
"
:
geofence
};
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
offfenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
setTimeout
(
async
()
=>
{
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
off fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
},
1000
);
done
();
})
...
...
@@ -886,28 +870,30 @@ describe('geolocationTest_geo3', function () {
*/
it
(
'
SUB_HSS_LocationSystem_GeoFence_0005
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
let
geofence
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
radius
"
:
1
,
"
expiration
"
:
5000
};
let
geofenceRequest
=
{
"
priority
"
:
0x203
,
"
scenario
"
:
0x300
,
"
geofence
"
:
geofence
};
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
offfenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
let
geofence
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
radius
"
:
1
,
"
expiration
"
:
""
};
let
geofenceRequest
=
{
"
priority
"
:
0x203
,
"
scenario
"
:
0x301
,
"
geofence
"
:
geofence
};
setTimeout
(
async
()
=>
{
let
want
=
(
wantAgent
)
=>
{
console
.
log
(
'
wantAgent:
'
+
JSON
.
stringify
(
wantAgent
));
};
geolocation
.
on
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange on callback err:
"
+
err
);
}
console
.
info
(
"
fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
done
();
});
geolocation
.
off
(
'
fenceStatusChange
'
,
geofenceRequest
,
(
want
)
=>
{
if
(
err
){
return
console
.
info
(
"
fenceStatusChange callback err:
"
+
err
);
}
console
.
info
(
"
off fenceStatusChange callback, result:
"
+
JSON
.
stringify
(
want
));
expect
(
true
).
assertEqual
(
want
!=
null
);
});
},
1000
);
done
();
})
...
...
@@ -922,7 +908,7 @@ describe('geolocationTest_geo3', function () {
it
(
'
SUB_HSS_LocationSystem_Batching_0001
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
let
request
=
{
"
reportingPeriodSec
"
:
5
,
"
wakeUpCacheQueueFull
"
:
false
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -935,7 +921,7 @@ describe('geolocationTest_geo3', function () {
let
locationChange
=
(
location
)
=>
{
console
.
log
(
'
locationChanger:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
(
locationChange
)
=>
{
if
(
err
){
return
console
.
info
(
"
onLocationChange callback err:
"
+
err
);
...
...
@@ -944,7 +930,7 @@ describe('geolocationTest_geo3', function () {
expect
(
true
).
assertEqual
(
locationChange
!=
null
);
});
let
request1
=
{
"
reportingPeriodSec
"
:
10
,
"
wakeUpCacheQueueFull
"
:
false
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request1
,
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request1
,
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -974,7 +960,7 @@ describe('geolocationTest_geo3', function () {
done
()
});
let
request
=
{
"
reportingPeriodSec
"
:
5
,
"
wakeUpCacheQueueFull
"
:
false
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
result
=>
{
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -988,7 +974,7 @@ describe('geolocationTest_geo3', function () {
let
locationChange
=
(
location
)
=>
{
console
.
log
(
'
locationChanger:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
(
locationChange
)
=>
{
if
(
err
){
return
console
.
info
(
"
onLocationChange callback err:
"
+
err
);
...
...
@@ -997,7 +983,7 @@ describe('geolocationTest_geo3', function () {
expect
(
true
).
assertEqual
(
locationChange
!=
null
);
done
()
});
geolocation
.
off
(
'
cachedGnssLocationsReporting
'
,
request
,
geolocation
.
off
(
'
cachedGnssLocationsReporting
'
,
request
,
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
cachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -1019,7 +1005,7 @@ describe('geolocationTest_geo3', function () {
it
(
'
SUB_HSS_LocationSystem_Batching_0003
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
let
request
=
{
"
reportingPeriodSec
"
:
5
,
"
wakeUpCacheQueueFull
"
:
true
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -1033,7 +1019,7 @@ describe('geolocationTest_geo3', function () {
let
locationChange
=
(
location
)
=>
{
console
.
log
(
'
locationChanger:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
(
locationChange
)
=>
{
if
(
err
){
return
console
.
info
(
"
onLocationChange callback err:
"
+
err
);
...
...
@@ -1067,7 +1053,7 @@ describe('geolocationTest_geo3', function () {
it
(
'
SUB_HSS_LocationSystem_Batching_0004
'
,
0
,
async
function
(
done
)
{
await
changedLocationMode
();
let
request
=
{
"
reportingPeriodSec
"
:
5
,
"
wakeUpCacheQueueFull
"
:
true
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
request
,
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
oncachedGnssLocationsReporting callback err:
"
+
err
);
...
...
@@ -1201,3 +1187,4 @@ describe('geolocationTest_geo3', function () {
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录