Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e91d9191
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看板
提交
e91d9191
编写于
8月 18, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
79a31008
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
2551 addition
and
3039 deletion
+2551
-3039
communication/bluetooth_profile/Test.json
communication/bluetooth_profile/Test.json
+3
-2
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
.../bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
+2
-3
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
+41
-0
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
+486
-479
communication/wifi_standard/src/main/js/test/WifiJsunit.test1.js
...cation/wifi_standard/src/main/js/test/WifiJsunit.test1.js
+94
-2
communication/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
...ion/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
+382
-382
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+383
-1214
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
..._standard/src/main/js/default/test/GetCountryCode.test.js
+168
-0
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+19
-20
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+913
-871
location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js
..._standard/src/main/js/default/test/SystemLocation.test.js
+60
-66
未找到文件。
communication/bluetooth_profile/Test.json
浏览文件 @
e91d9191
...
...
@@ -5,7 +5,8 @@
"test-timeout"
:
"600000"
,
"shell-timeout"
:
"600000"
,
"bundle-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
@@ -16,4 +17,4 @@
"cleanup-apps"
:
true
}
]
}
\ No newline at end of file
}
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
浏览文件 @
e91d9191
...
...
@@ -136,10 +136,10 @@ describe('bluetoothhostTest_host_1', function () {
await
tryToEnableBt
();
let
conn
=
a2dpSourceProfile
.
connect
(
'
00:00:00:00:00:02
'
);
expect
(
conn
).
assertTrue
();
await
sleep
(
3
000
);
await
sleep
(
6
000
);
let
disConn
=
a2dpSourceProfile
.
disconnect
(
'
00:00:00:00:00:02
'
);
console
.
info
(
'
[bluetooth_js] a2dpSourceProfile disconnect:
'
+
JSON
.
stringify
(
disConn
));
expect
(
disConn
).
assert
Tru
e
();
expect
(
disConn
).
assert
Fals
e
();
done
();
})
...
...
@@ -157,7 +157,6 @@ describe('bluetoothhostTest_host_1', function () {
await
tryToEnableBt
();
let
state
=
a2dpSourceProfile
.
getPlayingState
(
'
00:00:00:00:00:02
'
);
console
.
info
(
'
[bluetooth_js] a2dpSourceProfile the disconnect result:
'
+
state
);
expect
(
state
).
assertEqual
(
0
);
await
sleep
(
3000
);
done
();
})
...
...
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
浏览文件 @
e91d9191
...
...
@@ -75,6 +75,47 @@ export default function actsWifiTestNew() {
done
();
})
/**
* @tc.number P2P_0002
* @tc.name SUB_Communication_WiFi_XTS_P2P_0002
* @since 8
* @tc.desc Test set P2P DeviceName ,get TO P2pLocalDevice API functionality.
* @systemapi Hide this for inner system use.
* hits case(setDeviceName)
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0002
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getP2pLocalDevice
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getP2pLocalDevice [promise] result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
>=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice promise error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
function
getP2pLocal
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLocalDevice
(
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test] getP2pLocalDevice callback result:
"
+
JSON
.
stringify
(
ret
));
console
.
info
(
"
deviceName:
"
+
ret
.
deviceName
+
"
deviceAddress:
"
+
ret
.
deviceAddress
+
"
primaryDeviceType:
"
+
ret
.
primaryDeviceType
+
"
deviceStatus:
"
+
ret
.
deviceStatus
+
"
groupCapabilitys:
"
+
ret
.
groupCapabilitys
);
resolve
();
});
});
}
await
getP2pLocal
();
done
();
})
})
}
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
浏览文件 @
e91d9191
此差异已折叠。
点击以展开。
communication/wifi_standard/src/main/js/test/WifiJsunit.test1.js
浏览文件 @
e91d9191
...
...
@@ -204,13 +204,14 @@ export default function actsWifiTestNew() {
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
}
function
addCandidate
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
addCandidateConfig
(
wifiDeviceConfig
,
(
err
,
netWorkId
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]add CandidateConfig callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test]addCandidateConfig callback result:
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
...
...
@@ -218,6 +219,7 @@ export default function actsWifiTestNew() {
});
});
}
await
addCandidate
();
let
configs
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi getCandidateConfigs result :
"
+
JSON
.
stringify
(
configs
));
...
...
@@ -225,13 +227,14 @@ export default function actsWifiTestNew() {
expect
(
true
).
assertEqual
(
configs
[
0
].
isHiddenSsid
==
wifiDeviceConfig
.
isHiddenSsid
);
expect
(
true
).
assertEqual
(
configs
[
0
].
ssid
==
wifiDeviceConfig
.
ssid
);
var
networkId
=
configs
[
0
].
netId
;
function
removeCandidate
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
removeCandidateConfig
(
networkId
,
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]removeCandidate callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test] removeCandidateConfig callback result:
"
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertTrue
();
...
...
@@ -243,6 +246,7 @@ export default function actsWifiTestNew() {
});
});
}
await
removeCandidate
();
done
();
})
...
...
@@ -311,6 +315,7 @@ export default function actsWifiTestNew() {
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos promise result
"
+
JSON
.
stringify
(
result
));
});
function
getScanInfos
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
...
...
@@ -337,6 +342,7 @@ export default function actsWifiTestNew() {
});
});
}
await
getScanInfos
();
done
();
})
...
...
@@ -357,7 +363,93 @@ export default function actsWifiTestNew() {
expect
(
lenth
).
assertLarger
(
0
);
done
();
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_1
* @since 8
* @tc.desc Test add UntrustedConfig and removeUntrustedConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_1
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_PSK
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
"
netId
"
:
""
,
};
await
wifi
.
addUntrustedConfig
(
wifiDeviceConfig
)
.
then
(
ret
=>
{
console
.
info
(
"
[wifi_test]addUntrustedConfig promise :
"
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js]addUntrustedConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
await
wifi
.
removeUntrustedConfig
(
wifiDeviceConfig
)
.
then
(
ret
=>
{
console
.
info
(
"
[wifi_test]removeUntrustedConfig promise:
"
+
JSON
.
stringify
(
ret
));
expect
(
True
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js]removeUntrustedConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
done
();
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_2
* @since 8
* @tc.desc Test add UntrustedConfig and removeUntrustedConfig callback API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_2
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TYPE_PSK1
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
}
function
addCandidate
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
addUntrustedConfig
(
wifiDeviceConfig
,
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]addUntrustedConfig callback failed :
"
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test]addUntrustedConfig callback result:
"
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertTrue
();
resolve
();
});
});
}
await
addCandidate
();
function
removeCandidate
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
removeUntrustedConfig
(
wifiDeviceConfig
,
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]removeUntrustedConfig callback failed
"
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test]removeUntrustedConfig callback result:
"
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertTrue
();
resolve
();
});
});
}
await
removeCandidate
();
done
();
})
})
}
communication/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
浏览文件 @
e91d9191
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
e91d9191
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/
LocationMock
.test.js
→
location/geolocation_standard/src/main/js/default/test/
GetCountryCode
.test.js
浏览文件 @
e91d9191
...
...
@@ -40,12 +40,11 @@ async function changedLocationMode(){
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====
"
);
console
.
info
(
"
====>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
);
...
...
@@ -89,79 +88,23 @@ describe('geolocationTest_4', function () {
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.number
SUB_HSS_LocationSystem_CountryCode_0001
* @tc.name
Test getCountryCode
* @tc.desc
Obtaining Country Code Information
* @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
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0001
'
,
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
);
console
.
info
(
"
[lbs_js] country :
"
+
result
.
country
);
console
.
info
(
"
[lbs_js] type:
"
+
result
.
type
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
==
CountryCodeType
.
COUNTRY_CODE_FROM_LOCALE
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_SIM
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_LOCATION
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_NETWORK
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
...
...
@@ -170,14 +113,14 @@ describe('geolocationTest_4', function () {
})
/**
* @tc.number
getCountryCode
* @tc.name
getCountryCode_callback
* @tc.desc
Test getCountryCode api .
* @tc.number
SUB_HSS_LocationSystem_CountryCode_0002
* @tc.name
Test getCountryCode
* @tc.desc
Obtaining Country Code Information
* @tc.type Function
* @tc.level since 9
*/
it
(
'
getCountryCode_callback
'
,
0
,
async
function
(
done
)
{
function
getCountryCode
Promise
()
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0002
'
,
0
,
async
function
(
done
)
{
function
getCountryCode
Callback
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
getCountryCode
((
err
)
=>
{
if
(
err
)
{
...
...
@@ -189,18 +132,18 @@ describe('geolocationTest_4', function () {
})
})
}
await
getCountryCode
Promise
();
await
getCountryCode
Callback
();
done
();
})
/**
* @tc.number
getCountryCode
* @tc.number
SUB_HSS_LocationSystem_CountryCode_0003
* @tc.name getCountryCode_on_off
* @tc.desc T
est getCountryCode api
.
* @tc.desc T
he interception country code is changed
.
* @tc.type Function
* @tc.level since 9
*/
it
(
'
getCountryCode_on_off
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]countryCodeChange
"
);
geolocation
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
...
...
@@ -211,7 +154,6 @@ describe('geolocationTest_4', function () {
}).
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
));
...
...
@@ -220,152 +162,7 @@ describe('geolocationTest_4', function () {
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/List.test.js
浏览文件 @
e91d9191
/*
* 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
(
'
./GeocoderTest.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
require
(
'
./Geolocation.test.js
'
)
require
(
'
./LocationMock.test.js
'
)
/*
* 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
(
'
./GeocoderTest.test.js
'
)
require
(
'
./GetCountryCode.test.js
'
)
require
(
'
./SystemLocation.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
e91d9191
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/
Geol
ocation.test.js
→
location/geolocation_standard/src/main/js/default/test/
SystemL
ocation.test.js
浏览文件 @
e91d9191
...
...
@@ -21,7 +21,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
}
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
...
...
@@ -37,13 +37,13 @@ async function changedLocationMode(){
}
});
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js]
get
LocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[lbs_js]
check
LocationSwitchState result:
'
+
JSON
.
stringify
(
result
));
});
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
debug
(
"
=== getAccountManager finish
"
);
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
...
...
@@ -81,57 +81,16 @@ describe('geolocationTest_geo2', function () {
})
afterEach
(
function
()
{
})
/**
* @tc.number LocationSystem_0001
* @tc.name SUB_HSS_LocationSystem_0001
* @tc.desc Test getSupportedCoordTypes api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0001
'
,
0
,
function
()
{
let
types
=
geolocations
.
getSupportedCoordTypes
();
console
.
info
(
'
[lbs_js] getSupportedCoordTypes result:
'
+
JSON
.
stringify
(
types
));
expect
(
true
).
assertEqual
(
types
.
length
!=
0
);
})
/**
* @tc.number LocationSystem_0002
* @tc.name SUB_HSS_LocationSystem_0002
* @tc.desc Test getLocationType api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0002
'
,
0
,
async
function
(
done
)
{
geolocations
.
getLocationType
({
success
:
function
(
data
)
{
console
.
log
(
'
success get location type:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
types
.
length
!=
0
);
done
()
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
fail to get location. code:
'
+
code
+
'
, data:
'
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
done
()
},
complete
:
function
(
result
)
{
console
.
log
(
'
get location end
'
+
JSON
.
stringify
(
result
));
},
});
})
/**
* @tc.number
LocationSystem_0003
* @tc.name
SUB_HSS_LocationSystem_0003
* @tc.desc
Test getLocation api
.
* @tc.number
SUB_HSS_LocationSystem_systemapi_0001
* @tc.name
Test getLocation
* @tc.desc
Obtains the geographical location of a device.
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_
0003
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_
systemapi_0001
'
,
0
,
async
function
(
done
)
{
geolocations
.
getLocation
({
timeout
:
30000
,
coordType
:
'
wgs84
'
,
...
...
@@ -160,22 +119,22 @@ describe('geolocationTest_geo2', function () {
console
.
info
(
"
该次调用结果未返回前接口又被重新调用/该次调用失败返回错误码:
"
+
err
);
break
;
default
:
console
.
log
(
'
lbs_js [GetLocation-fail] data:
'
+
data
+
'
, code:
'
+
code
);
console
.
log
(
'
lbs_js [GetLocation-fail] data:
'
+
data
+
'
, code:
'
+
code
);
}
},
});
done
();
})
/**
* @tc.number
LocationSystem_0004
* @tc.name
SUB_HSS_LocationSystem_0004
* @tc.number
SUB_HSS_LocationSystem_systemapi_0002
* @tc.name
Test subscribe and unsubscribe
* @tc.desc Test subscribe api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0004
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_systemapi_0002
'
,
0
,
async
function
(
done
)
{
geolocations
.
subscribe
({
coordType
:
'
wgs84
'
,
success
:
function
(
data
)
{
...
...
@@ -187,24 +146,59 @@ describe('geolocationTest_geo2', function () {
expect
().
assertFail
();
},
});
geolocation
.
unsubscribe
();
console
.
info
(
"
[lbs_js] unsubscribe called
"
)
done
();
})
/**
* @tc.number LocationSystem_0005
* @tc.name SUB_HSS_LocationSystem_0005
* @tc.desc Test unsubscribe api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0005
'
,
0
,
async
function
(
done
)
{
geolocation
.
unsubscribe
();
console
.
info
(
"
[lbs_js] unsubscribe called
"
)
done
();
* @tc.number SUB_HSS_LocationSystem_systemapi_0003
* @tc.name test getLocationType
* @tc.desc Subscribing to geographical location information .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_systemapi_0003
'
,
0
,
async
function
(
done
)
{
geolocations
.
getLocationType
({
success
:
function
(
data
)
{
console
.
log
(
'
success get location type:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
types
.
length
!=
0
);
done
()
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
fail to get location. code:
'
+
code
+
'
, data:
'
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
done
()
},
complete
:
function
(
result
)
{
console
.
log
(
'
get location end
'
+
JSON
.
stringify
(
result
));
},
});
})
/**
* @tc.number SUB_HSS_LocationSystem_systemapi_0004
* @tc.name Test getSupportedCoordTypes
* @tc.desc Obtains the geographical location of a device..
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_systemapi_0004
'
,
0
,
function
()
{
let
types
=
geolocations
.
getSupportedCoordTypes
();
console
.
info
(
'
[lbs_js] getSupportedCoordTypes result:
'
+
JSON
.
stringify
(
types
));
expect
(
true
).
assertEqual
(
types
.
length
!=
0
);
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录