Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d958f3d7
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看板
提交
d958f3d7
编写于
7月 28, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
c2b4d2ab
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
58 addition
and
47 deletion
+58
-47
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
...on/wifi_standard/src/main/js/default/test/WifiSta.test.js
+58
-47
未找到文件。
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
浏览文件 @
d958f3d7
...
...
@@ -13,12 +13,12 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
...
...
@@ -31,24 +31,15 @@ let WifiSecurityType = {
}
function
checkWifiPowerOn
(){
let
enable
=
wifi
.
enableWifi
();
console
.
info
(
"
enableWifi result0000123:
"
+
enable
);
wifi
.
on
(
'
wifiStateChange
'
,
state
=>
{
console
.
info
(
"
wifiStateLisener state:
"
+
state
)
if
(
state
===
1
)
{
// 1: wifi is enable, 0:wifi is disable
wifi
.
scan
()
wifi
.
getLinkedInfo
()
}
})
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
Wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
let
WifiDeviceConfig
=
{
"
ssid
"
:
"
TEST
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
""
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_OPEN
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_OPEN
,
}
let
ConnState
=
{
SCANNING
:
0
,
...
...
@@ -61,6 +52,8 @@ let ConnState = {
UNKNOWN
:
7
,
}
describe
(
'
ACTS_WifiTest
'
,
function
()
{
beforeEach
(
function
()
{
...
...
@@ -73,10 +66,10 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number open_0001
* @tc.name SUB_Communication_WiFi_Sta_Open_0001
* @tc.desc Test wifi.isWifiEnable API functionality.
* @since 6
* @tc.desc Test wifi.isWifiActive API functionality.
*/
it
(
'
SUB_Communication_WiFi_Sta_Open_0001
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] check the state of wifi, if it's close, open it.
"
);
it
(
'
SUB_Communication_WiFi_Sta_WifiActive_0001
'
,
0
,
function
()
{
let
active
=
wifi
.
isWifiActive
();
console
.
log
(
"
[wifi_test] check the state of wifi:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
...
...
@@ -125,37 +118,47 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Scan_0004
* @tc.name SUB_Communication_WiFi_Sta_Scan_0004
* @since 7
* @tc.desc Test wifi.getSignalLevel API functionality.
*/
it
(
'
SUB_Communication_WiFi_Sta_Scan_0004
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] check the 2.4G rssi assgined to level test.
"
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
65
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
65
,
1
)).
assertEqual
(
4
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
66
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
66
,
1
)).
assertEqual
(
3
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
75
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
75
,
1
)).
assertEqual
(
3
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
76
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
76
,
1
)).
assertEqual
(
2
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
82
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
82
,
1
)).
assertEqual
(
2
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
83
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
83
,
1
)).
assertEqual
(
1
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
88
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
88
,
1
)).
assertEqual
(
1
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
89
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
89
,
1
)).
assertEqual
(
0
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
127
,
1
));
expect
(
wifi
.
getSignalLevel
(
-
127
,
1
)).
assertEqual
(
0
);
console
.
info
(
"
[wifi_test] check the 5G rssi assgined to level test.
"
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
65
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
65
,
2
)).
assertEqual
(
4
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
66
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
66
,
2
)).
assertEqual
(
3
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
72
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
72
,
2
)).
assertEqual
(
3
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
73
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
73
,
2
)).
assertEqual
(
2
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
79
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
79
,
2
)).
assertEqual
(
2
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
80
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
80
,
2
)).
assertEqual
(
1
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
85
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
85
,
2
)).
assertEqual
(
1
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
86
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
86
,
2
)).
assertEqual
(
0
);
console
.
info
(
"
[wifi_test] getSignalLevel
"
+
wifi
.
getSignalLevel
(
-
127
,
2
));
expect
(
wifi
.
getSignalLevel
(
-
127
,
2
)).
assertEqual
(
0
);
})
...
...
@@ -165,13 +168,14 @@ describe('ACTS_WifiTest', function() {
* @tc.number SUB_Communication_WiFi_Sta_info_0002
* @tc.name testgetCountryCode
* @tc.desc Test getCountryCode api.
* @since 7
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_Info_0002
'
,
0
,
function
()
{
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
console
.
info
(
"
[wifi_test] getCountryCode start ...
"
);
console
.
info
(
"
[wifi_test] getCountryCode start
"
);
let
countryCode
=
wifi
.
getCountryCode
();
console
.
info
(
"
[wifi_test] getCountryCode ->
"
+
JSON
.
stringify
(
countryCode
));
expect
(
JSON
.
stringify
(
countryCode
)).
assertEqual
(
'
"CN"
'
);
...
...
@@ -181,6 +185,7 @@ describe('ACTS_WifiTest', function() {
* @tc.number SUB_Communication_WiFi_Sta_info_0004
* @tc.name testFeatureSupported
* @tc.desc Test FeatureSupported api.
* @since 7
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -225,10 +230,11 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number conn_Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
* @since 7
* @tc.desc Test getLinkedInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]
isConnected :
"
+
wifi
.
isConnected
());
console
.
info
(
"
[wifi_test]
isConnected :
"
+
wifi
.
isConnected
());
expect
(
wifi
.
isConnected
()).
assertFalse
();
await
wifi
.
getLinkedInfo
()
.
then
((
result
)
=>
{
...
...
@@ -244,10 +250,11 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number conn_Config_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @since 7
* @tc.desc Test getLinkedInfo callback information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[wifi_test]
isConnected :
"
+
wifi
.
isConnected
());
console
.
info
(
"
[wifi_test]
isConnected :
"
+
wifi
.
isConnected
());
expect
(
wifi
.
isConnected
()).
assertFalse
();
await
wifi
.
getLinkedInfo
(
(
err
,
result
)
=>
{
...
...
@@ -271,6 +278,7 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number Conn_Info_0001
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @since 7
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
function
()
{
...
...
@@ -288,6 +296,7 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number wifiStateChange_0001
* @tc.name SUB_Communication_WiFi_Sta_wifiStateChange_0001
* @since 7
* @tc.desc Test wifiStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiStateChange_0001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -309,6 +318,7 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @since 7
* @tc.desc Test wifiStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -331,6 +341,7 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number wifiScanStateChange_0003
* @tc.name SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
* @since 7
* @tc.desc Test wifiScanStateChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
'
,
0
,
async
function
(
done
)
{
...
...
@@ -348,7 +359,6 @@ describe('ACTS_WifiTest', function() {
await
promise
.
then
(
done
)
});
let
scan
=
wifi
.
scan
();
await
sleep
(
3000
);
done
();
})
...
...
@@ -356,6 +366,7 @@ describe('ACTS_WifiTest', function() {
/**
* @tc.number wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @since 7
* @tc.desc Test wifiRssiChange callback
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiRssiChange_0004
'
,
0
,
async
function
(
done
)
{
...
...
@@ -380,6 +391,7 @@ describe('ACTS_WifiTest', function() {
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.name testhotspotStateChangeOn
* @tc.desc Test hotspotStateChangeOn api.
* @since 7
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -402,11 +414,12 @@ describe('ACTS_WifiTest', function() {
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0002
* @tc.name testhotspotStateChangeOff
* @tc.desc Test hotspotStateChange api.
* @since 7
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_
Sta
_Off_0002
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_
Hotspot
_Off_0002
'
,
0
,
async
function
(
done
)
{
try
{
await
wifi
.
off
(
'
hotspotStateChange
'
,
(
data
)
=>
{
console
.
info
(
"
[wifi_test] hotspotStateChange Off ->
"
+
data
);
...
...
@@ -422,5 +435,3 @@ describe('ACTS_WifiTest', function() {
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录