Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5863093a
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看板
未验证
提交
5863093a
编写于
2月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2019 【location】增加rk3568 LBS测试用例
Merge pull request !2019 from 权力/myfeature1
上级
ae4e3c46
bb4089ee
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
1088 addition
and
79 deletion
+1088
-79
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
...on/wifi_standard/src/main/js/default/test/WifiSta.test.js
+154
-79
location/BUILD.gn
location/BUILD.gn
+22
-0
location/geolocation_standard/BUILD.gn
location/geolocation_standard/BUILD.gn
+38
-0
location/geolocation_standard/Test.json
location/geolocation_standard/Test.json
+18
-0
location/geolocation_standard/signature/openharmony_sx.p7b
location/geolocation_standard/signature/openharmony_sx.p7b
+0
-0
location/geolocation_standard/src/main/config.json
location/geolocation_standard/src/main/config.json
+60
-0
location/geolocation_standard/src/main/js/default/app.js
location/geolocation_standard/src/main/js/default/app.js
+23
-0
location/geolocation_standard/src/main/js/default/i18n/en-US.json
.../geolocation_standard/src/main/js/default/i18n/en-US.json
+6
-0
location/geolocation_standard/src/main/js/default/i18n/zh-CN.json
.../geolocation_standard/src/main/js/default/i18n/zh-CN.json
+6
-0
location/geolocation_standard/src/main/js/default/pages/index/index.css
...cation_standard/src/main/js/default/pages/index/index.css
+9
-0
location/geolocation_standard/src/main/js/default/pages/index/index.hml
...cation_standard/src/main/js/default/pages/index/index.hml
+5
-0
location/geolocation_standard/src/main/js/default/pages/index/index.js
...ocation_standard/src/main/js/default/pages/index/index.js
+43
-0
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
...ion_standard/src/main/js/default/test/Geolocation.test.js
+675
-0
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+16
-0
location/geolocation_standard/src/main/resources/base/element/string.json
...tion_standard/src/main/resources/base/element/string.json
+12
-0
location/geolocation_standard/src/main/resources/base/media/icon.png
...olocation_standard/src/main/resources/base/media/icon.png
+0
-0
test_packages.gni
test_packages.gni
+1
-0
未找到文件。
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
浏览文件 @
5863093a
...
...
@@ -35,6 +35,21 @@ var WifiSecurityType = {
WIFI_SEC_TYPE_SAE
:
4
,
}
var
SuppState
=
{
DISCONNECTED
:
0
,
INTERFACE_DISABLED
:
1
,
INACTIVE
:
2
,
SCANNING
:
3
,
AUTHENTICATING
:
4
,
ASSOCIATING
:
5
,
ASSOCIATED
:
6
,
FOUR_WAY_HANDSHAKE
:
7
,
GROUP_HANDSHAKE
:
8
,
COMPLETED
:
9
,
UNINITIALIZED
:
10
,
INVALID
:
11
,
}
var
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST
"
,
"
bssid
"
:
"
A1:B1:C1:D1:E1:F1
"
,
...
...
@@ -43,6 +58,17 @@ var wifiDeviceConfig = {
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
}
var
ConnState
=
{
SCANNING
:
0
,
CONNECTING
:
1
,
AUTHENTICATING
:
2
,
OBTAINING_IPADDR
:
3
,
CONNECTED
:
4
,
DISCONNECTING
:
5
,
DISCONNECTED
:
6
,
UNKNOWN
:
7
,
}
var
ipConfig
=
{
"
ipAddress
"
:
1284752956
,
"
gateway
"
:
17017024
,
...
...
@@ -352,7 +378,7 @@ describe('ACTS_WifiTest', function() {
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
console
.
info
(
"
[wifi_test]connectdevice result:
"
+
wifi
.
connectToNetwork
(
netWorkId
));
expect
(
wifi
.
connectToNetwork
(
netWorkId
)).
assertTrue
();
console
.
info
(
"
[wifi_test]
get empty linked information and getIpInfo
.
"
);
console
.
info
(
"
[wifi_test]
disableNetwork test start
.
"
);
var
disconNet
=
wifi
.
disableNetwork
(
netWorkId
);
console
.
log
(
"
[wifi_test] wifi disableNetwork result:
"
+
disconNet
);
expect
(
disconNet
).
assertTrue
();
...
...
@@ -382,9 +408,33 @@ describe('ACTS_WifiTest', function() {
})
/**
* @tc.number Info_0002
* @tc.name SUB_Communication_WiFi_Sta_Info_0002
* @tc.desc Test get CountryCode
* @tc.number SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress
* @tc.desc Test getMacAddress api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0001
'
,
0
,
function
()
{
if
(
!
wifi
.
isWifiActive
())
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
3000
);
expect
(
enable
).
assertTrue
();
}
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
'
[wifi_test] getDeviceMacAddress test start ...
'
);
var
result
=
wifi
.
getDeviceMacAddress
();
console
.
info
(
"
[wifi_test] getDeviceMacAddress ->
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
.
length
>=
1
)
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0002
* @tc.name testgetCountryCode
* @tc.desc Test getCountryCode api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_Info_0002
'
,
0
,
function
()
{
if
(
!
wifi
.
isWifiActive
())
{
...
...
@@ -400,37 +450,84 @@ describe('ACTS_WifiTest', function() {
})
/**
* @tc.number Config_0002
* @tc.number SUB_Communication_WiFi_Sta_info_0004
* @tc.name testFeatureSupported
* @tc.desc Test FeatureSupported api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0004
'
,
0
,
function
()
{
console
.
info
(
'
[wifi_test]FeatureSupported test start ...
'
);
var
result
=
wifi
.
getSupportedFeatures
();
console
.
info
(
"
[wifi_test] getFeatureSupported ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[wifi_test] isFeatureSupported:
"
+
result
+
"
->
"
+
wifi
.
isFeatureSupported
(
result
));
expect
(
wifi
.
isFeatureSupported
(
result
)).
assertTrue
();
})
/**
* @tc.number Conn_Info_0001
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.desc Test cnnnection a PSK SecurityType wifi deviceconfig
* @tc.desc Test reconnect wifi
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
async
function
()
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Config_0002]
"
);
console
.
info
(
"
[wifi_test] create a PSK SecurityType wifi device config start.
"
);
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] wifi connectToDevice test.
"
);
var
wifiDeviceConfigConn
=
{
"
ssid
"
:
"
TEST_
CONN
"
,
"
ssid
"
:
"
TEST
CONN
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
console
.
info
(
"
[wifi_test] check add device configs successfully
"
);
var
configs
=
wifi
.
getDeviceConfigs
();
console
.
info
(
"
[wifi_test] wifi getDeviceConfigs result1 :
"
+
JSON
.
stringify
(
configs
));
console
.
info
(
"
[wifi_test] connect wifi start.
"
);
var
conn1
=
wifi
.
connectToDevice
(
wifiDeviceConfigConn
);
var
active
=
wifi
.
isWifiActive
();
sleep
(
3000
);
console
.
log
(
"
[wifi_test] wifi active result2:
"
+
active
);
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
expect
(
enable
).
assertTrue
();
sleep
(
3000
);
}
var
result1
=
wifi
.
connectToDevice
(
wifiDeviceConfigConn
);
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi Connected result:
"
+
conn1
);
console
.
log
(
"
[wifi_test] wifi connectToDevice result:
"
+
result1
);
expect
(
result1
).
assertTrue
();
console
.
info
(
"
[wifi_test] check isconnected wifi
"
);
var
isConnected
=
wifi
.
isConnected
();
console
.
log
(
"
[wifi_test] wifi isConnected result:
"
+
isConnected
);
expect
(
isConnected
).
assertFalse
();
wifi
.
getLinkedInfo
((
err
,
data
)
=>
{
console
.
info
(
"
[wifi_test] reconnect wifi
"
);
var
result
=
wifi
.
reconnect
();
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi reconnect result:
"
+
result
);
expect
(
result
).
assertTrue
();
})
/**
* @tc.number conn_Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
* @tc.desc Test getLinkedInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Conn_Info_0001]
"
);
console
.
info
(
'
console.info("[wifi_js] Wifi get link infos test[1]."
'
);
wifi
.
getLinkedInfo
()
.
then
((
result
)
=>
{
console
.
info
(
"
[wifi_js] get wifi link [promise] ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
'
band
'
);
console
.
info
(
"
[wifi_js] get wifi link [promise].
"
);
done
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_js] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
wifi
.
getLinkedInfo
((
err
,
result
)
=>
{
if
(
err
)
{
return
console
.
error
(
'
failed to get
link infos callback because
'
+
JSON
.
stringify
(
err
));
return
console
.
error
(
'
failed to getlink infos callback because
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[wifi_test] get wifi link [callback] ->
"
+
JSON
.
stringify
(
data
));
for
(
var
j
=
0
;
j
<
JSON
.
stringify
(
data
).
length
;
++
j
)
{
console
.
info
(
"
[wifi_test] get wifi link [callback] ->
"
+
JSON
.
stringify
(
result
));
for
(
var
j
=
0
;
j
<
JSON
.
stringify
(
result
).
length
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
);
console
.
info
(
"
bssid:
"
+
result
[
j
].
bssid
);
console
.
info
(
"
band:
"
+
result
[
j
].
band
);
...
...
@@ -447,24 +544,38 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
suppState:
"
+
result
[
j
].
suppState
);
console
.
info
(
"
connState:
"
+
result
[
j
].
connState
);
}
}
done
();
});
console
.
info
(
"
[wifi_test] get empty linked information and getIpInfo.
"
);
var
discon2
=
wifi
.
disconnect
();
console
.
log
(
"
[wifi_test] wifi disconnect result:
"
+
discon2
);
expect
(
discon2
).
assertTrue
();
})
/**
* @tc.number Conn_Info_000
2
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_000
2
* @tc.number Conn_Info_000
3
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_000
3
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0002
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] wifi connectToDevice test.
"
);
var
wifiDeviceConfigIp
=
{
"
ssid
"
:
"
TEST1
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
87654321
"
,
"
isHiddenSsid
"
:
"
false
"
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
var
result1
=
wifi
.
connectToDevice
(
wifiDeviceConfigIp
);
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi connectToDevice result:
"
+
result1
);
expect
(
result1
).
assertTrue
();
console
.
info
(
"
[wifi_test] check isconnected wifi
"
);
var
isConnected
=
wifi
.
isConnected
();
console
.
log
(
"
[wifi_test] wifi isConnected result:
"
+
isConnected
);
expect
(
isConnected
).
assertFalse
();
console
.
info
(
"
[wifi_test] reassociate wifi
"
);
var
result
=
wifi
.
reassociate
();
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi reassociate result:
"
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[wifi_test] get IpInfo.
"
);
var
ipInfo
=
wifi
.
getIpInfo
();
console
.
info
(
"
[wifi_test] getIpInfo ->
"
+
JSON
.
stringify
(
ipInfo
));
...
...
@@ -478,43 +589,6 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
serverIp:
"
+
ipInfo
.
serverIp
);
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0004
* @tc.name testFeatureSupported
* @tc.desc Test FeatureSupported api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0004
'
,
0
,
function
()
{
console
.
info
(
'
[wifi_test]FeatureSupported test start ...
'
);
var
result
=
wifi
.
getSupportedFeatures
();
console
.
info
(
"
[wifi_test] getFeatureSupported ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[wifi_test] isFeatureSupported:
"
+
result
+
"
->
"
+
wifi
.
isFeatureSupported
(
result
));
expect
(
wifi
.
isFeatureSupported
(
result
)).
assertTrue
();
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress
* @tc.desc Test getMacAddress api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0001
'
,
0
,
function
()
{
if
(
!
wifi
.
isWifiActive
())
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
3000
);
expect
(
enable
).
assertTrue
();
}
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
'
[wifi_test] getDeviceMacAddress test start ...
'
);
var
result
=
wifi
.
getDeviceMacAddress
();
console
.
info
(
"
[wifi_test] getDeviceMacAddress ->
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
.
length
>=
1
)
})
/**
* @tc.number SUB_Communication_WiFi_Sta_ON_0001
* @tc.name testwifiStateChangeOn
...
...
@@ -694,3 +768,4 @@ describe('ACTS_WifiTest', function() {
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
location/BUILD.gn
0 → 100644
浏览文件 @
5863093a
# Copyright (C) 2021 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("//build/ohos_var.gni")
group("location") {
testonly = true
if (is_standard_system) {
deps = [ "geolocation_standard:ActslocationJsTest" ]
} else {
deps = [ "geolocation_standard:ActslocationJsTest" ]
}
}
location/geolocation_standard/BUILD.gn
0 → 100644
浏览文件 @
5863093a
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActslocationJsTest") {
hap_profile = "./src/main/config.json"
deps = [
":geolocation_js_assets",
":geolocation_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActslocationJSApiTest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("geolocation_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("geolocation_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
location/geolocation_standard/Test.json
0 → 100644
浏览文件 @
5863093a
{
"description"
:
"Configuration for geolocation js api Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"600000"
,
"package"
:
"ohos.acts.location.geolocation.function"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActslocationJSApiTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
location/geolocation_standard/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
5863093a
文件已添加
location/geolocation_standard/src/main/config.json
0 → 100644
浏览文件 @
5863093a
{
"app"
:
{
"bundleName"
:
"ohos.acts.location.geolocation.function"
,
"vendor"
:
"acts"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.acts.location.geolocation.function"
,
"name"
:
".MyApplication"
,
"deviceType"
:
[
"phone"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
},
"abilities"
:
[
{
"visible"
:
true
,
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"name"
:
"ohos.acts.location.geolocation.function.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
location/geolocation_standard/src/main/js/default/app.js
0 → 100644
浏览文件 @
5863093a
/*
* Copyright (C) 2021 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.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
AceApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
AceApplication onDestroy
'
);
}
};
location/geolocation_standard/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
5863093a
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
}
}
\ No newline at end of file
location/geolocation_standard/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
5863093a
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
}
}
\ No newline at end of file
location/geolocation_standard/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
5863093a
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
.title
{
font-size
:
100px
;
}
location/geolocation_standard/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
5863093a
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
location/geolocation_standard/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
5863093a
/*
* Copyright (C) 2021 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
app
from
'
@system.app
'
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow finish
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
configService
.
setConfig
(
this
)
require
(
'
../../test/List.test
'
)
core
.
execute
()
},
onReady
()
{
},
}
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
0 → 100644
浏览文件 @
5863093a
/*
* Copyright (C) 2021 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
{
LocationEventListener
}
from
'
@ohos.geolocation
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
geolocationTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_PROMISE_0001
* @tc.name testenableLocation promise
* @tc.desc Test enableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_enableLocation_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
})
done
()
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001
* @tc.name testisLocationEnabled promise
* @tc.desc Test isLocationEnabled api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_isLocationEnabled_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
console
.
info
(
'
[lbs_js] LBS getLocationSwitchState promise test start ...
'
);
await
geolocation
.
isLocationEnabled
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] getLocationSwitchState promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
);
expect
().
assertFail
();
});
done
();
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
* @tc.name testgetAddressesFromLocationName callback
* @tc.desc Test getAddressesFromLocationName api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_getAddressesFromLocationName_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
console
.
info
(
'
LBS getAddressesFromLocationName callback test start ...
'
);
var
geocodeRequest
=
{
"
description
"
:
"
上海市浦东新区金穗路1800号
"
,
"
maxItems
"
:
1
,
"
locale
"
:
"
zh
"
};
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
switch
(
err
){
case
101
:
console
.
info
(
"
INPUT_PARAMS_ERROR:
"
+
err
);
break
;
case
102
:
console
.
info
(
"
REVERSE_GEOCODE_ERROR:
"
+
err
);
break
;
case
103
:
console
.
info
(
"
GEOCODE_ERROR:
"
+
err
);
break
;
case
104
:
console
.
info
(
"
LOCATOR_ERROR:
"
+
err
);
break
;
case
105
:
console
.
info
(
"
LOCATIOR_SWITCH_ERROR:
"
+
err
);
break
;
case
106
:
console
.
info
(
"
LAST_KNOWN_LOCATION_ERROR:
"
+
err
);
break
;
case
107
:
console
.
info
(
"
LOCATION_REUEST_TIMEOUT_ERROR:
"
+
err
);
break
;
default
:
console
.
info
(
'
[lbs_js]LocationName callback err:
'
+
err
);
}
}
else
{
console
.
info
(
"
[lbs_js]LocationName callback data
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName callback exit.
"
);
}
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001
* @tc.name testgetAddressesFromLocation callback
* @tc.desc Test getAddressesFromLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_getAddressesFromLocation_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
console
.
info
(
'
LBS getAddressesFromLocation callback test start ...
'
);
var
reverseGeocodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
,
"
locale
"
:
"
zh
"
};
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] Location callback data is:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
console
.
info
(
'
[lbs_js] Location addressUrl:
'
+
data
[
0
].
addressUrl
);
console
.
info
(
'
[lbs_js] Location administrativeArea:
'
+
data
[
0
].
administrativeArea
);
console
.
info
(
'
[lbs_js] Location countryCode:
'
+
data
[
0
].
countryCode
);
console
.
info
(
'
[lbs_js] Location countryName:
'
+
data
[
0
].
countryName
);
console
.
info
(
'
[lbs_js] Location descriptions:
'
+
data
[
0
].
descriptions
);
console
.
info
(
'
[lbs_js] Location descriptionsSize:
'
+
data
[
0
].
descriptionsSize
);
console
.
info
(
'
[lbs_js] Location latitude:
'
+
data
[
0
].
latitude
);
console
.
info
(
'
[lbs_js] Location locale:
'
+
data
[
0
].
locale
);
console
.
info
(
'
[lbs_js] Location locality:
'
+
data
[
0
].
locality
);
console
.
info
(
'
[lbs_js] Location longitude:
'
+
data
[
0
].
longitude
);
console
.
info
(
'
[lbs_js] Location phoneNumber:
'
+
data
[
0
].
phoneNumber
);
console
.
info
(
'
[lbs_js] Location placeName:
'
+
data
[
0
].
placeName
);
console
.
info
(
'
[lbs_js] FromLocation postalCode:
'
+
data
[
0
].
postalCode
);
console
.
info
(
'
[lbs_js] Location premises:
'
+
data
[
0
].
premises
);
console
.
info
(
'
[lbs_js] Location roadName:
'
+
data
[
0
].
roadName
);
console
.
info
(
'
[lbs_js] getAddressesFromLocation subAdministrativeArea:
'
+
data
[
0
].
subAdministrativeArea
);
console
.
info
(
'
[lbs_js] Location subLocality:
'
+
data
[
0
].
subLocality
);
console
.
info
(
'
[lbs_js] Location subRoadName:
'
+
data
[
0
].
subRoadName
);
console
.
info
(
"
[lbs_js] Location callback exit .
"
);
}
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
* @tc.name testisGeoServiceAvailable promise
* @tc.desc Test isGeoServiceAvailable api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_isGeoServiceAvailable_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
console
.
info
(
'
LBS getGeoServiceState promise test start ...
'
);
await
geolocation
.
isGeoServiceAvailable
().
then
(
(
result
)
=>
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] getGeoServiceState promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
done
();
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_CALLBACK_0001
* @tc.name testisLocationEnabled callback
* @tc.desc Test isLocationEnabled api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_isLocationEnabled_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
let
promiseOne
=
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
resolve
()
});
})
let
promiseTwo
=
new
Promise
((
resolve
,
reject
)
=>
{
console
.
info
(
'
LBS getLocationSwitchState callback test start ...
'
);
geolocation
.
isLocationEnabled
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getLocationSwitchState :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] getLocationSwitchState data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] getLocationSwitchState callback exit .
"
);
}
resolve
()
});
})
await
promiseOne
.
then
(()
=>
{
return
promiseTwo
}).
then
(
done
)
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_PROMISE_0001
* @tc.name testgetAddressesFromLocationName promise
* @tc.desc Test getAddressesFromLocationName api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_getAddressesFromLocationName_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation promise test start ...
'
);
await
geolocation
.
enableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] testenableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
console
.
info
(
'
LBS getAddressesFromLocationName promise test start ...
'
);
var
geocodeRequest
=
{
"
description
"
:
"
上海市浦东新区金穗路1800号
"
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
result
))
!=
null
);
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocationName promise then error.
"
+
error
);
expect
().
assertFail
();
});
done
();
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testrequestEnableLocation callback
* @tc.desc Test requestEnableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_requestEnableLocation_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS requestEnableLocation callback test start ...
'
);
geolocation
.
requestEnableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] requestEnableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] requestEnableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] requestEnableLocation callback exit .
"
);
}
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001
* @tc.name testrequestEnableLocation promise
* @tc.desc Test requestEnableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_requestEnableLocation_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS requestEnableLocation promise test start ...
'
);
await
geolocation
.
requestEnableLocation
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] requestEnableLocation result:
'
+
result
);
expect
(
result
).
assertTrue
();
console
.
info
(
"
[lbs_js] requestEnableLocation promise.
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
done
()
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001
* @tc.name testEnableLocation callback
* @tc.desc Test enableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_enableLocation_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
done
()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001
* @tc.name testdisableLocation callback
* @tc.desc Test disableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_disableLocation_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS disableLocation callback test start ...
'
);
geolocation
.
disableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] disableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] disableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] disableLocation callback exit .
"
);
}
done
()
});
})
/** @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_PROMISE_0001
* @tc.name testdisableLocation promise
* @tc.desc Test disableLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_disableLocation_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[lbs_js]LBS disableLocation promise test start ...
'
);
geolocation
.
disableLocation
().
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] disableLocation data:
'
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] disableLocation promise exit
"
);
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_PROMISE_0001
* @tc.name testgetAddressesFromLocation promise
* @tc.desc Test getAddressesFromLocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_getAddressesFromLocation_promise_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS getAddressesFromLocation promise test start ...
'
);
var
reverseGeocodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise exit.
"
);
done
();
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
* @tc.name testGetCurrentlocation callback
* @tc.desc Test GetCurrentlocation api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_GetCurrentlocation_callback_test_001
'
,
0
,
async
function
(
done
)
{
var
locationEventListener
=
new
LocationEventListener
();
var
requestInfo
=
{
"
priority
"
:
0x0203
,
"
scenario
"
:
0x0300
,
"
timeInterval
"
:
5
,
"
distanceInterval
"
:
0
,
"
maxAccuracy
"
:
0
};
locationEventListener
.
getCurrentLocation
(
requestInfo
,
result
=>
{
console
.
info
(
"
getCurrentLocation callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_CALLBACK_0001
* @tc.name testisGeoServiceAvailable callback
* @tc.desc Test isGeoServiceAvailable api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_isGeoServiceAvailable_callback_test_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
let
promiseOne
=
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
resolve
()
});
})
console
.
info
(
'
LBS getGeoServiceState callback test start ...
'
)
let
promiseTwo
=
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
isGeoServiceAvailable
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] getGeoServiceState err is :
'
+
err
);
}
else
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable result:
'
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] getGeoServiceState callback exit .
"
);
}
resolve
()
});
})
await
promiseOne
.
then
(()
=>
{
return
promiseTwo
}).
then
(
done
)
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
* @tc.name testlocationChangeOn promise
* @tc.desc Test locationChangeOn api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_locationChange_On_test_002
'
,
0
,
async
function
(
done
)
{
var
locationEventListener
=
new
LocationEventListener
();
console
.
info
(
'
LBS locationChange_On callback test start ...
'
);
var
requestInfo
=
{
"
priority
"
:
0x0203
,
"
scenario
"
:
0x0300
,
"
timeInterval
"
:
5
,
"
distanceInterval
"
:
0
,
"
maxAccuracy
"
:
0
};
await
locationEventListener
.
on
(
'
locationChange
'
,
requestInfo
,
result
=>
{
console
.
info
(
"
onLocationChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
done
()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
* @tc.name testOnLocationServiceState
* @tc.desc Test OnLocationServiceState api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_OnLocationServiceState_test_001
'
,
0
,
async
function
(
done
)
{
var
locationEventListener
=
new
LocationEventListener
();
console
.
info
(
'
LBS OnLocationServiceState test start ...
'
);
await
locationEventListener
.
on
(
'
locationServiceState
'
,
result
=>
{
console
.
info
(
"
onlocationServiceState callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
done
()
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
* @tc.name testOnLocationServiceState
* @tc.desc Test offLocationServiceState api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_offLocationServiceState_test_001
'
,
0
,
async
function
(
done
)
{
var
locationEventListener
=
new
LocationEventListener
();
console
.
info
(
'
LBS OnLocationServiceState test start ...
'
);
await
locationEventListener
.
on
(
'
locationServiceState
'
,
result
=>
{
console
.
info
(
"
onlocationServiceState callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
done
()
});
console
.
info
(
'
LBS disableLocation callback test start ...
'
);
geolocation
.
disableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] disableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] disableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] disableLocation callback exit .
"
);
}
done
()
});
console
.
info
(
'
LBS offLocationServiceState test start ...
'
);
locationEventListener
.
off
(
'
locationServiceState
'
,
result
=>
{
console
.
info
(
"
offlocationServiceState callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
})
/**
* @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
* @tc.name testlocationChangeOff promise
* @tc.desc Test locationChangeoff api .
* @tc.author wangsilu wwx1075324
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
geolocation_locationChange_Off_test_002
'
,
0
,
async
function
(
done
)
{
var
locationEventListener
=
new
LocationEventListener
();
console
.
info
(
'
LBS locationChange_On callback test start ...
'
);
var
requestInfo
=
{
"
priority
"
:
0x0203
,
"
scenario
"
:
0x0300
,
"
timeInterval
"
:
5
,
"
distanceInterval
"
:
0
,
"
maxAccuracy
"
:
0
};
locationEventListener
.
on
(
'
locationChange
'
,
requestInfo
,
result
=>
{
console
.
info
(
"
onLocationChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
console
.
info
(
'
LBS enableLocation callback test start ...
'
);
geolocation
.
enableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] enableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] enableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] enableLocation callback exit .
"
);
}
done
()
});
console
.
info
(
'
LBS disableLocation callback test start ...
'
);
geolocation
.
disableLocation
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
[lbs_js] disableLocation callback err is :
'
+
err
);
}
else
{
console
.
info
(
"
[lbs_js] disableLocation callback data:
"
+
data
);
expect
(
data
).
assertTrue
();
console
.
info
(
"
[lbs_js] disableLocation callback exit .
"
);
}
done
()
});
console
.
info
(
'
LBS locationChange_Off test2 start ...
'
);
locationEventListener
.
off
(
'
locationChange
'
,
result
=>
{
console
.
info
(
"
[lbs_js] offlocationChange callback result
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
})
})
location/geolocation_standard/src/main/js/default/test/List.test.js
0 → 100644
浏览文件 @
5863093a
/*
* Copyright (C) 2021 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.
*/
require
(
'
./Geolocation.test.js
'
)
location/geolocation_standard/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
5863093a
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"OsAccountTest"
},
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
location/geolocation_standard/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
5863093a
6.6 KB
test_packages.gni
浏览文件 @
5863093a
...
...
@@ -39,6 +39,7 @@ _all_test_packages = [
"${ACTS_ROOT}/resourceschedule:resourceschedule",
"${ACTS_ROOT}/telephony:telephony",
"${ACTS_ROOT}/hiviewdfx:hiviewdfxtestacts",
"${ACTS_ROOT}/location:location",
]
_all_test_packages_ivi = [
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录