未验证 提交 9ec86d40 编写于 作者: O openharmony_ci 提交者: Gitee

!1769 【communication】WIFI ACTS测试用例合入1

Merge pull request !1769 from 权力/cherry-pick-1643359697
...@@ -13,336 +13,369 @@ ...@@ -13,336 +13,369 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import wifi from '@ohos.wifi_native_js' import wifi from '@ohos.wifi'
// delay x ms // delay x ms
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime();
for (var start = (new Date()).getTime();(new Date()).getTime() - start <= delay;) { while ((new Date()).getTime() - start < delay) {
console.log("sleep ms:"+ delay);
} }
} }
var WifiSecurityType = { var WifiSecurityType = {
WIFI_SEC_TYPE_INVALID : 0, WIFI_SEC_TYPE_INVALID: 0,
WIFI_SEC_TYPE_OPEN : 1, WIFI_SEC_TYPE_OPEN: 1,
WIFI_SEC_TYPE_WEP : 2, WIFI_SEC_TYPE_WEP: 2,
WIFI_SEC_TYPE_PSK : 3, WIFI_SEC_TYPE_PSK: 3,
WIFI_SEC_TYPE_SAE : 4, WIFI_SEC_TYPE_SAE: 4,
} }
var wifiDeviceConfig = { var wifiDeviceConfig = {
"ssid": "TEST", "ssid": "TEST",
"bssid": "A1:B1:C1:D1:E1:F1", "bssid": "A1:B1:C1:D1:E1:F1",
"preSharedKey": "12345678", "preSharedKey": "12345678",
"isHiddenSsid": "false", "isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK, "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},
} }
var ipConfig = { var ipConfig = {
"ipAddress": 1284752956, "ipAddress": 1284752956,
"gateway": 17017024, "gateway": 17017024,
"dnsServers": 12345678, "dnsServers": 12345678,
"domains": ["aaa"], "domains": ["aaa"],
} }
describe('ACTS_WifiTest', function () { describe('ACTS_WifiTest', function() {
beforeEach(function () { beforeEach(function() {})
})
afterEach(function () { afterEach(function() {})
})
/** /**
* @tc.number wifi_native_js_unit_test_001 * @tc.number open_0001
* @tc.name Test wifi.isWifiEnable. * @tc.name SUB_Communication_WiFi_Sta_Open_0001
* @tc.desc Test wifi.isWifiEnable API functionality. * @tc.desc Test wifi.isWifiEnable API functionality.
*/ */
it('wifi_native_js_unit_test_001', 0, function () { it('SUB_Communication_WiFi_Sta_Open_0001', 0, function() {
console.info("[wifi_test] wifi open test."); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Open_0001]");
console.info("[wifi_test] check the state of wifi, if it's close, open it.");
var active = wifi.isWifiActive(); var active = wifi.isWifiActive();
if(!active){ if (!active) {
var enable = wifi.enableWifi(); var enable = wifi.enableWifi();
sleep(3000); sleep(3000);
console.log("[wifi_test] wifi open result: " + enable); console.log("[wifi_test] wifi open result: " + enable);
expect(enable).assertTrue(); expect(enable).assertTrue();
} }
console.info("[wifi_test] close wifi test start.");
var disable = wifi.disableWifi();
sleep(3000); sleep(3000);
console.log("[wifi_test] wifi close result: " + disable);
expect(disable).assertTrue();
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertFalse();
}) })
/** /**
* @tc.number wifi_native_js_unit_test_003 * @tc.number Scan_0001
* @tc.name Test wifi.getSignalLevel. * @tc.name SUB_Communication_WiFi_Sta_Scan_0001
* @tc.desc Test wifi.getSignalLevel API functionality. * @tc.desc Test get ScanInfos callback API functionality.
*/ */
it('wifi_native_js_unit_test_003', 0, function () { it('SUB_Communication_WiFi_Sta_Scan_0001', 0, async function(done) {
console.info("[wifi_test] wifi get signal level test."); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Scan_0001]");
var result = wifi.getSignalLevel(1, 1) if (!wifi.isWifiActive()) {
expect(result).assertEqual(4); var enable = wifi.enableWifi();
sleep(3000);
console.log("[wifi_test] wifi open result: " + enable);
expect(enable).assertTrue();
}
var scan = wifi.scan();
sleep(3000); sleep(3000);
}) console.log("[wifi_test] open wifi scan result: " + scan);
expect(scan).assertTrue();
/** console.info("[wifi_test] Wifi getScanInfos promise test[1].");
* @tc.number wifi_native_js_unit_test_005 await wifi.getScanInfos()
* @tc.name Test wifi.getScanInfos 0. .then(result => {
* @tc.desc Test wifi.getScanInfos API functionality. var clen = Object.keys(result).length;
*/ console.log("[wifi_test] wifi getScanInfos promise result length: " + clen);
it('wifi_native_js_unit_test_005', 0, async function (done) { expect(clen).assertLarger(0);
console.info("[wifi_test] Wifi get scan infos callback test[1]."); console.info("[wifi_test] getScanInfos promise result " + JSON.stringify(result));
var result = wifi.scan(); });
sleep(2000);
console.info("[wifi_test] Wifi getScanInfos callback test[2].");
wifi.getScanInfos( wifi.getScanInfos(
(result) => { (result) => {
var clen = Object.keys(result).length; var clen = Object.keys(result).length;
console.log("[wifi_test] wifi received scan info call back: " + clen); console.log("[wifi_test] wifi getScanInfos callback result length: " + clen);
expect(result).assertLarger(0); if (!(clen == 0 && i < 3)) {
console.info("[wifi_test] add device config callback: " + JSON.stringify(result)); expect(clen).assertLarger(0);
expect(JSON.stringify(result)).assertContain('ssid'); console.info("[wifi_test] getScanInfos callback result: " + JSON.stringify(result));
sleep(3000); for (var j = 0; j < clen; ++j) {
for (var j = 0; j < clen; ++j) { console.info("ssid: " + result[j].ssid);
console.info("ssid: " + result[j].ssid); console.info("bssid: " + result[j].bssid);
console.info("bssid: " + result[j].bssid); console.info("securityType: " + result[j].securityType);
console.info("securityType: " + result[j].securityType); console.info("rssi: " + result[j].rssi);
console.info("rssi: " + result[j].rssi); console.info("band: " + result[j].band);
console.info("band: " + result[j].band); console.info("frequency: " + result[j].frequency);
console.info("frequency: " + result[j].frequency); console.info("timestamp: " + result[j].timestamp);
console.info("timestamp: " + result[j].timestamp); console.info("capabilities: " + result[j].capabilities);
console.info("channelWidth: " + result[j].channelWidth);
}
} }
done()
}); });
done();
}) })
sleep(2000);
/**
/** * @tc.number Scan_0004
* @tc.number wifi_native_js_unit_test_006 * @tc.name SUB_Communication_WiFi_Sta_Scan_0004
* @tc.name Test wifi.getScanInfos 1. * @tc.desc Test wifi.getSignalLevel API functionality.
* @tc.desc Test wifi.getScanInfos API functionality. */
*/ it('SUB_Communication_WiFi_Sta_Scan_0004', 0, function() {
it('wifi_native_js_unit_test_006', 0, async function (done) { console.info("[wifi_test][SUB_Communication_WiFi_Sta_Scan_0004]");
console.info("[wifi_test] Wifi get scan infos callback test[2]."); console.info("[wifi_test] check the 2.4G rssi assgined to level test.");
wifi.getScanInfos() expect(wifi.getSignalLevel(-65, 1)).assertEqual(4);
.then(result => {
var clen = Object.keys(result).length; expect(wifi.getSignalLevel(-66, 1)).assertEqual(3);
console.log("[wifi_test] wifi received scan promise result: " + clen); expect(wifi.getSignalLevel(-75, 1)).assertEqual(3);
expect(result).assertLarger(0);
console.info("[wifi_test] test_006 promise... " + JSON.stringify(result)); expect(wifi.getSignalLevel(-76, 1)).assertEqual(2);
expect(JSON.stringify(result)).assertContain('ssid'); expect(wifi.getSignalLevel(-82, 1)).assertEqual(2);
sleep(2000); expect(wifi.getSignalLevel(-83, 1)).assertEqual(1);
for (var j = 0; j < clen; ++j) { expect(wifi.getSignalLevel(-88, 1)).assertEqual(1);
console.info("ssid: " + result[j].ssid);
console.info("bssid: " + result[j].bssid); expect(wifi.getSignalLevel(-89, 1)).assertEqual(0);
console.info("securityType: " + result[j].securityType); expect(wifi.getSignalLevel(-127, 1)).assertEqual(0);
console.info("rssi: " + result[j].rssi);
console.info("band: " + result[j].band); console.info("[wifi_test] check the 5G rssi assgined to level test.");
console.info("frequency: " + result[j].frequency); expect(wifi.getSignalLevel(-65, 2)).assertEqual(4);
console.info("timestamp: " + result[j].timestamp);
console.info("capabilities: " + result[j].capabilities); expect(wifi.getSignalLevel(-66, 2)).assertEqual(3);
console.info("channelWidth: " + result[j].channelWidth); expect(wifi.getSignalLevel(-72, 2)).assertEqual(3);
}
}); expect(wifi.getSignalLevel(-73, 2)).assertEqual(2);
done(); expect(wifi.getSignalLevel(-79, 2)).assertEqual(2);
expect(wifi.getSignalLevel(-80, 2)).assertEqual(1);
expect(wifi.getSignalLevel(-85, 2)).assertEqual(1);
expect(wifi.getSignalLevel(-86, 2)).assertEqual(0);
expect(wifi.getSignalLevel(-127, 2)).assertEqual(0);
}) })
/** /**
* @tc.number wifi_native_js_unit_test_007 * @tc.number Config_0001
* @tc.name Test wifi.removeDeviceconfig 1. * @tc.name SUB_Communication_WiFi_Sta_Config_0001
* @tc.desc Test wifi.addDeviceconfig API functionality. * @tc.desc Test create a OPEN SecurityType wifi device config
*/ */
it('wifi_native_js_unit_test_007', 0, async function (done) { it('SUB_Communication_WiFi_Sta_Config_0001', 0, async function(done) {
console.info('[wifi_test] wifi add device config test[1]'); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0001]");
var active = wifi.isWifiActive(); console.info("[wifi_test] create a OPEN SecurityType wifi device config start.");
sleep(3000); var wifiDeviceConfig1 = {
console.log("[wifi_test] wifi active result1: " + active); "ssid": "TEST_OPEN",
if(!active){ "bssid": "",
var enable = wifi.enableWifi(); "preSharedKey": "",
sleep(3000); "isHiddenSsid": false,
expect(enable).assertTrue(); "securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
} };
wifi.addDeviceConfig(wifiDeviceConfig,
(result) => { await wifi.addDeviceConfig(wifiDeviceConfig1)
expect(result).assertLarger(0); .then(netWorkId => {
console.info("[wifi_test] test_007 wifi addDeviceconfig callback: " +JSON.stringify(result)); console.info("[wifi_test]add OPEN Deviceconfig promise : " + JSON.stringify(netWorkId));
var conn = wifi.connectToNetwork(result); expect(true).assertEqual(netWorkId != -1);
expect(conn).assertTrue(); console.info("[wifi_test] check add device configs successfully ");
sleep(5000); var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] test_007 wifi addDeviceconfig callback: " + result); console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
for (var j = 0; j < JSON.stringify(result).length; ++j) { expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
console.info("ssid: " + result[j].ssid); expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
console.info("bssid: " + result[j].bssid); expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
console.info("securityType: " + result[j].securityType);
console.info("isHiddenSsid: " + result[j].isHiddenSsid);
console.info("preSharedKey: " + result[j].preSharedKey);
console.info("ipType: " + result[j].ipType);
console.info("creatorUid: " + result[j].creatorUid);
console.info("netId: " + result[j].netId);
console.info("disableReason: " + result[j].disableReason);
console.info("randomMacType: " + result[j].randomMacType);
console.info("randomMacAddr: " + result[j].randomMacAddr);
console.info("staticIp: " + result[j].staticIp);
}
}); });
var discon1 = wifi.disconnect();
console.log("[wifi_test] wifi discon1 result: " + discon1);
expect(discon1).assertTrue();
sleep(3000);
done(); wifi.addDeviceConfig(wifiDeviceConfig1,
(netWorkId) => {
console.info("[wifi_test]add OPEN Deviceconfig callback : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result2 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
console.info("[wifi_test] remove config");
var isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
done()
});
}) })
/** /**
* @tc.number wifi_native_js_unit_test_008 * @tc.number Config_0002
* @tc.name Test wifi.deviceconfig 2. * @tc.name SUB_Communication_WiFi_Sta_Config_0002
* @tc.desc Test wifi.adddeviceconfig API functionality. * @tc.desc Test create a PSK SecurityType wifi device config
*/ */
it('wifi_native_js_unit_test_008', 0, async function (done) { it('SUB_Communication_WiFi_Sta_Config_0002', 0, async function(done) {
console.info("[wifi_test]wifi add device config test[2]."); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0002]");
var active = wifi.isWifiActive(); console.info("[wifi_test] create a PSK SecurityType wifi device config start.");
if(!active){ var wifiDeviceConfig1 = {
var enable = wifi.enableWifi(); "ssid": "TEST_PSK",
sleep(3000); "bssid": "",
expect(enable).assertTrue(); "preSharedKey": "12345678",
"isHiddenSsid": false,
} "securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
wifi.addDeviceConfig(wifiDeviceConfig) };
.then(result => {
console.info("[wifi_test] test_008 wifi addDeviceconfig promise result: " + JSON.stringify(result)); await wifi.addDeviceConfig(wifiDeviceConfig1)
expect(result).assertLarger(0); .then(netWorkId => {
console.info("[wifi_test] test_008 wifi addDeviceconfig promise result: " + result) console.info("[wifi_test]add PSK Deviceconfig promise : " + JSON.stringify(netWorkId));
sleep(3000); expect(true).assertEqual(netWorkId != -1);
var conn = wifi.connectToNetwork(result); console.info("[wifi_test] check add device configs successfully ");
expect(conn).assertTrue(); var configs = wifi.getDeviceConfigs();
sleep(2000); console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
var discon2 = wifi.disconnect(); expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
console.log("[wifi_test] wifi discon2 result: " + discon2); expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(discon2).assertTrue(); expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfig1.preSharedKey);
sleep(3000); expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
console.info("[wifi_test] remove config");
var isRemoved = wifi.removeDevice(netWorkId);
console.info("[wifi_test] check remove config successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current getConfig: " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
}); });
done()
done();
}) })
/** /**
* @tc.number wifi_native_js_unit_test_009 * @tc.number Config_0005
* @tc.name Test wifi.connectToDevice. * @tc.name SUB_Communication_WiFi_Sta_Config_0005
* @tc.desc Test wifi.connectToDevice API functionality. * @tc.desc Test remove all wifi device config
*/ */
it('wifi_native_js_unit_test_009', 0, function () { it('SUB_Communication_WiFi_Sta_Config_0005', 0, async function(done) {
console.info("[wifi_test] wifi connectToDevice test."); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0005]");
console.info("[wifi_test] create multiple valid wifi device config and add it.");
var wifiDeviceConfig1 = { var wifiDeviceConfig1 = {
"ssid": "TEST", "ssid": "TESTWgr1",
"bssid": "A1:B1:C1:D1:E1:F1", "bssid": "",
"preSharedKey": "12345678", "preSharedKey": "12345678",
"isHiddenSsid": "false", "isHiddenSsid": "false",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_INVALID, "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},
}; };
var active = wifi.isWifiActive(); var wifiDeviceConfig2 = {
sleep(3000); "ssid": "TESTWgr2",
console.log("[wifi_test] wifi active result2: " + active); "bssid": "",
if(!active){ "preSharedKey": "",
var enable = wifi.enableWifi(); "isHiddenSsid": false,
expect(enable).assertTrue(); "securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
sleep(3000); };
} let promiseOne = new Promise((resolve, reject) => {
var result1 = wifi.connectToDevice(wifiDeviceConfig1); wifi.addDeviceConfig(wifiDeviceConfig1,
sleep(3000); (netWorkId1) => {
console.log("[wifi_test] wifi connectToDevice result: " + result1); console.info("[wifi_test] wifi addDeviceconfig1 callback:" + JSON.stringify(netWorkId1));
expect(result1).assertTrue(); expect(true).assertEqual(netWorkId1 != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length >= 1);
resolve()
});
})
console.log("[wifi_test] wifi disconnect() result: " + wifi.disconnect()); let promiseTwo = new Promise((resolve, reject) => {
expect(wifi.disconnect()).assertTrue(); wifi.addDeviceConfig(wifiDeviceConfig2,
sleep(3000); (netWorkId2) => {
console.info("[wifi_test] wifi addDeviceconfig2 callback : " + JSON.stringify(netWorkId2));
expect(true).assertEqual(netWorkId2 != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length >= 1);
console.info("[wifi_test] remove all configs");
var isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove configs,current get Configs : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
resolve()
});
})
Promise.all([promiseOne, promiseTwo]).then(done)
}) })
/** /**
* @tc.number wifi_native_js_unit_test_010 * @tc.number Config_0007
* @tc.name Test wifi.connectToDevice. * @tc.name SUB_Communication_WiFi_Sta_Config_0007
* @tc.desc Test wifi.connectToDevice API functionality. * @tc.desc Test update wifi device config
*/ */
it('wifi_native_js_unit_test_010', 0, function () { it('SUB_Communication_WiFi_Sta_Config_0007', 0, async function(done) {
console.info("[wifi_test] wifi connectToDevice test."); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0007]");
var wifiDeviceConfig2 = { console.info("[wifi_test] create a valid wifi device config start.");
var wifiDeviceConfig1 = {
"ssid": "TEST", "ssid": "TEST",
"bssid": "A1:B1:C1:D1:E1:F1", "bssid": "",
"preSharedKey": "12345678", "preSharedKey": "12345678",
"isHiddenSsid": "false", "isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN, "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},
}; };
var active = wifi.isWifiActive();
sleep(3000);
console.log("[wifi_test] wifi active result3: " + active);
if(!active){
var enable = wifi.enableWifi();
expect(enable).assertTrue();
sleep(3000);
}
var result1 = wifi.connectToDevice(wifiDeviceConfig2);
sleep(3000);
console.log("[wifi_test] wifi connectToDevice result1: " + result1);
expect(result1).assertTrue();
console.log("[wifi_test] wifi disconnect() result1: " + wifi.disconnect()); await wifi.addDeviceConfig(wifiDeviceConfig1)
expect(wifi.disconnect()).assertTrue(); .then(netWorkId => {
sleep(3000); console.info("[wifi_test]add PSK Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
wifiDeviceConfig1.ssid = "UPDATE";
wifiDeviceConfig1.preSharedKey = "1234567890";
console.info("[wifi_test] wifi new wifiDeviceConfig1:" + wifi.updateNetwork(wifiDeviceConfig1));
console.info("[wifi_test] check update device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] updated wifi device config result : " + JSON.stringify(configs));
expect(true).assertEqual(configs[1].ssid == wifiDeviceConfig1.ssid);
expect(true).assertEqual(configs[1].preSharedKey == wifiDeviceConfig1.preSharedKey);
console.info("[wifi_test] remove config");
var isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
});
done()
}) })
/** /**
* @tc.number wifi_native_js_unit_test_011 * @tc.number Info_0002
* @tc.name Test wifi.connectToDevice. * @tc.name SUB_Communication_WiFi_Sta_Info_0002
* @tc.desc Test wifi.connectToDevice API functionality. * @tc.desc Test get CountryCode
*/ */
it('wifi_native_js_unit_test_011', 0, function () { it('SUB_Communication_WiFi_Sta_Info_0002', 0, function() {
console.info("[wifi_test] wifi connectToDevice test."); if (!wifi.isWifiActive()) {
var active = wifi.isWifiActive();
sleep(3000);
console.log("[wifi_test] wifi active result2: " + active);
if(!active){
var enable = wifi.enableWifi(); var enable = wifi.enableWifi();
expect(enable).assertTrue();
sleep(3000); sleep(3000);
expect(enable).assertTrue();
} }
var result1 = wifi.connectToDevice(wifiDeviceConfig); expect(wifi.isWifiActive()).assertTrue();
sleep(3000); console.info(" [wifi_test] getCountryCode start ... ");
console.log("[wifi_test] wifi connectToDevice result: " + result1); var countryCode = wifi.getCountryCode();
expect(result1).assertTrue(); console.info("[wifi_test] getCountryCode -> " + JSON.stringify(countryCode));
expect(JSON.stringify(countryCode)).assertEqual('"CN"');
console.log("[wifi_test] wifi disconnect() result: " + wifi.disconnect());
expect(wifi.disconnect()).assertTrue();
sleep(3000);
var disable = wifi.disableWifi();
sleep(3000);
console.log("[wifi_test] wifi disable result: " + disable);
expect(disable).assertTrue();
}) })
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册