提交 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() { ...@@ -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')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册