Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
cd0907b4
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd0907b4
编写于
2月 20, 2022
作者:
Q
q00313334
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xts 3568 testcase runtime
Signed-off-by:
N
q00313334
<
quanli1@huawei.com
>
上级
18c54db7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
213 addition
and
253 deletion
+213
-253
communication/wifi_standard/src/main/js/default/test/WifiP2P.test.js
...on/wifi_standard/src/main/js/default/test/WifiP2P.test.js
+54
-61
communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js
...wifi_standard/src/main/js/default/test/WifiSoftAP.test.js
+66
-58
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
...on/wifi_standard/src/main/js/default/test/WifiSta.test.js
+93
-134
未找到文件。
communication/wifi_standard/src/main/js/default/test/WifiP2P.test.js
浏览文件 @
cd0907b4
...
...
@@ -17,20 +17,15 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
wifi
from
'
@ohos.wifi
'
// delay x ms
function
sleep
(
delay
)
{
var
start
=
(
new
Date
()).
getTime
();
while
(
true
){
if
((
new
Date
()).
getTime
()
-
start
>
delay
)
{
break
;
}
}
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
var
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
describe
(
'
ACTS_WifiTest
'
,
function
()
{
...
...
@@ -47,7 +42,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test setDeviceName infos
*/
it
(
'
SUB_Communication_WiFi_P2P_Setting_0001
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test]
check the state of wifi, if it's close, open i
t.
"
);
console
.
info
(
"
[wifi_test]
test setDeviceName star
t.
"
);
var
devName
=
wifi
.
setDeviceName
(
"
P2PTest
"
);
console
.
info
(
"
[wifi_test] test start setDeviceName->
"
+
devName
);
expect
(
devName
).
assertTrue
();
...
...
@@ -71,7 +66,7 @@ describe('ACTS_WifiTest', function () {
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
...
...
@@ -79,13 +74,13 @@ describe('ACTS_WifiTest', function () {
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] test start createGroup .
"
);
var
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
sleep
(
3
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test start createGroup result.
"
+
addConfig
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
((
data
)
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_js]getCurrentGroup promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
...
...
@@ -115,7 +110,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
});
});
})
/**
...
...
@@ -136,7 +131,7 @@ describe('ACTS_WifiTest', function () {
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
...
...
@@ -144,13 +139,13 @@ describe('ACTS_WifiTest', function () {
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] test start create 2.4G band Group .
"
);
var
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig2
);
sleep
(
3
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test start createGroup result.
"
+
addConfig
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
((
data
)
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_js]getCurrentGroup promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
...
...
@@ -169,7 +164,6 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test createGroup and deletePersistentGroup infos
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] check the state of wifi, if it's close, open it.
"
);
var
WifiP2PConfig
=
{
deviceAddress
:
"
02:11:65:f2:0d:6e
"
,
netId
:
-
2
,
...
...
@@ -177,10 +171,11 @@ describe('ACTS_WifiTest', function () {
groupName
:
"
AAAZZZ
"
,
goBand
:
0
};
console
.
info
(
"
[wifi_test] check the state of wifi, if it's close, open it.
"
);
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
...
...
@@ -188,23 +183,23 @@ describe('ACTS_WifiTest', function () {
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] test start createGroup [promise].
"
);
var
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
sleep
(
3
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test start createGroup [promise].
"
+
addConfig
);
expect
(
addConfig
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
((
data
)
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
console
.
info
(
"
[wifi_test] test start deletePersistentGroup
"
);
var
removePConfig
=
wifi
.
deletePersistentGroup
(
data
.
networkId
);
console
.
info
(
"
[wifi_test] test start deletePersistentGroup
"
+
removePConfig
);
expect
(
removePConfig
).
assertTrue
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
);
var
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
});
done
();
console
.
info
(
"
[wifi_test] getCurrentGroup [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
console
.
info
(
"
[wifi_test] test start deletePersistentGroup
"
);
var
removePConfig
=
wifi
.
deletePersistentGroup
(
data
.
networkId
);
console
.
info
(
"
[wifi_test] test start deletePersistentGroup
"
+
removePConfig
);
expect
(
removePConfig
).
assertTrue
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
);
var
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
});
done
();
})
/**
...
...
@@ -213,7 +208,7 @@ describe('ACTS_WifiTest', function () {
* @tc.author wudangping wwx1075776
* @tc.desc Test p2pConnect infos
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0004
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_P2P_Config_0004
'
,
0
,
async
function
(
done
)
{
var
WifiP2PConfig3
=
{
deviceAddress
:
"
02:11:65:f2:0d:6e
"
,
netId
:
-
2
,
...
...
@@ -225,7 +220,7 @@ describe('ACTS_WifiTest', function () {
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
...
...
@@ -233,16 +228,17 @@ describe('ACTS_WifiTest', function () {
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] test start startDiscoverDevices.
"
);
var
scanConfig
=
wifi
.
startDiscoverDevices
();
sleep
(
3
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test startDiscoverDevices result.
"
+
scanConfig
);
expect
(
scanConfig
).
assertTrue
();
console
.
info
(
"
[wifi_test] test start p2pConnect.
"
);
var
connConfig
=
wifi
.
p2pConnect
(
WifiP2PConfig3
);
sleep
(
5000
);
console
.
info
(
"
[wifi_test] test p2pConnect result.
"
+
connConfig
);
expect
(
connConfig
).
assertTrue
();
console
.
info
(
"
[wifi_test] test start stopDiscoverDevices.
"
);
var
stopScan
=
wifi
.
stopDiscoverDevices
();
console
.
info
(
"
[wifi_test] test stopDiscoverDevices result.
"
+
stopScan
);
done
()
})
/**
...
...
@@ -263,8 +259,7 @@ describe('ACTS_WifiTest', function () {
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLinkedInfo promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
error
).
assertFail
();
});
});
wifi
.
getP2pLinkedInfo
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to getP2pLinkedInfo callback
'
+
JSON
.
stringify
(
err
));
...
...
@@ -276,7 +271,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
groupOwnerAddr:
"
+
result
.
groupOwnerAddr
);
expect
(
false
).
assertEqual
(
result
.
connectState
==
P2pConnectState
.
CONNECTED
);
expect
(
false
).
assertEqual
(
result
.
connectState
==
P2pConnectState
.
DISCONNECTED
);
});
done
();
})
...
...
@@ -287,16 +282,17 @@ describe('ACTS_WifiTest', function () {
* @tc.author wudangping wwx1075776
* @tc.desc Test p2pCancelConnect infos
*/
it
(
'
SUB_Communication_WiFi_P2P_Config_0006
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_P2P_Config_0006
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] test start p2pCancelConnect.
"
);
var
disConn
=
wifi
.
p2pCancelConnect
();
sleep
(
5
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test p2pCancelConnect result.
"
+
disConn
);
expect
(
disConn
).
assertTrue
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
);
var
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
...
...
@@ -317,7 +313,7 @@ describe('ACTS_WifiTest', function () {
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
...
...
@@ -325,16 +321,16 @@ describe('ACTS_WifiTest', function () {
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] test start startDiscoverDevices.
"
);
var
scanConfig
=
wifi
.
startDiscoverDevices
();
sleep
(
10
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] test startDiscoverDevices result.
"
+
scanConfig
);
expect
(
scanConfig
).
assertTrue
();
await
wifi
.
getP2pDevices
()
.
then
((
data
)
=>
{
console
.
info
(
"
[wifi_test] getP2pDevices [promise] result ->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
length
!=
0
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pDevices promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pDevices promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
wifi
.
getP2pDevices
((
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -367,7 +363,6 @@ describe('ACTS_WifiTest', function () {
}
console
.
info
(
"
[wifi_test] test stopDiscoverDevices.
"
);
var
stopScan
=
wifi
.
stopDiscoverDevices
();
sleep
(
3000
);
console
.
info
(
"
[wifi_test] test stopDiscoverDevices result.
"
+
stopScan
);
expect
(
stopScan
).
assertTrue
();
done
();
...
...
@@ -394,7 +389,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
...
...
@@ -425,9 +420,9 @@ describe('ACTS_WifiTest', function () {
});
};
await
wifi
.
on
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
[wifi_test] p2pConnectionChange result ->
"
+
recvP2pConnectionChangeFunc
);
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
done
();
console
.
info
(
"
[wifi_test] p2pConnectionChange result ->
"
+
recvP2pConnectionChangeFunc
);
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
done
();
});
setTimeout
(
function
()
{
console
.
info
(
'
[wifi_test] offP2pStateChange test start ...
'
);
...
...
@@ -435,7 +430,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
p2pConnectionChange callback
"
+
JSON
.
stringify
(
recvP2pConnectionChangeFunc
));
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
...
...
@@ -458,7 +453,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
...
...
@@ -506,7 +501,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
offP2pPeerDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
...
...
@@ -550,7 +545,7 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
offP2pPersistentGroupChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
...
...
@@ -573,12 +568,10 @@ describe('ACTS_WifiTest', function () {
console
.
info
(
"
offp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
0
*
1000
);
},
1
*
1000
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
communication/wifi_standard/src/main/js/default/test/WifiSoftAP.test.js
浏览文件 @
cd0907b4
...
...
@@ -17,15 +17,8 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
wifi
from
'
@ohos.wifi
'
// delay x ms
function
sleep
(
delay
)
{
var
start
=
(
new
Date
()).
getTime
();
while
(
true
){
if
(
new
Date
().
getTime
()
-
start
>
delay
)
{
break
;
}
}
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
var
WifiSecurityType
=
{
...
...
@@ -55,15 +48,14 @@ describe('ACTS_WifiTest', function() {
* @tc.number OPEN_0002
* @tc.name SUB_Communication_WiFi_Hotspot_Open_0002
* @tc.desc Test wifi.enableHotspot and wifi.disableHotspot API functionality1.
* @tc.author wudangping wwx1075776
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Open_0002
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Open_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Open_0002
"
);
console
.
info
(
"
[wifi_test] enableHotspot and disableHotspot test start.
"
);
if
(
wifi
.
isWifiActive
())
{
if
(
wifi
.
isWifiActive
())
{
var
disable
=
wifi
.
disableWifi
();
sleep
(
5
000
);
await
sleep
(
2
000
);
console
.
log
(
"
[wifi_test] wifi close result:
"
+
disable
);
expect
(
disable
).
assertTrue
();
}
...
...
@@ -72,55 +64,56 @@ describe('ACTS_WifiTest', function() {
expect
(
close
).
assertFalse
();
if
(
!
wifi
.
isHotspotActive
())
{
var
on
=
wifi
.
enableHotspot
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
info
(
"
[wifi_test] enableHotspot result ->
"
+
on
);
expect
(
on
).
assertTrue
();
}
console
.
info
(
"
[wifi_test]
AP
status result ->
"
+
wifi
.
isHotspotActive
());
console
.
info
(
"
[wifi_test]
Hotspot
status result ->
"
+
wifi
.
isHotspotActive
());
expect
(
wifi
.
isHotspotActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] enableHotspot and close wifi test end.
"
);
console
.
info
(
"
[wifi_test] enableHotspot and disableHotspot test end.
"
);
done
();
})
/**
* @tc.number CONFIG_0001
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test set a valid 2.4G hotspot config
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0001
'
,
0
,
function
()
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0001
'
,
0
,
async
function
()
{
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001
"
);
console
.
info
(
"
[wifi_test] set a valid 2.4G hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5
000
);
await
sleep
(
2
000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
console
.
info
(
"
[wifi_test]
AP
status result ->
"
+
wifi
.
isHotspotActive
());
console
.
info
(
"
[wifi_test]
Hotspot
status result ->
"
+
wifi
.
isHotspotActive
());
expect
(
wifi
.
isHotspotActive
()).
assertFalse
();
var
isSuccess
=
wifi
.
setHotspotConfig
(
HotspotConfig
);
console
.
log
(
"
[wifi_test] set 2.4G hotspot config result:
"
+
isSuccess
);
expect
(
isSuccess
).
assertTrue
();
console
.
info
(
"
[wifi_test] check band of current band should be 2.4G.
"
);
var
hotspotConfig
=
wifi
.
getHotspotConfig
();
console
.
log
(
"
[wifi_test] getHotspotConfig result:
"
+
JSON
.
stringify
(
hotspotConfig
));
expect
(
hotspotConfig
.
band
).
assertEqual
(
1
);
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001 end
"
);
done
();
})
/**
/**
* @tc.number CONFIG_0002
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0002
* @tc.desc Test set a valid 5G hotspot config
* @tc.level Level 1
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0002
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0002
"
);
console
.
info
(
"
[wifi_test] set a valid hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -138,6 +131,7 @@ describe('ACTS_WifiTest', function() {
var
hotspotConfig5
=
wifi
.
getHotspotConfig
();
console
.
log
(
"
[wifi_test] getHotspotConfig result:
"
+
JSON
.
stringify
(
hotspotConfig5
));
expect
(
hotspotConfig5
.
band
).
assertEqual
(
1
);
done
();
})
/**
...
...
@@ -146,11 +140,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a invalid hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0003
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] set a invalid hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
10
000
);
await
sleep
(
3
000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -164,21 +158,23 @@ describe('ACTS_WifiTest', function() {
var
isSuccess1
=
wifi
.
setHotspotConfig
(
HotspotConfig1
);
console
.
log
(
"
[wifi_test] set invalid band hotspot config result1:
"
+
isSuccess1
);
expect
(
isSuccess1
).
assertFalse
();
done
();
})
/**
* @tc.number CONFIG_0004
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0004
* @tc.desc Test set a max preSharedKey is hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0004
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0004
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0004
"
);
console
.
info
(
"
[wifi_test] check the state of hotspot, if it's open, close it.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -204,6 +200,7 @@ describe('ACTS_WifiTest', function() {
var
isSuccess1
=
wifi
.
setHotspotConfig
(
HotspotConfigM1
);
console
.
log
(
"
[wifi_test] set 65 preSharedKey invalid hotspot config result:
"
+
isSuccess1
);
expect
(
isSuccess1
).
assertFalse
();
done
();
})
/**
...
...
@@ -212,11 +209,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a min preSharedKey is hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0005
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] check the state of hotspot, if it's open, close it.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -252,6 +249,7 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
[wifi_test] getHotspotConfig result ->
"
+
JSON
.
stringify
(
config
));
console
.
info
(
"
preSharedKey:
"
+
config
.
preSharedKey
);
expect
(
config
.
preSharedKey
.
length
).
assertEqual
(
8
);
done
();
})
/**
...
...
@@ -260,11 +258,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a max ssid for hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0006
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0006
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] check the state of hotspot, if it's open, close it.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
on2
).
assertTrue
();
}
...
...
@@ -295,6 +293,7 @@ describe('ACTS_WifiTest', function() {
var
isSuccess1
=
wifi
.
setHotspotConfig
(
HotspotConfigS1
);
console
.
log
(
"
[wifi_test] set 33bit ssid invalid hotspot config result:
"
+
isSuccess1
);
expect
(
isSuccess1
).
assertFalse
();
done
();
})
...
...
@@ -304,10 +303,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a null ssid invalid hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0007
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0007
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] set a null ssid invalid hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -321,6 +321,7 @@ describe('ACTS_WifiTest', function() {
var
isSuccess1
=
wifi
.
setHotspotConfig
(
HotspotConfigN
);
console
.
log
(
"
[wifi_test] set a null ssid invalid hotspot config result1:
"
+
isSuccess1
);
expect
(
isSuccess1
).
assertFalse
();
done
();
})
/**
...
...
@@ -332,7 +333,7 @@ describe('ACTS_WifiTest', function() {
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0008
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] set contains Chinese valid hotspot config start.
"
);
var
HotspotConfigC
=
{
"
ssid
"
:
"
¥%¥#
@12测试
"
,
"
ssid
"
:
"
�?�?
@12测试
"
,
"
band
"
:
1
,
"
preSharedKey
"
:
"
12345678
"
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -354,11 +355,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a invalid preSharedKey hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0009
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0009
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] set invalid hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
info
(
"
[wifi_test] enableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
...
...
@@ -395,6 +396,7 @@ describe('ACTS_WifiTest', function() {
var
isSuccess3
=
wifi
.
setHotspotConfig
(
HotspotConfigC
);
console
.
log
(
"
[wifi_test] set a invalid preSharedKey hotspot config result1:
"
+
isSuccess3
);
expect
(
isSuccess3
).
assertFalse
();
done
();
})
...
...
@@ -404,11 +406,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a valid PSK preSharedKey hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0010
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] set valid hotspot config start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] enableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
...
...
@@ -429,6 +431,7 @@ describe('ACTS_WifiTest', function() {
var
isHotspotActive
=
wifi
.
isHotspotActive
();
console
.
info
(
"
[wifi_test] isHotspotActive ->
"
+
isHotspotActive
);
expect
(
isHotspotActive
).
assertFalse
();
done
();
})
...
...
@@ -438,11 +441,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a valid OPEN preSharedKey hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0011
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0011
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] wifi disableHotspot start.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
}
...
...
@@ -457,6 +460,7 @@ describe('ACTS_WifiTest', function() {
var
isSuccess1
=
wifi
.
setHotspotConfig
(
HotspotConfigO
);
console
.
log
(
"
[wifi_test] set a open preSharedKey hotspot config result1:
"
+
isSuccess1
);
expect
(
isSuccess1
).
assertTrue
();
done
();
})
...
...
@@ -466,11 +470,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a maxConn and more maxConn hotspot config
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Conn_0001
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Conn_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] check the state of hotspot, if it's open, close it.
"
);
if
(
wifi
.
isHotspotActive
())
{
var
off
=
wifi
.
disableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] disableHotspot result ->
"
+
off
);
expect
(
off
).
assertTrue
();
...
...
@@ -508,6 +512,7 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
[wifi_test] getHotspotConfig result ->
"
+
JSON
.
stringify
(
config
));
console
.
info
(
"
ssid:
"
+
config
.
maxConn
);
expect
(
config
.
maxConn
).
assertEqual
(
8
);
done
();
})
/**
...
...
@@ -516,12 +521,12 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a valid hotspot config after open Hotspot
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0012
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Config_0012
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] wifi enableHotspot start.
"
);
console
.
info
(
"
[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0012.
"
);
if
(
!
wifi
.
isHotspotActive
())
{
var
on
=
wifi
.
enableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] enableHotspot result ->
"
+
on
);
expect
(
on
).
assertTrue
();
}
...
...
@@ -554,6 +559,7 @@ describe('ACTS_WifiTest', function() {
expect
(
config
.
preSharedKey
).
assertEqual
(
'
12345678
'
);
expect
(
config
.
securityType
).
assertEqual
(
3
);
expect
(
config
.
maxConn
).
assertEqual
(
8
);
done
();
})
...
...
@@ -563,11 +569,11 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test Obtains the list of clients that are connected to a Wi-Fi hotspot.
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Conn_0002
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Hotspot_Conn_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] check the state of hotspot, if it's open, close it.
"
);
if
(
!
wifi
.
isHotspotActive
())
{
var
on
=
wifi
.
enableHotspot
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
info
(
"
[wifi_test] enableHotspot result ->
"
+
on
);
expect
(
on
).
assertTrue
();
...
...
@@ -582,6 +588,7 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
ssid:
"
+
stationInfo
.
name
);
console
.
info
(
"
macAddress:
"
+
stationInfo
.
macAddress
);
console
.
info
(
"
ipAddress:
"
+
stationInfo
.
ipAddress
);
done
();
})
...
...
@@ -596,11 +603,11 @@ describe('ACTS_WifiTest', function() {
it
(
'
SUB_Communication_WiFi_Hotspot_ON_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStateChange On test
"
);
try
{
wifi
.
on
(
'
hotspotStateChange
'
,
(
data
)
=>
{
await
wifi
.
on
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -617,12 +624,12 @@ describe('ACTS_WifiTest', function() {
*/
it
(
'
SUB_Communication_WiFi_Sta_Off_0002
'
,
0
,
async
function
(
done
)
{
try
{
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
await
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange Off ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
"
[wifi_test] wifiRssiChange unregister end
"
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -640,11 +647,11 @@ describe('ACTS_WifiTest', function() {
it
(
'
SUB_Communication_WiFi_Hotspot_ON_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStaJoin On test
"
);
try
{
wifi
.
on
(
'
hotspotStaJoin
'
,
(
data
)
=>
{
await
wifi
.
on
(
'
hotspotStaJoin
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStaJoin On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -661,12 +668,12 @@ describe('ACTS_WifiTest', function() {
*/
it
(
'
SUB_Communication_WiFi_Sta_Off_0004
'
,
0
,
async
function
(
done
)
{
try
{
wifi
.
off
(
'
hotspotStaJoin
'
,
(
data
)
=>
{
await
wifi
.
off
(
'
hotspotStaJoin
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStaJoin Off ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
"
[wifi_test] wifiRssiChange unregister end
"
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -684,11 +691,11 @@ describe('ACTS_WifiTest', function() {
it
(
'
SUB_Communication_WiFi_Hotspot_ON_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]hotspotStaLeave On test
"
);
try
{
wifi
.
on
(
'
hotspotStaLeave
'
,
(
data
)
=>
{
await
wifi
.
on
(
'
hotspotStaLeave
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStaLeave On ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -705,12 +712,12 @@ describe('ACTS_WifiTest', function() {
*/
it
(
'
SUB_Communication_WiFi_Sta_Off_0006
'
,
0
,
async
function
(
done
)
{
try
{
wifi
.
off
(
'
hotspotStaLeave
'
,
(
data
)
=>
{
await
wifi
.
off
(
'
hotspotStaLeave
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStaLeave Off ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
"
[wifi_test] hotspotStaLeave unregister end
"
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
...
...
@@ -719,3 +726,4 @@ describe('ACTS_WifiTest', function() {
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
浏览文件 @
cd0907b4
...
...
@@ -17,17 +17,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
wifi
from
'
@ohos.wifi
'
// delay x ms
function
sleep
(
delay
)
{
var
start
=
(
new
Date
()).
getTime
();
while
(
true
){
if
((
new
Date
()).
getTime
()
-
start
>
delay
)
{
break
;
}
}
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
var
WifiSecurityType
=
{
WIFI_SEC_TYPE_INVALID
:
0
,
WIFI_SEC_TYPE_OPEN
:
1
,
...
...
@@ -85,29 +78,31 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number open_0001
* @tc.name SUB_Communication_WiFi_Sta_Open_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test wifi.isWifiEnable API functionality.
*/
it
(
'
SUB_Communication_WiFi_Sta_Open_0001
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Sta_Open_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Open_0001]
"
);
console
.
info
(
"
[wifi_test] check the state of wifi, if it's close, open it.
"
);
var
active
=
wifi
.
isWifiActive
();
if
(
!
active
)
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
console
.
info
(
"
[wifi_test] close wifi test start.
"
);
var
disable
=
wifi
.
disableWifi
();
await
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi close result:
"
+
disable
);
expect
(
disable
).
assertTrue
();
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assert
Tru
e
();
sleep
(
3000
);
expect
(
wifi
.
isWifiActive
()).
assert
Fals
e
();
done
(
);
})
/**
* @tc.number Scan_0001
* @tc.name SUB_Communication_WiFi_Sta_Scan_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test get ScanInfos callback API functionality.
*/
it
(
'
SUB_Communication_WiFi_Sta_Scan_0001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -115,12 +110,12 @@ describe('ACTS_WifiTest', function() {
var
active1
=
wifi
.
isWifiActive
();
if
(
!
active1
)
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
5000
);
await
sleep
(
5000
);
console
.
log
(
"
[wifi_test] wifi open result:
"
+
enable
);
expect
(
enable
).
assertTrue
();
}
var
scan
=
wifi
.
scan
();
sleep
(
5
000
);
await
sleep
(
3
000
);
console
.
log
(
"
[wifi_test] open wifi scan result:
"
+
scan
);
expect
(
scan
).
assertTrue
();
...
...
@@ -163,7 +158,6 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Scan_0004
* @tc.name SUB_Communication_WiFi_Sta_Scan_0004
* @tc.author wudangping wwx1075776
* @tc.desc Test wifi.getSignalLevel API functionality.
*/
it
(
'
SUB_Communication_WiFi_Sta_Scan_0004
'
,
0
,
function
()
{
...
...
@@ -202,13 +196,12 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Config_0001
* @tc.name SUB_Communication_WiFi_Sta_Config_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test create a OPEN SecurityType wifi device config
*/
it
(
'
SUB_Communication_WiFi_Sta_Config_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Config_0001]
"
);
console
.
info
(
"
[wifi_test] create a OPEN SecurityType wifi device config start.
"
);
wifi
.
removeAllNetwork
();
var
remov
=
wifi
.
removeAllNetwork
();
var
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TEST_OPEN
"
,
"
bssid
"
:
""
,
...
...
@@ -258,7 +251,6 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Config_0002
* @tc.author wudangping wwx1075776
* @tc.desc Test create a PSK SecurityType wifi device config
*/
it
(
'
SUB_Communication_WiFi_Sta_Config_0002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -293,12 +285,11 @@ describe('ACTS_WifiTest', function() {
expect
(
true
).
assertEqual
(
configs
.
length
==
0
);
});
done
()
})
})
/**
* @tc.number Config_0005
* @tc.name SUB_Communication_WiFi_Sta_Config_0005
* @tc.author wudangping wwx1075776
* @tc.desc Test remove all wifi device config
*/
it
(
'
SUB_Communication_WiFi_Sta_Config_0005
'
,
0
,
async
function
(
done
)
{
...
...
@@ -364,7 +355,6 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Config_0007
* @tc.name SUB_Communication_WiFi_Sta_Config_0007
* @tc.author wudangping wwx1075776
* @tc.desc Test update wifi device config
*/
it
(
'
SUB_Communication_WiFi_Sta_Config_0007
'
,
0
,
async
function
(
done
)
{
...
...
@@ -375,7 +365,7 @@ describe('ACTS_WifiTest', function() {
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
};
await
wifi
.
addDeviceConfig
(
wifiDeviceConfig1
)
...
...
@@ -417,15 +407,14 @@ describe('ACTS_WifiTest', function() {
* @tc.number SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress
* @tc.desc Test getMacAddress api.
* @tc.author wudangping wwx1075776
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0001
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Sta_info_0001
'
,
0
,
async
function
(
done
)
{
if
(
!
wifi
.
isWifiActive
())
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
3000
);
await
sleep
(
3000
);
expect
(
enable
).
assertTrue
();
}
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
...
...
@@ -433,21 +422,21 @@ describe('ACTS_WifiTest', function() {
var
result
=
wifi
.
getDeviceMacAddress
();
console
.
info
(
"
[wifi_test] getDeviceMacAddress ->
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
.
length
>=
1
)
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0002
* @tc.name testgetCountryCode
* @tc.desc Test getCountryCode api.
* @tc.author wudangping wwx1075776
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_Info_0002
'
,
0
,
function
(
)
{
it
(
'
SUB_Communication_WiFi_Sta_Info_0002
'
,
0
,
async
function
(
done
)
{
if
(
!
wifi
.
isWifiActive
())
{
var
enable
=
wifi
.
enableWifi
();
sleep
(
3000
);
await
sleep
(
3000
);
expect
(
enable
).
assertTrue
();
}
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
...
...
@@ -455,18 +444,18 @@ describe('ACTS_WifiTest', function() {
var
countryCode
=
wifi
.
getCountryCode
();
console
.
info
(
"
[wifi_test] getCountryCode ->
"
+
JSON
.
stringify
(
countryCode
));
expect
(
JSON
.
stringify
(
countryCode
)).
assertEqual
(
'
"CN"
'
);
done
()
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0004
* @tc.name testFeatureSupported
* @tc.desc Test FeatureSupported api.
* @tc.author wudangping wwx1075776
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_info_0004
'
,
0
,
function
()
{
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
));
...
...
@@ -478,106 +467,100 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Conn_Info_0001
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test reconnect wifi
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Conn_Info_0001]
"
);
console
.
info
(
"
[wifi_test] wifi connectToDevice test.
"
);
var
wifiDeviceConfigConn
=
{
"
ssid
"
:
"
TESTCONN
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
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 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] reconnect wifi
"
);
var
reconn
=
wifi
.
reconnect
();
console
.
log
(
"
[wifi_test] wifi reconnect result:
"
+
reconn
);
expect
(
reconn
).
assertTrue
();
console
.
info
(
"
[wifi_test] remove config
"
);
var
isRemoved
=
wifi
.
removeAllNetwork
();
console
.
info
(
"
[wifi_test] check remove configs successfully,result:
"
+
isRemoved
);
expect
(
isRemoved
).
assertTrue
();
var
configs
=
wifi
.
getDeviceConfigs
();
console
.
info
(
"
[wifi_test]remove config,current get Config :
"
+
JSON
.
stringify
(
configs
));
expect
(
true
).
assertEqual
(
configs
.
length
==
0
);
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
(
"
[wifi_test] wifi connectToDevice test.
"
);
var
wifiDeviceConfigConn
=
{
"
ssid
"
:
"
TESTCONN
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
var
active
=
wifi
.
isWifiActive
();
console
.
log
(
"
[wifi_test] wifi active result2:
"
+
active
);
if
(
!
active
){
var
enable
=
wifi
.
enableWifi
();
expect
(
enable
).
assertTrue
();
await
sleep
(
3000
);
}
var
result1
=
wifi
.
connectToDevice
(
wifiDeviceConfigConn
);
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] reconnect wifi
"
);
var
reconn
=
wifi
.
reconnect
();
console
.
log
(
"
[wifi_test] wifi reconnect result:
"
+
reconn
);
expect
(
reconn
).
assertTrue
();
console
.
info
(
"
[wifi_test] remove config
"
);
var
isRemoved
=
wifi
.
removeAllNetwork
();
console
.
info
(
"
[wifi_test] check remove configs successfully,result:
"
+
isRemoved
);
expect
(
isRemoved
).
assertTrue
();
var
configs
=
wifi
.
getDeviceConfigs
();
console
.
info
(
"
[wifi_test]remove config,current get Config :
"
+
JSON
.
stringify
(
configs
));
expect
(
true
).
assertEqual
(
configs
.
length
==
0
);
done
()
})
/**
* @tc.number conn_Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
* @tc.author wudangping wwx1075776
* @tc.desc Test getLinkedInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Conn_Info_0002]
"
);
console
.
info
(
'
console.info("[wifi_test] Wifi getlink infos test[1]."
'
);
console
.
info
(
"
[wifi_test] Wifi get link infos test[1].
"
);
await
wifi
.
getLinkedInfo
()
.
then
((
result
)
=>
{
console
.
info
(
"
[wifi_test] get wifilink [promise] ->
"
+
JSON
.
stringify
(
result
));
.
then
((
result
)
=>
{
console
.
info
(
"
[wifi_test] get wifi
link [promise] ->
"
+
JSON
.
stringify
(
result
));
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
'
band
'
);
console
.
info
(
"
[wifi_
test
] get wifi link [promise].
"
);
console
.
info
(
"
[wifi_
js
] get wifi link [promise].
"
);
done
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
wifi
.
getLinkedInfo
(
(
err
,
result
)
=>
{
await
wifi
.
getLinkedInfo
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to getlink infos callback because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
"
[wifi_test] wifi getLinkedInfo failed
"
+
err
);
}
var
clen
=
Object
.
key
(
result
).
length
;
console
.
info
(
"
[wifi_test] get wifilink callback result length ->
"
+
clen
);
if
(
!
(
clen
==
0
))
{
console
.
info
(
"
[wifi_test] get wifi link [callback] ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
ssid:
"
+
result
.
ssid
);
console
.
info
(
"
bssid:
"
+
result
.
bssid
);
console
.
info
(
"
band:
"
+
result
.
band
);
console
.
info
(
"
isHidden:
"
+
result
.
isHidden
);
console
.
info
(
"
isRestricted:
"
+
result
.
isRestricted
);
console
.
info
(
"
chload:
"
+
result
.
chload
);
console
.
info
(
"
rssi
"
+
result
.
rssi
);
console
.
info
(
"
netWorkId:
"
+
result
.
netWorkId
);
console
.
info
(
"
linkSpeed:
"
+
result
.
linkSpeed
);
console
.
info
(
"
frequency:
"
+
result
.
frequency
);
console
.
info
(
"
snr:
"
+
result
.
snr
);
console
.
info
(
"
macAddress:
"
+
result
.
macAddress
);
console
.
info
(
"
ipAddress:
"
+
result
.
ipAddress
);
console
.
info
(
"
suppState:
"
+
result
.
suppState
);
console
.
info
(
"
connState:
"
+
result
.
connState
);
}
done
();
var
clen
=
Object
.
keys
(
result
).
length
;
console
.
log
(
"
[wifi_test] wifi getLinkedInfo callback result length:
"
+
clen
);
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getLinkedInfo callback result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
ssid:
"
+
result
.
ssid
);
console
.
info
(
"
bssid:
"
+
result
.
bssid
);
console
.
info
(
"
band:
"
+
result
.
band
);
console
.
info
(
"
isHidden:
"
+
result
.
isHidden
);
console
.
info
(
"
isRestricted:
"
+
result
.
isRestricted
);
console
.
info
(
"
chload:
"
+
result
.
chload
);
console
.
info
(
"
rssi
"
+
result
.
rssi
);
console
.
info
(
"
netWorkId:
"
+
result
.
netWorkId
);
console
.
info
(
"
linkSpeed:
"
+
result
.
linkSpeed
);
console
.
info
(
"
frequency:
"
+
result
.
frequency
);
console
.
info
(
"
snr:
"
+
result
.
snr
);
console
.
info
(
"
macAddress:
"
+
result
.
macAddress
);
console
.
info
(
"
ipAddress:
"
+
result
.
ipAddress
);
console
.
info
(
"
suppState:
"
+
result
.
suppState
);
console
.
info
(
"
connState:
"
+
result
.
connState
);
done
();
});
})
/**
* @tc.number Conn_Info_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @tc.author wudangping wwx1075776
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0003
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test][SUB_Communication_WiFi_Sta_Conn_Info_0003]
"
);
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] wifi connectToDevice test.
"
);
var
wifiDeviceConfigIp
=
{
"
ssid
"
:
"
TEST1
"
,
...
...
@@ -587,7 +570,7 @@ describe('ACTS_WifiTest', function() {
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
var
result1
=
wifi
.
connectToDevice
(
wifiDeviceConfigIp
);
sleep
(
5
000
);
await
sleep
(
2
000
);
console
.
log
(
"
[wifi_test] wifi connectToDevice result:
"
+
result1
);
expect
(
result1
).
assertTrue
();
console
.
info
(
"
[wifi_test] check isconnected wifi
"
);
...
...
@@ -595,9 +578,9 @@ describe('ACTS_WifiTest', function() {
console
.
log
(
"
[wifi_test] wifi isConnected result:
"
+
isConnected
);
expect
(
isConnected
).
assertFalse
();
console
.
info
(
"
[wifi_test] reassociate wifi
"
);
var
reass
oc
=
wifi
.
reassociate
();
console
.
log
(
"
[wifi_test] wifi reassociate result:
"
+
reass
oc
);
expect
(
reass
oc
).
assertTrue
();
var
reass
=
wifi
.
reassociate
();
console
.
log
(
"
[wifi_test] wifi reassociate result:
"
+
reass
);
expect
(
reass
).
assertTrue
();
console
.
info
(
"
[wifi_test] get IpInfo.
"
);
var
ipInfo
=
wifi
.
getIpInfo
();
console
.
info
(
"
[wifi_test] getIpInfo ->
"
+
JSON
.
stringify
(
ipInfo
));
...
...
@@ -616,35 +599,11 @@ describe('ACTS_WifiTest', function() {
var
configs
=
wifi
.
getDeviceConfigs
();
console
.
info
(
"
[wifi_test]remove config,current get Config :
"
+
JSON
.
stringify
(
configs
));
expect
(
true
).
assertEqual
(
configs
.
length
==
0
);
done
()
})
/**
* @tc.number SUB_Communication_WiFi_Sta_Off_0002
* @tc.name testwifiStateChangeOff
* @tc.desc Test wifiStateChangeOff api.
* @tc.author wudangping wwx1075776
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_ON_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test] wifiConnectionChange On test
"
);
await
wifi
.
on
(
'
wifiConnectionChange
'
,
function
(
data
)
{
console
.
info
(
"
[wifi_test] wifiConnectionChangeOn ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
done
();
});
wifi
.
off
(
'
wifiConnectionChange
'
,
function
(
data
)
{
console
.
info
(
"
[wifi_test] wifiConnectionChangeOff ->
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
done
();
});
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录