提交 cb135430 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 9194ac45
...@@ -87,7 +87,7 @@ export default function actsWifiManagerEventTest() { ...@@ -87,7 +87,7 @@ export default function actsWifiManagerEventTest() {
}); });
await sleep(2000); await sleep(2000);
wifiMg.off(p2pConnectionState, p2pConnectionChangeCallback); wifiMg.off(p2pConnectionState, p2pConnectionChangeCallback);
let removeGroupResult = wifiMg.removeGroup(); let removeP2pGroupResult = wifiMg.removeP2pGroup();
done(); done();
}) })
...@@ -122,9 +122,9 @@ export default function actsWifiManagerEventTest() { ...@@ -122,9 +122,9 @@ export default function actsWifiManagerEventTest() {
console.info("[wifi_test]p2pPeerDeviceChange callback, result: " + JSON.stringify(result)); console.info("[wifi_test]p2pPeerDeviceChange callback, result: " + JSON.stringify(result));
} }
wifiMg.on(p2pPeerDeviceState, p2pPeerDeviceChangeCallback); wifiMg.on(p2pPeerDeviceState, p2pPeerDeviceChangeCallback);
let startDiscover = wifiMg.startDiscoverDevices(); let startDiscover = wifiMg.startDiscoverP2pDevices();
await sleep(3000); await sleep(3000);
let stopDiscover = wifiMg.stopDiscoverDevices(); let stopDiscover = wifiMg.stopDiscoverP2pDevices();
wifiMg.off(p2pPeerDeviceState, p2pPeerDeviceChangeCallback); wifiMg.off(p2pPeerDeviceState, p2pPeerDeviceChangeCallback);
done(); done();
}) })
...@@ -149,7 +149,7 @@ export default function actsWifiManagerEventTest() { ...@@ -149,7 +149,7 @@ export default function actsWifiManagerEventTest() {
groupName : "AAAZZZ123", groupName : "AAAZZZ123",
goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO,
}; };
let createGroupResult = wifiMg.createGroup(WifiP2PConfig); let createP2pGroupResult = wifiMg.createP2pGroup(WifiP2PConfig);
await (2000); await (2000);
try { try {
await wifiMg.getCurrentP2pGroup() await wifiMg.getCurrentP2pGroup()
...@@ -182,9 +182,9 @@ export default function actsWifiManagerEventTest() { ...@@ -182,9 +182,9 @@ export default function actsWifiManagerEventTest() {
console.info("[wifi_test]p2pDiscoveryChange callback, result: " + JSON.stringify(result)); console.info("[wifi_test]p2pDiscoveryChange callback, result: " + JSON.stringify(result));
} }
wifiMg.on(p2pPeerDeviceState, p2pDiscoveryChangeCallback); wifiMg.on(p2pPeerDeviceState, p2pDiscoveryChangeCallback);
let startDiscover = wifiMg.startDiscoverDevices(); let startDiscover = wifiMg.startDiscoverP2pDevices();
await sleep(3000); await sleep(3000);
let stopDiscover = wifiMg.stopDiscoverDevices(); let stopDiscover = wifiMg.stopDiscoverP2pDevices();
wifiMg.off(p2pPeerDeviceState, p2pDiscoveryChangeCallback); wifiMg.off(p2pPeerDeviceState, p2pDiscoveryChangeCallback);
done(); done();
}) })
......
...@@ -130,6 +130,9 @@ export default function actsWifiFunctionTest() { ...@@ -130,6 +130,9 @@ export default function actsWifiFunctionTest() {
.then(data => { .then(data => {
console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data));
expect(true).assertEqual(data.networkId == -999); expect(true).assertEqual(data.networkId == -999);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -140,7 +143,7 @@ export default function actsWifiFunctionTest() { ...@@ -140,7 +143,7 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
expect(true).assertEqual(data.deviceName == null); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => { }).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null); expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
...@@ -265,6 +268,9 @@ export default function actsWifiFunctionTest() { ...@@ -265,6 +268,9 @@ export default function actsWifiFunctionTest() {
.then(data => { .then(data => {
console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data)); console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data));
expect(true).assertEqual(data.passphrase != wifiP2PConfig.passphrase); expect(true).assertEqual(data.passphrase != wifiP2PConfig.passphrase);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -275,7 +281,7 @@ export default function actsWifiFunctionTest() { ...@@ -275,7 +281,7 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
expect(true).assertEqual(data.deviceName == null); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => { }).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error)); console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null); expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
......
...@@ -125,4 +125,3 @@ export default function actsWifiCandidateNetWorkTest() { ...@@ -125,4 +125,3 @@ export default function actsWifiCandidateNetWorkTest() {
}) })
} }
...@@ -78,7 +78,6 @@ export default function actsWifiManagerCandidateNetWorkTest() { ...@@ -78,7 +78,6 @@ export default function actsWifiManagerCandidateNetWorkTest() {
"isHiddenSsid": false, "isHiddenSsid": false,
"securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WEP, "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WEP,
}; };
await wifiMg.addCandidateConfig(wifiDeviceConfig1) await wifiMg.addCandidateConfig(wifiDeviceConfig1)
.then(netWorkId => { .then(netWorkId => {
console.info("[wifi_test]add WEP CandidateConfig promise : " + JSON.stringify(netWorkId)); console.info("[wifi_test]add WEP CandidateConfig promise : " + JSON.stringify(netWorkId));
...@@ -343,4 +342,3 @@ export default function actsWifiManagerCandidateNetWorkTest() { ...@@ -343,4 +342,3 @@ export default function actsWifiManagerCandidateNetWorkTest() {
}) })
} }
...@@ -332,4 +332,3 @@ export default function actsWifiManagerEventTest() { ...@@ -332,4 +332,3 @@ export default function actsWifiManagerEventTest() {
}) })
} }
...@@ -46,52 +46,6 @@ export default function actsWifiManagerFunctionsTest() { ...@@ -46,52 +46,6 @@ export default function actsWifiManagerFunctionsTest() {
afterEach(function () { afterEach(function () {
}) })
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name testgetScanResults
* @tc.desc Test getScanResults promise and callback API functionality.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_Communication_WiFi_XTS_Sta_0002', 0, async function (done) {
let scanResult = wifiMg.scan();
await sleep(3000);
await wifiMg.getScanResults()
.then(result => {
let clen = Object.keys(result).length;
expect(true).assertEqual(clen >= 0);
console.info("[wifi_test]getScanInfos promise result:" + JSON.stringify(result));
});
function getScan() {
return new Promise((resolve, reject) => {
wifiMg.getScanResults(
(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
+ "eid: " + result[j].infoElems.eid + "content: " + result[j].infoElems.content);
}
}
resolve();
});
});
}
await getScan();
done();
})
/** /**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0021 * @tc.number SUB_Communication_WiFi_XTS_Sta_0021
* @tc.name testGetSignalLevel * @tc.name testGetSignalLevel
...@@ -230,7 +184,7 @@ export default function actsWifiManagerFunctionsTest() { ...@@ -230,7 +184,7 @@ export default function actsWifiManagerFunctionsTest() {
function getLinked(){ function getLinked(){
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wifiMg.getLinkedInfo( wifiMg.getLinkedInfo(
(err, result) => { (err, result) => {
if(err) { if(err) {
console.log("[wifi_test]wifi getLinkedInfo failed " + err); console.log("[wifi_test]wifi getLinkedInfo failed " + err);
} }
...@@ -246,28 +200,28 @@ export default function actsWifiManagerFunctionsTest() { ...@@ -246,28 +200,28 @@ export default function actsWifiManagerFunctionsTest() {
"suppState: " + result.suppState + "connState: " + result.connState "suppState: " + result.suppState + "connState: " + result.connState
+ "macType: " + result.macType); + "macType: " + result.macType);
let state = wifiMg.getLinkedInfo().ConnState; let state = wifiMg.getLinkedInfo().ConnState;
if (state == wifiMg.connState.SCANNING) { if (state == wifiMg.ConnState.SCANNING) {
expect(true).assertEqual(state == 0); expect(true).assertEqual(state == 0);
} }
if (state == wifiMg.connState.CONNECTING) { if (state == wifiMg.ConnState.CONNECTING) {
expect(true).assertEqual(state == 1); expect(true).assertEqual(state == 1);
} }
if (state == wifiMg.connState.AUTHENTICATING) { if (state == wifiMg.ConnState.AUTHENTICATING) {
expect(true).assertEqual(state == 2); expect(true).assertEqual(state == 2);
} }
if (state == wifiMg.connState.OBTAINING_IPADDR) { if (state == wifiMg.ConnState.OBTAINING_IPADDR) {
expect(true).assertEqual(state == 3); expect(true).assertEqual(state == 3);
} }
if (state == wifiMg.connState.CONNECTED) { if (state == wifiMg.ConnState.CONNECTED) {
expect(true).assertEqual(state == 4); expect(true).assertEqual(state == 4);
} }
if (state == wifiMg.connState.DISCONNECTING) { if (state == wifiMg.ConnState.DISCONNECTING) {
expect(true).assertEqual(state == 5); expect(true).assertEqual(state == 5);
} }
if (state == wifiMg.connState.DISCONNECTED) { if (state == wifiMg.ConnState.DISCONNECTED) {
expect(true).assertEqual(state == 6); expect(true).assertEqual(state == 6);
} }
if (state == wifiMg.connState.UNKNOWN) { if (state == wifiMg.ConnState.UNKNOWN) {
expect(true).assertEqual(state == 7); expect(true).assertEqual(state == 7);
} }
resolve(); resolve();
...@@ -286,15 +240,29 @@ export default function actsWifiManagerFunctionsTest() { ...@@ -286,15 +240,29 @@ export default function actsWifiManagerFunctionsTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_Communication_WiFi_XTS_Sta_0034', 0, async function (done) { it('SUB_Communication_WiFi_XTS_Sta_0034', 0, async function (done) {
let getScanResultsResult = wifiMg.getScanResultsSync(); let scanResult = wifiMg.scan();
console.info("[wifi_test]wifi getScanResultsSync result : " + JSON.stringify(getScanResultsResult)); await sleep(3000);
let scanInfolenth = Object.keys(getScanResultsResult).length; let getScanInfoListResult = wifiMg.getScanInfoList();
console.info("[wifi_test]wifi ScanInfosSync length result : " + JSON.stringify(scanInfolenth)); console.info("[wifi_test]wifi getScanInfoList result : " + JSON.stringify(getScanInfoListResult));
expect(true).assertEqual(scanInfolenth >= 0); let clen = Object.keys(getScanInfoListResult).length;
console.info("[wifi_test]wifi getScanInfoList length result : " + JSON.stringify(clen));
let result = getScanInfoListResult;
if (clen >= 0) {
expect(true).assertEqual(clen >= 0);
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
+ "eid: " + result[j].infoElems.eid + "content: " + result[j].infoElems.content);
}
}
done(); done();
}) })
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
} }
...@@ -31,7 +31,7 @@ function resolveIP(ip) { ...@@ -31,7 +31,7 @@ function resolveIP(ip) {
return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF); return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF);
} }
let powerModel = { let PowerModel = {
SLEEPING : 0, SLEEPING : 0,
GENERAL : 1, GENERAL : 1,
THROUGH_WALL : 2, THROUGH_WALL : 2,
...@@ -339,4 +339,3 @@ export default function actsWifiEventTest() { ...@@ -339,4 +339,3 @@ export default function actsWifiEventTest() {
}) })
} }
...@@ -44,8 +44,6 @@ export default function actsWifiFunctionsTest() { ...@@ -44,8 +44,6 @@ export default function actsWifiFunctionsTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('Communication_WiFi_XTS_Sta_0002', 0, async function (done) { it('Communication_WiFi_XTS_Sta_0002', 0, async function (done) {
let scan = wifi.scan();
await sleep(3000);
await wifi.getScanInfos() await wifi.getScanInfos()
.then(result => { .then(result => {
let clen = Object.keys(result).length; let clen = Object.keys(result).length;
...@@ -268,4 +266,3 @@ export default function actsWifiFunctionsTest() { ...@@ -268,4 +266,3 @@ export default function actsWifiFunctionsTest() {
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册