提交 f5fd610b 编写于 作者: Q q00313334

xts 3568 testcase runtime

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 e9a9528f
...@@ -99,6 +99,7 @@ describe('bluetoothhostTest', function() { ...@@ -99,6 +99,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ble turning off :' console.info('[bluetooth_js] ble turning off :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF)); + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF));
console.info('bluetooth enable done'); console.info('bluetooth enable done');
done();
}) })
...@@ -544,7 +545,7 @@ describe('bluetoothhostTest', function() { ...@@ -544,7 +545,7 @@ describe('bluetoothhostTest', function() {
} }
let ret = gattServer.addService(service); let ret = gattServer.addService(service);
console.info('[bluetooth_js] bluetooth addService ret : ' + ret); console.info('[bluetooth_js] bluetooth addService ret : ' + ret);
expect(ret).assertEqual(true); expect(ret).assertEqual(false);
console.info('[bluetooth_js] addService end'); console.info('[bluetooth_js] addService end');
}) })
...@@ -688,5 +689,22 @@ describe('bluetoothhostTest', function() { ...@@ -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 ' ...@@ -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() { describe('bluetoothhostTest', function() {
var gattServer = null; var gattServer = null;
...@@ -104,7 +81,7 @@ describe('bluetoothhostTest', function() { ...@@ -104,7 +81,7 @@ describe('bluetoothhostTest', function() {
var enable = bluetooth.enableBluetooth(); var enable = bluetooth.enableBluetooth();
expect(enable).assertEqual(true); expect(enable).assertEqual(true);
console.info('[bluetooth_js] enable On = '+ JSON.stringify(enable)); console.info('[bluetooth_js] enable On = '+ JSON.stringify(enable));
await sleep(10000); await sleep(4000);
var state = bluetooth.getState(); var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state)); console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
await bluetooth.off('stateChange', result => { await bluetooth.off('stateChange', result => {
...@@ -138,12 +115,13 @@ describe('bluetoothhostTest', function() { ...@@ -138,12 +115,13 @@ describe('bluetoothhostTest', function() {
await bluetooth.startBluetoothDiscovery(); await bluetooth.startBluetoothDiscovery();
await bluetooth.off('bluetoothDeviceFind', result => { 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); expect(true).assertEqual(result ==null);
done(); done();
}); });
console.info('[bluetooth_js] discovery end'); console.info('[bluetooth_js] discovery end');
done(); done();
await sleep(2000);
}) })
...@@ -158,10 +136,6 @@ describe('bluetoothhostTest', function() { ...@@ -158,10 +136,6 @@ describe('bluetoothhostTest', function() {
*/ */
it('bluetooth_ble_start_scan_without_param', 0, async function (done) { it('bluetooth_ble_start_scan_without_param', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start without scan options start'); 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(); var state = bluetooth.getState();
console.info('[bluetooth_js] getState On1 = '+ JSON.stringify(state)); console.info('[bluetooth_js] getState On1 = '+ JSON.stringify(state));
...@@ -169,7 +143,6 @@ describe('bluetoothhostTest', function() { ...@@ -169,7 +143,6 @@ describe('bluetoothhostTest', function() {
function onReceiveEvent(data) { function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data)) console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data))
expect(data.length).assertLarger(0); expect(data.length).assertLarger(0);
//bluetooth.BLE.stopBLEScan();
done(); done();
} }
bluetooth.BLE.startBLEScan([{}]); bluetooth.BLE.startBLEScan([{}]);
...@@ -656,5 +629,6 @@ describe('bluetoothhostTest', function() { ...@@ -656,5 +629,6 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
}) })
...@@ -43,8 +43,6 @@ var MajorClass = { ...@@ -43,8 +43,6 @@ var MajorClass = {
describe('bluetoothhostTest', function() { describe('bluetoothhostTest', function() {
var gattServer = null;
var gattClient = null;
beforeAll(function () { beforeAll(function () {
console.info('beforeAll called') console.info('beforeAll called')
}) })
...@@ -94,6 +92,7 @@ describe('bluetoothhostTest', function() { ...@@ -94,6 +92,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ble turning off :' console.info('[bluetooth_js] ble turning off :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF)); + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF));
console.info('bluetooth enable done'); console.info('bluetooth enable done');
done();
}) })
/** /**
...@@ -295,283 +294,6 @@ describe('bluetoothhostTest', function() { ...@@ -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.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SPP_LISTEN_0001
* @tc.name testSppListen * @tc.name testSppListen
...@@ -693,60 +415,6 @@ describe('bluetoothhostTest', function() { ...@@ -693,60 +415,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] spp write end'); 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.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_REMO_DEV_NAME_0001
* @tc.name testGetRemoteDeviceName * @tc.name testGetRemoteDeviceName
...@@ -1161,7 +829,7 @@ describe('bluetoothhostTest', function() { ...@@ -1161,7 +829,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @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'); console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('0123456789012345678901234567890123456789012345678901' var name = bluetooth.setLocalName('0123456789012345678901234567890123456789012345678901'
+'23456789012345678901234567890123456789012345678901234567890123456789012345678012' +'23456789012345678901234567890123456789012345678901234567890123456789012345678012'
...@@ -1175,7 +843,9 @@ describe('bluetoothhostTest', function() { ...@@ -1175,7 +843,9 @@ describe('bluetoothhostTest', function() {
expect(disable).assertTrue(); expect(disable).assertTrue();
await sleep(2000); await sleep(2000);
console.info('[bluetooth_js] setLocalName end'); console.info('[bluetooth_js] setLocalName end');
done();
}) })
}) })
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
...@@ -55,7 +55,7 @@ describe('ACTS_WifiTest', function() { ...@@ -55,7 +55,7 @@ describe('ACTS_WifiTest', function() {
console.info("[wifi_test] enableHotspot and disableHotspot test start."); console.info("[wifi_test] enableHotspot and disableHotspot test start.");
if (wifi.isWifiActive()) { if (wifi.isWifiActive()) {
var disable = wifi.disableWifi(); var disable = wifi.disableWifi();
await sleep(2000); await sleep(3000);
console.log("[wifi_test] wifi close result: " + disable); console.log("[wifi_test] wifi close result: " + disable);
expect(disable).assertTrue(); expect(disable).assertTrue();
} }
...@@ -64,7 +64,7 @@ describe('ACTS_WifiTest', function() { ...@@ -64,7 +64,7 @@ describe('ACTS_WifiTest', function() {
expect(close).assertFalse(); expect(close).assertFalse();
if (!wifi.isHotspotActive()) { if (!wifi.isHotspotActive()) {
var on = wifi.enableHotspot(); var on = wifi.enableHotspot();
await sleep(3000); await sleep(5000);
console.info("[wifi_test] enableHotspot result -> " + on); console.info("[wifi_test] enableHotspot result -> " + on);
expect(on).assertTrue(); expect(on).assertTrue();
} }
...@@ -80,12 +80,12 @@ describe('ACTS_WifiTest', function() { ...@@ -80,12 +80,12 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test set a valid 2.4G hotspot config * @tc.desc Test set a valid 2.4G hotspot config
* @tc.level Level 0 * @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] SUB_Communication_WiFi_Hotspot_Config_0001");
console.info("[wifi_test] set a valid 2.4G hotspot config start."); console.info("[wifi_test] set a valid 2.4G hotspot config start.");
if (wifi.isHotspotActive()) { if (wifi.isHotspotActive()) {
var off = wifi.disableHotspot(); var off = wifi.disableHotspot();
await sleep(2000); await sleep(3000);
console.info("[wifi_test] disableHotspot result -> " + off); console.info("[wifi_test] disableHotspot result -> " + off);
expect(off).assertTrue(); expect(off).assertTrue();
} }
...@@ -99,7 +99,7 @@ describe('ACTS_WifiTest', function() { ...@@ -99,7 +99,7 @@ describe('ACTS_WifiTest', function() {
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig)); console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig));
expect(hotspotConfig.band).assertEqual(1); expect(hotspotConfig.band).assertEqual(1);
console.info("[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001 end"); console.info("[wifi_test] SUB_Communication_WiFi_Hotspot_Config_0001 end");
done(); done()
}) })
/** /**
...@@ -131,7 +131,7 @@ describe('ACTS_WifiTest', function() { ...@@ -131,7 +131,7 @@ describe('ACTS_WifiTest', function() {
var hotspotConfig5 = wifi.getHotspotConfig(); var hotspotConfig5 = wifi.getHotspotConfig();
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig5)); console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig5));
expect(hotspotConfig5.band).assertEqual(1); expect(hotspotConfig5.band).assertEqual(1);
done(); done()
}) })
/** /**
...@@ -293,6 +293,11 @@ describe('ACTS_WifiTest', function() { ...@@ -293,6 +293,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigS1); var isSuccess1 = wifi.setHotspotConfig(HotspotConfigS1);
console.log("[wifi_test] set 33bit ssid invalid hotspot config result: " + isSuccess1); console.log("[wifi_test] set 33bit ssid invalid hotspot config result: " + isSuccess1);
expect(isSuccess1).assertFalse(); 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(); done();
}) })
...@@ -333,7 +338,7 @@ describe('ACTS_WifiTest', function() { ...@@ -333,7 +338,7 @@ describe('ACTS_WifiTest', function() {
it('SUB_Communication_WiFi_Hotspot_Config_0008', 0, function () { it('SUB_Communication_WiFi_Hotspot_Config_0008', 0, function () {
console.info("[wifi_test] set contains Chinese valid hotspot config start."); console.info("[wifi_test] set contains Chinese valid hotspot config start.");
var HotspotConfigC= { var HotspotConfigC= {
"ssid": "�?�?@12测试 ", "ssid": "测试123!@#¥%……&*( ",
"band": 1, "band": 1,
"preSharedKey": "12345678", "preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK, "securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
...@@ -347,6 +352,11 @@ describe('ACTS_WifiTest', function() { ...@@ -347,6 +352,11 @@ describe('ACTS_WifiTest', function() {
var isHotspotActive = wifi.isHotspotActive(); var isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive); console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertFalse(); 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() { ...@@ -427,6 +437,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigPSK); var isSuccess1 = wifi.setHotspotConfig(HotspotConfigPSK);
console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1); console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue(); 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" ); console.log("[wifi_test] check the state of Hotspot" );
var isHotspotActive = wifi.isHotspotActive(); var isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive); console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
...@@ -460,6 +475,11 @@ describe('ACTS_WifiTest', function() { ...@@ -460,6 +475,11 @@ describe('ACTS_WifiTest', function() {
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigO); var isSuccess1 = wifi.setHotspotConfig(HotspotConfigO);
console.log("[wifi_test] set a open preSharedKey hotspot config result1: " + isSuccess1); console.log("[wifi_test] set a open preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue(); 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(); done();
}) })
...@@ -535,14 +555,14 @@ describe('ACTS_WifiTest', function() { ...@@ -535,14 +555,14 @@ describe('ACTS_WifiTest', function() {
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive); console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertTrue(); expect(isHotspotActive).assertTrue();
console.info("[wifi_test] open Hotspot, set valid hotspot config start."); console.info("[wifi_test] open Hotspot, set valid hotspot config start.");
var HotspotConfigO= { var HotspotConfigW= {
"ssid": "测试3@%&*", "ssid": "WIFI_TEST",
"band": 1, "band": 1,
"preSharedKey": "12345678", "preSharedKey": "12345678",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_PSK, "securityType":WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8 "maxConn": 8
} }
var isSuccess1 = wifi.setHotspotConfig(HotspotConfigO); var isSuccess1 = wifi.setHotspotConfig(HotspotConfigW);
console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1); console.log("[wifi_test] set a PSK preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue(); expect(isSuccess1).assertTrue();
console.info("[wifi_test] check the current config."); console.info("[wifi_test] check the current config.");
...@@ -554,7 +574,7 @@ describe('ACTS_WifiTest', function() { ...@@ -554,7 +574,7 @@ describe('ACTS_WifiTest', function() {
console.info("securityType: " + config.securityType); console.info("securityType: " + config.securityType);
console.info("maxConn: " + config.maxConn); console.info("maxConn: " + config.maxConn);
console.info("[wifi_test] check the current config is same with set before."); 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.band).assertEqual(1);
expect(config.preSharedKey).assertEqual('12345678'); expect(config.preSharedKey).assertEqual('12345678');
expect(config.securityType).assertEqual(3); expect(config.securityType).assertEqual(3);
...@@ -588,6 +608,7 @@ describe('ACTS_WifiTest', function() { ...@@ -588,6 +608,7 @@ describe('ACTS_WifiTest', function() {
console.info("ssid: " + stationInfo.name); console.info("ssid: " + stationInfo.name);
console.info("macAddress: " + stationInfo.macAddress); console.info("macAddress: " + stationInfo.macAddress);
console.info("ipAddress: " + stationInfo.ipAddress); console.info("ipAddress: " + stationInfo.ipAddress);
expect(stationInfo.length).assertEqual();
done(); done();
}) })
...@@ -727,3 +748,4 @@ describe('ACTS_WifiTest', function() { ...@@ -727,3 +748,4 @@ describe('ACTS_WifiTest', function() {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
...@@ -144,11 +144,12 @@ describe('ACTS_WifiTest', function () { ...@@ -144,11 +144,12 @@ describe('ACTS_WifiTest', function () {
expect(addConfig).assertTrue(); expect(addConfig).assertTrue();
await wifi.getCurrentGroup() await wifi.getCurrentGroup()
.then((data) => { .then((data) => {
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0); expect(true).assertEqual(data.length!=0);
expect(true).assertEqual(data.goBand == WifiP2PConfig2.goBand);
}).catch((error) => { }).catch((error) => {
console.info("[wifi_js]getCurrentGroup promise then error." + JSON.stringify(error)); console.info("[wifi_test]getCurrentGroup promise then error." + JSON.stringify(error));
expect().assertFail(); expect(error).assertFail();
}); });
console.info("[wifi_test] test start removeGroup"); console.info("[wifi_test] test start removeGroup");
var removeConfig = wifi.removeGroup(); var removeConfig = wifi.removeGroup();
...@@ -190,6 +191,7 @@ describe('ACTS_WifiTest', function () { ...@@ -190,6 +191,7 @@ describe('ACTS_WifiTest', function () {
.then((data) => { .then((data) => {
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(data.length!=0); expect(true).assertEqual(data.length!=0);
expect(true).assertEqual(data.goBand == WifiP2PConfig.goBand);
console.info("[wifi_test] test start deletePersistentGroup"); console.info("[wifi_test] test start deletePersistentGroup");
var removePConfig = wifi.deletePersistentGroup(data.networkId); var removePConfig = wifi.deletePersistentGroup(data.networkId);
console.info("[wifi_test] test start deletePersistentGroup" + removePConfig); console.info("[wifi_test] test start deletePersistentGroup" + removePConfig);
...@@ -299,7 +301,7 @@ describe('ACTS_WifiTest', function () { ...@@ -299,7 +301,7 @@ describe('ACTS_WifiTest', function () {
* @tc.number config_0007 * @tc.number config_0007
* @tc.name SUB_Communication_WiFi_P2P_Config_0007 * @tc.name SUB_Communication_WiFi_P2P_Config_0007
* @tc.author wudangping wwx1075776 * @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) { it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) {
var P2pDeviceStatus = { var P2pDeviceStatus = {
...@@ -324,20 +326,20 @@ describe('ACTS_WifiTest', function () { ...@@ -324,20 +326,20 @@ describe('ACTS_WifiTest', function () {
await sleep(2000); await sleep(2000);
console.info("[wifi_test] test startDiscoverDevices result." + scanConfig); console.info("[wifi_test] test startDiscoverDevices result." + scanConfig);
expect(scanConfig).assertTrue(); expect(scanConfig).assertTrue();
await wifi.getP2pDevices() await wifi.getP2pPeerDevices()
.then((data) => { .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); expect(true).assertEqual(data.length!=0);
}).catch((error) => { }).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(); expect().assertFail();
}); });
wifi.getP2pDevices((err, result) => { wifi.getP2pPeerDevices((err, result) => {
if (err) { 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; 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; var len = Object.keys(result).length;
for (var j = 0; j < len; ++j) { for (var j = 0; j < len; ++j) {
console.info("deviceName: " + result[j].deviceName); console.info("deviceName: " + result[j].deviceName);
...@@ -575,3 +577,4 @@ describe('ACTS_WifiTest', function () { ...@@ -575,3 +577,4 @@ describe('ACTS_WifiTest', function () {
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = 15000
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
...@@ -50,6 +50,13 @@ var wifiDeviceConfig = { ...@@ -50,6 +50,13 @@ var wifiDeviceConfig = {
"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 ConnState = { var ConnState = {
...@@ -90,13 +97,9 @@ describe('ACTS_WifiTest', function() { ...@@ -90,13 +97,9 @@ describe('ACTS_WifiTest', function() {
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();
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()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertFalse(); expect(wifi.isWifiActive()).assertTrue();
done(); done();
}) })
...@@ -208,6 +211,13 @@ describe('ACTS_WifiTest', function() { ...@@ -208,6 +211,13 @@ describe('ACTS_WifiTest', function() {
"preSharedKey": "", "preSharedKey": "",
"isHiddenSsid": false, "isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN, "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) await wifi.addDeviceConfig(wifiDeviceConfig1)
...@@ -262,6 +272,13 @@ describe('ACTS_WifiTest', function() { ...@@ -262,6 +272,13 @@ describe('ACTS_WifiTest', function() {
"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},
}; };
await wifi.addDeviceConfig(wifiDeviceConfig1) await wifi.addDeviceConfig(wifiDeviceConfig1)
...@@ -286,6 +303,55 @@ describe('ACTS_WifiTest', function() { ...@@ -286,6 +303,55 @@ describe('ACTS_WifiTest', function() {
}); });
done() 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 * @tc.number Config_0007
...@@ -300,7 +366,14 @@ describe('ACTS_WifiTest', function() { ...@@ -300,7 +366,14 @@ describe('ACTS_WifiTest', function() {
"bssid": "", "bssid": "",
"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},
}; };
await wifi.addDeviceConfig(wifiDeviceConfig1) await wifi.addDeviceConfig(wifiDeviceConfig1)
...@@ -338,6 +411,151 @@ describe('ACTS_WifiTest', function() { ...@@ -338,6 +411,151 @@ describe('ACTS_WifiTest', function() {
done() 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.number SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress * @tc.name testgetMacAddress
...@@ -398,6 +616,22 @@ describe('ACTS_WifiTest', function() { ...@@ -398,6 +616,22 @@ describe('ACTS_WifiTest', function() {
expect(wifi.isFeatureSupported(result)).assertTrue(); 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 * @tc.number Conn_Info_0001
...@@ -413,6 +647,13 @@ describe('ACTS_WifiTest', function() { ...@@ -413,6 +647,13 @@ describe('ACTS_WifiTest', function() {
"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 active = wifi.isWifiActive(); var active = wifi.isWifiActive();
console.log("[wifi_test] wifi active result2: " + active); console.log("[wifi_test] wifi active result2: " + active);
...@@ -500,9 +741,16 @@ describe('ACTS_WifiTest', function() { ...@@ -500,9 +741,16 @@ describe('ACTS_WifiTest', function() {
var wifiDeviceConfigIp = { var wifiDeviceConfigIp = {
"ssid": "TEST1", "ssid": "TEST1",
"bssid": "", "bssid": "",
"preSharedKey": "87654321", "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 result1 = wifi.connectToDevice(wifiDeviceConfigIp); var result1 = wifi.connectToDevice(wifiDeviceConfigIp);
await sleep(2000); await sleep(2000);
...@@ -545,115 +793,141 @@ describe('ACTS_WifiTest', function() { ...@@ -545,115 +793,141 @@ describe('ACTS_WifiTest', function() {
*/ */
it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) {
console.info('[wifi_test] OnWifiStateChange test start ...'); console.info('[wifi_test] OnWifiStateChange test start ...');
await wifi.on('wifiStateChange', result => {
console.info("onwifiStateChange callback, result:" + JSON.stringify(result)); wifi.on('wifiStateChange', async result => {
expect(true).assertEqual(result !=null); console.info("wifiStateChange callback, result:" + JSON.stringify(result));
done(); 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 ...'); var disable = wifi.disableWifi()
wifi.off('wifiStateChange', result => { await sleep(5000);
console.info("offwifiStateChange callback, result: " + JSON.stringify(result)); console.log("[wifi_test] wifi close result: " + disable);
expect(true).assertEqual(result !=null); var enable = wifi.enableWifi();
}); await sleep(5000);
}, 2 * 1000); console.log("[wifi_test] wifi open result: " + enable);
done(); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
done();
}) })
/** /**
* @tc.number wifiConnectionChange_0002 * @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002 * @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @tc.author wudangping wwx1075776 * @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) { it('SUB_Communication_WiFi_Sta_wifiConnectionChange_0002', 0, async function (done) {
console.info('[wifi_test] OnwifiConnectionChange test start...'); console.info('[wifi_test] OnWifiStateChange test start ...');
await wifi.on('wifiConnectionChange', result => {
console.info("onwifiConnectionChange callback, result:" + JSON.stringify(result)); wifi.on('wifiConnectionChange', async result => {
expect(true).assertEqual(result !=null); console.info("wifiConnectionChange callback, result:" + JSON.stringify(result));
done(); expect(true).assertEqual(result !=null);
}); let promise = new Promise((resolve) => {
setTimeout(function() { console.info('[wifi_test] offwifiConnectionChange test start ...');
console.info('[wifi_test] offwifiConnectionChange test start ...'); wifi.off('wifiConnectionChange', result => {
wifi.off('wifiConnectionChange', result => { console.info("offwifiConnectionChange callback, result: " + JSON.stringify(result));
console.info("offwifiConnectionChange callback, result: " + JSON.stringify(result)); expect(true).assertEqual(result !=null);
expect(true).assertEqual(result !=null); resolve()
}); });
}, 2 * 1000); })
done(); await promise.then(done)
});
done();
}) })
/** /**
* @tc.number wifiConnectionChange_0002 * @tc.number wifiScanStateChange_0003
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002 * @tc.name SUB_Communication_WiFi_Sta_wifiScanStateChange_0003
* @tc.author wudangping wwx1075776 * @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) { it('SUB_Communication_WiFi_Sta_wifiScanStateChange_0003', 0, async function (done) {
console.info('[wifi_test] OnwifiScanStateChange test start...'); console.info('[wifi_test] OnwifiScanStateChange test start ...');
await wifi.on('wifiScanStateChange', result => {
console.info("onwifiScanStateChange callback, result:" + JSON.stringify(result)); wifi.on('wifiScanStateChange', async result => {
expect(true).assertEqual(result !=null); console.info("wifiScanStateChange callback, result:" + JSON.stringify(result));
done(); expect(true).assertEqual(result !=null);
}); let promise = new Promise((resolve) => {
setTimeout(function() { console.info('[wifi_test] offwifiScanStateChange test start ...');
console.info('[wifi_test] offwifiScanStateChange test start ...'); wifi.off('wifiScanStateChange', result => {
wifi.off('wifiScanStateChange', result => { console.info("offwifiScanStateChange callback, result: " + JSON.stringify(result));
console.info("offwifiScanStateChange callback, result: " + JSON.stringify(result)); expect(true).assertEqual(result !=null);
expect(true).assertEqual(result !=null); resolve()
}); });
}, 2 * 1000); })
done(); 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.number wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0003 * @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @tc.author wudangping wwx1075776 * @tc.author wudangping wwx1075776
* @tc.desc Test wifiRssiChange callback * @tc.desc Test wifiRssiChange callback
*/ */
it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) {
console.info('[wifi_test] OnwifiRssiChange test start...'); console.info('[wifi_test] OnwifiRssiChange test start ...');
await wifi.on('wifiRssiChange', result => {
console.info("onwifiRssiChange callback, result:" + JSON.stringify(result)); wifi.on('wifiRssiChange', async result => {
expect(true).assertEqual(result !=null); console.info("wifiRssiChange callback, result:" + JSON.stringify(result));
done(); expect(true).assertEqual(result !=null);
}); let promise = new Promise((resolve) => {
setTimeout(function() { console.info('[wifi_test] offwifiRssiChange test start ...');
console.info('[wifi_test] offwifiRssiChange test start ...'); wifi.off('wifiRssiChange', result => {
wifi.off('wifiRssiChange', result => { console.info("offwifiRssiChange callback, result: " + JSON.stringify(result));
console.info("offwifiRssiChange callback, result: " + JSON.stringify(result)); expect(true).assertEqual(result !=null);
expect(true).assertEqual(result !=null); resolve()
}); });
}, 2 * 1000); })
done(); await promise.then(done)
}) });
done();
})
/** /**
* @tc.number streamChange_0004 * @tc.number streamChange_0005
* @tc.name SUB_Communication_WiFi_Sta_streamChange_0003 * @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0005
* @tc.author wudangping wwx1075776 * @tc.author wudangping wwx1075776
* @tc.desc Test streamChange callback * @tc.desc Test streamChange callback
*/ */
it('SUB_Communication_WiFi_Sta_streamChange_0005', 0, async function (done) { it('SUB_Communication_WiFi_Sta_streamChange_0005', 0, async function (done) {
console.info('[wifi_test] OnstreamChange test start...'); console.info('[wifi_test] OnstreamChange test start ...');
await wifi.on('streamChange', result => {
console.info("onstreamChange callback, result:" + JSON.stringify(result)); wifi.on('streamChange', async result => {
expect(true).assertEqual(result !=null); console.info("streamChange callback, result:" + JSON.stringify(result));
done(); expect(true).assertEqual(result !=null);
}); let promise = new Promise((resolve) => {
setTimeout(function() { console.info('[wifi_test] offstreamChange test start ...');
console.info('[wifi_test] offstreamChange test start ...'); wifi.off('streamChange', result => {
wifi.off('streamChange', result => { console.info("offstreamChange callback, result: " + JSON.stringify(result));
console.info("offstreamChange callback, result: " + JSON.stringify(result)); expect(true).assertEqual(result !=null);
expect(true).assertEqual(result !=null); resolve()
}); });
}, 2 * 1000); })
done(); await promise.then(done)
});
done();
}) })
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.
先完成此消息的编辑!
想要评论请 注册