未验证 提交 5342b642 编写于 作者: O openharmony_ci 提交者: Gitee

!8332 【XTS】【communication】【同步3.2release】优化WIFI、lbs脚本

Merge pull request !8332 from 权力/myfeature2
...@@ -14,13 +14,10 @@ ...@@ -14,13 +14,10 @@
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import wifiMg from '@ohos.wifiManager' import wifiMg from '@ohos.wifiManager'
import osaccount from '@ohos.account.osAccount' import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
function sleep(delay) { function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
...@@ -182,12 +179,20 @@ export default function actsWifiManagerEventTest() { ...@@ -182,12 +179,20 @@ export default function actsWifiManagerEventTest() {
groupName : "DIRECT-AAAZZZ123", groupName : "DIRECT-AAAZZZ123",
goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO,
}; };
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentP2pGroup()
let resultLength = Object.keys(data).length; .then(data => {
console.info("[wifi_test] getCurrentGroup promise result -> " + JSON.stringify(data)); let resultLength = Object.keys(data).length;
expect(true).assertEqual(resultLength!=0); console.info("[wifi_test] getCurrentP2pGroup promise result -> " + JSON.stringify(data));
}); expect(true).assertEqual(resultLength!=0);
}).catch((error) => {
console.error('[wifi_test] getCurrentP2pGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentP2pGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
wifiMg.off(p2pGroupState, p2pPersistentGroupChangeCallback); wifiMg.off(p2pGroupState, p2pPersistentGroupChangeCallback);
done(); done();
}) })
...@@ -214,5 +219,3 @@ export default function actsWifiManagerEventTest() { ...@@ -214,5 +219,3 @@ export default function actsWifiManagerEventTest() {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
} }
...@@ -84,11 +84,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -84,11 +84,19 @@ export default function actsWifiManagerFunctionTest() {
expect(wifiMg.isWifiActive()).assertTrue(); expect(wifiMg.isWifiActive()).assertTrue();
let createGroupResult = wifiMg.createGroup(wifiP2PConfig); let createGroupResult = wifiMg.createGroup(wifiP2PConfig);
await sleep(2000); await sleep(2000);
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test]getCurrentGroup promise result -> " + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName); console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
function getCurrentGroupResult(){ function getCurrentGroupResult(){
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wifiMg.getCurrentGroup( wifiMg.getCurrentGroup(
...@@ -116,11 +124,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -116,11 +124,19 @@ export default function actsWifiManagerFunctionTest() {
await getCurrentGroupResult(); await getCurrentGroupResult();
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -148,11 +164,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -148,11 +164,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.networkId == -999); console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data));
}); expect(true).assertEqual(data.networkId == -999);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
try { try {
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -160,11 +184,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -160,11 +184,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -194,11 +226,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -194,11 +226,19 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -228,11 +268,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -228,11 +268,19 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -260,11 +308,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -260,11 +308,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.passphrase != wifiP2PConfig.passphrase); console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data));
}); expect(true).assertEqual(data.networkId == -999);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
try { try {
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -272,11 +328,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -272,11 +328,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -306,11 +370,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -306,11 +370,19 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifiMg.removeGroup(); let removeGroupResult = wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -337,7 +409,10 @@ export default function actsWifiManagerFunctionTest() { ...@@ -337,7 +409,10 @@ export default function actsWifiManagerFunctionTest() {
await wifiMg.getCurrentGroup() await wifiMg.getCurrentGroup()
.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(5160 < data.frequency < 5865); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
let removeGroupResult = await wifiMg.removeGroup(); let removeGroupResult = await wifiMg.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -345,6 +420,9 @@ export default function actsWifiManagerFunctionTest() { ...@@ -345,6 +420,9 @@ export default function actsWifiManagerFunctionTest() {
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message));
...@@ -384,6 +462,9 @@ export default function actsWifiManagerFunctionTest() { ...@@ -384,6 +462,9 @@ export default function actsWifiManagerFunctionTest() {
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message));
...@@ -418,10 +499,13 @@ export default function actsWifiManagerFunctionTest() { ...@@ -418,10 +499,13 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
await wifi.getCurrentGroup() await wifiMg.getCurrentGroup()
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message));
...@@ -456,10 +540,13 @@ export default function actsWifiManagerFunctionTest() { ...@@ -456,10 +540,13 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
await wifi.getCurrentGroup() await wifiMg.getCurrentGroup()
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message));
...@@ -494,10 +581,13 @@ export default function actsWifiManagerFunctionTest() { ...@@ -494,10 +581,13 @@ export default function actsWifiManagerFunctionTest() {
}); });
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
await wifi.getCurrentGroup() await wifiMg.getCurrentGroup()
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message));
...@@ -533,11 +623,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -533,11 +623,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -556,11 +654,19 @@ export default function actsWifiManagerFunctionTest() { ...@@ -556,11 +654,19 @@ export default function actsWifiManagerFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifiMg.getCurrentGroup() try {
.then(data => { await wifiMg.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -720,5 +826,3 @@ export default function actsWifiManagerFunctionTest() { ...@@ -720,5 +826,3 @@ export default function actsWifiManagerFunctionTest() {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
} }
...@@ -180,12 +180,20 @@ export default function actsWifiEventTest() { ...@@ -180,12 +180,20 @@ export default function actsWifiEventTest() {
groupName : "DIRECT-AAAZZZ123", groupName : "DIRECT-AAAZZZ123",
goBand : wifi.GroupOwnerBand.GO_BAND_AUTO, goBand : wifi.GroupOwnerBand.GO_BAND_AUTO,
}; };
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
let resultLength = Object.keys(data).length; .then(data => {
console.info("[wifi_test] getCurrentGroup promise result -> " + JSON.stringify(data)); let resultLength = Object.keys(data).length;
expect(true).assertEqual(resultLength!=0); console.info("[wifi_test] getCurrentGroup promise result -> " + JSON.stringify(data));
}); expect(true).assertEqual(resultLength!=0);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
wifi.off(p2pGroupState, p2pPersistentGroupChangeCallback); wifi.off(p2pGroupState, p2pPersistentGroupChangeCallback);
done(); done();
}) })
...@@ -214,5 +222,3 @@ export default function actsWifiEventTest() { ...@@ -214,5 +222,3 @@ export default function actsWifiEventTest() {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
} }
...@@ -86,11 +86,19 @@ export default function actsWifiFunctionTest() { ...@@ -86,11 +86,19 @@ export default function actsWifiFunctionTest() {
console.log("[wifi_test]createGroup result: " + JSON.stringify(createGroupResult)); console.log("[wifi_test]createGroup result: " + JSON.stringify(createGroupResult));
await sleep(2000); await sleep(2000);
expect(createGroupResult).assertTrue(); expect(createGroupResult).assertTrue();
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test]getCurrentGroup promise result -> " + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName); console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data));
}); expect(true).assertEqual(data.groupName == wifiP2PConfig.groupName);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error != null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
function getCurrentGroupResult(){ function getCurrentGroupResult(){
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wifi.getCurrentGroup( wifi.getCurrentGroup(
...@@ -119,11 +127,19 @@ export default function actsWifiFunctionTest() { ...@@ -119,11 +127,19 @@ export default function actsWifiFunctionTest() {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
expect(removeGroupResult).assertTrue(); expect(removeGroupResult).assertTrue();
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error != null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error1: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -156,6 +172,9 @@ export default function actsWifiFunctionTest() { ...@@ -156,6 +172,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);
}); });
try { try {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
...@@ -165,11 +184,19 @@ export default function actsWifiFunctionTest() { ...@@ -165,11 +184,19 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -202,11 +229,19 @@ export default function actsWifiFunctionTest() { ...@@ -202,11 +229,19 @@ export default function actsWifiFunctionTest() {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
expect(removeGroupResult).assertTrue(); expect(removeGroupResult).assertTrue();
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -239,11 +274,19 @@ export default function actsWifiFunctionTest() { ...@@ -239,11 +274,19 @@ export default function actsWifiFunctionTest() {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
expect(removeGroupResult).assertTrue(); expect(removeGroupResult).assertTrue();
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -276,6 +319,9 @@ export default function actsWifiFunctionTest() { ...@@ -276,6 +319,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);
}); });
try { try {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
...@@ -285,11 +331,19 @@ export default function actsWifiFunctionTest() { ...@@ -285,11 +331,19 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -322,11 +376,19 @@ export default function actsWifiFunctionTest() { ...@@ -322,11 +376,19 @@ export default function actsWifiFunctionTest() {
let removeGroupResult = wifi.removeGroup(); let removeGroupResult = wifi.removeGroup();
await sleep(2000); await sleep(2000);
expect(removeGroupResult).assertTrue(); expect(removeGroupResult).assertTrue();
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -355,7 +417,10 @@ export default function actsWifiFunctionTest() { ...@@ -355,7 +417,10 @@ export default function actsWifiFunctionTest() {
await wifi.getCurrentGroup() await wifi.getCurrentGroup()
.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(5160 < data.frequency < 5865); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error != null);
}); });
let removeGroupResult = await wifi.removeGroup(); let removeGroupResult = await wifi.removeGroup();
await sleep(2000); await sleep(2000);
...@@ -364,6 +429,9 @@ export default function actsWifiFunctionTest() { ...@@ -364,6 +429,9 @@ export default function actsWifiFunctionTest() {
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed1 :' + JSON.stringify(error));
expect(true).assertEqual(error != null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup 5G goBand result : " + JSON.stringify(error.message));
...@@ -406,6 +474,9 @@ export default function actsWifiFunctionTest() { ...@@ -406,6 +474,9 @@ export default function actsWifiFunctionTest() {
.then(data => { .then(data => {
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) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
}); });
}catch(error){ }catch(error){
console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message)); console.info("[wifi_test]createGroup auto goBand result : " + JSON.stringify(error.message));
...@@ -442,11 +513,19 @@ export default function actsWifiFunctionTest() { ...@@ -442,11 +513,19 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error: " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -465,11 +544,19 @@ export default function actsWifiFunctionTest() { ...@@ -465,11 +544,19 @@ export default function actsWifiFunctionTest() {
console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message)); console.info("[wifi_test]removeGroup message : " + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null); expect(true).assertEqual((JSON.stringify(error.message)) != null);
} }
await wifi.getCurrentGroup() try {
.then(data => { await wifi.getCurrentGroup()
console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); .then(data => {
expect(true).assertEqual(data.deviceName == null); console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data));
}); expect(true).assertEqual(data.deviceName == null);
}).catch((error) => {
console.error('[wifi_test] getCurrentGroup promise failed :' + JSON.stringify(error));
expect(true).assertEqual(error !=null);
});
}catch(error){
console.info("[wifi_test]getCurrentGroup promise error message : " + JSON.stringify(error.message));
expect(true).assertEqual( (JSON.stringify(error.message)) !=null);
}
done(); done();
}) })
...@@ -600,5 +687,3 @@ export default function actsWifiFunctionTest() { ...@@ -600,5 +687,3 @@ export default function actsWifiFunctionTest() {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
} }
...@@ -53,14 +53,6 @@ function resolveIP(ip) { ...@@ -53,14 +53,6 @@ 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 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,
}
export default function actsWifiCandidateNetWorkTest() { export default function actsWifiCandidateNetWorkTest() {
describe('actsWifiCandidateNetWorkTest', function () { describe('actsWifiCandidateNetWorkTest', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -88,7 +80,7 @@ export default function actsWifiCandidateNetWorkTest() { ...@@ -88,7 +80,7 @@ export default function actsWifiCandidateNetWorkTest() {
"bssid": "22:9b:e6:48:1f:5c", "bssid": "22:9b:e6:48:1f:5c",
"preSharedKey": "12345678", "preSharedKey": "12345678",
"isHiddenSsid": false, "isHiddenSsid": false,
"securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, "securityType": wifi.WifiSecurityType.WIFI_SEC_TYPE_PSK,
}; };
await wifi.addUntrustedConfig(wifiDeviceConfig) await wifi.addUntrustedConfig(wifiDeviceConfig)
.then(ret => { .then(ret => {
...@@ -104,6 +96,19 @@ export default function actsWifiCandidateNetWorkTest() { ...@@ -104,6 +96,19 @@ export default function actsWifiCandidateNetWorkTest() {
}).catch((error) => { }).catch((error) => {
console.error('[wifi_test]removeUntrustedConfig promise failed -> ' + JSON.stringify(error)); console.error('[wifi_test]removeUntrustedConfig promise failed -> ' + JSON.stringify(error));
}); });
let WIFI_SEC_TYPE_INVALID = wifi.WifiSecurityType.WIFI_SEC_TYPE_INVALID;
console.info("[wifi_test]WIFI_SEC_TYPE_INVALID : " + JSON.stringify(WIFI_SEC_TYPE_INVALID));
expect(true).assertEqual( WIFI_SEC_TYPE_INVALID == 0);
let WIFI_SEC_TYPE_OPEN = wifi.WifiSecurityType.WIFI_SEC_TYPE_OPEN;
console.info("[wifi_test]WIFI_SEC_TYPE_OPEN : " + JSON.stringify(WIFI_SEC_TYPE_OPEN));
expect(true).assertEqual( WIFI_SEC_TYPE_OPEN == 1);
let WIFI_SEC_TYPE_WEP = wifi.WifiSecurityType.WIFI_SEC_TYPE_WEP;
console.info("[wifi_test]WIFI_SEC_TYPE_WEP : " + JSON.stringify(WIFI_SEC_TYPE_WEP));
expect(true).assertEqual( WIFI_SEC_TYPE_WEP == 2);
let WIFI_SEC_TYPE_SAE = wifi.WifiSecurityType.WIFI_SEC_TYPE_SAE;
console.info("[wifi_test]WIFI_SEC_TYPE_SAE : " + JSON.stringify(WIFI_SEC_TYPE_SAE));
expect(true).assertEqual( WIFI_SEC_TYPE_SAE == 4);
done(); done();
}) })
...@@ -120,7 +125,7 @@ export default function actsWifiCandidateNetWorkTest() { ...@@ -120,7 +125,7 @@ export default function actsWifiCandidateNetWorkTest() {
"bssid": "22:9b:e6:48:1f:5c", "bssid": "22:9b:e6:48:1f:5c",
"preSharedKey": "12345678", "preSharedKey": "12345678",
"isHiddenSsid": false, "isHiddenSsid": false,
"securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, "securityType": wifi.WifiSecurityType.WIFI_SEC_TYPE_PSK,
} }
function addCandidate() { function addCandidate() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
...@@ -20,6 +20,18 @@ import osaccount from '@ohos.account.osAccount' ...@@ -20,6 +20,18 @@ import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
function checkWifiPowerOn(){
console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive());
}
function resolveIP(ip) {
return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF);
}
async function applyPermission() { async function applyPermission() {
let osAccountManager = osaccount.getAccountManager(); let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish"); console.info("=== getAccountManager finish");
...@@ -41,27 +53,6 @@ async function applyPermission() { ...@@ -41,27 +53,6 @@ async function applyPermission() {
} }
} }
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
function checkWifiPowerOn(){
console.info("[wifi_test]wifi status:" + wifiMg.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_EAP: 5,
WIFI_SEC_TYPE_EAP_SUITE_B: 6,
WIFI_SEC_TYPE_OWE:7 ,
WIFI_SEC_TYPE_WAPI_CERT:8 ,
WIFI_SEC_TYPE_WAPI_PSK:9 ,
}
export default function actsWifiManagerCandidateNetWorkTest() { export default function actsWifiManagerCandidateNetWorkTest() {
describe('actsWifiManagerCandidateNetWorkTest', function () { describe('actsWifiManagerCandidateNetWorkTest', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -118,6 +109,25 @@ export default function actsWifiManagerCandidateNetWorkTest() { ...@@ -118,6 +109,25 @@ export default function actsWifiManagerCandidateNetWorkTest() {
expect(true).assertEqual( (JSON.stringify(error)) !=null); expect(true).assertEqual( (JSON.stringify(error)) !=null);
}); });
console.info("[wifi_test]wifi get WEP CandidateConfigs result : " + JSON.stringify(getconfig)); console.info("[wifi_test]wifi get WEP CandidateConfigs result : " + JSON.stringify(getconfig));
let WIFI_SEC_TYPE_INVALID = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_INVALID;
console.info("[wifi_test]WIFI_SEC_TYPE_INVALID : " + JSON.stringify(WIFI_SEC_TYPE_INVALID));
expect(true).assertEqual( WIFI_SEC_TYPE_INVALID == 0);
let WIFI_SEC_TYPE_EAP = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_EAP;
console.info("[wifi_test]WIFI_SEC_TYPE_EAP : " + JSON.stringify(WIFI_SEC_TYPE_EAP));
expect(true).assertEqual( WIFI_SEC_TYPE_EAP == 5);
let WIFI_SEC_TYPE_EAP_SUITE_B = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_EAP_SUITE_B;
console.info("[wifi_test]WIFI_SEC_TYPE_EAP_SUITE_B : " + JSON.stringify(WIFI_SEC_TYPE_EAP_SUITE_B));
expect(true).assertEqual( WIFI_SEC_TYPE_EAP_SUITE_B == 6);
let WIFI_SEC_TYPE_OWE = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_OWE;
console.info("[wifi_test]WIFI_SEC_TYPE_OWE : " + JSON.stringify(WIFI_SEC_TYPE_OWE));
expect(true).assertEqual( WIFI_SEC_TYPE_OWE == 7);
let WIFI_SEC_TYPE_WAPI_CERT = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WAPI_CERT;
console.info("[wifi_test]WIFI_SEC_TYPE_WAPI_CERT : " + JSON.stringify(WIFI_SEC_TYPE_WAPI_CERT));
expect(true).assertEqual( WIFI_SEC_TYPE_WAPI_CERT == 8);
let WIFI_SEC_TYPE_WAPI_PSK = wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WAPI_PSK;
console.info("[wifi_test]WIFI_SEC_TYPE_WAPI_CERT : " + JSON.stringify(WIFI_SEC_TYPE_WAPI_PSK));
expect(true).assertEqual( WIFI_SEC_TYPE_WAPI_PSK == 9);
done(); done();
}) })
......
...@@ -14,12 +14,23 @@ ...@@ -14,12 +14,23 @@
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wifiMg from '@ohos.wifiManager' import wifiMg from '@ohos.wifiManager'
import wifiManagerExt from '@ohos.wifiManagerExt'
import osaccount from '@ohos.account.osAccount' import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
function checkWifiPowerOn(){
console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive());
}
function resolveIP(ip) {
return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF);
}
async function applyPermission() { async function applyPermission() {
let osAccountManager = osaccount.getAccountManager(); let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish"); console.info("=== getAccountManager finish");
...@@ -41,19 +52,6 @@ async function applyPermission() { ...@@ -41,19 +52,6 @@ async function applyPermission() {
} }
} }
import wifiManagerExt from '@ohos.wifiManagerExt'
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
function checkWifiPowerOn(){
console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive());
}
function resolveIP(ip) {
return (ip>>24 & 0xFF) + "." + (ip>>16 & 0xFF) + "." + (ip>>8 & 0xFF) + "." + (ip & 0xFF);
}
export default function actsWifiManagerEventTest() { export default function actsWifiManagerEventTest() {
describe('actsWifiManagerEventTest', function() { describe('actsWifiManagerEventTest', function() {
beforeAll(async function (done) { beforeAll(async function (done) {
......
...@@ -53,15 +53,6 @@ async function applyPermission() { ...@@ -53,15 +53,6 @@ async function applyPermission() {
} }
} }
let wifiChannelWidth = {
WIDTH_20MHZ : 0,
WIDTH_40MHZ : 1,
WIDTH_80MHZ : 2,
WIDTH_160MHZ : 3,
WIDTH_80MHZ_PLUS : 4,
WIDTH_INVALID:null,
}
export default function actsWifiManagerFunctionsTest() { export default function actsWifiManagerFunctionsTest() {
describe('actsWifiManagerFunctionsTest', function() { describe('actsWifiManagerFunctionsTest', function() {
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -185,6 +176,25 @@ export default function actsWifiManagerFunctionsTest() { ...@@ -185,6 +176,25 @@ export default function actsWifiManagerFunctionsTest() {
let countrylenth = getCountryCodeResult.length; let countrylenth = getCountryCodeResult.length;
console.info("[wifi_test]getCountryCode.length :" + JSON.stringify(countrylenth)); console.info("[wifi_test]getCountryCode.length :" + JSON.stringify(countrylenth));
expect(true).assertEqual(countrylenth == 2); expect(true).assertEqual(countrylenth == 2);
let WIDTH_20MHZ = wifiMg.WifiChannelWidth .WIDTH_20MHZ;
console.info("[wifi_test]WIDTH_20MHZ : " + JSON.stringify(WIDTH_20MHZ));
expect(true).assertEqual( WIDTH_20MHZ == 0);
let WIDTH_40MHZ = wifiMg.WifiChannelWidth .WIDTH_40MHZ;
console.info("[wifi_test]WIDTH_40MHZ : " + JSON.stringify(WIDTH_40MHZ));
expect(true).assertEqual( WIDTH_40MHZ == 1);
let WIDTH_80MHZ = wifiMg.WifiChannelWidth .WIDTH_80MHZ;
console.info("[wifi_test]WIDTH_80MHZ : " + JSON.stringify(WIDTH_80MHZ));
expect(true).assertEqual( WIDTH_80MHZ == 2);
let WIDTH_160MHZ = wifiMg.WifiChannelWidth .WIDTH_160MHZ;
console.info("[wifi_test]WIDTH_160MHZ : " + JSON.stringify(WIDTH_160MHZ));
expect(true).assertEqual( WIDTH_160MHZ == 3);
let WIDTH_80MHZ_PLUS = wifiMg.WifiChannelWidth .WIDTH_80MHZ_PLUS;
console.info("[wifi_test]WIDTH_80MHZ_PLUS : " + JSON.stringify(WIDTH_80MHZ_PLUS));
expect(true).assertEqual( WIDTH_80MHZ_PLUS == 4);
let WIDTH_INVALID = wifiMg.WifiChannelWidth .WIDTH_INVALID;
console.info("[wifi_test]WIDTH_INVALID : " + JSON.stringify(WIDTH_INVALID));
expect(true).assertEqual( WIDTH_INVALID == 5);
}) })
/** /**
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wifi from '@ohos.wifi' import wifi from '@ohos.wifi'
import wifiext from '@ohos.wifiext' import wifiext from '@ohos.wifiext'
import osaccount from '@ohos.account.osAccount' import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
...@@ -42,6 +43,7 @@ async function applyPermission() { ...@@ -42,6 +43,7 @@ async function applyPermission() {
} }
} }
function sleep(delay) { function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
...@@ -53,12 +55,6 @@ function resolveIP(ip) { ...@@ -53,12 +55,6 @@ 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 = {
SLEEPING : 0,
GENERAL : 1,
THROUGH_WALL : 2,
}
export default function actsWifiEventTest() { export default function actsWifiEventTest() {
describe('actsWifiEventTest', function() { describe('actsWifiEventTest', function() {
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -361,6 +357,15 @@ export default function actsWifiEventTest() { ...@@ -361,6 +357,15 @@ export default function actsWifiEventTest() {
console.info("SUB_Communication_WiFi_SysCaps_Test_0007 canIUse isAccessToken error: " + e); console.info("SUB_Communication_WiFi_SysCaps_Test_0007 canIUse isAccessToken error: " + e);
} }
console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end'); console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end');
let SLEEPING = wifiext.PowerModel.SLEEPING;
console.info("[wifi_test]SLEEPING : " + JSON.stringify(SLEEPING));
expect(true).assertEqual( SLEEPING == 0);
let GENERAL = wifiext.PowerModel.GENERAL;
console.info("[wifi_test]GENERAL : " + JSON.stringify(GENERAL));
expect(true).assertEqual( GENERAL == 1);
let THROUGH = wifiext.PowerModel.THROUGH_WALL;
console.info("[wifi_test]THROUGH : " + JSON.stringify(THROUGH));
expect(true).assertEqual( THROUGH == 2);
done(); done();
}) })
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
......
...@@ -20,6 +20,17 @@ import osaccount from '@ohos.account.osAccount' ...@@ -20,6 +20,17 @@ import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
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);
}
async function applyPermission() { async function applyPermission() {
let osAccountManager = osaccount.getAccountManager(); let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish"); console.info("=== getAccountManager finish");
...@@ -41,17 +52,6 @@ async function applyPermission() { ...@@ -41,17 +52,6 @@ async function applyPermission() {
} }
} }
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);
}
export default function actsWifiFunctionsTest() { export default function actsWifiFunctionsTest() {
describe('actsWifiFunctionsTest', function() { describe('actsWifiFunctionsTest', function() {
beforeAll(async function (done) { beforeAll(async function (done) {
...@@ -74,8 +74,6 @@ export default function actsWifiFunctionsTest() { ...@@ -74,8 +74,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;
......
/* /*
* Copyright (C) 2023 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -30,7 +30,7 @@ async function changedLocationMode(){ ...@@ -30,7 +30,7 @@ async function changedLocationMode(){
console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1));
if(!result1){ if(!result1){
await geolocation.requestEnableLocation().then(async(result) => { await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000); await sleep(1000);
console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result));
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + JSON.stringify(error)); console.info("[lbs_js] promise then error." + JSON.stringify(error));
...@@ -130,6 +130,7 @@ export default function geolocationTest_6() { ...@@ -130,6 +130,7 @@ export default function geolocationTest_6() {
geolocationm.getCountryCode((err,data) => { geolocationm.getCountryCode((err,data) => {
if (err) { if (err) {
return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err)); return console.info("[lbs_js] getCountryCode callback err: " + JSON.stringify(err));
expect().assertFail();
} else { } else {
console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data)); console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data));
expect(true).assertEqual(data != null); expect(true).assertEqual(data != null);
...@@ -158,7 +159,7 @@ export default function geolocationTest_6() { ...@@ -158,7 +159,7 @@ export default function geolocationTest_6() {
}); });
} catch (error) { } catch (error) {
console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error));
expect(true).assertEqual(error != null); expect().assertFail();
} }
try { try {
await geolocationm.getCountryCode().then((result) => { await geolocationm.getCountryCode().then((result) => {
...@@ -178,7 +179,7 @@ export default function geolocationTest_6() { ...@@ -178,7 +179,7 @@ export default function geolocationTest_6() {
}) })
} catch (error) { } catch (error) {
console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error)); console.info("[lbs_js] countryCodeChangeOn try err." + JSON.stringify(error));
expect(true).assertEqual(error != null); expect().assertFail();
} }
done(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册