提交 059131cb 编写于 作者: Q q00313334 提交者: 权力

fixed f5fd610b from https://gitee.com/q00313334/xts_acts/pulls/2228

xts 3568 testcase runtime
Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 570b6c96
......@@ -99,6 +99,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ble turning off :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF));
console.info('bluetooth enable done');
done();
})
......@@ -544,7 +545,7 @@ describe('bluetoothhostTest', function() {
}
let ret = gattServer.addService(service);
console.info('[bluetooth_js] bluetooth addService ret : ' + ret);
expect(ret).assertEqual(true);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] addService end');
})
......@@ -688,5 +689,22 @@ describe('bluetoothhostTest', function() {
}
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
* @tc.desc Test DisConnect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_disconnect', 0, function () {
console.info('[bluetooth_js] gatt disconnect start');
let ret = gattClient.disconnect();
console.info('[bluetooth_js] gatt disconnect ret:' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] gatt disconnect end');
})
})
......@@ -18,29 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
var SppType = {
SPP_RFCOMM : 0
}
var MatchMode = {
MATCH_MODE_AGGRESSIVE : 1,
MATCH_MODE_STICKY : 2
}
var MajorClass = {
MAJOR_MISC : 0x0000,
MAJOR_COMPUTER : 0x0100,
MAJOR_PHONE : 0x0200,
MAJOR_NETWORKING : 0x0300,
MAJOR_AUDIO_VIDEO : 0x0400,
MAJOR_PERIPHERAL : 0x0500,
MAJOR_IMAGING : 0x0600,
MAJOR_WEARABLE : 0x0700,
MAJOR_TOY : 0x0800,
MAJOR_HEALTH : 0x0900,
MAJOR_UNCATEGORIZED : 0x1F00
}
describe('bluetoothhostTest', function() {
var gattServer = null;
......@@ -104,7 +81,7 @@ describe('bluetoothhostTest', function() {
var enable = bluetooth.enableBluetooth();
expect(enable).assertEqual(true);
console.info('[bluetooth_js] enable On = '+ JSON.stringify(enable));
await sleep(10000);
await sleep(4000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
await bluetooth.off('stateChange', result => {
......@@ -138,12 +115,13 @@ describe('bluetoothhostTest', function() {
await bluetooth.startBluetoothDiscovery();
await bluetooth.off('bluetoothDeviceFind', result => {
console.info("bluetoothDeviceFind off:" + JSON.stringify(result));
console.info("[bluetooth_js] bluetoothDeviceFind off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
});
console.info('[bluetooth_js] discovery end');
done();
await sleep(2000);
})
......@@ -158,10 +136,6 @@ describe('bluetoothhostTest', function() {
*/
it('bluetooth_ble_start_scan_without_param', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start without scan options start');
var enable = bluetooth.enableBluetooth();
expect(enable).assertEqual(true);
console.info('[bluetooth_js] enable On1 = '+ JSON.stringify(enable));
await sleep(5000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On1 = '+ JSON.stringify(state));
......@@ -169,7 +143,6 @@ describe('bluetoothhostTest', function() {
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data))
expect(data.length).assertLarger(0);
//bluetooth.BLE.stopBLEScan();
done();
}
bluetooth.BLE.startBLEScan([{}]);
......@@ -656,5 +629,6 @@ describe('bluetoothhostTest', function() {
done();
})
})
......@@ -43,8 +43,6 @@ var MajorClass = {
describe('bluetoothhostTest', function() {
var gattServer = null;
var gattClient = null;
beforeAll(function () {
console.info('beforeAll called')
})
......@@ -94,6 +92,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ble turning off :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF));
console.info('bluetooth enable done');
done();
})
/**
......@@ -295,283 +294,6 @@ describe('bluetoothhostTest', function() {
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
* @tc.desc Test DisConnect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_disconnect', 0, function () {
console.info('[bluetooth_js] gatt disconnect start');
let ret = gattClient.disconnect();
console.info('[bluetooth_js] gatt disconnect ret:' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] gatt disconnect end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_READ_CHARA_VALUE_0001
* @tc.name testReadCharacteristicValue
* @tc.desc Test ReadCharacteristicValue api by promise.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_readCharacteristicValue', 0, async function (done) {
console.info('[bluetooth_js] readCharacteristicValue start');
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
for (var key in characteristic ){
console.info('[bluetooth_js] readCharValue:' +characteristic[key]);
}
gattClient.readCharacteristicValue(characteristic).then((object) => {
if (object != null) {
console.info('[bluetooth_js] bluetooth BLECharacteristic is null');
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] BLECharacteristic uuid is successfully');
console.info('[bluetooth_js] readCharacValue data:' + JSON.stringify(data));
expect(null).assertFail();
}
done();
}).catch(err => {
console.error(`bluetooth readCharacteristicValue has error: ${err}`);
expect(true).assertEqual(true);
done();
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_READ_DESCRI_VALUE_0001
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_readDescriptorValue', 0, async function (done) {
console.info('[bluetooth_js] readDescriptorValue start');
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
gattClient.readDescriptorValue(descriptor).then((object) => {
if (object != null) {
console.info('[bluetooth_js] BLEDescriptor is null');
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] BLEDescriptor uuid is successfully');
console.info('[bluetooth_js] BLEDescriptor data:' + JSON.stringify(object));
expect(null).assertFail();
}
done();
}).catch(err => {
console.error(`bluetooth readDescriptorValue has error: ${err}`);
expect(true).assertEqual(true);
done();
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_WRITE_CHARACT_VALUE_0001
* @tc.name testWriteCharacteristicValue
* @tc.desc Test WriteCharacteristicValue api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_writeCharacteristicValue', 0, function () {
console.info('[bluetooth_js] writeCharacteristicValue start');
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
for (var key in characteristic ){
console.info('[bluetooth_js] writeCharValue:' +characteristic[key]);
}
let ret = gattClient.writeCharacteristicValue(characteristic);
console.info('[bluetooth_js] bluetooth writeCharacteristicValue ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] writeCharacteristicValue end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_WRITE_DESC_VALUE_0001
* @tc.name testWriteDescriptorValue
* @tc.desc Test WriteDescriptorValue api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_writeDescriptorValue', 0, function () {
console.info('[bluetooth_js] writeDescriptorValue start');
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let ret = gattClient.writeDescriptorValue(descriptor);
console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] writeDescriptorValue end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_SET_BLE_MTUSIZE_0001
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_setBLEMtuSize', 0, function () {
console.info('[bluetooth_js] setBLEMtuSize start');
let ret = gattClient.setBLEMtuSize(128);
console.info('[bluetooth_js] bluetooth setBLEMtuSize ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] setBLEMtuSize end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_SET_NOTIFY_CHARA_CHANGED_0001
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_setNotifyCharacteristicChanged', 0, function () {
console.info('[bluetooth_js] setNotifyCharacteristicChanged start');
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let arrayBufferNotify = new ArrayBuffer(8);
let descNotifyValue = new Uint8Array(arrayBufferNotify);
descNotifyValue[0] = 1
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBuffer};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBufferNotify};
descriptors[0] = descriptor;
descriptors[1] = descriptorNotify;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let ret = gattClient.setNotifyCharacteristicChanged(characteristic, false);
console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] setNotifyCharacteristicChanged end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_NOTIFY_CHARA_CHANGED_0001
* @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_notifyCharacteristicChanged', 0, function () {
console.info('[bluetooth_js] notifyCharacteristicChanged start');
let descriptors = [];
let arrayBufferDesc = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBufferDesc);
desValue[0] = 11;
let arrayBufferNotifyDesc = new ArrayBuffer(8);
let descNotifyValue = new Uint8Array(arrayBufferNotifyDesc);
descNotifyValue[0] = 1
let
descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: desValue};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: descNotifyValue};
descriptors[0] = descriptor;
descriptors[1] = descriptorNotify;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: cccValue,
descriptors:descriptors,confirm:'false'};
for (var key in characteristic ){
console.info('[bluetooth_js] notifyCharChanged:' + characteristic[key]);
}
let ret = gattServer.notifyCharacteristicChanged('00:00:00:00:00:00', characteristic);
console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] notifyCharacteristicChanged end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_SEND_RESPONSE_0001
* @tc.name testSendResponse
* @tc.desc Test SendResponse api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_sendResponse', 0, function () {
console.info('[bluetooth_js] sendResponse start');
let arrayBuffer = new ArrayBuffer(8);
let value = new Uint8Array(arrayBuffer);
value[0] = 1;
let serverResponse = {deviceId: '00:00:00:00:00', transId: 1,
status: 0, offset: 0, value: arrayBuffer};
for (var key in serverResponse ){
console.info('[bluetooth_js] serverResponse:'+ serverResponse[key]);
}
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] sendResponse end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SPP_LISTEN_0001
* @tc.name testSppListen
......@@ -693,60 +415,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] spp write end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_BLE_PERIPHERA_MANAGER_CLOSE_0001
* @tc.name testBlePeripheralManagerClose
* @tc.desc Test BlePeripheralManagerClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetoothble_gattserver_close_test_001', 0, function () {
console.info('[bluetooth_js] GattserverClose test start ...');
if (gattServer == null) {
console.info("[bluetooth_js] GattserverClose: please CreateGattServer first!");
}
console.info('[bluetooth_js] gattclose_server is:' + JSON.stringify(gattServer));
try{
var result = gattServer.close();
console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result));
expect(result).assertTrue();
console.info("[bluetooth_js] GattserverClose end.");
}catch(error){
console.info("[bluetooth_js] GattserverClose err:" + JSON.stringify(error));
expect(null).assertFail();
}
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose
* @tc.desc Test GattClientClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gattclient_close_test_001', 0, function () {
console.info('[bluetooth_js] GattclientClose test start ...');
if (gattClient == null) {
console.info("[bluetooth_js] GattclientClose: please CreateGatt first!");
}
console.info('[bluetooth_js] gattClient is:' + JSON.stringify(gattServer));
try{
var result = gattClient.close();
console.info("[bluetooth_js] GattclientClose result: " + result);
console.info("[bluetooth_js] GattclientClose json_result:" + JSON.stringify(result));
expect(result).assertTrue();
console.info("[bluetooth_js] GattclientClose end.");
}catch(error){
console.info("[bluetooth_js] GattclientClose err:" + JSON.stringify(error));
expect(null).assertFail();
}
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_REMO_DEV_NAME_0001
* @tc.name testGetRemoteDeviceName
......@@ -1161,7 +829,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name14', 0, async function () {
it('bluetooth_classic_set_local_name14', 0, async function (done) {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('0123456789012345678901234567890123456789012345678901'
+'23456789012345678901234567890123456789012345678901234567890123456789012345678012'
......@@ -1175,7 +843,9 @@ describe('bluetoothhostTest', function() {
expect(disable).assertTrue();
await sleep(2000);
console.info('[bluetooth_js] setLocalName end');
done();
})
})
......@@ -37,6 +37,7 @@ export default {
core.init()
const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this)
require('../../test/List.test')
......
......@@ -55,7 +55,7 @@ describe('ACTS_WifiTest', function() {
console.info("[wifi_test] enableHotspot and disableHotspot test start.");
if (wifi.isWifiActive()) {
var disable = wifi.disableWifi();
await sleep(2000);
await sleep(3000);
console.log("[wifi_test] wifi close result: " + disable);
expect(disable).assertTrue();
}
......@@ -64,7 +64,7 @@ describe('ACTS_WifiTest', function() {
expect(close).assertFalse();
if (!wifi.isHotspotActive()) {
var on = wifi.enableHotspot();
await sleep(3000);
await sleep(5000);
console.info("[wifi_test] enableHotspot result -> " + on);
expect(on).assertTrue();
}
......@@ -80,12 +80,12 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a valid 2.4G hotspot config
* @tc.level Level 0
*/
it('SUB_Communication_WiFi_Hotspot_Config_0001', 0, async function () {
it('SUB_Communication_WiFi_Hotspot_Config_0001', 0, async function (done) {
console.info("[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001");
console.info("[wifi_test] set a valid 2.4G hotspot config start.");
if (wifi.isHotspotActive()) {
var off = wifi.disableHotspot();
await sleep(2000);
await sleep(3000);
console.info("[wifi_test] disableHotspot result -> " + off);
expect(off).assertTrue();
}
......@@ -99,7 +99,7 @@ describe('ACTS_WifiTest', function() {
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig));
expect(hotspotConfig.band).assertEqual(1);
console.info("[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001 end");
done();
done()
})
/**
......@@ -131,7 +131,7 @@ describe('ACTS_WifiTest', function() {
var hotspotConfig5 = wifi.getHotspotConfig();
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig5));
expect(hotspotConfig5.band).assertEqual(1);
done();
done()
})
/**
......@@ -293,6 +293,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigS1);
console.log("[wifi_test] set 33bit ssid invalid hotspot config result: " + isSuccess1);
expect(isSuccess1).assertFalse();
console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" );
var config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
console.info("preSharedKey: " + config.ssid);
expect(config.ssid.length).assertEqual(32);
done();
})
......@@ -333,7 +338,7 @@ describe('ACTS_WifiTest', function() {
it('SUB_Communication_WiFi_Hotspot_Config_0008', 0, function () {
console.info("[wifi_test] set contains Chinese valid hotspot config start.");
var HotspotConfigC= {
"ssid": "�?�?@12测试 ",
"ssid": "测试123!@#¥%……&*( ",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
......@@ -347,6 +352,11 @@ describe('ACTS_WifiTest', function() {
var isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertFalse();
console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" );
var config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
console.info("preSharedKey: " + config.ssid);
expect(true).assertEqual(config.ssid==HotspotConfigC.ssid);
})
/**
......@@ -427,6 +437,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigPSK);
console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue();
console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" );
var config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
console.info("preSharedKey: " + config.ssid);
expect(config.preSharedKey).assertEqual(3);
console.log("[wifi_test] check the state of Hotspot" );
var isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
......@@ -460,6 +475,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigO);
console.log("[wifi_test] set a open preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue();
console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" );
var config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
console.info("preSharedKey: " + config.ssid);
expect(config.preSharedKey).assertEqual(1);
done();
})
......@@ -535,14 +555,14 @@ describe('ACTS_WifiTest', function() {
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertTrue();
console.info("[wifi_test] open Hotspot, set valid hotspot config start.");
var HotspotConfigO= {
"ssid": "测试3@%&*",
var HotspotConfigW= {
"ssid": "WIFI_TEST",
"band": 1,
"preSharedKey": "12345678",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
}
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigO);
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigW);
console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue();
console.info("[wifi_test] check the current config.");
......@@ -554,7 +574,7 @@ describe('ACTS_WifiTest', function() {
console.info("securityType: " + config.securityType);
console.info("maxConn: " + config.maxConn);
console.info("[wifi_test] check the current config is same with set before.");
expect(config.ssid).assertEqual('测试3@%&*');
expect(config.ssid).assertEqual('WIFI_TEST');
expect(config.band).assertEqual(1);
expect(config.preSharedKey).assertEqual('12345678');
expect(config.securityType).assertEqual(3);
......@@ -588,6 +608,7 @@ describe('ACTS_WifiTest', function() {
console.info("ssid: " + stationInfo.name);
console.info("macAddress: " + stationInfo.macAddress);
console.info("ipAddress: " + stationInfo.ipAddress);
expect(stationInfo.length).assertEqual();
done();
})
......@@ -727,3 +748,4 @@ describe('ACTS_WifiTest', function() {
console.log("*************[wifi_test] start wifi js unit test end*************");
})
......@@ -37,6 +37,7 @@ export default {
core.init()
const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this)
require('../../test/List.test')
......
......@@ -144,11 +144,12 @@ describe('ACTS_WifiTest', function () {
expect(addConfig).assertTrue();
await wifi.getCurrentGroup()
.then((data) => {
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0);
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0);
expect(true).assertEqual(data.goBand == WifiP2PConfig2.goBand);
}).catch((error) => {
console.info("[wifi_js]getCurrentGroup promise then error." + JSON.stringify(error));
expect().assertFail();
console.info("[wifi_test]getCurrentGroup promise then error." + JSON.stringify(error));
expect(error).assertFail();
});
console.info("[wifi_test] test start removeGroup");
var removeConfig = wifi.removeGroup();
......@@ -190,6 +191,7 @@ describe('ACTS_WifiTest', function () {
.then((data) => {
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0);
expect(true).assertEqual(data.goBand == WifiP2PConfig.goBand);
console.info("[wifi_test] test start deletePersistentGroup");
var removePConfig = wifi.deletePersistentGroup(data.networkId);
console.info("[wifi_test] test start deletePersistentGroup" + removePConfig);
......@@ -299,7 +301,7 @@ describe('ACTS_WifiTest', function () {
* @tc.number config_0007
* @tc.name SUB_Communication_WiFi_P2P_Config_0007
* @tc.author wudangping wwx1075776
* @tc.desc Test getP2pDevices infos
* @tc.desc Test getP2pPeerDevices infos
*/
it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) {
var P2pDeviceStatus = {
......@@ -324,20 +326,20 @@ describe('ACTS_WifiTest', function () {
await sleep(2000);
console.info("[wifi_test] test startDiscoverDevices result." + scanConfig);
expect(scanConfig).assertTrue();
await wifi.getP2pDevices()
await wifi.getP2pPeerDevices()
.then((data) => {
console.info("[wifi_test] getP2pDevices [promise] result -> " + JSON.stringify(data));
console.info("[wifi_test] getP2pPeerDevices [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0);
}).catch((error) => {
console.info("[wifi_test]getP2pDevices promise then error." + JSON.stringify(error));
console.info("[wifi_test]getP2pPeerDevices promise then error." + JSON.stringify(error));
expect().assertFail();
});
wifi.getP2pDevices((err, result) => {
wifi.getP2pPeerDevices((err, result) => {
if (err) {
console.error('failed to getP2pDevices infos callback because ' + JSON.stringify(err));
console.error('failed to getP2pPeerDevices infos callback because ' + JSON.stringify(err));
return;
}
console.info("[wifi_test] getP2pDevices [callback] -> " + JSON.stringify(result));
console.info("[wifi_test] getP2pPeerDevices [callback] -> " + JSON.stringify(result));
var len = Object.keys(result).length;
for (var j = 0; j < len; ++j) {
console.info("deviceName: " + result[j].deviceName);
......@@ -575,3 +577,4 @@ describe('ACTS_WifiTest', function () {
console.log("*************[wifi_test] start wifi js unit test end*************");
})
......@@ -37,6 +37,7 @@ export default {
core.init()
const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this)
require('../../test/List.test')
......
......@@ -50,6 +50,13 @@ var wifiDeviceConfig = {
"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},
}
var ConnState = {
......@@ -90,13 +97,9 @@ describe('ACTS_WifiTest', function() {
console.log("[wifi_test] wifi open result: " + enable);
expect(enable).assertTrue();
}
console.info("[wifi_test] close wifi test start.");
var disable = wifi.disableWifi();
await sleep(5000);
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();
expect(wifi.isWifiActive()).assertTrue();
done();
})
......@@ -208,6 +211,13 @@ describe('ACTS_WifiTest', function() {
"preSharedKey": "",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
......@@ -262,6 +272,13 @@ describe('ACTS_WifiTest', function() {
"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.addDeviceConfig(wifiDeviceConfig1)
......@@ -286,6 +303,55 @@ describe('ACTS_WifiTest', function() {
});
done()
})
/**
* @tc.number Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Config_0002
* @tc.desc Test create a PSK SecurityType wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0003', 0, async function(done) {
console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0003]");
console.info("[wifi_test] create WEP SecurityType wifi device config start.");
var wifiDeviceConfig1 = {
"ssid": "TEST_WEP",
"bssid": "",
"preSharedKey": "ABCDEF1234",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
.then(netWorkId => {
console.info("[wifi_test]add WEP 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]connectdevice result: " + wifi.connectToNetwork(netWorkId));
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfig1.preSharedKey);
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()
})
/**
* @tc.number Config_0007
......@@ -300,7 +366,14 @@ describe('ACTS_WifiTest', function() {
"bssid": "",
"preSharedKey": "12345678",
"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},
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
......@@ -338,6 +411,151 @@ describe('ACTS_WifiTest', function() {
done()
})
/**
* @tc.number Config_SSID_0001
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0001
* @tc.desc Test SSID wifi device config
*/
it('SUB_Communication_WiFi_Sta_Conn_SSID_0001', 0, async function(done) {
console.info("[wifi_test][SSUB_Communication_WiFi_Sta_Conn_SSID_0001]");
console.info("[wifi_test] create a contains chinese SSID wifi device config start.");
var wifiDeviceConfigZ = {
"ssid": "中文测试SSID",
"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.addDeviceConfig(wifiDeviceConfigZ)
.then(netWorkId => {
console.info("[wifi_test]add contains chinese Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
console.info("[wifi_test] disableNetwork test start.");
var disconNet = wifi.disableNetwork(netWorkId);
console.log("[wifi_test] wifi disableNetwork result: " + disconNet);
expect(disconNet).assertTrue();
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigZ.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigZ.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 Config_SSID_0002
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0002
* @tc.desc Test SSID wifi device config
*/
it('SUB_Communication_WiFi_Sta_Conn_SSID_0002', 0, async function(done) {
console.info("[wifi_test][SSUB_Communication_WiFi_Sta_Conn_SSID_0002]");
console.info("[wifi_test] create a kongge SSID wifi device config start.");
var wifiDeviceConfigK = {
"ssid": "test text",
"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.addDeviceConfig(wifiDeviceConfigK)
.then(netWorkId => {
console.info("[wifi_test]add contains chinese Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
console.info("[wifi_test] disableNetwork test start.");
var disconNet = wifi.disableNetwork(netWorkId);
console.log("[wifi_test] wifi disableNetwork result: " + disconNet);
expect(disconNet).assertTrue();
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigK.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigK.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 Config_SSID_0003
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0003
* @tc.desc Test SSID wifi device config
*/
it('SUB_Communication_WiFi_Sta_Conn_SSID_0003', 0, async function(done) {
console.info("[wifi_test][SSUB_Communication_WiFi_Sta_Conn_SSID_0003]");
console.info("[wifi_test] create a kongge SSID wifi device config start.");
var wifiDeviceConfigT = {
"ssid": "!@#¥%&*/",
"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.addDeviceConfig(wifiDeviceConfigT)
.then(netWorkId => {
console.info("[wifi_test]add contains chinese Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigT.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigT.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 SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress
......@@ -398,6 +616,22 @@ describe('ACTS_WifiTest', function() {
expect(wifi.isFeatureSupported(result)).assertTrue();
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0005
* @tc.name testHotspotDualBandSupported
* @tc.desc Test HotspotDualBandSupported api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_Info_0005', 0, async function(done) {
console.info(" [wifi_test] isHotspotDualBandSupported start ... ");
var DualBand = wifi.isHotspotDualBandSupported();
console.info("[wifi_test] isHotspotDualBandSupported -> " + JSON.stringify(DualBand));
expect(DualBand).assertFalse();
done();
})
/**
* @tc.number Conn_Info_0001
......@@ -413,6 +647,13 @@ describe('ACTS_WifiTest', function() {
"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},
};
var active = wifi.isWifiActive();
console.log("[wifi_test] wifi active result2: " + active);
......@@ -500,9 +741,16 @@ describe('ACTS_WifiTest', function() {
var wifiDeviceConfigIp = {
"ssid": "TEST1",
"bssid": "",
"preSharedKey": "87654321",
"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},
};
var result1 = wifi.connectToDevice(wifiDeviceConfigIp);
await sleep(2000);
......@@ -545,115 +793,141 @@ describe('ACTS_WifiTest', function() {
*/
it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) {
console.info('[wifi_test] OnWifiStateChange test start ...');
await wifi.on('wifiStateChange', result => {
console.info("onwifiStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
wifi.on('wifiStateChange', async result => {
console.info("wifiStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offwifiStateChange test start ...');
wifi.off('wifiStateChange', result => {
console.info("offwifiStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
setTimeout(function() {
console.info('[wifi_test] offwifiStateChange test start ...');
wifi.off('wifiStateChange', result => {
console.info("offwifiStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
var disable = wifi.disableWifi()
await sleep(5000);
console.log("[wifi_test] wifi close result: " + disable);
var enable = wifi.enableWifi();
await sleep(5000);
console.log("[wifi_test] wifi open result: " + enable);
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
done();
})
/**
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiConnectionChange callback
* @tc.desc Test wifiStateChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiConnectionChange_0002', 0, async function (done) {
console.info('[wifi_test] OnwifiConnectionChange test start...');
await wifi.on('wifiConnectionChange', result => {
console.info("onwifiConnectionChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiConnectionChange test start ...');
wifi.off('wifiConnectionChange', result => {
console.info("offwifiConnectionChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
console.info('[wifi_test] OnWifiStateChange test start ...');
wifi.on('wifiConnectionChange', async result => {
console.info("wifiConnectionChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offwifiConnectionChange test start ...');
wifi.off('wifiConnectionChange', result => {
console.info("offwifiConnectionChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
done();
})
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @tc.number wifiScanStateChange_0003
* @tc.name SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiConnectionChange callback
* @tc.desc Test wifiScanStateChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiScanStateChange_0003', 0, async function (done) {
console.info('[wifi_test] OnwifiScanStateChange test start...');
await wifi.on('wifiScanStateChange', result => {
console.info("onwifiScanStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiScanStateChange test start ...');
wifi.off('wifiScanStateChange', result => {
console.info("offwifiScanStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
console.info('[wifi_test] OnwifiScanStateChange test start ...');
wifi.on('wifiScanStateChange', async result => {
console.info("wifiScanStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offwifiScanStateChange test start ...');
wifi.off('wifiScanStateChange', result => {
console.info("offwifiScanStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
var scan = wifi.scan();
await sleep(3000);
console.log("[wifi_test] open wifi scan result: " + scan);
done();
})
/**
* @tc.number wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0003
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiRssiChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) {
console.info('[wifi_test] OnwifiRssiChange test start...');
await wifi.on('wifiRssiChange', result => {
console.info("onwifiRssiChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiRssiChange test start ...');
wifi.off('wifiRssiChange', result => {
console.info("offwifiRssiChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) {
console.info('[wifi_test] OnwifiRssiChange test start ...');
wifi.on('wifiRssiChange', async result => {
console.info("wifiRssiChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offwifiRssiChange test start ...');
wifi.off('wifiRssiChange', result => {
console.info("offwifiRssiChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
done();
})
/**
* @tc.number streamChange_0004
* @tc.name SUB_Communication_WiFi_Sta_streamChange_0003
* @tc.number streamChange_0005
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0005
* @tc.author wudangping wwx1075776
* @tc.desc Test streamChange callback
*/
it('SUB_Communication_WiFi_Sta_streamChange_0005', 0, async function (done) {
console.info('[wifi_test] OnstreamChange test start...');
await wifi.on('streamChange', result => {
console.info("onstreamChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offstreamChange test start ...');
wifi.off('streamChange', result => {
console.info("offstreamChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
console.info('[wifi_test] OnstreamChange test start ...');
wifi.on('streamChange', async result => {
console.info("streamChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offstreamChange test start ...');
wifi.off('streamChange', result => {
console.info("offstreamChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
});
})
await promise.then(done)
});
done();
})
console.log("*************[wifi_test] start wifi js unit test end*************");
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册