Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7caee5bf
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看板
未验证
提交
7caee5bf
编写于
8月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5253 【communication】修改WIFI JS L2测试用例
Merge pull request !5253 from 权力/myfeature
上级
621fbe9a
eda1d847
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
1411 addition
and
2173 deletion
+1411
-2173
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+1
-1
communication/bluetooth_on/src/main/js/test/BluetoothADD.test.js
...cation/bluetooth_on/src/main/js/test/BluetoothADD.test.js
+0
-1772
communication/wifi_p2p/src/main/js/test/List.test.js
communication/wifi_p2p/src/main/js/test/List.test.js
+4
-5
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
+0
-115
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
+225
-0
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
...ication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
+831
-0
communication/wifi_standard/src/main/js/test/List.test.js
communication/wifi_standard/src/main/js/test/List.test.js
+7
-4
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
...fi_standard/src/main/js/test/WifiCandidateNetWork.test.js
+92
-96
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+206
-0
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
...fi_standard/src/main/js/test/WifiStationFunctions.test.js
+45
-180
未找到文件。
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
7caee5bf
...
...
@@ -475,7 +475,7 @@ describe('bluetoothhostTest', function() {
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off14
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
(
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
onReceiveEvent
);
done
();
...
...
communication/bluetooth_on/src/main/js/test/BluetoothADD.test.js
已删除
100644 → 0
浏览文件 @
621fbe9a
此差异已折叠。
点击以展开。
communication/wifi_p2p/src/main/js/test/List.test.js
浏览文件 @
7caee5bf
...
...
@@ -12,10 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
actsWifi
TestNew
from
'
./WifiP2P.testsame
.js
'
import
actsWifi
Test
from
'
./WifiP2P.test2
.js
'
import
actsWifi
FunctionTest
from
'
./WifiP2PFunction.test
.js
'
import
actsWifi
EventTest
from
'
./WifiP2PEvent.test
.js
'
export
default
function
testsuite
()
{
actsWifi
TestNew
()
actsWifiTest
()
actsWifi
FunctionTest
()
actsWifi
Event
Test
()
}
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
已删除
100644 → 0
浏览文件 @
621fbe9a
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
export
default
function
actsWifiTestNew
()
{
describe
(
'
actsWifiTestNew
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
afterEach
(
function
()
{
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0009
* @tc.name testp2pCancelConnect
* @tc.desc Test p2pCancelConnect Group API functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0009
'
,
0
,
async
function
(
done
)
{
let
WifiP2PConfig
=
{
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
goBand
:
0
};
let
addConfig
=
wifi
.
createGroup
(
WifiP2PConfig
);
console
.
info
(
"
[wifi_test] test p2pConnect result.
"
+
addConfig
);
let
disConn
=
wifi
.
p2pCancelConnect
();
sleep
(
2000
);
console
.
info
(
"
[wifi_test] test p2pCancelConnect result.
"
+
disConn
);
expect
(
disConn
).
assertTrue
();
let
removeConfig
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test] test start removeGroup
"
+
removeConfig
);
expect
(
removeConfig
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0011
* @tc.name testremoveGroup
* @tc.desc Test remove error Group functionality.
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_XTS_P2P_0011
'
,
0
,
async
function
(
done
)
{
let
isRemoved
=
wifi
.
removeGroup
(
10000
);
console
.
info
(
"
[wifi_test]removeGroup(10000) result :
"
+
JSON
.
stringify
(
isRemoved
));
expect
(
isRemoved
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_P2P_0002
* @tc.name testP2pLocalDevice
* @tc.desc Test get TO 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
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice promise error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
function
getP2pLocal
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getP2pLocalDevice
(
(
err
,
ret
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]getP2pLocalDevice callback failed :
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
[wifi_test] getP2pLocalDevice callback result:
"
+
JSON
.
stringify
(
ret
));
console
.
info
(
"
deviceName:
"
+
ret
.
deviceName
+
"
deviceAddress:
"
+
ret
.
deviceAddress
+
"
primaryDeviceType:
"
+
ret
.
primaryDeviceType
+
"
deviceStatus:
"
+
ret
.
deviceStatus
+
"
groupCapabilitys:
"
+
ret
.
groupCapabilitys
);
resolve
();
});
});
}
await
getP2pLocal
();
done
();
})
})
}
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
0 → 100644
浏览文件 @
7caee5bf
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
let
GroupOwnerBand
=
{
GO_BAND_AUTO
:
0
,
GO_BAND_2GHZ
:
1
,
GO_BAND_5GHZ
:
2
,
}
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeEach
(
function
()
{
console
.
info
(
"
beforeEach start
"
);
checkWifiPowerOn
();
})
afterEach
(
async
function
()
{
console
.
info
(
"
afterEach start
"
);
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0008
* @tc.name testp2pStateChange
* @tc.desc Test p2pStateChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0008
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pStateChange
'
,
result
=>
{
console
.
info
(
"
onP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pStateChange
'
,
result
=>
{
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0009
* @tc.name testp2pConnectionChange
* @tc.desc Test p2pConnectionChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0009
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
[wifi_test] p2pConnectionChange result ->
"
+
recvP2pConnectionChangeFunc
);
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
done
();
});
setTimeout
(
function
()
{
console
.
info
(
'
[wifi_test] offP2pStateChange test start ...
'
);
wifi
.
off
(
'
p2pConnectionChange
'
,
recvP2pConnectionChangeFunc
=>
{
console
.
info
(
"
p2pConnectionChange callback
"
+
JSON
.
stringify
(
recvP2pConnectionChangeFunc
));
expect
(
true
).
assertEqual
(
recvP2pConnectionChangeFunc
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0012
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0012
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[wifi_test] Onp2pDeviceChange test start ...
'
);
await
wifi
.
on
(
'
p2pDeviceChange
'
,
result
=>
{
console
.
info
(
"
onP2pDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
console
.
info
(
'
[wifi_test] offP2pDeviceChange test start ...
'
);
wifi
.
off
(
'
p2pDeviceChange
'
,
result
=>
{
console
.
info
(
"
offP2pStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0010
* @tc.name testp2pDeviceChange
* @tc.desc Test p2pDeviceChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0010
'
,
0
,
async
function
(
done
)
{
let
recvP2pPeerDeviceChangeFunc
=
result
=>
{
console
.
info
(
"
wifi_test / p2p peer device change receive event:
"
+
JSON
.
stringify
(
result
));
wifi
.
getP2pDevices
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
wifi_test / failed to get getP2pDevices:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
wifi_test / getP2pDevices [callback] ->
"
+
JSON
.
stringify
(
data
));
let
len
=
Object
.
keys
(
data
).
length
;
console
.
log
(
"
getP2pDevices number:
"
+
len
);
for
(
let
i
=
0
;
i
<
len
;
++
i
)
{
if
(
data
[
i
].
deviceName
===
"
GRE
"
)
{
console
.
info
(
"
wifi_test / p2pConnect: ->
"
+
data
[
i
].
deviceAddress
);
let
config
=
{
"
deviceAddress
"
:
data
[
i
].
deviceAddress
,
"
netId
"
:
-
1
,
"
passphrase
"
:
""
,
"
groupName
"
:
""
,
"
goBand
"
:
0
,
}
wifi
.
p2pConnect
(
config
);
}
}
});
}
await
wifi
.
on
(
'
p2pPeerDeviceChange
'
,
result
=>
{
console
.
info
(
"
onP2pPeerDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pPeerDeviceChange
'
,
result
=>
{
console
.
info
(
"
offP2pPeerDeviceChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0013
* @tc.name testp2pPersistentGroupChange
* @tc.desc Test p2pPersistentGroupChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0013
'
,
0
,
async
function
(
done
)
{
let
recvP2pPersistentGroupChangeFunc
=
()
=>
{
console
.
info
(
"
wifi_test / p2p persistent group change receive event
"
);
let
config
=
{
"
deviceAddress
"
:
"
02:11:65:f2:0d:6e
"
,
"
netId
"
:
-
2
,
"
passphrase
"
:
""
,
"
groupName
"
:
""
,
"
goBand
"
:
0
,
};
let
addConfig
=
wifi
.
createGroup
(
config
);
expect
(
addConfig
).
assertTrue
();
wifi
.
getCurrentGroup
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
wifi_test / failed to get getCurrentGroup:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
"
wifi_test / get getCurrentGroup [callback] ->
"
+
JSON
.
stringify
(
data
));
});
};
wifi
.
on
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);
setTimeout
(
async
function
()
{
wifi
.
off
(
'
p2pPersistentGroupChange
'
,
result
=>
{
console
.
info
(
"
offP2pPersistentGroupChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0011
* @tc.name testpp2pDiscoveryChange
* @tc.desc Test p2pDiscoveryChange callback
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Event_Test_0011
'
,
0
,
async
function
(
done
)
{
await
wifi
.
on
(
'
p2pDiscoveryChange
'
,
result
=>
{
console
.
info
(
"
onp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
((
result
!=
null
));
done
();
});
setTimeout
(
function
()
{
wifi
.
off
(
'
p2pDiscoveryChange
'
,
result
=>
{
console
.
info
(
"
offp2pDiscoveryChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
},
1
*
1000
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_p2p/src/main/js/test/WifiP2P
.testsame
.js
→
communication/wifi_p2p/src/main/js/test/WifiP2P
Function.test
.js
浏览文件 @
7caee5bf
此差异已折叠。
点击以展开。
communication/wifi_standard/src/main/js/test/List.test.js
浏览文件 @
7caee5bf
...
...
@@ -12,10 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
actsWifiTestNew
from
'
./WifiJsunit.test1.js
'
import
actsWifiTest
from
'
./WifiJsunit.testsame.js
'
import
actsWifiCandidateNetWorkTest
from
'
./WifiCandidateNetWork.test.js
'
import
actsWifiFunctionsTest
from
'
./WifiStationFunctions.test.js
'
import
actsWifiEventTest
from
'
./WifiStationEvent.test.js
'
export
default
function
testsuite
()
{
actsWifiTestNew
()
actsWifiTest
()
actsWifiCandidateNetWorkTest
()
actsWifiFunctionsTest
()
actsWifiEventTest
()
}
communication/wifi_standard/src/main/js/test/Wifi
Jsunit.test1
.js
→
communication/wifi_standard/src/main/js/test/Wifi
CandidateNetWork.test
.js
浏览文件 @
7caee5bf
...
...
@@ -56,8 +56,8 @@ let WifiChannelWidth = {
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifi
TestNew
()
{
describe
(
'
actsWifi
TestNew
'
,
function
()
{
export
default
function
actsWifi
CandidateNetWorkTest
()
{
describe
(
'
actsWifi
CandidateNetWorkTest
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -65,12 +65,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0001
* @since 9
* @tc.desc Test add OPEN and WEP CandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0001
* @tc.name testaddCandidateConfig
* @tc.desc Test add OPEN and WEP CandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0001
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -113,12 +112,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0001
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0002
* @since 8
* @tc.desc Test add PSK CandidateConfig and removeCandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0002
* @tc.name testaddCandidateConfig
* @tc.desc Test add PSK CandidateConfig and removeCandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0002
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -156,12 +154,11 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0003
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0003
* @since 8
* @tc.desc Test add SAE CandidateConfig Promise API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0003
* @tc.name testaddCandidateConfig
* @tc.desc Test add SAE CandidateConfig Promise API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0003
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -198,12 +195,72 @@ export default function actsWifiTestNew() {
})
/**
* @tc.number CandidateNetWork_0005
* @tc.name SUB_Communication_WiFi_XTS_CandidateNetWork_0005
* @since 8
* @tc.desc Test add CandidateConfig and removeCandidateConfig callback API functionality.
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0004
* @tc.name testaddCandidateConfig
* @tc.desc Test add MAX CandidateConfig and removeall CandidateConfig.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0004
'
,
0
,
async
function
(
done
)
{
let
SSID
=
"
TYPE_PSK
"
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
SSID
=
"
TYPE_PSK
"
+
i
console
.
info
(
"
[wifi_test] get canshu result :
"
);
let
wifiDeviceConfig
=
{
"
ssid
"
:
SSID
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
console
.
info
(
"
[wifi_test] get wifiDeviceConfig ssid result :
"
+
JSON
.
stringify
(
wifiDeviceConfig
.
ssid
));
await
wifi
.
addCandidateConfig
(
wifiDeviceConfig
)
.
then
(
netWorkId
=>
{
console
.
info
(
"
[wifi_test]add 16th CandidateConfig promise :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] add 16th CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
}
let
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TYPE_17
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
};
await
wifi
.
addCandidateConfig
(
wifiDeviceConfig1
)
.
then
(
netWorkId
=>
{
console
.
info
(
"
[wifi_test]add 17th CandidateConfig promise :
"
+
JSON
.
stringify
(
netWorkId
));
expect
(
true
).
assertEqual
(
netWorkId
!=
-
1
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] add 17th CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
let
getconfig
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi get 16 CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig
));
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
var
networkId
=
getconfig
[
i
].
netId
;
console
.
info
(
"
[wifi_test] wifi get networkId result :
"
+
JSON
.
stringify
(
networkId
));
await
wifi
.
removeCandidateConfig
(
networkId
)
.
then
(
ret
=>
{
console
.
info
(
"
[wifi_test]remove CandidateConfig promise
"
+
JSON
.
stringify
(
ret
));
let
getconfig1
=
wifi
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi get CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig1
));
console
.
info
(
"
[wifi_test] wifi getconfiglength result :
"
+
JSON
.
stringify
(
getconfig1
.
length
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_js] remove CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
});
}
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0005
* @tc.name testaddCandidateConfig
* @tc.desc Test add CandidateConfig and removeCandidateConfig callback API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0005
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
...
...
@@ -249,18 +306,16 @@ export default function actsWifiTestNew() {
});
});
}
await
removeCandidate
();
done
();
})
/**
* @tc.number CandidateNetWork_0006
* @tc.name SUB_Communication_WiFi_XTS_SUB_Communication_WiFi_XTS_CandidateNetWork_0006
* @tc.desc Test connect To CandidateConfig API functionality.
* @since 9
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.SET_WIFI_INFO
* @tc.number SUB_Communication_WiFi_XTS_CandidateNetWork_0006
* @tc.name testaddCandidateConfig
* @tc.desc Test connect To CandidateConfig API functionality.
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0006
'
,
0
,
async
function
(
done
)
{
let
WifiSecurityType
=
{
...
...
@@ -302,69 +357,6 @@ export default function actsWifiTestNew() {
done
();
})
/**
* @tc.number Sta_0002
* @tc.name SUB_Communication_WiFi_XTS_Sta_0002
* @tc.desc Test get to ScanInfos promise and callback API functionality.
* @since 6
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION)
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0002
'
,
0
,
async
function
(
done
)
{
await
wifi
.
getScanInfos
()
.
then
(
result
=>
{
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos promise result
"
+
JSON
.
stringify
(
result
));
});
function
getScanInfos
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
resolve
();
});
});
}
await
getScanInfos
();
done
();
})
/**
* @tc.number Sta_0034
* @tc.name SUB_Communication_WiFi_XTS_Sta_0034
* @tc.desc Test get to ScanInfos Sync API functionality.
* @since 9
* @syscap SystemCapability.Communication.WiFi.STA
* @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION)
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0034
'
,
0
,
async
function
(
done
)
{
let
getScanInfos
=
wifi
.
getScanInfosSync
();
console
.
info
(
"
[wifi_test] wifi get to ScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfos
));
let
lenth
=
Object
.
keys
(
getScanInfos
).
length
;
console
.
info
(
"
[wifi_test] wifi ScanInfosSync length result :
"
+
JSON
.
stringify
(
lenth
));
expect
(
lenth
).
assertLarger
(
0
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_XTS_UntrustedConfig_0001
* @tc.name testaddUntrustedConfig
...
...
@@ -448,3 +440,7 @@ export default function actsWifiTestNew() {
})
})
}
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
0 → 100644
浏览文件 @
7caee5bf
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
function
checkWifiPowerOn
(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
}
function
resolveIP
(
ip
)
{
return
(
ip
>>
24
&
0xFF
)
+
"
.
"
+
(
ip
>>
16
&
0xFF
)
+
"
.
"
+
(
ip
>>
8
&
0xFF
)
+
"
.
"
+
(
ip
&
0xFF
);
}
let
WifiSecurityType
=
{
WIFI_SEC_TYPE_INVALID
:
0
,
WIFI_SEC_TYPE_OPEN
:
1
,
WIFI_SEC_TYPE_WEP
:
2
,
WIFI_SEC_TYPE_PSK
:
3
,
WIFI_SEC_TYPE_SAE
:
4
,
}
let
ConnState
=
{
SCANNING
:
0
,
CONNECTING
:
1
,
AUTHENTICATING
:
2
,
OBTAINING_IPADDR
:
3
,
CONNECTED
:
4
,
DISCONNECTING
:
5
,
DISCONNECTED
:
6
,
UNKNOWN
:
7
,
}
let
untrustedDeviceConfig
=
{
"
ssid
"
:
"
untrusted_ssid
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
}
let
WifiChannelWidth
=
{
WIDTH_20MHZ
:
0
,
WIDTH_40MHZ
:
1
,
WIDTH_80MHZ
:
2
,
WIDTH_160MHZ
:
3
,
WIDTH_80MHZ_PLUS
:
4
,
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
afterEach
(
function
()
{
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0001
* @tc.name testwifiStateChange
* @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
(
"
wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
wifi
.
off
(
'
wifiStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0002
* @tc.name testwifiConnectionChange
* @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
(
"
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
(
"
offwifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0003
* @tc.name testwifiScanStateChange
* @tc.desc Test 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
(
"
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
(
"
offwifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
scan
=
wifi
.
scan
();
await
sleep
(
3000
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0004
* @tc.name testwifiRssiChange
* @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
(
"
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
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Event_Test_0005
* @tc.name testhotspotStateChange
* @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
();
}
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_standard/src/main/js/test/Wifi
Jsunit.testsame
.js
→
communication/wifi_standard/src/main/js/test/Wifi
StationFunctions.test
.js
浏览文件 @
7caee5bf
...
...
@@ -66,8 +66,8 @@ let WifiChannelWidth = {
WIDTH_INVALID
:
null
,
}
export
default
function
actsWifiTest
()
{
describe
(
'
actsWifiTest
'
,
function
()
{
export
default
function
actsWifi
Functions
Test
()
{
describe
(
'
actsWifi
Functions
Test
'
,
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -77,43 +77,47 @@ export default function actsWifiTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name testgetScanInfos
* @tc.desc Test get
ScanInfos callback API functionality.
.
* @tc.desc Test get
to ScanInfos promise and callback API functionality
.
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_Communication_WiFi_XTS_Sta_0002
'
,
0
,
async
function
(
done
)
{
let
scan
=
wifi
.
scan
();
sleep
(
3000
);
console
.
log
(
"
[wifi_test] open wifi scan result:
"
+
scan
);
await
sleep
(
3000
);
await
wifi
.
getScanInfos
()
.
then
(
result
=>
{
let
clen
=
Object
.
keys
(
result
).
length
;
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos promise result
"
+
JSON
.
stringify
(
result
));
});
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
done
()
function
getScanInfos
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wifi
.
getScanInfos
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
"
[wifi_test] wifi getScanInfos failed
"
+
err
);
}
let
clen
=
Object
.
keys
(
result
).
length
;
if
(
!
(
clen
==
0
))
{
expect
(
clen
).
assertLarger
(
0
);
console
.
info
(
"
[wifi_test] getScanInfos callback result:
"
+
JSON
.
stringify
(
result
));
for
(
let
j
=
0
;
j
<
clen
;
++
j
)
{
console
.
info
(
"
ssid:
"
+
result
[
j
].
ssid
+
"
bssid:
"
+
result
[
j
].
bssid
+
"
securityType:
"
+
result
[
j
].
securityType
+
"
rssi:
"
+
result
[
j
].
rssi
+
"
band:
"
+
result
[
j
].
band
+
"
frequency:
"
+
result
[
j
].
frequency
+
"
channelWidth:
"
+
result
[
j
].
channelWidth
+
"
timestamp
"
+
result
[
j
].
timestamp
+
"
capabilities
"
+
result
[
j
].
capabilities
+
"
centerFrequency0:
"
+
result
[
j
].
centerFrequency0
+
"
centerFrequency1:
"
+
result
[
j
].
centerFrequency1
+
"
infoElems:
"
+
result
[
j
].
infoElems
);
}
}
resolve
();
});
});
}
await
getScanInfos
();
done
();
})
/**
...
...
@@ -297,163 +301,24 @@ export default function actsWifiTest() {
});
})
/**
* @tc.number Conn_Info_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @since 7
* @tc.desc Test get IpInfo information
*/
it
(
'
SUB_Communication_WiFi_Sta_Conn_Info_0001
'
,
0
,
function
()
{
let
isConnected
=
wifi
.
isConnected
();
expect
(
isConnected
).
assertFalse
();
let
ipInfo
=
wifi
.
getIpInfo
();
expect
(
JSON
.
stringify
(
ipInfo
)).
assertContain
(
"
gateway
"
);
let
ipAddress
=
resolveIP
(
ipInfo
.
ipAddress
);
console
.
info
(
"
ipAddress result:
"
+
ipAddress
);
console
.
info
(
"
gateway:
"
+
ipInfo
.
gateway
+
"
ipAddress:
"
+
ipInfo
.
ipAddress
+
"
leaseDuration:
"
+
ipInfo
.
leaseDuration
+
"
leaseDuration:
"
+
ipInfo
.
leaseDuration
+
"
netmask:
"
+
ipInfo
.
netmask
+
"
primaryDns:
"
+
ipInfo
.
primaryDns
+
"
secondDns:
"
+
ipInfo
.
secondDns
+
"
serverIp:
"
+
ipInfo
.
serverIp
);
})
/**
* @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
)
{
wifi
.
on
(
'
wifiStateChange
'
,
async
result
=>
{
console
.
info
(
"
wifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
wifi
.
off
(
'
wifiStateChange
'
,
result
=>
{
console
.
info
(
"
offwifiStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @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
)
{
wifi
.
on
(
'
wifiConnectionChange
'
,
async
result
=>
{
console
.
info
(
"
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
(
"
offwifiConnectionChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @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
)
{
wifi
.
on
(
'
wifiScanStateChange
'
,
async
result
=>
{
console
.
info
(
"
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
(
"
offwifiScanStateChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
let
scan
=
wifi
.
scan
();
sleep
(
3000
);
done
();
})
/**
* @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
)
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
console
.
info
(
"
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
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
});
})
await
promise
.
then
(
done
)
});
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.name testhotspotStateChangeOn
* @since 7
* @tc.desc Test hotspotStateChangeOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Hotspot_ON_0001
'
,
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
();
}
done
();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0002
* @tc.name testhotspotStateChangeOff
* @since 7
* @tc.desc Test hotspotStateChange api.
* @tc.size MEDIUM
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0034
* @tc.name testgetScanInfosSync
* @tc.desc Test get to ScanInfos Sync API functionality.
* @tc.type Function
* @tc.level Level
3
* @tc.level Level
0
*/
it
(
'
SUB_Communication_WiFi_Hotspot_Off_0002
'
,
0
,
async
function
(
done
)
{
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
();
}
it
(
'
SUB_Communication_WiFi_XTS_Sta_0034
'
,
0
,
async
function
(
done
)
{
let
getScanInfos
=
wifi
.
getScanInfosSync
();
console
.
info
(
"
[wifi_test] wifi get to ScanInfosSync result :
"
+
JSON
.
stringify
(
getScanInfos
));
let
lenth
=
Object
.
keys
(
getScanInfos
).
length
;
console
.
info
(
"
[wifi_test] wifi ScanInfosSync length result :
"
+
JSON
.
stringify
(
lenth
));
expect
(
lenth
).
assertLarger
(
0
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录