diff --git a/communication/bluetooth_ble/src/main/js/test/BleService.test.js b/communication/bluetooth_ble/src/main/js/test/BleService.test.js index 79d7eb948280198c9326e64ce1d4f7de23cb517f..b8360840c10b2b68935d0d340363a9123e27ed40 100644 --- a/communication/bluetooth_ble/src/main/js/test/BleService.test.js +++ b/communication/bluetooth_ble/src/main/js/test/BleService.test.js @@ -107,12 +107,12 @@ describe('bluetoothBLETest1', function() { isPrimary: true, includeServices: []}; let ret = gattServer.addService(service); console.info('[bluetooth_js] bluetooth addService characteristics is null result:' + ret); - expect(ret).assertTrue(); + expect(ret).assertFalse(); await sleep(1000); let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB'); await sleep(1000); console.info('[bluetooth_js]removeService ret:'+ret1); - expect(ret1).assertTrue(); + expect(ret1).assertFalse(); done(); }) @@ -542,10 +542,26 @@ describe('bluetoothBLETest1', function() { * @tc.level Level 3 */ it('SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100', 0, async function (done) { + let descriptors = []; + let arrayBuffer = new ArrayBuffer(8); + let descV = new Uint8Array(arrayBuffer); + descV[0] = 11; + let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptors[0] = descriptor; + let characteristics = []; + let arrayBufferC = new ArrayBuffer(8); + let cccV = new Uint8Array(arrayBufferC); + cccV[0] = 1; + let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', + characteristicValue: arrayBufferC, descriptors:descriptors}; + characteristics[0] = characteristic; let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', - isPrimary: true,includeServices:[]}; + isPrimary: true,characteristics:characteristics,includeServices:[]}; let gattService1 = {serviceUuid:'00001888-0000-1000-8000-00805f9b34fb', - isPrimary: false,includeServices:[]}; + isPrimary: false,characteristics:characteristics,includeServices:[]}; let ret = gattServer.addService(gattService); console.info('[bluetooth_js] bluetooth addService1 result : ' + ret); expect(ret).assertTrue(); diff --git a/communication/wifi_p2p/Test.json b/communication/wifi_p2p/Test.json index 74df7750738c266d1c4c698d8c8195658c9f829c..3c1431b138666c97fb64d7759300393d1e71774a 100644 --- a/communication/wifi_p2p/Test.json +++ b/communication/wifi_p2p/Test.json @@ -4,7 +4,7 @@ "type": "OHJSUnitTest", "test-timeout": "600000", "shell-timeout": "600000", - "testcase-timeout": "600000", + "testcase-timeout": "600000", "bundle-name": "ohos.acts.communication.wifi.wifidevice", "package-name": "ohos.acts.communication.wifi.wifidevice" }, @@ -15,6 +15,15 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "hilog -Q pidoff", + "power-shell wakeup", + "power-shell setmode 602" + ] } ] } + diff --git a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js index 5fe3c6162dd37f937bc06299f4ac87ff82b9fd14..029e74456ada3a827ed18962e9ab828fddf27efe 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js @@ -25,12 +25,6 @@ function checkWifiPowerOn(){ console.info("[wifi_test]wifi status:" + wifiMg.isWifiActive()); } -let groupOwnerBand = { - GO_BAND_AUTO : 0, - GO_BAND_2GHZ : 1, - GO_BAND_5GHZ : 2, -} - export default function actsWifiManagerEventTest() { describe('actsWifiManagerEventTest', function () { beforeEach(function () { @@ -81,7 +75,7 @@ export default function actsWifiManagerEventTest() { netId : -1, passphrase : "12345678", groupName : "AAAZZZ456", - goBand : 0 + goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, }; let connectResult = wifiMg.p2pConnect(wifiP2PConfig); await wifiMg.getP2pLinkedInfo() @@ -153,7 +147,7 @@ export default function actsWifiManagerEventTest() { netId : -2, passphrase : "12345678", groupName : "AAAZZZ123", - goBand : 0, + goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, }; let createGroupResult = wifiMg.createGroup(WifiP2PConfig); await (2000); @@ -190,3 +184,4 @@ export default function actsWifiManagerEventTest() { }) } + diff --git a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js index 08d40c0d31df31c7b70264ed1af0dd53400256d6..2e2f08ba2484e882d2985b014aa1912dd8ca2a35 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js @@ -25,12 +25,6 @@ function checkWifiPowerOn(){ console.info("[wifi_test]/wifi status:" + wifiMg.isWifiActive()); } -let groupOwnerBand = { - GO_BAND_AUTO : 0, - GO_BAND_2GHZ : 1, - GO_BAND_5GHZ : 2, -} - export default function actsWifiManagerFunctionTest() { describe('actsWifiManagerFunctionTest', function () { beforeEach(function () { @@ -54,7 +48,7 @@ export default function actsWifiManagerFunctionTest() { netId : -1, passphrase : "12345678", groupName : "AAAZZZ123", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; console.log("[wifi_test]check the state of wifi: " + wifiMg.isWifiActive()); expect(wifiMg.isWifiActive()).assertTrue(); @@ -115,7 +109,7 @@ export default function actsWifiManagerFunctionTest() { netId: -1, passphrase: "1234567", groupName: "test_pass", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -149,7 +143,7 @@ export default function actsWifiManagerFunctionTest() { netId: -1, passphrase: "123@%abcD", groupName: "test_pass1", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -183,7 +177,7 @@ export default function actsWifiManagerFunctionTest() { netId: -1, passphrase: "abc345678901234567890123456789012345678901234567890123456789012", groupName: "test_pass2", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -217,7 +211,7 @@ export default function actsWifiManagerFunctionTest() { netId: -1, passphrase: "abc3456789012345678901234567890123456789012345678901234567890123", groupName: "test_pass3", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -251,7 +245,7 @@ export default function actsWifiManagerFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band1", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -286,7 +280,7 @@ export default function actsWifiManagerFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band2", - goBand : groupOwnerBand.GO_BAND_5GHZ, + goBand : wifiMg.GroupOwnerBand.GO_BAND_5GHZ, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -325,7 +319,7 @@ export default function actsWifiManagerFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band3", - goBand : groupOwnerBand.GO_BAND_AUTO, + goBand : wifiMg.GroupOwnerBand.GO_BAND_AUTO, }; let createGroupResult = wifiMg.createGroup(wifiP2PConfig); await sleep(2000); @@ -348,6 +342,120 @@ export default function actsWifiManagerFunctionTest() { done(); }) + /** + * @tc.number SUB_Communication_WiFi_XTS_P2P_0008 + * @tc.name testCreateGroup + * @tc.desc Test createGroup-SSID is an empty string Function. + * @tc.type Function + * @tc.level Level 0 + */ + it('SUB_Communication_WiFi_XTS_P2P_0008', 0, async function (done) { + console.log("[wifi_test]check the state of wifi: " + wifiMg.isWifiActive()); + expect(wifiMg.isWifiActive()).assertTrue(); + try { + let wifiP2PConfig = { + deviceAddress: "00:00:00:00:00:00", + netId: -1, + passphrase: "12345678", + groupName: "", + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, + }; + let createGroupResult = wifi.createGroup(wifiP2PConfig); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test]getCurrentGroup promise result : " + JSON.stringify(data)); + }); + let removeGroupResult = wifi.removeGroup(); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }); + }catch(error){ + console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } + done(); + }) + + /** + * @tc.number SUB_Communication_WiFi_XTS_P2P_0108 + * @tc.name testCreateGroup + * @tc.desc Test createGroup-SSID is a space Function. + * @tc.type Function + * @tc.level Level 0 + */ + it('SUB_Communication_WiFi_XTS_P2P_0108', 0, async function (done) { + console.log("[wifi_test]check the state of wifi: " + wifiMg.isWifiActive()); + expect(wifiMg.isWifiActive()).assertTrue(); + try { + let wifiP2PConfig = { + deviceAddress: "00:00:00:00:00:00", + netId: -1, + passphrase: "12345678", + groupName: " ", + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, + }; + let createGroupResult = wifi.createGroup(wifiP2PConfig); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test]getCurrentGroup promise result :" + JSON.stringify(data)); + }); + let removeGroupResult = wifi.removeGroup(); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }); + }catch(error){ + console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } + done(); + }) + + /** + * @tc.number SUB_Communication_WiFi_XTS_P2P_0308 + * @tc.name testCreateGroup + * @tc.desc Test createGroup-the password must be a space. + * @tc.type Function + * @tc.level Level 0 + */ + it('SUB_Communication_WiFi_XTS_P2P_0308', 0, async function (done) { + console.log("[wifi_test]check the state of wifi: " + wifiMg.isWifiActive()); + expect(wifiMg.isWifiActive()).assertTrue(); + try { + let wifiP2PConfig = { + deviceAddress: "00:00:00:00:00:00", + netId: -1, + passphrase: " ", + groupName: "testpassword", + goBand: wifiMg.GroupOwnerBand.GO_BAND_2GHZ, + }; + let createGroupResult = wifi.createGroup(wifiP2PConfig); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result :" + JSON.stringify(data)); + }); + let removeGroupResult = wifi.removeGroup(); + await sleep(2000); + await wifi.getCurrentGroup() + .then(data => { + console.info("[wifi_test] getCurrentGroup promise result1 :" + JSON.stringify(data)); + expect(true).assertEqual(data.deviceName == null); + }); + }catch(error){ + console.info("[wifi_test]createGroup error passphrase result : " + JSON.stringify(error.message)); + expect(true).assertEqual( (JSON.stringify(error.message)) !=null); + } + done(); + }) + /** * @tc.number SUB_Communication_WiFi_XTS_P2P_0009 * @tc.name testP2pCancelConnect @@ -361,7 +469,7 @@ export default function actsWifiManagerFunctionTest() { netId : -1, passphrase : "12345678", groupName : "AAAZZZ456", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifiMg.GroupOwnerBand.GO_BAND_2GHZ, }; let p2pConnectResult = wifiMg.p2pConnect(wifiP2PConfig); console.info("[wifi_test]test p2pConnect successful." ); @@ -506,13 +614,6 @@ export default function actsWifiManagerFunctionTest() { * @tc.level Level 0 */ it('SUB_Communication_WiFi_XTS_P2P_0101', 0, async function(done){ - let p2pDeviceStatus = { - CONNECTED : 0, - INVITED : 1, - FAILED : 2, - AVAILABLE : 3, - UNAVAILABLE : 4, - }; console.log("[wifi_test]check the state of wifi: " + wifiMg.isWifiActive()); expect(wifiMg.isWifiActive()).assertTrue(); let startDiscover = wifiMg.startDiscoverDevices(); @@ -532,19 +633,19 @@ export default function actsWifiManagerFunctionTest() { "primaryDeviceType: " + result[j].primaryDeviceType + "deviceStatus: " + result[j].deviceStatus + "groupCapabilitys: " + result[j].groupCapabilitys ); - if(result[j].deviceStatus ==p2pDeviceStatus.UNAVAILABLE){ + if(result[j].deviceStatus == wifiMg.P2pDeviceStatus.UNAVAILABLE){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.CONNECTED){ + if(result[j].deviceStatus == wifiMg.P2pDeviceStatus.CONNECTED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.INVITED){ + if(result[j].deviceStatus == wifiMg.P2pDeviceStatus.INVITED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.FAILED){ + if(result[j].deviceStatus == wifiMg.P2pDeviceStatus.FAILED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.AVAILABLE){ + if(result[j].deviceStatus == wifiMg.P2pDeviceStatus.AVAILABLE){ console.info("deviceStatus: " + result[j].deviceStatus); } } @@ -554,8 +655,9 @@ export default function actsWifiManagerFunctionTest() { } await getP2pPeerDevicesResult(); done(); - }); + }); console.log("*************[wifi_test] start wifi js unit test end*************"); }) } + diff --git a/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js b/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js index 44ff0074de1af78e7dd20dd11c03767aeb3f50bd..d7ff7990b3e7cc61994f0f5d4dc0f75aa055f04a 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js @@ -25,12 +25,6 @@ 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 () { @@ -42,13 +36,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0008 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0008', 0, async function (done) { let p2pState = "p2pStateChange"; let p2pStateChangeCallback = result => { console.info("[wifi_test]p2pStateChange callback, result: " + JSON.stringify(result)); @@ -60,28 +54,24 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0009 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0009', 0, async function (done) { let p2pConnectionState = "p2pConnectionChange"; let p2pConnectionChangeCallback = result => { console.info("[wifi_test]p2pConnectionChange callback, result: " + JSON.stringify(result)); } wifi.on(p2pConnectionState, p2pConnectionChangeCallback); - let p2pConnectState = { - DISCONNECTED :0, - CONNECTED : 1, - }; let wifiP2PConfig = { deviceAddress : "00:00:00:00:00:00", netId : -1, passphrase : "12345678", groupName : "AAAZZZ456", - goBand : 0 + goBand : wifi.GroupOwnerBand.GO_BAND_AUTO }; let connectResult = wifi.p2pConnect(wifiP2PConfig); console.info("[wifi_test]test p2pConnect result." + connectResult); @@ -101,13 +91,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0012 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0012', 0, async function (done) { let p2pDeviceState = "p2pDeviceChange"; let p2pDeviceChangeCallback = result => { console.info("[wifi_test]p2pDeviceChange callback, result: " + JSON.stringify(result)); @@ -119,13 +109,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0010 + * @tc.number Communication_WiFi_Event_Test_0010 * @tc.name testp2pPeerDeviceChange * @tc.desc Test p2pPeerDeviceChange callback * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_Event_Test_0010', 0, async function (done) { + it('Communication_WiFi_Event_Test_0010', 0, async function (done) { let p2pPeerDeviceState = "p2pPeerDeviceChange"; let p2pPeerDeviceChangeCallback = result => { console.info("[wifi_test]p2pPeerDeviceChange callback, result: " + JSON.stringify(result)); @@ -141,13 +131,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0013 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0013', 0, async function (done) { let p2pGroupState = "p2pPersistentGroupChange"; let p2pPersistentGroupChangeCallback = () => { console.info("[wifi_test]p2pPersistentGroupChange callback, result: " + JSON.stringify(result)); @@ -158,7 +148,7 @@ export default function actsWifiEventTest() { netId : -2, passphrase : "12345678", groupName : "AAAZZZ123", - goBand : 0, + goBand : wifi.GroupOwnerBand.GO_BAND_AUTO, }; let createGroupResult = wifi.createGroup(WifiP2PConfig); await (2000); @@ -175,13 +165,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0011 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0011', 0, async function (done) { let p2pPeerDeviceState = "p2pDiscoveryChange"; let p2pDiscoveryChangeCallback = result => { console.info("[wifi_test]p2pDiscoveryChange callback, result: " + JSON.stringify(result)); @@ -199,3 +189,4 @@ export default function actsWifiEventTest() { }) } + diff --git a/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js b/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js index 39cafa711a063f1b736fedeec233dab7bc3d64e8..87e260615b8b6c7073d4e554493a9c2cae310dc3 100644 --- a/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js +++ b/communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js @@ -25,12 +25,6 @@ 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 actsWifiFunctionTest() { describe('actsWifiFunctionTest', function () { beforeEach(function () { @@ -42,19 +36,19 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0003 + * @tc.number Communication_WiFi_XTS_P2P_0003 * @tc.name testCreateGroup * @tc.desc Test createGroup and getCurrentGroup API Function * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0003', 0, async function(done) { + it('Communication_WiFi_XTS_P2P_0003', 0, async function(done) { let wifiP2PConfig = { deviceAddress : "00:00:00:00:00:00", netId : -1, passphrase : "12345678", groupName : "AAAZZZ123", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifi.GroupOwnerBand.GO_BAND_2GHZ, }; console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); @@ -104,13 +98,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0004 + * @tc.number Communication_WiFi_XTS_P2P_0004 * @tc.name testCreateGroup * @tc.desc Test createGroup-Setting a 7-bit Key Function. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0004', 0, async function (done) { + it('Communication_WiFi_XTS_P2P_0004', 0, async function (done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let wifiP2PConfig = { @@ -118,7 +112,7 @@ export default function actsWifiFunctionTest() { netId: -1, passphrase: "1234567", groupName: "test_pass", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); console.info("[wifi_test]test createGroup end." + JSON.stringify(createGroupResult)); @@ -141,13 +135,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0104 + * @tc.number Communication_WiFi_XTS_P2P_0104 * @tc.name testCreateGroup * @tc.desc Test createGroup-Key setting: Chinese, English, and characters Function. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0104', 0, async function (done) { + it('Communication_WiFi_XTS_P2P_0104', 0, async function (done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let wifiP2PConfig = { @@ -155,7 +149,7 @@ export default function actsWifiFunctionTest() { netId: -1, passphrase: "123@%abcD", groupName: "test_pass1", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); console.info("[wifi_test]test createGroup end." + JSON.stringify(createGroupResult)); @@ -178,13 +172,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0204 + * @tc.number Communication_WiFi_XTS_P2P_0204 * @tc.name testCreateGroup * @tc.desc Test createGroup-Key setting 64 bit Function. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0204', 0, async function (done) { + it('Communication_WiFi_XTS_P2P_0204', 0, async function (done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let wifiP2PConfig = { @@ -192,7 +186,7 @@ export default function actsWifiFunctionTest() { netId: -1, passphrase: "abc345678901234567890123456789012345678901234567890123456789012", groupName: "test_pass2", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); console.info("[wifi_test]test createGroup end." + JSON.stringify(createGroupResult)); @@ -215,13 +209,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0304 + * @tc.number Communication_WiFi_XTS_P2P_0304 * @tc.name testCreateGroup * @tc.desc Test createGroup-Key setting 65 bitsFunction. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0304', 0, async function (done) { + it('Communication_WiFi_XTS_P2P_0304', 0, async function (done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let wifiP2PConfig = { @@ -229,7 +223,7 @@ export default function actsWifiFunctionTest() { netId: -1, passphrase: "abc3456789012345678901234567890123456789012345678901234567890123", groupName: "test_pass3", - goBand: groupOwnerBand.GO_BAND_2GHZ, + goBand: wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); console.info("[wifi_test]test createGroup end." + JSON.stringify(createGroupResult)); @@ -252,13 +246,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0007 + * @tc.number Communication_WiFi_XTS_P2P_0007 * @tc.name testCreateGroup * @tc.desc Test createGroup-2.4 GHz frequency band setting Function * @tc.type Function * @tc.level Level 0 */ - it('SUB_Communication_WiFi_XTS_P2P_0007', 0, async function(done) { + it('Communication_WiFi_XTS_P2P_0007', 0, async function(done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let wifiP2PConfig = { @@ -266,7 +260,7 @@ export default function actsWifiFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band1", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); await sleep(2000); @@ -289,13 +283,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0107 + * @tc.number Communication_WiFi_XTS_P2P_0107 * @tc.name testCreateGroup * @tc.desc Test createGroup-5 GHz frequency band setting Function * @tc.type Function * @tc.level Level 0 */ - it('SUB_Communication_WiFi_XTS_P2P_0107', 0, async function(done) { + it('Communication_WiFi_XTS_P2P_0107', 0, async function(done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); try { @@ -304,7 +298,7 @@ export default function actsWifiFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band2", - goBand : groupOwnerBand.GO_BAND_5GHZ, + goBand : wifi.GroupOwnerBand.GO_BAND_5GHZ, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); await sleep(2000); @@ -331,13 +325,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0207 + * @tc.number Communication_WiFi_XTS_P2P_0207 * @tc.name testCreateGroup * @tc.desc Test createGroup-Auto frequency band setting Function * @tc.type Function * @tc.level Level 0 */ - it('SUB_Communication_WiFi_XTS_P2P_0207', 0, async function(done) { + it('Communication_WiFi_XTS_P2P_0207', 0, async function(done) { console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); try { @@ -346,7 +340,7 @@ export default function actsWifiFunctionTest() { netId : -1, passphrase : "12345678", groupName : "test_band3", - goBand : groupOwnerBand.GO_BAND_AUTO, + goBand : wifi.GroupOwnerBand.GO_BAND_AUTO, }; let createGroupResult = wifi.createGroup(wifiP2PConfig); await sleep(2000); @@ -373,19 +367,19 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0009 + * @tc.number 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) { + it('Communication_WiFi_XTS_P2P_0009', 0, async function (done) { let wifiP2PConfig = { deviceAddress : "11:22:33:44:55:66", netId : -1, passphrase : "12345678", groupName : "AAAZZZ456", - goBand : groupOwnerBand.GO_BAND_2GHZ, + goBand : wifi.GroupOwnerBand.GO_BAND_2GHZ, }; let p2pConnectResult = wifi.p2pConnect(wifiP2PConfig); console.info("[wifi_test]test p2pConnect result." + p2pConnectResult); @@ -405,13 +399,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0011 + * @tc.number Communication_WiFi_XTS_P2P_0011 * @tc.name testRemoveGroup * @tc.desc Test remove a nonexistent group. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_P2P_0011', 0, async function (done) { + it('Communication_WiFi_XTS_P2P_0011', 0, async function (done) { let removeGroupResult = wifi.removeGroup(10000); console.info("[wifi_test]removeGroup(10000) result : " + JSON.stringify(removeGroupResult)); expect(removeGroupResult).assertTrue(); @@ -424,51 +418,14 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0002 - * @tc.name testP2pLocalDevice - * @tc.desc Test get 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 => { - console.info("[wifi_test]getP2pLocalDevice promise result :" + JSON.stringify(data)); - expect(true).assertEqual(data.deviceName !=null); - }).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(); - }) - - /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0010 + * @tc.number Communication_WiFi_XTS_P2P_0010 * @tc.name testGetP2pLinkedInfo * @tc.desc Test getP2pLinkedInfo API functionality * @tc.type Function * @tc.level Level 2 */ - it('SUB_Communication_WiFi_XTS_P2P_0010', 0, async function(done) { - let p2pConnectState = { + it('Communication_WiFi_XTS_P2P_0010', 0, async function(done) { + let P2pConnectState = { DISCONNECTED :0, CONNECTED : 1, }; @@ -502,13 +459,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0001 + * @tc.number Communication_WiFi_XTS_P2P_0001 * @tc.name testGetP2pPeerDevices * @tc.desc Test getP2pPeerDevices promise API functionality * @tc.type Function * @tc.level Level 0 */ - it('SUB_Communication_WiFi_XTS_P2P_0001', 0, async function(done){ + it('Communication_WiFi_XTS_P2P_0001', 0, async function(done){ console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let startDiscover = wifi.startDiscoverDevices(); @@ -529,20 +486,13 @@ export default function actsWifiFunctionTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_P2P_0101 + * @tc.number Communication_WiFi_XTS_P2P_0101 * @tc.name testGetP2pPeerDevices * @tc.desc Test getP2pPeerDevices callback API functionality * @tc.type Function * @tc.level Level 0 */ - it('SUB_Communication_WiFi_XTS_P2P_0101', 0, async function(done){ - let p2pDeviceStatus = { - CONNECTED : 0, - INVITED : 1, - FAILED : 2, - AVAILABLE : 3, - UNAVAILABLE : 4, - }; + it('Communication_WiFi_XTS_P2P_0101', 0, async function(done){ console.log("[wifi_test]check the state of wifi: " + wifi.isWifiActive()); expect(wifi.isWifiActive()).assertTrue(); let startDiscover = wifi.startDiscoverDevices(); @@ -564,30 +514,35 @@ export default function actsWifiFunctionTest() { "primaryDeviceType: " + result[j].primaryDeviceType + "deviceStatus: " + result[j].deviceStatus + "groupCapabilitys: " + result[j].groupCapabilitys ); - if(result[j].deviceStatus ==p2pDeviceStatus.UNAVAILABLE){ + if(result[j].deviceStatus == wifi.P2pDeviceStatus.UNAVAILABLE){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.CONNECTED){ + if(result[j].deviceStatus == wifi.P2pDeviceStatus.CONNECTED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.INVITED){ + if(result[j].deviceStatus == wifi.P2pDeviceStatus.INVITED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.FAILED){ + if(result[j].deviceStatus == wifi.P2pDeviceStatus.FAILED){ console.info("deviceStatus: " + result[j].deviceStatus); } - if(result[j].deviceStatus ==p2pDeviceStatus.AVAILABLE){ + if(result[j].deviceStatus == wifi.P2pDeviceStatus.AVAILABLE){ console.info("deviceStatus: " + result[j].deviceStatus); } } resolve(); + + + + }); }); } await getP2pPeerDevicesResult(); done(); - }); + }); console.log("*************[wifi_test] start wifi js unit test end*************"); }) } + diff --git a/communication/wifi_standard/Test.json b/communication/wifi_standard/Test.json index fd2a374a9985174e6ce841017b704d885019e77e..4f21a7271562778599eb5118cc22063fdeab825f 100644 --- a/communication/wifi_standard/Test.json +++ b/communication/wifi_standard/Test.json @@ -4,6 +4,7 @@ "type": "OHJSUnitTest", "test-timeout": "600000", "shell-timeout": "600000", + "testcase-timeout":"600000", "bundle-name": "ohos.acts.communication.wifi.wifidevice", "package-name": "ohos.acts.communication.wifi.wifidevice" }, @@ -19,6 +20,7 @@ "type": "ShellKit", "run-command": [ "hilog -Q pidoff", + "power-shell wakeup", "power-shell setmode 602" ] } diff --git a/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js b/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js index af4d6519333830e26b9ffb6ee1ad29cef697ad1b..9e893e5b214eb2148f1e0d27e98e6f4735325306 100644 --- a/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js @@ -35,31 +35,6 @@ let wifiSecurityType = { WIFI_SEC_TYPE_WEP: 2, WIFI_SEC_TYPE_PSK: 3, WIFI_SEC_TYPE_SAE: 4, - 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 , -} - -let connState = { - SCANNING: 0, - CONNECTING: 1, - AUTHENTICATING: 2, - OBTAINING_IPADDR: 3, - CONNECTED: 4, - DISCONNECTING: 5, - DISCONNECTED: 6, - UNKNOWN: 7, -} - -let wifiChannelWidth = { - WIDTH_20MHZ : 0, - WIDTH_40MHZ : 1, - WIDTH_80MHZ : 2, - WIDTH_160MHZ : 3, - WIDTH_80MHZ_PLUS : 4, - WIDTH_INVALID:null, } export default function actsWifiCandidateNetWorkTest() { @@ -71,321 +46,13 @@ export default function actsWifiCandidateNetWorkTest() { }) /** - * @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 = { - "ssid": "TEST_OPEN", - "bssid": "", - "preSharedKey": "", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_OPEN, - }; - await wifi.addCandidateConfig(wifiDeviceConfig) - .then(netWorkId => { - console.info("[wifi_test]add OPEN CandidateConfig promise : " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId = -1); - }).catch((error) => { - console.error('[wifi_test]add OPEN CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect(false).assertFalse(); - }); - let getconfig = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get OPEN CandidateConfigs result : " + JSON.stringify(getconfig)); - let wifiDeviceConfig1 = { - "ssid": "TEST_WEP", - "bssid": "", - "preSharedKey": "ABCDEF1234", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_WEP, - }; - await wifi.addCandidateConfig(wifiDeviceConfig1) - .then(netWorkId => { - console.info("[wifi_test]add WEP CandidateConfig promise : " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId = -1); - }).catch((error) => { - console.error('[wifi_test]add WEP CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect(false).assertFalse(); - }); - console.info("[wifi_test]wifi get WEP CandidateConfigs result : " + JSON.stringify(getconfig)); - done(); - }) - - /** - * @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 = { - "ssid": "TEST_PSK", - "bssid": "", - "preSharedKey": "12345678", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, - "netId": -1, - "ipType": 1, - "creatorUid": 7, - "disableReason": 0, - "randomMacType": 0, - "randomMacAddr": "11:22:33:44:55:66", - "staticIp": {"ipAddress": 1284752956,"gateway": 1284752936}, - }; - await wifi.addCandidateConfig(wifiDeviceConfig) - .then(netWorkId => { - console.info("[wifi_test]add PSK CandidateConfig promise : " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId != -1); - }).catch((error) => { - console.error('[wifi_test]add PSK CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect().assertFail(); - }); - let getCandidateResult = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get PSK CandidateConfigs result : " + JSON.stringify(getCandidateResult)); - var networkId = getCandidateResult[0].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 getCandidate = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get CandidateConfigs result : " + JSON.stringify(getCandidate)); - console.info("[wifi_test]wifi getconfig.length result : " + JSON.stringify(getCandidate.length)); - expect(true).assertEqual(getCandidate.length == 0); - }).catch((error) => { - console.error('[wifi_test]remove CandidateConfig promise failed : ' + JSON.stringify(error)); - expect().assertFail(); - }); - done(); - }) - - /** - * @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 = { - "ssid": "TEST_SAE", - "bssid": "", - "preSharedKey": "12345678", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_SAE, - }; - await wifi.addCandidateConfig(wifiDeviceConfig) - .then(netWorkId => { - console.info("[wifi_test]add SAE CandidateConfig promise : " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId != -1); - }).catch((error) => { - console.error('[wifi_js]add SAE CandidateConfig promise failed -> ' + JSON.stringify(error)); - }); - let getCandidateResult = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get SAE CandidateConfigs result : " + JSON.stringify(getCandidateResult)); - var networkId = getCandidateResult[0].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 getconfig.length result : " + JSON.stringify(getconfig1.length)); - expect(true).assertEqual(getconfig1.length == 0); - }).catch((error) => { - console.error('[wifi_test]remove CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect().assertFail(); - }); - done(); - }) - - /** - * @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_test]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_test]add 17th CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect(true).assertEqual(error == -1); - }); - let getCandidateResult = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get 16 CandidateConfigs result : " + JSON.stringify(getCandidateResult)); - for (let i = 0; i < 16; i++) { - var networkId = getCandidateResult[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_test]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 = { - "ssid": "TYPE_PSK1", - "bssid": "", - "preSharedKey": "12345678", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, - } - - function addCandidate() { - return new Promise((resolve, reject) => { - wifi.addCandidateConfig(wifiDeviceConfig, - (err, netWorkId) => { - if (err) { - console.info("[wifi_test]add CandidateConfig callback failed : " + JSON.stringify(err)); - } - console.info("[wifi_test]addCandidateConfig callback result: " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId != -1); - resolve(); - }); - }); - } - await addCandidate(); - let getCandidateResult = wifi.getCandidateConfigs(); - console.info("[wifi_test] wifi getCandidateConfigs result : " + JSON.stringify(getCandidateResult)); - var networkId = getCandidateResult[0].netId; - function removeCandidate() { - return new Promise((resolve, reject) => { - wifi.removeCandidateConfig(networkId, - (err, ret) => { - if (err) { - console.info("[wifi_test]removeCandidate callback failed : " + JSON.stringify(err)); - } - console.info("[wifi_test] removeCandidateConfig callback result:" + JSON.stringify(ret)); - expect(ret).assertTrue(); - let configs1 = wifi.getCandidateConfigs(); - console.info("[wifi_test] wifi get CandidateConfigs result : " + JSON.stringify(configs1)); - console.info("[wifi_test] getconfig.length result : " + JSON.stringify(configs1.length)); - expect(true).assertEqual(configs1.length == 0); - resolve(); - }); - }); - } - await removeCandidate(); - done(); - }) - - /** - * @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 = { - 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 wifiDeviceConfig = { - "ssid": "TEST_connect", - "bssid": "", - "preSharedKey": "12345678", - "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, - }; - await wifi.addCandidateConfig(wifiDeviceConfig) - .then(netWorkId => { - console.info("[wifi_test]add CandidateConfig promise : " + JSON.stringify(netWorkId)); - expect(true).assertEqual(netWorkId != -1); - }).catch((error) => { - console.error('[wifi_test]add CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect().assertFail(); - }); - let getCandidateResult = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get CandidateConfigs result : " + JSON.stringify(getCandidateResult)); - let connectToCandidateResult = wifi.connectToCandidateConfig(getCandidateResult[0].netId); - console.info("[wifi_test]connect To CandidateConfig result : " + JSON.stringify(connectToCandidateResult)); - await sleep(3000); - await wifi.getLinkedInfo() - .then((result) => { - console.info("[wifi_test]get wifi link [promise] -> " + JSON.stringify(result)); - done(); - }).catch((error) => { - console.info("[wifi_test]promise then error." + JSON.stringify(error)); - expect().assertFail(); - }); - let getCandidateResult1 = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get CandidateConfigs result1 : " + JSON.stringify(getCandidateResult1)); - var networkId = getCandidateResult1[0].netId; - console.info("[wifi_test]wifi get networkId result : " + JSON.stringify(networkId)); - await wifi.removeCandidateConfig(networkId) - .then(ret => { - let getconfig1 = wifi.getCandidateConfigs(); - console.info("[wifi_test]wifi get CandidateConfigs result2 : " + JSON.stringify(getconfig1)); - console.info("[wifi_test]wifi getconfig.length result : " + JSON.stringify(getconfig1.length)); - expect(true).assertEqual(getconfig1.length == 0); - }).catch((error) => { - console.error('[wifi_test]remove CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect().assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_XTS_UntrustedConfig_0001 + * @tc.number Communication_WiFi_XTS_UntrustedConfig_0001 * @tc.name testaddUntrustedConfig * @tc.desc Test add UntrustedConfig and removeUntrustedConfig Promise API functionality. * @tc.type Function * @tc.level Level 2 */ - it('SUB_Communication_WiFi_XTS_UntrustedConfig_0001', 0, async function (done) { + it('Communication_WiFi_XTS_UntrustedConfig_0001', 0, async function (done) { let wifiDeviceConfig = { "ssid": "TEST_PSK", "bssid": "", @@ -411,13 +78,13 @@ export default function actsWifiCandidateNetWorkTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_UntrustedConfig_0002 + * @tc.number Communication_WiFi_XTS_UntrustedConfig_0002 * @tc.name testaddUntrustedConfig * @tc.desc Test add UntrustedConfig and removeUntrustedConfig callback API functionality. * @tc.type Function * @tc.level Level 2 */ - it('SUB_Communication_WiFi_XTS_UntrustedConfig_0002', 0, async function (done) { + it('Communication_WiFi_XTS_UntrustedConfig_0002', 0, async function (done) { let wifiDeviceConfig = { "ssid": "TYPE_PSK1", "bssid": "", @@ -458,3 +125,4 @@ export default function actsWifiCandidateNetWorkTest() { }) } + diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js index 757d479f71956cb2982e5b1d0700f8cac4d74551..e7d6b480db18fabfbf5f86774626c73c8a9c753c 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js @@ -31,10 +31,6 @@ function resolveIP(ip) { 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, WIFI_SEC_TYPE_EAP: 5, WIFI_SEC_TYPE_EAP_SUITE_B: 6, WIFI_SEC_TYPE_OWE:7 , @@ -42,26 +38,6 @@ let wifiSecurityType = { WIFI_SEC_TYPE_WAPI_PSK:9 , } -let connState = { - SCANNING: 0, - CONNECTING: 1, - AUTHENTICATING: 2, - OBTAINING_IPADDR: 3, - CONNECTED: 4, - DISCONNECTING: 5, - DISCONNECTED: 6, - UNKNOWN: 7, -} - -let wifiChannelWidth = { - WIDTH_20MHZ : 0, - WIDTH_40MHZ : 1, - WIDTH_80MHZ : 2, - WIDTH_160MHZ : 3, - WIDTH_80MHZ_PLUS : 4, - WIDTH_INVALID:null, -} - export default function actsWifiManagerCandidateNetWorkTest() { describe('actsWifiManagerCandidateNetWorkTest', function () { beforeEach(function () { @@ -83,7 +59,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_OPEN, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_OPEN, }; await wifiMg.addCandidateConfig(wifiDeviceConfig) .then(netWorkId => { @@ -91,7 +67,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { expect(true).assertEqual(netWorkId = -1); }).catch((error) => { console.error('[wifi_test]add OPEN CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect(false).assertFalse(); + expect(true).assertEqual( (JSON.stringify(error)) !=null); }); let getconfig = wifiMg.getCandidateConfigs(); console.info("[wifi_test]wifi get OPEN CandidateConfigs result : " + JSON.stringify(getconfig)); @@ -100,7 +76,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "ABCDEF1234", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_WEP, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_WEP, }; await wifiMg.addCandidateConfig(wifiDeviceConfig1) @@ -109,7 +85,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { expect(true).assertEqual(netWorkId = -1); }).catch((error) => { console.error('[wifi_test]add WEP CandidateConfig promise failed -> ' + JSON.stringify(error)); - expect(false).assertFalse(); + expect(true).assertEqual( (JSON.stringify(error)) !=null); }); console.info("[wifi_test]wifi get WEP CandidateConfigs result : " + JSON.stringify(getconfig)); done(); @@ -128,7 +104,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_PSK, "netId": -1, "ipType": 1, "creatorUid": 7, @@ -175,7 +151,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_SAE, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_SAE, }; await wifiMg.addCandidateConfig(wifiDeviceConfig) .then(netWorkId => { @@ -218,7 +194,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_PSK, }; console.info("[wifi_test]get wifiDeviceConfig ssid result : " + JSON.stringify(wifiDeviceConfig.ssid)); await wifiMg.addCandidateConfig(wifiDeviceConfig) @@ -235,7 +211,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_PSK, }; await wifiMg.addCandidateConfig(wifiDeviceConfig1) .then(netWorkId => { @@ -275,7 +251,7 @@ export default function actsWifiManagerCandidateNetWorkTest() { "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_PSK, } function addCandidate() { return new Promise((resolve, reject) => { @@ -321,19 +297,12 @@ export default function actsWifiManagerCandidateNetWorkTest() { * @tc.level Level 2 */ it('SUB_Communication_WiFi_XTS_CandidateNetWork_0006', 0, async function (done) { - 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 wifiDeviceConfig = { "ssid": "HONOR 3000", "bssid": "", "preSharedKey": "12345678", "isHiddenSsid": false, - "securityType": wifiSecurityType.WIFI_SEC_TYPE_PSK, + "securityType": wifiMg.WifiSecurityType.WIFI_SEC_TYPE_PSK, }; await wifiMg.addCandidateConfig(wifiDeviceConfig) .then(netWorkId => { @@ -374,3 +343,4 @@ export default function actsWifiManagerCandidateNetWorkTest() { }) } + diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js index b5dab1ef72b1cf70d9150e3a2464d882b63f26ea..d1c52ac285f619589d106ee9326f1d50a170dcad 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js @@ -17,8 +17,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import wifiMg from '@ohos.wifiManager' -import wifiext from '@ohos.wifiext' - import wifiManagerExt from '@ohos.wifiManagerExt' function sleep(delay) { @@ -32,53 +30,6 @@ 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, - 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 , -} - -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, -} - -let groupOwnerBand = { - GO_BAND_AUTO : 0, - GO_BAND_2GHZ : 1, - GO_BAND_5GHZ : 2, -} - export default function actsWifiManagerEventTest() { describe('actsWifiManagerEventTest', function() { beforeEach(function () { @@ -178,206 +129,6 @@ export default function actsWifiManagerEventTest() { done(); }) - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0001 - * @tc.name testenableHotspot - * @tc.desc Test enableHotspot api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0001', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0001 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0001 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] enableHotspot: " + wifiext.enableHotspot()) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0001 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0001 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0002 - * @tc.name testdisableHotspot - * @tc.desc Test disableHotspot api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0002', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0002 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0002 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] disableHotspot: " + wifiext.disableHotspot()) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0002 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0002 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0003 - * @tc.name testgetSupportedPowerModel - * @tc.desc Test getSupportedPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0003', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0003 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0003 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - await wifiext.getSupportedPowerModel() - .then(data => { - console.info("[wifi_test]getSupportedPowerModel promise result -> " + JSON.stringify(data)); - }); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0003 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0003 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0004 - * @tc.name testgetSupportedPowerModel - * @tc.desc Test getSupportedPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0004', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0004 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0004 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - function getSupportedPowerModelResult(){ - return new Promise((resolve, reject) => { - wifiext.getSupportedPowerModel( - (err, result) => { - if(err) { - console.info("[wifi_test]failed to getSupportedPowerModel:" + JSON.stringify(err)); - expect(true).assertTrue(); - } - console.info("[wifi_test]getSupportedPowerModel callback:" + JSON.stringify(result)); - resolve(); - }); - }); - } - await getSupportedPowerModelResult(); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0004 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0004 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0005 - * @tc.name testgetPowerModel - * @tc.desc Test getPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0005', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0005 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0005 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - await wifiext.getPowerModel() - .then(data => { - console.info("[wifi_test]getPowerModel promise result -> " + JSON.stringify(data)); - }); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0005 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0005 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0006 - * @tc.name testgetPowerModel - * @tc.desc Test getPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0006', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0006 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0006 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - function getPowerModelResult(){ - return new Promise((resolve, reject) => { - wifiext.getPowerModel( - (err, result) => { - if(err) { - console.info("[wifi_test]failed to getPowerModel:" + JSON.stringify(err)); - expect(true).assertTrue(); - } - console.info("[wifi_test]getPowerModel callback:" + JSON.stringify(result)); - resolve(); - }); - }); - } - await getPowerModelResult(); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0006 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0006 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0007 - * @tc.name testsetPowerModel - * @tc.desc Test setPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0007', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0007 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.wifiMg.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0007 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] setPowerModel: " + wifiext.setPowerModel(PowerModel)) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0007 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end'); - done(); - }) - /** * @tc.number SUB_Communication_WiFi_SysCaps_Test_0008 * @tc.name testenableHotspot @@ -581,3 +332,4 @@ export default function actsWifiManagerEventTest() { }) } + diff --git a/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js b/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js index 0b9d4cae89b89835a44f83eb55c38ed1ae2ba591..aabe731785e9d4c4a94775c08dcddb03c41b3d65 100644 --- a/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js @@ -29,38 +29,6 @@ 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, - 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 , -} - -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, @@ -278,28 +246,28 @@ export default function actsWifiManagerFunctionsTest() { "suppState: " + result.suppState + "connState: " + result.connState + "macType: " + result.macType); let state = wifiMg.getLinkedInfo().ConnState; - if (state == connState.SCANNING) { + if (state == wifiMg.connState.SCANNING) { expect(true).assertEqual(state == 0); } - if (state == connState.CONNECTING) { + if (state == wifiMg.connState.CONNECTING) { expect(true).assertEqual(state == 1); } - if (state == connState.AUTHENTICATING) { + if (state == wifiMg.connState.AUTHENTICATING) { expect(true).assertEqual(state == 2); } - if (state == connState.OBTAINING_IPADDR) { + if (state == wifiMg.connState.OBTAINING_IPADDR) { expect(true).assertEqual(state == 3); } - if (state == connState.CONNECTED) { + if (state == wifiMg.connState.CONNECTED) { expect(true).assertEqual(state == 4); } - if (state == connState.DISCONNECTING) { + if (state == wifiMg.connState.DISCONNECTING) { expect(true).assertEqual(state == 5); } - if (state == connState.DISCONNECTED) { + if (state == wifiMg.connState.DISCONNECTED) { expect(true).assertEqual(state == 6); } - if (state == connState.UNKNOWN) { + if (state == wifiMg.connState.UNKNOWN) { expect(true).assertEqual(state == 7); } resolve(); @@ -326,6 +294,7 @@ export default function actsWifiManagerFunctionsTest() { done(); }) console.log("*************[wifi_test] start wifi js unit test end*************"); - }) + }) } + diff --git a/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js b/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js index d0015bf8f5595782d73eecadd55cf843457c5fd5..737831b7f5d130bde34bf1f529041684154ce6b8 100644 --- a/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js @@ -19,7 +19,6 @@ import wifi from '@ohos.wifi' import wifiext from '@ohos.wifiext' -import wifiManagerExt from '@ohos.wifiManagerExt' function sleep(delay) { return new Promise(resovle => setTimeout(resovle, delay)) @@ -32,48 +31,12 @@ 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 PowerModel = { +let powerModel = { SLEEPING : 0, GENERAL : 1, THROUGH_WALL : 2, } -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 () { @@ -83,13 +46,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0001 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0001', 0, async function (done) { let wifiState = "wifiStateChange"; let wifiStateChangeCallback = result => { console.info("[wifi_test]wifiStateChange callback, result: " + JSON.stringify(result)); @@ -101,13 +64,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0002 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0002', 0, async function (done) { let wifiConnectionState = "wifiConnectionChange"; let wifiConnectionChangeCallback = result => { console.info("[wifi_test]wifiConnectionChange callback, result: " + JSON.stringify(result)); @@ -119,13 +82,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0003 + * @tc.number Communication_WiFi_Event_Test_0003 * @tc.name testWifiScanStateChange * @tc.desc Test wifiScanStateChange callback * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_Event_Test_0003', 0, async function (done) { + it('Communication_WiFi_Event_Test_0003', 0, async function (done) { let wifiScanState = "wifiScanStateChange"; let wifiScanStateChangeCallback = result => { console.info("[wifi_test]wifiScanStateChange callback, result: " + JSON.stringify(result)); @@ -138,13 +101,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0004 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0004', 0, async function (done) { let wifiRssiState = "wifiRssiChange"; let wifiRssiChangeCallback = result => { console.info("[wifi_test]wifiRssiChange callback, result: " + JSON.stringify(result)); @@ -156,13 +119,13 @@ export default function actsWifiEventTest() { }) /** - * @tc.number SUB_Communication_WiFi_Event_Test_0005 + * @tc.number 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) { + it('Communication_WiFi_Event_Test_0005', 0, async function (done) { let hotspotState = "hotspotStateChange"; let hotspotStateChangeCallback = result => { console.info("[wifi_test]hotspotStateChange callback, result: " + JSON.stringify(result)); @@ -372,207 +335,8 @@ export default function actsWifiEventTest() { console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end'); done(); }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0008 - * @tc.name testenableHotspot - * @tc.desc Test enableHotspot api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0008', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0008 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0008 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] enableHotspot: " + wifiManagerExt.enableHotspot()) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0008 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0008 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0009 - * @tc.name testdisableHotspot - * @tc.desc Test disableHotspot api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0009', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0009 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0009 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] disableHotspot: " + wifiManagerExt.disableHotspot()) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0009 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0009 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0010 - * @tc.name testgetSupportedPowerModel - * @tc.desc Test getSupportedPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0010', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0010 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0010 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - await wifiManagerExt.getSupportedPowerModel() - .then(data => { - console.info("[wifi_test]getSupportedPowerModel promise result -> " + JSON.stringify(data)); - }); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0010 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0010 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0011 - * @tc.name testgetSupportedPowerModel - * @tc.desc Test getSupportedPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0011', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0011 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0011 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - function getSupportedPowerModelResult(){ - return new Promise((resolve, reject) => { - wifiManagerExt.getSupportedPowerModel( - (err, result) => { - if(err) { - console.info("[wifi_test]failed to getSupportedPowerModel:" + JSON.stringify(err)); - expect(true).assertTrue(); - } - console.info("[wifi_test]getSupportedPowerModel callback:" + JSON.stringify(result)); - resolve(); - }); - }); - } - await getSupportedPowerModelResult(); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0011 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0011 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0012 - * @tc.name testgetPowerModel - * @tc.desc Test getPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0012', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0012 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0012 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - await wifiManagerExt.getPowerModel() - .then(data => { - console.info("[wifi_test]getPowerModel promise result -> " + JSON.stringify(data)); - }); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0012 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0012 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0013 - * @tc.name testgetPowerModel - * @tc.desc Test getPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0013', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0013 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0013 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - function getPowerModelResult(){ - return new Promise((resolve, reject) => { - wifiManagerExt.getPowerModel( - (err, result) => { - if(err) { - console.info("[wifi_test]failed to getPowerModel:" + JSON.stringify(err)); - expect(true).assertTrue(); - } - console.info("[wifi_test]getPowerModel callback:" + JSON.stringify(result)); - resolve(); - }); - }); - } - await getPowerModelResult(); - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0013 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0013 end'); - done(); - }) - - /** - * @tc.number SUB_Communication_WiFi_SysCaps_Test_0007 - * @tc.name testsetPowerModel - * @tc.desc Test setPowerModel api. - * @tc.type Function - */ - it('SUB_Communication_WiFi_SysCaps_Test_0014', 0, async function (done) { - console.info('SUB_Communication_WiFi_SysCaps_Test_0014 start'); - let ret = false; - try { - var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension"); - console.info("SUB_Communication_WiFi_SysCaps_Test_0014 test.syscap.param.001 : " + isAccessToken); - if (isAccessToken) { - console.info("[wifi_test] setPowerModel: " + wifiManagerExt.setPowerModel(PowerModel)) - done(); - } - expect(isAccessToken).assertFalse(); - } catch (e) { - console.info("SUB_Communication_WiFi_SysCaps_Test_0014 canIUse isAccessToken error: " + e); - } - console.info('SUB_Communication_WiFi_SysCaps_Test_0014 end'); - done(); - }) console.log("*************[wifi_test] start wifi js unit test end*************"); - }) + }) } + diff --git a/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js b/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js index 778b884488f3f0c76892bcc55408a94b1e629ca3..3be034b34ff15ca1a91fea974611bf6c0de2c7c8 100644 --- a/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js +++ b/communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js @@ -17,12 +17,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import wifi from '@ohos.wifi' -function sleep(delay) { // delay x ms - var start = (new Date()).getTime(); - while ((new Date()).getTime() - start > delay) { - break; - } +function sleep(delay) { + return new Promise(resovle => setTimeout(resovle, delay)) } + function checkWifiPowerOn(){ console.info("[wifi_test]wifi status:" + wifi.isWifiActive()); } @@ -30,42 +28,6 @@ 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 actsWifiFunctionsTest() { describe('actsWifiFunctionsTest', function() { beforeEach(function () { @@ -75,13 +37,13 @@ export default function actsWifiFunctionsTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0002 + * @tc.number Communication_WiFi_XTS_Sta_0002 * @tc.name testgetScanInfos * @tc.desc Test getScanInfos promise and callback API functionality. * @tc.type Function * @tc.level Level 0 */ - it('SUB_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() @@ -106,10 +68,7 @@ export default function actsWifiFunctionsTest() { "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); + "timestamp" + result[j].timestamp + "capabilities" + result[j].capabilities); } } resolve(); @@ -121,13 +80,13 @@ export default function actsWifiFunctionsTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0021 + * @tc.number Communication_WiFi_XTS_Sta_0021 * @tc.name testGetSignalLevel * @tc.desc Test getSignalLevel API functionality.. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_Sta_0021', 0, function () { + it('Communication_WiFi_XTS_Sta_0021', 0, function () { console.info("[wifi_test] check the 2.4G rssi assgined to level test."); console.info("[wifi_test] getSignalLevel " + wifi.getSignalLevel(-65, 1)); expect(wifi.getSignalLevel(-65, 1)).assertEqual(4); @@ -170,13 +129,13 @@ export default function actsWifiFunctionsTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0017 + * @tc.number Communication_WiFi_XTS_Sta_0017 * @tc.name testgetCountryCode * @tc.desc Test getCountryCode API function. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_Sta_0017', 0, function () { + it('Communication_WiFi_XTS_Sta_0017', 0, function () { expect(wifi.isWifiActive()).assertTrue(); let getCountryCodeResult = wifi.getCountryCode(); console.info("[wifi_test]getCountryCode :" + JSON.stringify(getCountryCodeResult)); @@ -186,13 +145,13 @@ export default function actsWifiFunctionsTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0020 + * @tc.number Communication_WiFi_XTS_Sta_0020 * @tc.name testFeatureSupported * @tc.desc Test FeatureSupported API function. * @tc.type Function * @tc.level Level 3 */ - it('SUB_Communication_WiFi_XTS_Sta_0020', 0, function () { + it('Communication_WiFi_XTS_Sta_0020', 0, function () { expect(wifi.isWifiActive()).assertTrue(); let wifiUtils = { WIFI_FEATURE_INFRA: 0x0001, @@ -229,13 +188,13 @@ export default function actsWifiFunctionsTest() { }) /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0004 + * @tc.number Communication_WiFi_XTS_Sta_0004 * @tc.name testGetLinkedInfo * @tc.desc Test Test getLinkedInfo and getIpInfo information. * @tc.type Function * @tc.level Level 1 */ - it('SUB_Communication_WiFi_XTS_Sta_0004', 0, async function (done) { + it('Communication_WiFi_XTS_Sta_0004', 0, async function (done) { let isConnectedResult = wifi.isConnected(); let ipInfoResult = wifi.getIpInfo(); expect(JSON.stringify(ipInfoResult)).assertContain("gateway"); @@ -271,31 +230,31 @@ export default function actsWifiFunctionsTest() { "linkSpeed: " + result.linkSpeed + "frequency:" + result.frequency + "snr:" + result.snr + "macAddress: " + result.macAddress + "ipAddress: " + result.ipAddress + - "suppState: " + result.suppState + "connState: " + result.connState + "suppState: " + result.suppState + "ConnState: " + result.ConnState + "macType: " + result.macType); let state = wifi.getLinkedInfo().ConnState; - if (state == connState.SCANNING) { + if (state == wifi.ConnState.SCANNING) { expect(true).assertEqual(state == 0); } - if (state == connState.CONNECTING) { + if (state == wifi.ConnState.CONNECTING) { expect(true).assertEqual(state == 1); } - if (state == connState.AUTHENTICATING) { + if (state == wifi.ConnState.AUTHENTICATING) { expect(true).assertEqual(state == 2); } - if (state == connState.OBTAINING_IPADDR) { + if (state == wifi.ConnState.OBTAINING_IPADDR) { expect(true).assertEqual(state == 3); } - if (state == connState.CONNECTED) { + if (state == wifi.ConnState.CONNECTED) { expect(true).assertEqual(state == 4); } - if (state == connState.DISCONNECTING) { + if (state == wifi.ConnState.DISCONNECTING) { expect(true).assertEqual(state == 5); } - if (state == connState.DISCONNECTED) { + if (state == wifi.ConnState.DISCONNECTED) { expect(true).assertEqual(state == 6); } - if (state == connState.UNKNOWN) { + if (state == wifi.ConnState.UNKNOWN) { expect(true).assertEqual(state == 7); } resolve(); @@ -305,25 +264,8 @@ export default function actsWifiFunctionsTest() { await getLinked(); done(); }) - - /** - * @tc.number SUB_Communication_WiFi_XTS_Sta_0034 - * @tc.name testgetScanInfosSync - * @tc.desc Test getScanInfos Sync API functionality. - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_Communication_WiFi_XTS_Sta_0034', 0, async function (done) { - let getScanInfosResult = wifi.getScanInfosSync(); - console.info("[wifi_test]wifi getScanInfosSync result : " + JSON.stringify(getScanInfosResult)); - let scanInfolenth = Object.keys(getScanInfosResult).length; - console.info("[wifi_test]wifi ScanInfosSync length result : " + JSON.stringify(scanInfolenth)); - expect(true).assertEqual(scanInfolenth >= 0); - done(); - }) console.log("*************[wifi_test] start wifi js unit test end*************"); - }) + }) } -