Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
cd58d0a0
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看板
提交
cd58d0a0
编写于
8月 21, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updata 0906
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
8e413a0f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
339 addition
and
441 deletion
+339
-441
communication/wifi_p2p/Test.json
communication/wifi_p2p/Test.json
+2
-1
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
...ication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
+226
-285
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
...fi_standard/src/main/js/test/WifiCandidateNetWork.test.js
+3
-7
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+39
-75
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
...fi_standard/src/main/js/test/WifiStationFunctions.test.js
+61
-56
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
..._standard/src/main/js/default/test/GetCountryCode.test.js
+3
-2
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+5
-15
未找到文件。
communication/wifi_p2p/Test.json
浏览文件 @
cd58d0a0
...
...
@@ -4,6 +4,7 @@
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
"600000"
,
"bundle-name"
:
"ohos.acts.communication.wifi.wifidevice"
,
"package-name"
:
"ohos.acts.communication.wifi.wifidevice"
},
...
...
@@ -16,4 +17,4 @@
"cleanup-apps"
:
true
}
]
}
\ No newline at end of file
}
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
浏览文件 @
cd58d0a0
...
...
@@ -43,8 +43,8 @@ export default function actsWifiFunctionTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0003
* @tc.name test
c
reateGroup
* @tc.desc Test createGroup and getCurrentGroup
infos
* @tc.name test
C
reateGroup
* @tc.desc Test createGroup and getCurrentGroup
API Function
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -54,47 +54,57 @@ export default function actsWifiFunctionTest() {
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
log
(
"
[wifi_test]c
heck the state of wifi
:
"
+
JSON
.
stringify
(
createGroupResult
));
console
.
log
(
"
[wifi_test]c
reateGroup result
:
"
+
JSON
.
stringify
(
createGroupResult
));
await
sleep
(
2000
);
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
expect
(
true
).
assertEqual
(
data
.
groupName
==
wifiP2PConfig
.
groupName
);
});
wifi
.
getCurrentGroup
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
[wifi_test]failed to get getCurrentGroup:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
}
else
{
console
.
info
(
"
[wifi_test]getCurrentGroup callback:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
isP2pGo:
"
+
result
.
isP2pGo
+
"
deviceName:
"
+
result
.
ownerInfo
.
deviceName
+
"
deviceAddress:
"
+
result
.
ownerInfo
.
deviceAddress
+
"
primaryDeviceType:
"
+
result
.
ownerInfo
.
primaryDeviceType
+
"
deviceStatus:
"
+
result
.
ownerInfo
.
deviceStatus
+
"
groupCapabilitys:
"
+
result
.
ownerInfo
.
groupCapabilitys
+
"
passphrase:
"
+
result
.
passphrase
+
"
interface:
"
+
result
.
interface
+
"
groupName:
"
+
result
.
groupName
+
"
frequency:
"
+
result
.
frequency
+
"
goIpAddress:
"
+
result
.
goIpAddress
);
}
function
getCurrentGroupResult
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getCurrentGroup
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]failed to get getCurrentGroup:
"
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
}
console
.
info
(
"
[wifi_test]getCurrentGroup callback:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
isP2pGo:
"
+
result
.
isP2pGo
+
"
deviceName:
"
+
result
.
ownerInfo
.
deviceName
+
"
deviceAddress:
"
+
result
.
ownerInfo
.
deviceAddress
+
"
primaryDeviceType:
"
+
result
.
ownerInfo
.
primaryDeviceType
+
"
deviceStatus:
"
+
result
.
ownerInfo
.
deviceStatus
+
"
groupCapabilitys:
"
+
result
.
ownerInfo
.
groupCapabilitys
+
"
passphrase:
"
+
result
.
passphrase
+
"
interface:
"
+
result
.
interface
+
"
groupName:
"
+
result
.
groupName
+
"
frequency:
"
+
result
.
frequency
+
"
goIpAddress:
"
+
result
.
goIpAddress
);
resolve
();
});
});
}
await
getCurrentGroupResult
();
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0004
* @tc.name test
c
reateGroup
* @tc.desc Test
set password createGroup API
Function.
* @tc.name test
C
reateGroup
* @tc.desc Test
createGroup-Setting a 7-bit Key
Function.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -106,7 +116,7 @@ export default function actsWifiFunctionTest() {
netId
:
-
1
,
passphrase
:
"
1234567
"
,
groupName
:
"
test_pass
"
,
goBand
:
0
,
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup end.
"
+
JSON
.
stringify
(
createGroupResult
));
...
...
@@ -116,16 +126,23 @@ export default function actsWifiFunctionTest() {
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
expect
(
true
).
assertEqual
(
data
.
networkId
==
-
999
);
});
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0104
* @tc.name test
c
reateGroup
* @tc.desc Test
set password createGroup API
Function.
* @tc.name test
C
reateGroup
* @tc.desc Test
createGroup-Key setting: Chinese, English, and characters
Function.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -137,7 +154,7 @@ export default function actsWifiFunctionTest() {
netId
:
-
1
,
passphrase
:
"
123@%abcD
"
,
groupName
:
"
test_pass1
"
,
goBand
:
0
,
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup end.
"
+
JSON
.
stringify
(
createGroupResult
));
...
...
@@ -145,18 +162,24 @@ export default function actsWifiFunctionTest() {
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
expect
(
true
).
assertEqual
(
data
.
passphrase
==
wifiP2PConfig
.
passphrase
);
});
done
()
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0204
* @tc.name test
c
reateGroup
* @tc.desc Test
set password createGroup API
Function.
* @tc.name test
C
reateGroup
* @tc.desc Test
createGroup-Key setting 64 bit
Function.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -166,9 +189,9 @@ export default function actsWifiFunctionTest() {
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc345678901234567890123456789012345678901234567890123456789012
3
"
,
passphrase
:
"
abc345678901234567890123456789012345678901234567890123456789012
"
,
groupName
:
"
test_pass2
"
,
goBand
:
0
,
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup end.
"
+
JSON
.
stringify
(
createGroupResult
));
...
...
@@ -176,18 +199,24 @@ export default function actsWifiFunctionTest() {
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
expect
(
true
).
assertEqual
(
data
.
passphrase
==
wifiP2PConfig
.
passphrase
);
});
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
()
done
()
;
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0304
* @tc.name test
c
reateGroup
* @tc.desc Test
set password createGroup API
Function.
* @tc.name test
C
reateGroup
* @tc.desc Test
createGroup-Key setting 65 bits
Function.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -197,9 +226,9 @@ export default function actsWifiFunctionTest() {
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc3456789012345678901234567890123456789012345678901234567890123
4
"
,
passphrase
:
"
abc3456789012345678901234567890123456789012345678901234567890123
"
,
groupName
:
"
test_pass3
"
,
goBand
:
0
,
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup end.
"
+
JSON
.
stringify
(
createGroupResult
));
...
...
@@ -207,248 +236,145 @@ export default function actsWifiFunctionTest() {
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
expect
(
true
).
assertEqual
(
data
.
passphrase
!=
wifiP2PConfig
.
passphrase
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0007
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0007
'
,
0
,
async
function
(
done
)
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
1
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test createGroup3 result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
1
07
* @tc.name test
sethotspot
* @tc.desc Test createGroup
band setting infos
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
0
07
* @tc.name test
CreateGroup
* @tc.desc Test createGroup
-2.4 GHz frequency band setting Function
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0107
'
,
0
,
async
function
(
done
)
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
2
,
};
it
(
'
SUB_Communication_WiFi_XTS_P2P_0007
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
await
(
2000
);
console
.
info
(
"
[wifi_test]test createGroup3 result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0207
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0207
'
,
0
,
async
function
(
done
)
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
,
groupName
:
"
test_band1
"
,
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test]
test createGroup3
result.
"
+
createGroupResult
)
console
.
info
(
"
[wifi_test]
test createGroup
result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
frequency
==
2412
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0307
* @tc.name testsethotspot
* @tc.desc Test createGroup band setting infos
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0307
'
,
0
,
async
function
(
done
)
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
3
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test]test createGroup3 result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
008
* @tc.name test
sethotspot
* @tc.desc Test create
P2P error SSID Group functionality.
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
107
* @tc.name test
CreateGroup
* @tc.desc Test create
Group-5 GHz frequency band setting Function
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0008
'
,
0
,
async
function
(
done
)
{
let
groupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
it
(
'
SUB_Communication_WiFi_XTS_P2P_0107
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
try
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band2
"
,
goBand
:
groupOwnerBand
.
GO_BAND_5GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test]test createGroup result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
frequency
==
5745
);
});
let
removeGroupResult
=
await
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
}
catch
(
error
){
console
.
info
(
"
[wifi_test]createGroup 5G goBand result :
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
(
(
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
""
,
goBand
:
0
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup result:
"
+
JSON
.
stringify
(
createGroupResult
));
await
sleep
(
2000
);
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
108
* @tc.name test
sethotspot
* @tc.desc Test create
P2P error SSID Group functionality.
* @tc.number SUB_Communication_WiFi_XTS_P2P_0
207
* @tc.name test
CreateGroup
* @tc.desc Test create
Group-Auto frequency band setting Function
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0108
'
,
0
,
async
function
(
done
)
{
let
groupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
"
,
goBand
:
0
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup result:
"
+
JSON
.
stringify
(
createGroupResult
));
await
sleep
(
2000
);
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0308
* @tc.name testsethotspot
* @tc.desc Test create P2P error SSID Group functionality.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0308
'
,
0
,
async
function
(
done
)
{
let
groupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
it
(
'
SUB_Communication_WiFi_XTS_P2P_0207
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
try
{
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band3
"
,
goBand
:
groupOwnerBand
.
GO_BAND_AUTO
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test]test createGroup result.
"
+
createGroupResult
)
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
frequency
!=
null
);
});
let
removeGroupResult
=
await
wifi
.
removeGroup
();
await
sleep
(
2000
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
}
catch
(
error
){
console
.
info
(
"
[wifi_test]createGroup auto goBand result :
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
(
(
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
wifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
"
,
groupName
:
"
testpassword
"
,
goBand
:
0
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test createGroup result:
"
+
JSON
.
stringify
(
createGroupResult
));
await
sleep
(
2000
);
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
let
removeGroupResult
=
wifi
.
removeGroup
();
expect
(
removeGroupResult
).
assertTrue
();
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0009
* @tc.name test
p
2pCancelConnect
* @tc.desc Test p2pCancelConnect Group
API functionality.
* @tc.name test
P
2pCancelConnect
* @tc.desc Test p2pCancelConnect Group API functionality.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -458,7 +384,7 @@ export default function actsWifiFunctionTest() {
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
goBand
:
0
goBand
:
groupOwnerBand
.
GO_BAND_2GHZ
,
};
let
p2pConnectResult
=
wifi
.
p2pConnect
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test p2pConnect result.
"
+
p2pConnectResult
);
...
...
@@ -469,13 +395,18 @@ export default function actsWifiFunctionTest() {
let
removeGroupResult
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test]test start removeGroup:
"
+
removeGroupResult
);
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0011
* @tc.name test
r
emoveGroup
* @tc.desc Test remove
error Group functionality
.
* @tc.name test
R
emoveGroup
* @tc.desc Test remove
a nonexistent group
.
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -483,22 +414,26 @@ export default function actsWifiFunctionTest() {
let
removeGroupResult
=
wifi
.
removeGroup
(
10000
);
console
.
info
(
"
[wifi_test]removeGroup(10000) result :
"
+
JSON
.
stringify
(
removeGroupResult
));
expect
(
removeGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result1 :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
deviceName
==
null
);
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0002
* @tc.name testP2pLocalDevice
* @tc.desc Test get
TO
P2pLocalDevice API functionality.
* @tc.desc Test get P2pLocalDevice API functionality.
* @tc.type Function
* @tc.level Level 3
*/
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
);
expect
(
true
).
assertEqual
(
data
.
deviceName
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice promise error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
...
...
@@ -526,8 +461,8 @@ export default function actsWifiFunctionTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0010
* @tc.name test
g
etP2pLinkedInfo
* @tc.desc Test
Test getP2pLinkedInfo infos
* @tc.name test
G
etP2pLinkedInfo
* @tc.desc Test
getP2pLinkedInfo API functionality
* @tc.type Function
* @tc.level Level 2
*/
...
...
@@ -543,7 +478,7 @@ export default function actsWifiFunctionTest() {
expect
(
true
).
assertEqual
(
resultLength
!=
0
);
done
()
});
function
getP2p
Info
(){
function
getP2p
LinkedInfoResult
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLinkedInfo
(
(
err
,
result
)
=>
{
...
...
@@ -561,14 +496,14 @@ export default function actsWifiFunctionTest() {
});
});
}
await
getP2p
Info
();
await
getP2p
LinkedInfoResult
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0001
* @tc.name test
g
etP2pPeerDevices
* @tc.desc Test getP2pPeerDevices promise
infos
* @tc.name test
G
etP2pPeerDevices
* @tc.desc Test getP2pPeerDevices promise
API functionality
* @tc.type Function
* @tc.level Level 0
*/
...
...
@@ -594,8 +529,8 @@ export default function actsWifiFunctionTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0101
* @tc.name test
g
etP2pPeerDevices
* @tc.desc Test getP2pPeerDevices callback
infos
* @tc.name test
G
etP2pPeerDevices
* @tc.desc Test getP2pPeerDevices callback
API functionality
* @tc.type Function
* @tc.level Level 0
*/
...
...
@@ -612,40 +547,46 @@ export default function actsWifiFunctionTest() {
let
startDiscover
=
wifi
.
startDiscoverDevices
();
await
sleep
(
2000
);
expect
(
startDiscover
).
assertTrue
();
await
wifi
.
getP2pPeerDevices
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
[wifi_test]failed to getP2pPeerDevices infos callback:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[wifi_test] getP2pPeerDevices callback :
"
+
JSON
.
stringify
(
result
));
let
len
=
Object
.
keys
(
result
).
length
;
for
(
let
j
=
0
;
j
<
len
;
++
j
)
{
console
.
info
(
"
deviceName:
"
+
result
[
j
].
deviceName
+
"
deviceAddress:
"
+
result
[
j
].
deviceAddress
+
"
primaryDeviceType:
"
+
result
[
j
].
primaryDeviceType
+
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
+
"
groupCapabilitys:
"
+
result
[
j
].
groupCapabilitys
);
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
UNAVAILABLE
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
CONNECTED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
INVITED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
FAILED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
AVAILABLE
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
}
let
stopDiscover
=
wifi
.
stopDiscoverDevices
();
expect
(
stopDiscover
).
assertTrue
();
}
done
();
function
getP2pPeerDevicesResult
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pPeerDevices
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
[wifi_test]failed to getP2pPeerDevices :
'
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test] getP2pPeerDevices callback result :
"
+
JSON
.
stringify
(
result
));
let
len
=
Object
.
keys
(
result
).
length
;
for
(
let
j
=
0
;
j
<
len
;
++
j
)
{
console
.
info
(
"
deviceName:
"
+
result
[
j
].
deviceName
+
"
deviceAddress:
"
+
result
[
j
].
deviceAddress
+
"
primaryDeviceType:
"
+
result
[
j
].
primaryDeviceType
+
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
+
"
groupCapabilitys:
"
+
result
[
j
].
groupCapabilitys
);
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
UNAVAILABLE
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
CONNECTED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
INVITED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
FAILED
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
if
(
result
[
j
].
deviceStatus
==
p2pDeviceStatus
.
AVAILABLE
){
console
.
info
(
"
deviceStatus:
"
+
result
[
j
].
deviceStatus
);
}
}
resolve
();
});
});
}
await
getP2pPeerDevicesResult
();
done
();
});
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
浏览文件 @
cd58d0a0
...
...
@@ -236,6 +236,7 @@ export default function actsWifiCandidateNetWorkTest() {
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_test]add 17th CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
error
==
-
1
);
});
let
getCandidateResult
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test]wifi get 16 CandidateConfigs result :
"
+
JSON
.
stringify
(
getCandidateResult
));
...
...
@@ -294,7 +295,6 @@ export default function actsWifiCandidateNetWorkTest() {
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]removeCandidate callback failed :
"
+
JSON
.
stringify
(
err
));
}
console
.
info
(
"
[wifi_test] removeCandidateConfig callback result:
"
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertTrue
();
...
...
@@ -348,7 +348,6 @@ export default function actsWifiCandidateNetWorkTest() {
await
wifi
.
getLinkedInfo
()
.
then
((
result
)
=>
{
console
.
info
(
"
[wifi_test]get wifi link [promise] ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
'
band
'
);
done
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]promise then error.
"
+
JSON
.
stringify
(
error
));
...
...
@@ -378,15 +377,13 @@ export default function actsWifiCandidateNetWorkTest() {
expect
(
ret
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_test]addUntrustedConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
await
wifi
.
removeUntrustedConfig
(
wifiDeviceConfig
)
.
then
(
ret
=>
{
console
.
info
(
"
[wifi_test]removeUntrustedConfig promise:
"
+
JSON
.
stringify
(
ret
));
expect
(
True
).
assertTrue
();
expect
(
ret
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_test]removeUntrustedConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
done
();
})
...
...
@@ -412,7 +409,6 @@ export default function actsWifiCandidateNetWorkTest() {
(
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
();
...
...
@@ -427,7 +423,6 @@ export default function actsWifiCandidateNetWorkTest() {
(
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
();
...
...
@@ -440,3 +435,4 @@ export default function actsWifiCandidateNetWorkTest() {
})
})
}
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
浏览文件 @
cd58d0a0
...
...
@@ -74,128 +74,92 @@ export default function actsWifiEventTest() {
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0001
* @tc.name test
w
ifiStateChange
* @tc.name test
W
ifiStateChange
* @tc.desc Test wifiStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0001
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiStateChange
'
,
async
result
=>
{
console
.
info
(
"
[wifi_test]wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
wifi
.
off
(
'
wifiStateChange
'
,
result
=>
{
console
.
info
(
"
[wifi_test]offwifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
wifiState
=
"
wifiStateChange
"
;
let
wifiStateChangeCallback
=
result
=>
{
console
.
info
(
"
[wifi_test]wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
}
wifi
.
on
(
wifiState
,
wifiStateChangeCallback
);
await
sleep
(
3000
);
wifi
.
off
(
wifiState
,
wifiStateChangeCallback
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0002
* @tc.name test
w
ifiConnectionChange
* @tc.name test
W
ifiConnectionChange
* @tc.desc Test wifiConnectionChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0002
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiConnectionChange
'
,
async
result
=>
{
console
.
info
(
"
[wifi_test]wifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiConnectionChange test start ...
'
);
wifi
.
off
(
'
wifiConnectionChange
'
,
result
=>
{
console
.
info
(
"
[wifi_test]offwifiConnectionChange callback result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
wifiConnectionState
=
"
wifiConnectionChange
"
;
let
wifiConnectionChangeCallback
=
result
=>
{
console
.
info
(
"
[wifi_test]wifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
}
wifi
.
on
(
wifiConnectionState
,
wifiConnectionChangeCallback
);
await
sleep
(
3000
);
wifi
.
off
(
wifiConnectionState
,
wifiConnectionChangeCallback
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0003
* @tc.name test
w
ifiScanStateChange
* @tc.desc Test
Test
wifiScanStateChange callback
* @tc.name test
W
ifiScanStateChange
* @tc.desc Test wifiScanStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0003
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiScanStateChange
'
,
async
result
=>
{
console
.
info
(
"
[wifi_test]wifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test]offwifiScanStateChange test start ...
'
);
wifi
.
off
(
'
wifiScanStateChange
'
,
result
=>
{
console
.
info
(
"
[wifi_test]offwifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
wifiScanState
=
"
wifiScanStateChange
"
;
let
wifiScanStateChangeCallback
=
result
=>
{
console
.
info
(
"
[wifi_test]wifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
}
wifi
.
on
(
wifiScanState
,
wifiScanStateChangeCallback
);
let
scanResult
=
wifi
.
scan
();
await
sleep
(
3000
);
wifi
.
off
(
wifiScanState
,
wifiScanStateChangeCallback
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0004
* @tc.name test
w
ifiRssiChange
* @tc.name test
W
ifiRssiChange
* @tc.desc Test wifiRssiChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0004
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
console
.
info
(
"
[wifi_test]wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiRssiChange test start ...
'
);
wifi
.
off
(
'
wifiRssiChange
'
,
result
=>
{
console
.
info
(
"
[wifi_test]offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
wifiRssiState
=
"
wifiRssiChange
"
;
let
wifiRssiChangeCallback
=
result
=>
{
console
.
info
(
"
[wifi_test]wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
}
wifi
.
on
(
wifiRssiState
,
wifiRssiChangeCallback
);
await
sleep
(
3000
);
wifi
.
off
(
wifiRssiState
,
wifiRssiChangeCallback
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0005
* @tc.name test
h
otspotStateChange
* @tc.name test
H
otspotStateChange
* @tc.desc Test hotspotStateChange api.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStateChange On test
"
);
try
{
await
wifi
.
on
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
console
.
info
(
"
[wifi_test]hotspotStateChange Off test
"
);
try
{
await
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange Off :
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
let
hotspotState
=
"
hotspotStateChange
"
;
let
hotspotStateChangeCallback
=
result
=>
{
console
.
info
(
"
[wifi_test]hotspotStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
}
wifi
.
on
(
hotspotState
,
hotspotStateChangeCallback
);
await
sleep
(
3000
);
wifi
.
off
(
hotspotState
,
hotspotStateChangeCallback
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
...
...
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
浏览文件 @
cd58d0a0
...
...
@@ -76,8 +76,8 @@ export default function actsWifiFunctionsTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name test
g
etScanInfos
* @tc.desc Test get
to
ScanInfos promise and callback API functionality.
* @tc.name test
G
etScanInfos
* @tc.desc Test getScanInfos promise and callback API functionality.
* @tc.type Function
* @tc.level Level 0
*/
...
...
@@ -87,10 +87,10 @@ export default function actsWifiFunctionsTest() {
await
wifi
.
getScanInfos
()
.
then
(
result
=>
{
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
expect
(
true
).
assertEqual
(
clen
>=
0
);
console
.
info
(
"
[wifi_test]getScanInfos promise result:
"
+
JSON
.
stringify
(
result
));
});
function
getScan
Infos
()
{
function
getScan
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
...
...
@@ -116,14 +116,14 @@ export default function actsWifiFunctionsTest() {
});
});
}
await
getScan
Infos
();
await
getScan
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0021
* @tc.name test
g
etSignalLevel
* @tc.desc Test get
SignalLevel
API functionality..
* @tc.name test
G
etSignalLevel
* @tc.desc Test get
SignalLevel
API functionality..
* @tc.type Function
* @tc.level Level 3
*/
...
...
@@ -230,14 +230,13 @@ export default function actsWifiFunctionsTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0004
* @tc.name test
g
etLinkedInfo
* @tc.name test
G
etLinkedInfo
* @tc.desc Test Test getLinkedInfo and getIpInfo information.
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0004
'
,
0
,
async
function
(
done
)
{
let
isConnectedResult
=
wifi
.
isConnected
();
expect
(
isConnectedResult
).
assertFalse
();
let
ipInfoResult
=
wifi
.
getIpInfo
();
expect
(
JSON
.
stringify
(
ipInfoResult
)).
assertContain
(
"
gateway
"
);
let
ipAddress
=
resolveIP
(
ipInfoResult
.
ipAddress
);
...
...
@@ -250,70 +249,76 @@ export default function actsWifiFunctionsTest() {
await
wifi
.
getLinkedInfo
()
.
then
((
result
)
=>
{
console
.
info
(
"
[wifi_test]get wifi link promise:
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
'
band
'
);
done
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
wifi
.
getLinkedInfo
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test]wifi getLinkedInfo failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test]getLinkedInfo callback result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
ssid:
"
+
result
.
ssid
+
"
bssid:
"
+
result
.
bssid
+
"
band:
"
+
result
.
band
+
"
isHidden:
"
+
result
.
isHidden
+
"
isRestricted:
"
+
result
.
isRestricted
+
"
chload:
"
+
result
.
chload
+
"
rssi
"
+
result
.
rssi
+
"
netWorkId:
"
+
result
.
netWorkId
+
"
linkSpeed:
"
+
result
.
linkSpeed
+
"
frequency:
"
+
result
.
frequency
+
"
snr:
"
+
result
.
snr
+
"
macAddress:
"
+
result
.
macAddress
+
"
ipAddress:
"
+
result
.
ipAddress
+
"
suppState:
"
+
result
.
suppState
+
"
connState:
"
+
result
.
connState
+
"
macType:
"
+
result
.
macType
);
let
state
=
wifi
.
getLinkedInfo
().
ConnState
;
if
(
state
==
connState
.
SCANNING
)
{
expect
(
true
).
assertEqual
(
state
==
0
);
}
if
(
state
==
connState
.
CONNECTING
)
{
expect
(
true
).
assertEqual
(
state
==
1
);
}
if
(
state
==
connState
.
AUTHENTICATING
)
{
expect
(
true
).
assertEqual
(
state
==
2
);
}
if
(
state
==
connState
.
OBTAINING_IPADDR
)
{
expect
(
true
).
assertEqual
(
state
==
3
);
}
if
(
state
==
connState
.
CONNECTED
)
{
expect
(
true
).
assertEqual
(
state
==
4
);
}
if
(
state
==
connState
.
DISCONNECTING
)
{
expect
(
true
).
assertEqual
(
state
==
5
);
}
if
(
state
==
connState
.
DISCONNECTED
)
{
expect
(
true
).
assertEqual
(
state
==
6
);
}
if
(
state
==
connState
.
UNKNOWN
)
{
expect
(
true
).
assertEqual
(
state
==
7
);
}
done
();
function
getLinked
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getLinkedInfo
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test]wifi getLinkedInfo failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test]getLinkedInfo callback result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
ssid:
"
+
result
.
ssid
+
"
bssid:
"
+
result
.
bssid
+
"
band:
"
+
result
.
band
+
"
isHidden:
"
+
result
.
isHidden
+
"
isRestricted:
"
+
result
.
isRestricted
+
"
chload:
"
+
result
.
chload
+
"
rssi
"
+
result
.
rssi
+
"
netWorkId:
"
+
result
.
netWorkId
+
"
linkSpeed:
"
+
result
.
linkSpeed
+
"
frequency:
"
+
result
.
frequency
+
"
snr:
"
+
result
.
snr
+
"
macAddress:
"
+
result
.
macAddress
+
"
ipAddress:
"
+
result
.
ipAddress
+
"
suppState:
"
+
result
.
suppState
+
"
connState:
"
+
result
.
connState
+
"
macType:
"
+
result
.
macType
);
let
state
=
wifi
.
getLinkedInfo
().
ConnState
;
if
(
state
==
connState
.
SCANNING
)
{
expect
(
true
).
assertEqual
(
state
==
0
);
}
if
(
state
==
connState
.
CONNECTING
)
{
expect
(
true
).
assertEqual
(
state
==
1
);
}
if
(
state
==
connState
.
AUTHENTICATING
)
{
expect
(
true
).
assertEqual
(
state
==
2
);
}
if
(
state
==
connState
.
OBTAINING_IPADDR
)
{
expect
(
true
).
assertEqual
(
state
==
3
);
}
if
(
state
==
connState
.
CONNECTED
)
{
expect
(
true
).
assertEqual
(
state
==
4
);
}
if
(
state
==
connState
.
DISCONNECTING
)
{
expect
(
true
).
assertEqual
(
state
==
5
);
}
if
(
state
==
connState
.
DISCONNECTED
)
{
expect
(
true
).
assertEqual
(
state
==
6
);
}
if
(
state
==
connState
.
UNKNOWN
)
{
expect
(
true
).
assertEqual
(
state
==
7
);
}
resolve
();
});
});
})
}
await
getLinked
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0034
* @tc.name test
g
etScanInfosSync
* @tc.name test
G
etScanInfosSync
* @tc.desc Test getScanInfos Sync API functionality.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0034
'
,
0
,
async
function
(
done
)
{
let
getScanInfosResult
=
wifi
.
getScanInfosSync
();
console
.
info
(
"
[wifi_test]wifi get
to
ScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfosResult
));
console
.
info
(
"
[wifi_test]wifi getScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfosResult
));
let
scanInfolenth
=
Object
.
keys
(
getScanInfosResult
).
length
;
console
.
info
(
"
[wifi_test]wifi ScanInfosSync length result :
"
+
JSON
.
stringify
(
scanInfolenth
));
expect
(
scanInfolenth
).
assertLarger
(
0
);
expect
(
true
).
assertEqual
(
scanInfolenth
>=
0
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
...
...
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
浏览文件 @
cd58d0a0
...
...
@@ -122,11 +122,12 @@ describe('geolocationTest_4', function () {
it
(
'
SUB_HSS_LocationSystem_CountryCode_0200
'
,
0
,
async
function
(
done
)
{
function
getCountryCodeCallback
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
getCountryCode
((
err
)
=>
{
geolocation
.
getCountryCode
((
err
,
data
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getCountryCode callback success
"
);
console
.
info
(
"
getCountryCode callback success
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
!=
null
);
}
resolve
();
})
...
...
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
cd58d0a0
...
...
@@ -164,6 +164,7 @@ describe('geolocationTest_geo3', function () {
}
geolocation
.
on
(
'
locationServiceState
'
,
locationServiceState
);
geolocation
.
off
(
'
locationServiceState
'
,
locationServiceState
);
expect
(
true
).
assertTrue
();
done
();
})
...
...
@@ -388,14 +389,14 @@ describe('geolocationTest_geo3', function () {
})
/**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_
01
00
* @tc.number SUB_HSS_LocationSystem_SingleLoc_
10
00
* @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request and set the location reporting precision.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_SingleLoc_
01
00
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_SingleLoc_
10
00
'
,
0
,
async
function
(
done
)
{
let
currentLocationRequest
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0300
,
"
timeoutMs
"
:
1000
,
"
maxAccuracy
"
:
5
};
let
currentLocationRequest1
=
{
"
priority
"
:
0x0200
,
"
scenario
"
:
0x0300
,
"
timeoutMs
"
:
1000
,
"
maxAccuracy
"
:
2
};
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
...
...
@@ -716,14 +717,14 @@ describe('geolocationTest_geo3', function () {
})
/**
* @tc.number SUB_HSS_LocationSystem_LocRequest_
01
00
* @tc.number SUB_HSS_LocationSystem_LocRequest_
10
00
* @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the reporting interval.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_LocRequest_
01
00
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_LocRequest_
10
00
'
,
0
,
async
function
(
done
)
{
enableLocationSwitch
();
let
requestInfo
=
{
"
priority
"
:
0x200
,
"
scenario
"
:
0x301
,
"
timeInterval
"
:
3
,
"
distanceInterval
"
:
0
,
"
maxAccuracy
"
:
0
};
...
...
@@ -1060,17 +1061,6 @@ describe('geolocationTest_geo3', function () {
"
distanceInterval
"
:
0
,
"
maxAccuracy
"
:
0
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
CachedGnssLoactionsRequest
,
cachedLocationsCb
);
geolocation
.
off
(
'
cachedGnssLocationsReporting
'
,
cachedLocationsCb
);
// geolocation.getCachedGnssLocationsSize((err, data) => {
// if (err) {
// console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + err);
// expect(true).assertTrue(err != null);
// done();
// }else {
// console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data));
// expect(true).assertTrue(data != null);
// done()
// }
// });
function
getCachedGnssLocationsSizeCallback
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
getCachedGnssLocationsSize
((
err
,
data
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录