提交 6419b8b4 编写于 作者: Q q00313334

quanli1@huawei.com

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 cd0907b4
...@@ -26,6 +26,9 @@ export default { ...@@ -26,6 +26,9 @@ export default {
}, },
onShow() { onShow() {
console.info('onShow finish') console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
const core = Core.getInstance() const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
'id': 'extend' 'id': 'extend'
...@@ -38,7 +41,7 @@ export default { ...@@ -38,7 +41,7 @@ export default {
require('../../test/List.test') require('../../test/List.test')
core.execute() core.execute()
},
onReady() {
}, },
} }
...@@ -28,18 +28,18 @@ var MatchMode = { ...@@ -28,18 +28,18 @@ var MatchMode = {
} }
var MajorClass = { var MajorClass = {
MAJOR_MISC : 0x0000, MAJOR_MISC : 0x0000,
MAJOR_COMPUTER : 0x0100, MAJOR_COMPUTER : 0x0100,
MAJOR_PHONE : 0x0200, MAJOR_PHONE : 0x0200,
MAJOR_NETWORKING : 0x0300, MAJOR_NETWORKING : 0x0300,
MAJOR_AUDIO_VIDEO : 0x0400, MAJOR_AUDIO_VIDEO : 0x0400,
MAJOR_PERIPHERAL : 0x0500, MAJOR_PERIPHERAL : 0x0500,
MAJOR_IMAGING : 0x0600, MAJOR_IMAGING : 0x0600,
MAJOR_WEARABLE : 0x0700, MAJOR_WEARABLE : 0x0700,
MAJOR_TOY : 0x0800, MAJOR_TOY : 0x0800,
MAJOR_HEALTH : 0x0900, MAJOR_HEALTH : 0x0900,
MAJOR_UNCATEGORIZED : 0x1F00 MAJOR_UNCATEGORIZED : 0x1F00
} }
describe('bluetoothhostTest', function() { describe('bluetoothhostTest', function() {
...@@ -48,18 +48,10 @@ describe('bluetoothhostTest', function() { ...@@ -48,18 +48,10 @@ describe('bluetoothhostTest', function() {
beforeAll(function () { beforeAll(function () {
console.info('beforeAll called') console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
setTimeout(function(){
console.debug('==createGattServer==timeout')
},5000);
console.info('[bluetooth_js] gattServer beforeAll is:' + JSON.stringify(gattServer)); console.info('[bluetooth_js] gattServer beforeAll is:' + JSON.stringify(gattServer));
console.info('[bluetooth_js] gattServer type beforeAll is:' + gattServer);
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
setTimeout(function(){
console.debug('==createGattClientDevice==timeout')
},5000);
console.info('[bluetooth_js] GattClientDevice beforeAll is:' + JSON.stringify(gattClient)); console.info('[bluetooth_js] GattClientDevice beforeAll is:' + JSON.stringify(gattClient));
console.info('[bluetooth_js] GattClientDevice type beforeAll is:' + gattClient);
}) })
beforeEach(function () { beforeEach(function () {
console.info('beforeEach called') console.info('beforeEach called')
...@@ -72,8 +64,12 @@ describe('bluetoothhostTest', function() { ...@@ -72,8 +64,12 @@ describe('bluetoothhostTest', function() {
console.info('afterAll called') console.info('afterAll called')
}) })
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_ENABLE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_ENABLE_0001
* @tc.name testEnableBluetooth * @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise. * @tc.desc Test EnableBluetooth api by promise.
...@@ -96,17 +92,25 @@ describe('bluetoothhostTest', function() { ...@@ -96,17 +92,25 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js]state on:' + JSON.stringify(bluetooth.BluetoothState.STATE_ON)); console.info('[bluetooth_js]state on:' + JSON.stringify(bluetooth.BluetoothState.STATE_ON));
console.info('[bluetooth_js]off :' + JSON.stringify(bluetooth.BluetoothState.STATE_OFF)); console.info('[bluetooth_js]off :' + JSON.stringify(bluetooth.BluetoothState.STATE_OFF));
console.info('[bluetooth_js] turning on :' console.info('[bluetooth_js] turning on :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_ON)); + JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_ON));
console.info('[bluetooth_js] turning off :' console.info('[bluetooth_js] turning off :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_OFF)); + JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_OFF));
console.info('[bluetooth_js] ble turning on :' console.info('[bluetooth_js] ble turning on :'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_ON)); + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_ON));
console.info('[bluetooth_js] ble on:' console.info('[bluetooth_js] ble on:'
+ JSON.stringify(bluetooth.BluetoothState.STATE_BLE_ON)); + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_ON));
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));
await bluetooth.enableBluetooth(); var enable = bluetooth.enableBluetooth();
expect(enable).assertEqual(true); expect(enable).assertEqual(true);
await sleep(3000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
await bluetooth.off('stateChange', result => {
console.info("stateChange off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
});
console.info('bluetooth enable done'); console.info('bluetooth enable done');
}) })
...@@ -119,14 +123,12 @@ describe('bluetoothhostTest', function() { ...@@ -119,14 +123,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_get_state', 0, async function (done) { it('bluetooth_classic_get_state', 0, function () {
console.info('[bluetooth_js] get state start'); console.info('[bluetooth_js] get state start');
var state = bluetooth.getState(); var state = bluetooth.getState();
console.info('get bluetooth state end'); console.info('get bluetooth state end');
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state)); console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON); expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
done();
await(3000);
}) })
/** /**
...@@ -138,49 +140,12 @@ describe('bluetoothhostTest', function() { ...@@ -138,49 +140,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_set_local_name', 0, async function (done) { it('bluetooth_classic_set_local_name', 0, function () {
console.info('[bluetooth_js] set localname start'); console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('bluetooth_test'); var name = bluetooth.setLocalName('bluetooth_test');
console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name)); console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name));
expect(name).assertEqual(true); expect(name).assertEqual(true);
console.info('[bluetooth_js] set localname end'); console.info('[bluetooth_js] set localname end');
done();
await(3000);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0001', 0, async function (done) {
console.info('[bluetooth_js] pair device start');
await bluetooth.on("pinRequired", onReceiveEvent)
await bluetooth.on("bondStateChange", onReceivePairStateEvent)
var device;
function onReceiveEvent(data) {
console.info('[bluetooth_js] pinRequired'+ JSON.stringify(data));
bluetooth.setDevicePairingConfirmation(data,false);
console.info('[bluetooth_js] pinRequired deviceId'+ data.deviceId);
console.info('[bluetooth_js] pinRequired pinCode'+ data.pinCode);
}
function onReceivePairStateEvent(data) {
console.info('[bluetooth_js] pair state = '+ JSON.stringify(data))
if (data == 0) {
done();
}
}
var enable = bluetooth.pairDevice("32:15:00:19:42:F6")
console.info("[bluetooth_js] pairDevice result is:" + JSON.stringify(result));
expect(JSON.stringify(result)).assertTrue();
setTimeout(function(){
console.debug('====bluetooth_classic_pair_device====timeout')
},5000);
console.info('[bluetooth_js] pair device end');
}) })
/** /**
...@@ -194,7 +159,7 @@ describe('bluetoothhostTest', function() { ...@@ -194,7 +159,7 @@ describe('bluetoothhostTest', function() {
*/ */
it('bluetooth_Startpair_test_001', 0, function () { it('bluetooth_Startpair_test_001', 0, function () {
console.info('[bluetooth_js] Startpair test start ...'); console.info('[bluetooth_js] Startpair test start ...');
var result = bluetooth.pairDevice("32:15:00:19:42:F6"); var result = bluetooth.pairDevice("00:00:00:00:00:00");
console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result)); console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result));
expect(result).assertFalse(); expect(result).assertFalse();
}) })
...@@ -208,14 +173,12 @@ describe('bluetoothhostTest', function() { ...@@ -208,14 +173,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_get_local_name', 0, async function (done) { it('bluetooth_classic_get_local_name', 0, function () {
console.info('[bluetooth_js] get localName start'); console.info('[bluetooth_js] get localName start');
var localName = bluetooth.getLocalName(); var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName)); console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName));
expect(localName).assertEqual('bluetooth_test'); expect(localName).assertEqual('bluetooth_test');
console.info('[bluetooth_js] get localName end'); console.info('[bluetooth_js] get localName end');
done();
await(3000);
}) })
/** /**
...@@ -227,19 +190,17 @@ describe('bluetoothhostTest', function() { ...@@ -227,19 +190,17 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_set_scan_mode', 0, async function (done) { it('bluetooth_classic_set_scan_mode', 0, function () {
console.info('[bluetooth_js] set scan mode start'); console.info('[bluetooth_js] set scan mode start');
var result = bluetooth.setBluetoothScanMode(1,10000); var result = bluetooth.setBluetoothScanMode(1,10000);
console.info('[bluetooth_js] set bluetooth scan mode result ' + JSON.stringify(result)); console.info('[bluetooth_js] set bluetooth scan mode result ' + JSON.stringify(result));
console.info('[bluetooth_js] low power :' console.info('[bluetooth_js] low power :'
+ JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER)); + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER));
console.info('[bluetooth_js] balanced :' console.info('[bluetooth_js] balanced :'
+ JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED)); + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED));
console.info('[bluetooth_js] low latency:' console.info('[bluetooth_js] low latency:'
+ JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY)); + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY));
expect(result).assertEqual(true); expect(result).assertEqual(true);
done();
await(3000);
}) })
/** /**
...@@ -251,7 +212,7 @@ describe('bluetoothhostTest', function() { ...@@ -251,7 +212,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_get_scan_mode', 0, async function (done) { it('bluetooth_classic_get_scan_mode', 0, function () {
console.info('[bluetooth_js] get scan mode start'); console.info('[bluetooth_js] get scan mode start');
var result = bluetooth.setBluetoothScanMode(1,10000); var result = bluetooth.setBluetoothScanMode(1,10000);
...@@ -262,18 +223,16 @@ describe('bluetoothhostTest', function() { ...@@ -262,18 +223,16 @@ describe('bluetoothhostTest', function() {
expect(scanMode).assertEqual(1); expect(scanMode).assertEqual(1);
console.info('[bluetooth_js] mode1:' + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_NONE)); console.info('[bluetooth_js] mode1:' + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_NONE));
console.info('[bluetooth_js] mode2:' console.info('[bluetooth_js] mode2:'
+ JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE)); + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE));
console.info('[bluetooth_js] mode3:' console.info('[bluetooth_js] mode3:'
+ JSON.stringify(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE)); + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE));
console.info('[bluetooth_js] mode4:' console.info('[bluetooth_js] mode4:'
+ JSON.stringify(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE)); + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE));
console.info('[bluetooth_js] mode5:' console.info('[bluetooth_js] mode5:'
+ JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE)); + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE));
console.info('[bluetooth_js] mode6:' console.info('[bluetooth_js] mode6:'
+ JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE)); + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE));
console.info('[bluetooth_js] get scan mode end'); console.info('[bluetooth_js] get scan mode end');
done();
await(3000);
}) })
/** /**
...@@ -285,22 +244,20 @@ describe('bluetoothhostTest', function() { ...@@ -285,22 +244,20 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_get_connection', 0, async function (done) { it('bluetooth_classic_get_connection', 0, function () {
console.info('[bluetooth_js] get connection state start'); console.info('[bluetooth_js] get connection state start');
var connState = bluetooth.getBtConnectionState(); var connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState)); console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED); expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED);
console.info('[bluetooth_js] pr1:' console.info('[bluetooth_js] pr1:'
+ JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTED)); + JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTED));
console.info('[bluetooth_js] pr2:' console.info('[bluetooth_js] pr2:'
+ JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTING)); + JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTING));
console.info('[bluetooth_js] pr3:' console.info('[bluetooth_js] pr3:'
+ JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTED)); + JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTED));
console.info('[bluetooth_js] pr4:' console.info('[bluetooth_js] pr4:'
+ JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTING)); + JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTING));
console.info('[bluetooth_js] get connection end'); console.info('[bluetooth_js] get connection end');
done();
await(3000);
}) })
/** /**
...@@ -323,9 +280,14 @@ describe('bluetoothhostTest', function() { ...@@ -323,9 +280,14 @@ describe('bluetoothhostTest', function() {
done(); done();
} }
await bluetooth.startBluetoothDiscovery(); await bluetooth.startBluetoothDiscovery();
await bluetooth.off('bluetoothDeviceFind', result => {
console.info("bluetoothDeviceFind off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
});
console.info('[bluetooth_js] discovery end'); console.info('[bluetooth_js] discovery end');
done(); done();
await(3000);
}) })
/** /**
...@@ -337,18 +299,12 @@ describe('bluetoothhostTest', function() { ...@@ -337,18 +299,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_stop_discovery', 0, async function (done) { it('bluetooth_classic_stop_discovery', 0, function () {
console.info('[bluetooth_js] stop discovery start'); console.info('[bluetooth_js] stop discovery start');
bluetooth.stopBluetoothDiscovery(); let result = bluetooth.stopBluetoothDiscovery();
await bluetooth.off("bluetoothDeviceFind", onReceiveEvent) console.info("stopBluetoothDiscovery :" + JSON.stringify(result));
function onReceiveEvent(data) { expect(result).assertTrue();
console.info('[bluetooth_js] stop bluetooth discovery result = '+ JSON.stringify(data));
expect(data).assertNull();
done();
}
console.info('[bluetooth_js] stop discovery end'); console.info('[bluetooth_js] stop discovery end');
done();
await(3000);
}) })
/** /**
...@@ -360,15 +316,13 @@ describe('bluetoothhostTest', function() { ...@@ -360,15 +316,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_classic_get_paired_devices', 0, async function (done) { it('bluetooth_classic_get_paired_devices', 0, function () {
console.info('[bluetooth_js] get paired devices start'); console.info('[bluetooth_js] get paired devices start');
var devices = bluetooth.getPairedDevices(); var devices = bluetooth.getPairedDevices();
console.info('[bluetooth_js] get paired devices result:' + JSON.stringify(devices)); console.info('[bluetooth_js] get paired devices result:' + JSON.stringify(devices));
console.info("[bluetooth_js] getConnectedDevices length:" + devices.length); console.info("[bluetooth_js] getConnectedDevices length:" + devices.length);
expect(devices.length).assertEqual(0); expect(devices.length).assertEqual(0);
console.info('[bluetooth_js] get paired devices end'); console.info('[bluetooth_js] get paired devices end');
done();
await(3000);
}) })
...@@ -381,36 +335,15 @@ describe('bluetoothhostTest', function() { ...@@ -381,36 +335,15 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_getConnectedBLEDevices_test_001', 0, async function (done) { it('bluetooth_getConnectedBLEDevices_test_001', 0, function () {
console.info('[bluetooth_js] getConnectedBLEDevices test start ...'); console.info('[bluetooth_js] getConnectedBLEDevices test start ...');
var result = bluetooth.BLE.getConnectedBLEDevices(); var result = bluetooth.BLE.getConnectedBLEDevices();
console.info("[bluetooth_js] getConnectedBLEDevices:" + JSON.stringify(result)); console.info("[bluetooth_js] getConnectedBLEDevices:" + JSON.stringify(result));
console.info("[bluetooth_js] getConnectedBLEDevices length:" + result.length); console.info("[bluetooth_js] getConnectedBLEDevices length:" + result.length);
expect(result.length).assertEqual(0); expect(result.length).assertEqual(0);
done(); console.info('[bluetooth_js] getConnectedBLEDevices end');
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_STOP_BLE_SCAN_0001
* @tc.name testStopBLEScan
* @tc.desc Test StopBLEScan api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetoothble_stopBLEScan_test_001', 0, function () {
console.info('[bluetooth_js] StopBLEScan test start ...');
try{
var result = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] StopBLEScan:" + JSON.stringify(result));
expect(result).assertNull();
console.info("[bluetooth_js] StopBLEScan end");
}catch(error){
expect(null).assertFail();
console.info("[bluetooth_js] StopBLEScan err:" + JSON.stringify(error));
}
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CREATE_GATT_SERVER_0002 * @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CREATE_GATT_SERVER_0002
...@@ -428,29 +361,12 @@ describe('bluetoothhostTest', function() { ...@@ -428,29 +361,12 @@ describe('bluetoothhostTest', function() {
var resultLength = Object.keys(result).length; var resultLength = Object.keys(result).length;
console.info("[bluetooth_js] createGattServer length:" + resultLength); console.info("[bluetooth_js] createGattServer length:" + resultLength);
expect(resultLength).assertEqual(1); expect(resultLength).assertEqual(1);
console.info('[bluetooth_js] createGattServer end');
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_GET_CONNECTED_BLEDEVICES_0001
* @tc.name testGetConnectedBLEDevices
* @tc.desc Test getConnectedBLEDevices api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_getConnectedBLEDevices_test_001', 0, async function (done) {
console.info('[bluetooth_js] getConnectedBLEDevices test start ...');
var result = bluetooth.BLE.getConnectedBLEDevices();
console.info("[bluetooth_js] getConnectedBLEDevices:" + JSON.stringify(result));
console.info("[bluetooth_js] getConnectedBLEDevices length:" + result.length);
expect(result.length).assertEqual(0);
done();
await(3000);
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_BLESCAN_NO_FILTER_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan * @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api. * @tc.desc Test ClassicStartBLEScan api.
* @tc.author quanli 00313334 * @tc.author quanli 00313334
...@@ -458,79 +374,76 @@ describe('bluetoothhostTest', function() { ...@@ -458,79 +374,76 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_ble_start_scan_no_filter', 0, async function (done) { it('bluetooth_ble_start_scan_without_param', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start'); console.info('[bluetooth_js] BLE scan start without scan options start');
await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) { function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result2 = '+ 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);
console.info('[bluetooth_js] BLEDevFind deviceId:' + data.deviceId); bluetooth.BLE.stopBLEScan();
console.info('[bluetooth_js] BLEDevFind rssi:' + data.rssi); done();
console.info('[bluetooth_js] BLEDevFind data: ' + data.data);
done()
} }
bluetooth.BLE.startBLEScan( bluetooth.BLE.startBLEScan([{}]);
[{}], bluetooth.BLE.off('BLEDeviceFind', result => {
{ console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result));
interval: 500, expect(true).assertEqual(result ==null);
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER, done();
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, });
} console.info('[bluetooth_js] BLE scan start end');
);
console.info('[bluetooth_js] BLE scan2 end');
done(); done();
await(3000);
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_BLESCAN_WITHOUT_PARAM_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0001
* @tc.name testClassicStartBLEScan * @tc.name testClassicPairDevice
* @tc.desc Test ClassicStartBLEScan api. * @tc.desc Test ClassicPairDevice api.
* @tc.author quanli 00313334 * @tc.author quanli 00313334
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_ble_start_scan_without_param', 0, async function (done) { it('bluetooth_classic_pair_device_0001', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start without scan options start'); console.info('[bluetooth_js] pair device start');
await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) await bluetooth.BLE.on('pinRequired', result => {
function onReceiveEvent(data) { console.info("[bluetooth_js] pinRequired on:" + JSON.stringify(result));
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data)) expect(true).assertEqual(result !=null);
expect(data.length).assertLarger(0);
bluetooth.BLE.stopBLEScan();
done(); done();
} });
bluetooth.BLE.startBLEScan([{}]); var enable = bluetooth.pairDevice("00:00:00:00:00:00")
console.info('[bluetooth_js] BLE scan start end'); bluetooth.BLE.off('pinRequired', result => {
done(); console.info("[bluetooth_js] pinRequired off:" + JSON.stringify(result));
setTimeout(function(){ expect(true).assertEqual(result ==null);
console.debug('========bluetooth_ble_stop_scan=======timeout') done();
},1000); });
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_STOP_BLESCAN_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_PAIR_DEVICE_0002
* @tc.name testClassicStopBLEScan * @tc.name testClassicPairDevice
* @tc.desc Test ClassicStopBLEScan api. * @tc.desc Test ClassicPairDevice api.
* @tc.author quanli 00313334 * @tc.author quanli 00313334
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_ble_stop_scan', 0, async function (done) { it('bluetooth_classic_pair_device_0002', 0, async function (done) {
console.info('[bluetooth_js] BLE stop scan start'); console.info('[bluetooth_js] pair device start');
await bluetooth.off("BLEDeviceFind", onReceiveEvent) await bluetooth.BLE.on('bondStateChange', result => {
function onReceiveEvent(data) { console.info("[bluetooth_js] bondStateChange on:" + JSON.stringify(result));
console.info('[bluetooth_js] BLE scan device find result4 ='+ JSON.stringify(data)) console.info('[bluetooth_js] bondStateChange deviceId: ' + data.deviceId);
} console.info('[bluetooth_js] bondStateChange state: ' + data.state);
var result = bluetooth.BLE.stopBLEScan(); expect(true).assertEqual(result !=null);
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result)); done();
expect(result).assertNull(); });
console.info('[bluetooth_js] BLE stop scan end'); var enable = bluetooth.pairDevice("00:00:00:00:00:00")
done(); bluetooth.BLE.off('bondStateChange', result => {
setTimeout(function(){ console.info("[bluetooth_js] bondStateChange off:" + JSON.stringify(result));
console.debug('========bluetooth_ble_stop_scan=======timeout') expect(true).assertEqual(result ==null);
},1000); done();
});
console.info('[bluetooth_js]INVALID' + JSON.stringify(bluetooth.BondState.BOND_STATE_INVALID));
console.info('[bluetooth_js]BONDING' + JSON.stringify(bluetooth.BondState.BOND_STATE_BONDING));
console.info('[bluetooth_js]BONDED' + JSON.stringify(bluetooth.BondState.BOND_STATE_BONDED));
}) })
/** /**
...@@ -542,7 +455,7 @@ describe('bluetoothhostTest', function() { ...@@ -542,7 +455,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_ble_start_advertising', 0, async function (done) { it('bluetooth_ble_start_advertising', 0, function () {
console.info('[bluetooth_js] BLE advertising start'); console.info('[bluetooth_js] BLE advertising start');
var manufactureValueBuffer = new Uint8Array(4); var manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
...@@ -576,23 +489,18 @@ describe('bluetoothhostTest', function() { ...@@ -576,23 +489,18 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] startAdv:' +advData[key]); console.info('[bluetooth_js] startAdv:' +advData[key]);
} }
await gattServer.startAdvertising(setting,advData,{ gattServer.startAdvertising(setting,advData,{
serviceUuids:["12"], serviceUuids:["12"],
manufactureData:[{ manufactureData:[{
manufactureId:1789, manufactureId:1789,
manufactureValue:manufactureValueBuffer.buffer manufactureValue:manufactureValueBuffer.buffer
}], }],
serviceData:[{ serviceData:[{
serviceUuid:"1794", serviceUuid:"1794",
serviceValue:serviceValueBuffer.buffer serviceValue:serviceValueBuffer.buffer
}], }],
}); });
console.info('[bluetooth_js] BLE start advertising end'); console.info('[bluetooth_js] BLE start advertising end');
done();
setTimeout(function(){
console.debug('====bluetooth_ble_start_advertising====timeout')
},5000);
await(3000);
}) })
/** /**
...@@ -604,39 +512,11 @@ describe('bluetoothhostTest', function() { ...@@ -604,39 +512,11 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_ble_stop_advertising', 0, async function (done) { it('bluetooth_ble_stop_advertising', 0, function () {
console.info('[bluetooth_js] BLE stop advertising start'); console.info('[bluetooth_js] BLE stop advertising start');
var gattServer = bluetooth.BLE.createGattServer(); var gattServer = bluetooth.BLE.createGattServer();
gattServer.stopAdvertising(); gattServer.stopAdvertising();
console.info('[bluetooth_js] BLE stop advertising end'); console.info('[bluetooth_js] BLE stop advertising end');
done();
setTimeout(function(){
console.debug('====bluetooth_ble_stop_advertising====timeout')
},1000);
await(3000);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEVICE_NAME_CALLBACK_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by callback.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_ble_get_device_name_callback_001', 0, async function (done) {
console.info('[bluetooth_js] get device name1 callback start');
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
var deviceName = gattClient.getDeviceName((err, data)=> {
console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err));
console.info('[bluetooth_js] device name1' + JSON.stringify(data));
done();
})
console.info('[bluetooth_js] get device name callback end');
setTimeout(function(){
console.debug('=====bluetooth_ble_get_device_name_callback1====timeout')
},1000);
}) })
/** /**
...@@ -651,14 +531,11 @@ describe('bluetoothhostTest', function() { ...@@ -651,14 +531,11 @@ describe('bluetoothhostTest', function() {
it('bluetooth_ble_get_device_name_promise', 0, async function (done) { it('bluetooth_ble_get_device_name_promise', 0, async function (done) {
console.info('BLE get device name promise start'); console.info('BLE get device name promise start');
var gattClient = gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); var gattClient = gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
var deviceName = gattClient.getDeviceName().then((data) => { await gattClient.getDeviceName().then((data) => {
console.info('[bluetooth_js] device name' + JSON.stringify(data)) console.info('[bluetooth_js] device name' + JSON.stringify(data))
done() done();
}) })
console.info('BLE get device name promise end') console.info('BLE get device name promise end')
setTimeout(function(){
console.debug('========bluetooth_ble_stop_advertising=======timeout')
},1000);
}) })
/** /**
...@@ -673,16 +550,13 @@ describe('bluetoothhostTest', function() { ...@@ -673,16 +550,13 @@ describe('bluetoothhostTest', function() {
it('bluetooth_ble_read_rssi', 0, async function (done) { it('bluetooth_ble_read_rssi', 0, async function (done) {
console.info('[bluetooth_js] BLE get rssi1 start'); console.info('[bluetooth_js] BLE get rssi1 start');
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
await gattClient.getRssiValue((err, data)=> { gattClient.getRssiValue((err, data)=> {
console.info('[bluetooth_js] rssi err:' + JSON.stringify(err)); console.info('[bluetooth_js] rssi err:' + JSON.stringify(err));
console.info('[bluetooth_js] rssi value:' + JSON.stringify(data)); console.info('[bluetooth_js] rssi value:' + JSON.stringify(data));
expect(data).assertNull(); expect(data).assertNull();
console.info('[bluetooth_js] BLE read rssi1 end');
done(); done();
}); });
console.info('[bluetooth_js] BLE read rssi1 end');
setTimeout(function(){
console.debug('========bluetooth_ble_read_rssi=======timeout')
},1000);
}) })
/** /**
...@@ -710,52 +584,10 @@ describe('bluetoothhostTest', function() { ...@@ -710,52 +584,10 @@ describe('bluetoothhostTest', function() {
done(); done();
} }
}).catch(err => { }).catch(err => {
console.error(`bluetooth getDeviceName has error: ${err}`); console.error(`bluetooth getRssiValue has error: ${err}`);
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
setTimeout(function(){
console.debug('====bluetooth_ble_stop_advertising====timeout')
},1000);
await(3000);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DISABLE_BLUETOOTH_0001
* @tc.name testDisableBluetooth
* @tc.desc Test DisableBluetooth api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_disable_bluetooth', 0, async function (done) {
console.info('[bluetooth_js] disable bluetooth start');
bluetooth.off("pinRequired", onPinRequiredReceiveEvent)
function onPinRequiredReceiveEvent(data) {
console.info('[bluetooth_js] pin required = '+ JSON.stringify(data));
}
bluetooth.off("bondStateChange", onBoneStateReceiveEvent)
function onBoneStateReceiveEvent(data) {
console.info('[bluetooth_js] bondStateChange = '+ JSON.stringify(data));
console.info('[bluetooth_js] bondStateChange deviceId: ' + data.deviceId);
console.info('[bluetooth_js] bondStateChange state: ' + data.state);
}
console.info('[bluetooth_js]INVALID' + JSON.stringify(bluetooth.BondState.BOND_STATE_INVALID));
console.info('[bluetooth_js]BONDING' + JSON.stringify(bluetooth.BondState.BOND_STATE_BONDING));
console.info('[bluetooth_js]BONDED' + JSON.stringify(bluetooth.BondState.BOND_STATE_BONDED));
bluetooth.off("stateChange", onReceiveEvent);
function onReceiveEvent(data) {
console.info('[bluetooth_js] enable bluetooth data = '+ JSON.stringify(data));
done();
}
var enable = bluetooth.disableBluetooth();
setTimeout(function(){
console.debug('========bluetooth_classic_disable_bluetooth=======timeout')
}, 1000);
console.info('[bluetooth_js] disable bluetooth end');
await(3000);
}) })
/** /**
...@@ -767,14 +599,13 @@ describe('bluetoothhostTest', function() { ...@@ -767,14 +599,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_connect', 0, function (done) { it('bluetooth_gatt_connect', 0, function () {
console.info('[bluetooth_js] gatt connect start'); console.info('[bluetooth_js] gatt connect start');
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.connect(); let ret = gattClient.connect();
console.info('[bluetooth_js] gatt connect ret : ' + ret); console.info('[bluetooth_js] gatt connect ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(true);
console.info('[bluetooth_js] gatt connect end'); console.info('[bluetooth_js] gatt connect end');
done();
}) })
/** /**
...@@ -786,13 +617,12 @@ describe('bluetoothhostTest', function() { ...@@ -786,13 +617,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_disconnect', 0, function (done) { it('bluetooth_gatt_disconnect', 0, function () {
console.info('[bluetooth_js] gatt disconnect start'); console.info('[bluetooth_js] gatt disconnect start');
let ret = gattClient.disconnect(); let ret = gattClient.disconnect();
console.info('[bluetooth_js] gatt disconnect ret:' + ret); console.info('[bluetooth_js] gatt disconnect ret:' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] gatt disconnect end'); console.info('[bluetooth_js] gatt disconnect end');
done();
}) })
/** /**
...@@ -807,15 +637,12 @@ describe('bluetoothhostTest', function() { ...@@ -807,15 +637,12 @@ describe('bluetoothhostTest', function() {
it('bluetooth_ble_get_services_callback_001', 0, async function (done) { it('bluetooth_ble_get_services_callback_001', 0, async function (done) {
console.info('[bluetooth_js] getServices callback start'); console.info('[bluetooth_js] getServices callback start');
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
var services = gattClient.getServices((err, data)=> { gattClient.getServices((err, data)=> {
console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err)); console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err));
console.info('[bluetooth_js] device name1' + JSON.stringify(data)); console.info('[bluetooth_js] device name1' + JSON.stringify(data));
done(); done();
}) })
console.info('[bluetooth_js] getServices callback end'); console.info('[bluetooth_js] getServices callback end');
setTimeout(function(){
console.debug('=====bluetooth_ble_getServices_callback====timeout')
},1000);
}) })
/** /**
...@@ -845,7 +672,6 @@ describe('bluetoothhostTest', function() { ...@@ -845,7 +672,6 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
await(3000);
}) })
/** /**
...@@ -893,7 +719,6 @@ describe('bluetoothhostTest', function() { ...@@ -893,7 +719,6 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
await(3000);
}) })
/** /**
...@@ -905,7 +730,7 @@ describe('bluetoothhostTest', function() { ...@@ -905,7 +730,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_readDescriptorValue', 0, function (done) { it('bluetooth_gatt_readDescriptorValue', 0, async function (done) {
console.info('[bluetooth_js] readDescriptorValue start'); console.info('[bluetooth_js] readDescriptorValue start');
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -938,7 +763,7 @@ describe('bluetoothhostTest', function() { ...@@ -938,7 +763,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_writeCharacteristicValue', 0, function (done) { it('bluetooth_gatt_writeCharacteristicValue', 0, function () {
console.info('[bluetooth_js] writeCharacteristicValue start'); console.info('[bluetooth_js] writeCharacteristicValue start');
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
...@@ -961,7 +786,6 @@ describe('bluetoothhostTest', function() { ...@@ -961,7 +786,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] bluetooth writeCharacteristicValue ret : ' + ret); console.info('[bluetooth_js] bluetooth writeCharacteristicValue ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] writeCharacteristicValue end'); console.info('[bluetooth_js] writeCharacteristicValue end');
done();
}) })
/** /**
...@@ -973,7 +797,7 @@ describe('bluetoothhostTest', function() { ...@@ -973,7 +797,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_writeDescriptorValue', 0, function (done) { it('bluetooth_gatt_writeDescriptorValue', 0, function () {
console.info('[bluetooth_js] writeDescriptorValue start'); console.info('[bluetooth_js] writeDescriptorValue start');
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -984,8 +808,6 @@ describe('bluetoothhostTest', function() { ...@@ -984,8 +808,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret); console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] writeDescriptorValue end'); console.info('[bluetooth_js] writeDescriptorValue end');
done();
}) })
/** /**
...@@ -997,13 +819,12 @@ describe('bluetoothhostTest', function() { ...@@ -997,13 +819,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_setBLEMtuSize', 0, function (done) { it('bluetooth_gatt_setBLEMtuSize', 0, function () {
console.info('[bluetooth_js] setBLEMtuSize start'); console.info('[bluetooth_js] setBLEMtuSize start');
let ret = gattClient.setBLEMtuSize(128); let ret = gattClient.setBLEMtuSize(128);
console.info('[bluetooth_js] bluetooth setBLEMtuSize ret : ' + ret); console.info('[bluetooth_js] bluetooth setBLEMtuSize ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] setBLEMtuSize end'); console.info('[bluetooth_js] setBLEMtuSize end');
done();
}) })
/** /**
...@@ -1015,7 +836,7 @@ describe('bluetoothhostTest', function() { ...@@ -1015,7 +836,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_setNotifyCharacteristicChanged', 0, function (done) { it('bluetooth_gatt_setNotifyCharacteristicChanged', 0, function () {
console.info('[bluetooth_js] setNotifyCharacteristicChanged start'); console.info('[bluetooth_js] setNotifyCharacteristicChanged start');
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
...@@ -1042,7 +863,6 @@ describe('bluetoothhostTest', function() { ...@@ -1042,7 +863,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret); console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] setNotifyCharacteristicChanged end'); console.info('[bluetooth_js] setNotifyCharacteristicChanged end');
done();
}) })
/** /**
...@@ -1054,7 +874,7 @@ describe('bluetoothhostTest', function() { ...@@ -1054,7 +874,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_addService', 0, function (done) { it('bluetooth_gatt_addService', 0, function () {
console.info('[bluetooth_js] addService start'); console.info('[bluetooth_js] addService start');
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
...@@ -1085,11 +905,8 @@ describe('bluetoothhostTest', function() { ...@@ -1085,11 +905,8 @@ 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(false); expect(ret).assertEqual(true);
console.info('[bluetooth_js] addService end'); console.info('[bluetooth_js] addService end');
done();
}) })
/** /**
...@@ -1101,14 +918,13 @@ describe('bluetoothhostTest', function() { ...@@ -1101,14 +918,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_removeService', 0, function (done) { it('bluetooth_gatt_removeService', 0, function () {
console.info('[bluetooth_js] removeService start'); console.info('[bluetooth_js] removeService start');
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
let ret = gattServer.removeService('00001810-0000-1000-8000-008000000000'); let ret = gattServer.removeService('00001810-0000-1000-8000-008000000000');
console.info('[bluetooth_js] removeService ret : ' + ret); console.info('[bluetooth_js] removeService ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] removeService end'); console.info('[bluetooth_js] removeService end');
done();
}) })
/** /**
...@@ -1120,7 +936,7 @@ describe('bluetoothhostTest', function() { ...@@ -1120,7 +936,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_notifyCharacteristicChanged', 0, function (done) { it('bluetooth_gatt_notifyCharacteristicChanged', 0, function () {
console.info('[bluetooth_js] notifyCharacteristicChanged start'); console.info('[bluetooth_js] notifyCharacteristicChanged start');
let descriptors = []; let descriptors = [];
let arrayBufferDesc = new ArrayBuffer(8); let arrayBufferDesc = new ArrayBuffer(8);
...@@ -1131,7 +947,7 @@ describe('bluetoothhostTest', function() { ...@@ -1131,7 +947,7 @@ describe('bluetoothhostTest', function() {
descNotifyValue[0] = 1 descNotifyValue[0] = 1
let let
descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: desValue}; descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: desValue};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: descNotifyValue}; descriptorValue: descNotifyValue};
...@@ -1152,7 +968,6 @@ describe('bluetoothhostTest', function() { ...@@ -1152,7 +968,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret); console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] notifyCharacteristicChanged end'); console.info('[bluetooth_js] notifyCharacteristicChanged end');
done();
}) })
/** /**
...@@ -1164,13 +979,13 @@ describe('bluetoothhostTest', function() { ...@@ -1164,13 +979,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_gatt_sendResponse', 0, function (done) { it('bluetooth_gatt_sendResponse', 0, function () {
console.info('[bluetooth_js] sendResponse start'); console.info('[bluetooth_js] sendResponse start');
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let value = new Uint8Array(arrayBuffer); let value = new Uint8Array(arrayBuffer);
value[0] = 1; value[0] = 1;
let serverResponse = {deviceId: '00:00:00:00:00', transId: 1, let serverResponse = {deviceId: '00:00:00:00:00', transId: 1,
status: 0, offset: 0, value: arrayBuffer}; status: 0, offset: 0, value: arrayBuffer};
for (var key in serverResponse ){ for (var key in serverResponse ){
console.info('[bluetooth_js] serverResponse:'+ serverResponse[key]); console.info('[bluetooth_js] serverResponse:'+ serverResponse[key]);
} }
...@@ -1178,8 +993,6 @@ describe('bluetoothhostTest', function() { ...@@ -1178,8 +993,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] sendResponse ret : ' + ret); console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] sendResponse end'); console.info('[bluetooth_js] sendResponse end');
done();
}) })
/** /**
...@@ -1191,7 +1004,7 @@ describe('bluetoothhostTest', function() { ...@@ -1191,7 +1004,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_spp_listen', 0, function (done) { it('bluetooth_spp_listen', 0, async function (done) {
console.log("[bluetooth_js]: spp listen start"); console.log("[bluetooth_js]: spp listen start");
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: false, type: 0}; secure: false, type: 0};
...@@ -1212,7 +1025,6 @@ describe('bluetoothhostTest', function() { ...@@ -1212,7 +1025,6 @@ describe('bluetoothhostTest', function() {
} }
}); });
console.log("[bluetooth_js] spp listen end"); console.log("[bluetooth_js] spp listen end");
done();
}) })
/** /**
...@@ -1224,7 +1036,7 @@ describe('bluetoothhostTest', function() { ...@@ -1224,7 +1036,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_spp_Accept', 0, function (done) { it('bluetooth_spp_Accept', 0, async function (done) {
console.log("[bluetooth_js] spp accept start"); console.log("[bluetooth_js] spp accept start");
bluetooth.sppAccept(-1, function(code, clientSocketNumber) { bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
if (code.code == 0) { if (code.code == 0) {
...@@ -1237,9 +1049,8 @@ describe('bluetoothhostTest', function() { ...@@ -1237,9 +1049,8 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(false); expect(true).assertEqual(false);
} }
}); });
console.log("[bluetooth_js] spp accept end");
done(); done();
console.log("[bluetooth_js] spp accept end");
}) })
/** /**
...@@ -1251,13 +1062,12 @@ describe('bluetoothhostTest', function() { ...@@ -1251,13 +1062,12 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_spp_closeServerSocket', 0, function (done) { it('bluetooth_spp_closeServerSocket', 0, function () {
console.log("[bluetooth_js] spp closeServerSocket start"); console.log("[bluetooth_js] spp closeServerSocket start");
let ret = bluetooth.sppCloseServerSocket(-1); let ret = bluetooth.sppCloseServerSocket(-1);
console.info('[bluetooth_js] bluetooth sppCloseServerSocket ret : ' + ret); console.info('[bluetooth_js] bluetooth sppCloseServerSocket ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.log("[bluetooth_js] spp closeServerSocket end"); console.log("[bluetooth_js] spp closeServerSocket end");
done();
}) })
/** /**
...@@ -1269,7 +1079,7 @@ describe('bluetoothhostTest', function() { ...@@ -1269,7 +1079,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_spp_connect', 0, function (done) { it('bluetooth_spp_connect', 0, async function (done) {
console.info('[bluetooth_js] spp_connect start'); console.info('[bluetooth_js] spp_connect start');
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0}; secure: true, type: 0};
...@@ -1295,7 +1105,7 @@ describe('bluetoothhostTest', function() { ...@@ -1295,7 +1105,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_spp_write', 0, function (done) { it('bluetooth_spp_write', 0, function () {
console.info('[bluetooth_js] spp write start'); console.info('[bluetooth_js] spp write start');
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let data = new Uint8Array(arrayBuffer); let data = new Uint8Array(arrayBuffer);
...@@ -1304,8 +1114,6 @@ describe('bluetoothhostTest', function() { ...@@ -1304,8 +1114,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] bluetooth sppWrite ret : ' + ret); console.info('[bluetooth_js] bluetooth sppWrite ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
console.info('[bluetooth_js] spp write end'); console.info('[bluetooth_js] spp write end');
done();
}) })
/** /**
...@@ -1317,15 +1125,13 @@ describe('bluetoothhostTest', function() { ...@@ -1317,15 +1125,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetoothble_CharacteristicReadOn_test_001', 0, function () { it('bluetoothble_CharacteristicReadOn_test_001', 0, async function (done) {
console.info('[bluetooth_js] CharacteristicReadOn test start'); try {
if (gattServer == null) { console.info('[bluetooth_js] CharacteristicReadOn test start');
console.info("[bluetooth_js] BlePerManager: please click CreateGattServer first!"); if (gattServer == null) {
} console.info("[bluetooth_js] : click onCreateGattServer first!");
gattServer.on('characteristicRead', (err, data) => { }
if (err) { await gattServer.on('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead callback err:" + JSON.stringify(err));
} else {
console.info('[bluetooth_js] charRead callback data ->'); console.info('[bluetooth_js] charRead callback data ->');
console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId); console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId);
console.info('[bluetooth_js] CharRedReq transId: ' + data.transId); console.info('[bluetooth_js] CharRedReq transId: ' + data.transId);
...@@ -1343,8 +1149,25 @@ describe('bluetoothhostTest', function() { ...@@ -1343,8 +1149,25 @@ describe('bluetoothhostTest', function() {
console.info("[bluetooth_js] sendResponse -> " + JSON.stringify(result)); console.info("[bluetooth_js] sendResponse -> " + JSON.stringify(result));
expect(JSON.stringify(result)).assertContain("true"); expect(JSON.stringify(result)).assertContain("true");
console.info("[bluetooth_js] onBlePeripheralManagerClose ."); console.info("[bluetooth_js] onBlePeripheralManagerClose .");
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] characteristicRead test1 start');
if (gattServer == null) {
console.info("[bluetooth_js] :plese CreateGattServer first!");
} }
}); await gattServer.off('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead off jsdata1:" + JSON.stringify(data));
console.info("[bluetooth_js] charaRead off data1:" + data);
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
}) })
/** /**
...@@ -1356,15 +1179,13 @@ describe('bluetoothhostTest', function() { ...@@ -1356,15 +1179,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetoothble_CharacteristicwriteOn_test_001', 0, function () { it('bluetoothble_CharacteristicwriteOn_test_001', 0, async function (done) {
console.info('[bluetooth_js] CharacteristicwriteOn test start ...'); try {
if (gattServer == null) { console.info('[bluetooth_js] CharacteristicwriteOn test start');
console.info("[bluetooth_js] Charwrite: please click CreateGattServer first!"); if (gattServer == null) {
} console.info("[bluetooth_js] : click onCreateGattServer first!");
gattServer.on('characteristicWrite', (err, data) => { }
if (err) { await gattServer.on('characteristicWrite', function (data) {
console.info("[bluetooth_js] characteristic callback error" + JSON.stringify(err));
} else {
console.info('[bluetooth_js] characteristicWrite callback data ->'); console.info('[bluetooth_js] characteristicWrite callback data ->');
console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId); console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId);
console.info('[bluetooth_js] CharWriReq transId: ' + data.transId); console.info('[bluetooth_js] CharWriReq transId: ' + data.transId);
...@@ -1394,9 +1215,25 @@ describe('bluetoothhostTest', function() { ...@@ -1394,9 +1215,25 @@ describe('bluetoothhostTest', function() {
console.info("[bluetooth_js] sendResponse:" + JSON.stringify(result)); console.info("[bluetooth_js] sendResponse:" + JSON.stringify(result));
expect(JSON.stringify(result)).assertContain("true"); expect(JSON.stringify(result)).assertContain("true");
console.info("[bluetooth_js] characteristicWrite end"); console.info("[bluetooth_js] characteristicWrite end");
} });
}); }catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] characteristicWrite test1 start');
if (gattServer == null) {
console.info("[bluetooth_js] :plese CreateGattServer first!");
}
await gattServer.off('characteristicWrite', function (data) {
console.info("[bluetooth_js] charaWrite off jsdata2:" + JSON.stringify(data));
console.info("[bluetooth_js] charaWrite off data2:" + data);
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
}) })
/** /**
...@@ -1414,7 +1251,7 @@ describe('bluetoothhostTest', function() { ...@@ -1414,7 +1251,7 @@ describe('bluetoothhostTest', function() {
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!"); console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!");
} }
gattServer.on('descriptorRead', function (data) { await gattServer.on('descriptorRead', function (data) {
console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data)); console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data));
console.info("[bluetooth_js] DesRedon data:" + data); console.info("[bluetooth_js] DesRedon data:" + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
...@@ -1426,40 +1263,27 @@ describe('bluetoothhostTest', function() { ...@@ -1426,40 +1263,27 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] DesRedReq charUuid:' + data.characteristicUuid); console.info('[bluetooth_js] DesRedReq charUuid:' + data.characteristicUuid);
console.info('[bluetooth_js] DesRedReq serUuid:' + data.serviceUuid); console.info('[bluetooth_js] DesRedReq serUuid:' + data.serviceUuid);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_READ_OFF_0001
* @tc.name testDescriptorReadOff
* @tc.desc Test DescriptorReadOff api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_descriptorRead_Off_test_001', 0, async function (done) {
try { try {
console.info('[bluetooth_js] descriptorReadOff test start ...'); console.info('[bluetooth_js] descriptorReadOff test start ...');
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper:click onCreateGattServer first!"); console.info("[bluetooth_js] onAddServiceHelper:click onCreateGattServer first!");
} }
gattServer.off('descriptorRead', function (data) { await gattServer.off('descriptorRead', function (data) {
console.info("[bluetooth_js] descriptorRead_off json_data-> " + JSON.stringify(data)); console.info("[bluetooth_js] descriptorRead_off json_data-> " + JSON.stringify(data));
console.info("[bluetooth_js] descriptorRead_off data -> " + data); console.info("[bluetooth_js] descriptorRead_off data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data ==null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_WRITE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn * @tc.name testDescriptorWriteOn
...@@ -1475,7 +1299,7 @@ describe('bluetoothhostTest', function() { ...@@ -1475,7 +1299,7 @@ describe('bluetoothhostTest', function() {
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!"); console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!");
} }
gattServer.on('descriptorWrite', function (data) { await gattServer.on('descriptorWrite', function (data) {
console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data)); console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data));
console.info("[bluetooth_js] desWriOn data:" + data); console.info("[bluetooth_js] desWriOn data:" + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
...@@ -1491,40 +1315,27 @@ describe('bluetoothhostTest', function() { ...@@ -1491,40 +1315,27 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] desWriOn needRsp: ' + data.needRsp); console.info('[bluetooth_js] desWriOn needRsp: ' + data.needRsp);
console.info('[bluetooth_js] desWriOn isPrep: ' + data.isPrep); console.info('[bluetooth_js] desWriOn isPrep: ' + data.isPrep);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_WRITE_OFF_0001
* @tc.name testDescriptorWriteOff
* @tc.desc Test DescriptorWriteOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_descriptorWrite_Off_test_001', 0, async function (done) {
try { try {
console.info('[bluetooth_js] descriptorWriteOff test start ...'); console.info('[bluetooth_js] descriptorWriteOff test start ...');
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!"); console.info("[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!");
} }
gattServer.off('descriptorWrite', function (data) { await gattServer.off('descriptorWrite', function (data) {
console.info("[bluetooth_js] desWriOff jsonData-> " + JSON.stringify(data)); console.info("[bluetooth_js] desWriOff jsonData-> " + JSON.stringify(data));
console.info("[bluetooth_js] desWriOff data -> " + data); console.info("[bluetooth_js] desWriOff data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data ==null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn * @tc.name testConnectStateChangeOn
...@@ -1538,51 +1349,37 @@ describe('bluetoothhostTest', function() { ...@@ -1538,51 +1349,37 @@ describe('bluetoothhostTest', function() {
try { try {
console.info('[bluetooth_js] ConnectStateChangeOn test start ...'); console.info('[bluetooth_js] ConnectStateChangeOn test start ...');
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper: click CreateGattServer first!"); console.info("[bluetooth_js] on: click CreateGattServer first!");
} }
gattServer.on('connectStateChange', function (data) { await gattServer.on('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data)); console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data));
console.info("[bluetooth_js] connectStaOn data -> " + data); console.info("[bluetooth_js] connectStaOn data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
console.info('[bluetooth_js] connectStaOn callback data ->'); console.info('[bluetooth_js] connectStaOn callback data ->');
console.info('[bluetooth_js] connectStaOn deviceId: ' + data.deviceId); console.info('[bluetooth_js] connectStaOn deviceId: ' + data.deviceId);
console.info('[bluetooth_js] connectStaOn state: ' + data.state); console.info('[bluetooth_js] connectStaOn state: ' + data.state);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_OFF_0001
* @tc.name testConnectStateChangeOff
* @tc.desc Test ConnectStateChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_connectStateChange_Off_test_001', 0, async function (done) {
try { try {
console.info('[bluetooth_js] ConnectStateChangeOff test start ...'); console.info('[bluetooth_js] ConnectStateChangeOff test start ...');
if (gattServer == null) { if (gattServer == null) {
console.info("[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!"); console.info("[bluetooth_js] on: please click onCreateGattServer first!");
} }
gattServer.off('connectStateChange', function (data) { await gattServer.off('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStateChange_off jsonData-> " + JSON.stringify(data)); console.info("[bluetooth_js] connectStateChange_off jsonData-> " + JSON.stringify(data));
console.info("[bluetooth_js] connectStateChange_off data -> " + data); console.info("[bluetooth_js] connectStateChange_off data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data ==null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CHAR_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn * @tc.name testBLECharacteristicChangeOn
...@@ -1596,47 +1393,34 @@ describe('bluetoothhostTest', function() { ...@@ -1596,47 +1393,34 @@ describe('bluetoothhostTest', function() {
try { try {
console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...'); console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...');
if (gattClient == null) { if (gattClient == null) {
console.info("[bluetooth_js] OnGattclientClose:click onCreateGattClientDevice first!"); console.info("[bluetooth_js] OnGattclientClose:click onCreateGattClient first!");
} }
gattClient.on('BLECharacteristicChange', function (data) { await gattClient.on('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data));
console.info("[bluetooth_js] BLECharacteristicChange_on data -> " + data); console.info("[bluetooth_js] BLECharacteristicChange_on data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CHAR_CHANGE_OFF_0001
* @tc.name testBLECharacteristicChangeOff
* @tc.desc Test BLECharacteristicChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_BLECharacteristicChange_Off_test_001', 0, async function (done) {
try { try {
console.info('[bluetooth_js] BLECharacteristicChangeOff test start'); console.info('[bluetooth_js] BLECharacteristicChangeOff test start');
if (gattClient == null) { if (gattClient == null) {
console.info("[bluetooth_js] OnGattclientClose: CreateGattClientDevice first!"); console.info("[bluetooth_js] OnGattclientClose: CreateGattClient first!");
} }
gattClient.off('BLECharacteristicChange', function (data) { await gattClient.off('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharcChange_off json_data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharcChange_off json_data-> " + JSON.stringify(data));
console.info("[bluetooth_js] BLECharcChange_off data -> " + data); console.info("[bluetooth_js] BLECharcChange_off data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data ==null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CONNE_STATE_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn * @tc.name testBLEConnectionStateChangeOn
...@@ -1650,9 +1434,9 @@ describe('bluetoothhostTest', function() { ...@@ -1650,9 +1434,9 @@ describe('bluetoothhostTest', function() {
try { try {
console.info('[bluetooth_js] BLEConnectionStateChangeOn test start'); console.info('[bluetooth_js] BLEConnectionStateChangeOn test start');
if (gattClient == null) { if (gattClient == null) {
console.info("[bluetooth_js] GattclientClose:CreateGattClientDevice first!"); console.info("[bluetooth_js] GattclientClose:CreateGattClient first!");
} }
gattClient.on('BLEConnectionStateChange', function (data) { await gattClient.on('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data)); console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data));
console.info("[bluetooth_js] BLEConneStateChange_on data -> " + data); console.info("[bluetooth_js] BLEConneStateChange_on data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
...@@ -1660,114 +1444,27 @@ describe('bluetoothhostTest', function() { ...@@ -1660,114 +1444,27 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLEConneStateChange deviceId : ' + data.deviceId); console.info('[bluetooth_js] BLEConneStateChange deviceId : ' + data.deviceId);
console.info('[bluetooth_js] BLEConneStateChange state : ' + data.state); console.info('[bluetooth_js] BLEConneStateChange state : ' + data.state);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_BLE_CONNE_STATE_CHANGE_OFF_0001
* @tc.name testBLEConnectionStateChangeOff
* @tc.desc Test BLEConnectionStateChangeOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_BLEConnectionStateChange_Off_test_001', 0, async function (done) {
try { try {
console.info('[bluetooth_js] BLEConnectionStateChangeOff test start'); console.info('[bluetooth_js] BLEConnectionStateChangeOff test start');
if (gattClient == null) { if (gattClient == null) {
console.info("[bluetooth_js] GattclientClose:click CreateGattClientDevice first!"); console.info("[bluetooth_js] GattclientClose:click CreateGattClient first!");
} }
gattClient.on('BLEConnectionStateChange', function (result) { await gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_on1 result: " + JSON.stringify(result));
console.info("[bluetooth_js] BLEConneStateChange_on1 result: " + result);
expect(true).assertEqual(result !=null);
});
await(3000);
gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data));
console.info("[bluetooth_js] BLEConneStateChange_off data -> " + data); console.info("[bluetooth_js] BLEConneStateChange_off data -> " + data);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data ==null);
}); });
await(3000);
}catch(e) { }catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_sppReadOn_test_001', 0, async function (done) {
try {
console.info('[bluetooth_js] sppReadOn test start');
console.info('bluetooth sppReadOn test start ...');
bluetooth.on("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOn json_result -> " + JSON.stringify(result));
console.info("[bluetooth_js] sppReadOn result -> " + result);
expect(true).assertEqual(result !=null);
});
await(3000);
}catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_SPP_READ_ON_0002
* @tc.name testsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_sppReadOn_test_002', 0, async function (done) {
console.info('[bluetooth_js] sppReadOn test2 start ...');
await bluetooth.on("sppRead",-1, onSppReadEvent)
function onSppReadEvent(data) {
console.info('[bluetooth_js] sppRead data1='+ JSON.stringify(data));
console.info('[bluetooth_js] sppRead data2='+ data);
}
done();
await(3000);
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_READ_OFF_0001
* @tc.name testsppReadOff
* @tc.desc Test sppReadOff api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_sppReadOff_test_001', 0, async function (done) {
try {
console.info('[bluetooth_js] sppReadOff test start ...');
bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
console.info("[bluetooth_js] sppReadOff result -> " + result);
expect(true).assertEqual(result !=null);
});
await(3000);
}catch(e) {
expect(null).assertFail();
}
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_BLE_PERIPHERA_MANAGER_CLOSE_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_BLE_PERIPHERA_MANAGER_CLOSE_0001
...@@ -1807,7 +1504,7 @@ describe('bluetoothhostTest', function() { ...@@ -1807,7 +1504,7 @@ describe('bluetoothhostTest', function() {
it('bluetooth_gattclient_close_test_001', 0, function () { it('bluetooth_gattclient_close_test_001', 0, function () {
console.info('[bluetooth_js] GattclientClose test start ...'); console.info('[bluetooth_js] GattclientClose test start ...');
if (gattClient == null) { if (gattClient == null) {
console.info("[bluetooth_js] GattclientClose: please click CreateGattClientDevice first!"); console.info("[bluetooth_js] GattclientClose: please click Create first!");
} }
console.info('[bluetooth_js] gattClient is:' + JSON.stringify(gattServer)); console.info('[bluetooth_js] gattClient is:' + JSON.stringify(gattServer));
try{ try{
...@@ -1831,14 +1528,13 @@ describe('bluetoothhostTest', function() { ...@@ -1831,14 +1528,13 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_getRemoteDeviceName_test', 0, function (done) { it('bluetooth_getRemoteDeviceName_test', 0, function () {
console.info('[bluetooth_js] getRemoteDeviceName start'); console.info('[bluetooth_js] getRemoteDeviceName start');
let ret = bluetooth.getRemoteDeviceName("00:00:00:00:00:00"); let ret = bluetooth.getRemoteDeviceName("00:00:00:00:00:00");
console.info('[bluetooth_js] getRemoteDeviceName ret : ' + ret); console.info('[bluetooth_js] getRemoteDeviceName ret : ' + ret);
console.info('[bluetooth_js] getRemoteDeviceName ret2 : ' + JSON.stringify(ret)); console.info('[bluetooth_js] getRemoteDeviceName ret2 : ' + JSON.stringify(ret));
expect(ret.length).assertEqual(0); expect(ret.length).assertEqual(0);
console.info('[bluetooth_js] getRemoteDeviceName end.'); console.info('[bluetooth_js] getRemoteDeviceName end.');
done();
}) })
/** /**
...@@ -1850,7 +1546,7 @@ describe('bluetoothhostTest', function() { ...@@ -1850,7 +1546,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_getRemoteDeviceClass_test', 0, function (done) { it('bluetooth_getRemoteDeviceClass_test', 0, function () {
console.info('[bluetooth_js] getRemoteDeviceClass start'); console.info('[bluetooth_js] getRemoteDeviceClass start');
var MajorMinorClass = { var MajorMinorClass = {
COMPUTER_UNCATEGORIZED : 0x0100, COMPUTER_UNCATEGORIZED : 0x0100,
...@@ -1906,27 +1602,27 @@ describe('bluetoothhostTest', function() { ...@@ -1906,27 +1602,27 @@ describe('bluetoothhostTest', function() {
PERIPHERAL_DIGITAL_PEN : 0x051C, PERIPHERAL_DIGITAL_PEN : 0x051C,
PERIPHERAL_SCANNER_RFID : 0x0520, PERIPHERAL_SCANNER_RFID : 0x0520,
PERIPHERAL_GESTURAL_INPUT : 0x0522, PERIPHERAL_GESTURAL_INPUT : 0x0522,
IMAGING_UNCATEGORIZED : 0x0600, IMAGING_UNCATEGORIZED : 0x0600,
IMAGING_DISPLAY : 0x0610, IMAGING_DISPLAY : 0x0610,
IMAGING_CAMERA : 0x0620, IMAGING_CAMERA : 0x0620,
IMAGING_SCANNER : 0x0640, IMAGING_SCANNER : 0x0640,
IMAGING_PRINTER : 0x0680, IMAGING_PRINTER : 0x0680,
WEARABLE_UNCATEGORIZED : 0x0700, WEARABLE_UNCATEGORIZED : 0x0700,
WEARABLE_WRIST_WATCH : 0x0704, WEARABLE_WRIST_WATCH : 0x0704,
WEARABLE_PAGER : 0x0708, WEARABLE_PAGER : 0x0708,
WEARABLE_JACKET : 0x070C, WEARABLE_JACKET : 0x070C,
WEARABLE_HELMET : 0x0710, WEARABLE_HELMET : 0x0710,
WEARABLE_GLASSES : 0x0714, WEARABLE_GLASSES : 0x0714,
TOY_UNCATEGORIZED : 0x0800, TOY_UNCATEGORIZED : 0x0800,
TOY_ROBOT : 0x0804, TOY_ROBOT : 0x0804,
TOY_VEHICLE : 0x0808, TOY_VEHICLE : 0x0808,
TOY_DOLL_ACTION_FIGURE : 0x080C, TOY_DOLL_ACTION_FIGURE : 0x080C,
TOY_CONTROLLER : 0x0810, TOY_CONTROLLER : 0x0810,
TOY_GAME : 0x0814, TOY_GAME : 0x0814,
HEALTH_UNCATEGORIZED : 0x0900, HEALTH_UNCATEGORIZED : 0x0900,
HEALTH_BLOOD_PRESSURE : 0x0904, HEALTH_BLOOD_PRESSURE : 0x0904,
HEALTH_THERMOMETER : 0x0908, HEALTH_THERMOMETER : 0x0908,
...@@ -1945,7 +1641,6 @@ describe('bluetoothhostTest', function() { ...@@ -1945,7 +1641,6 @@ describe('bluetoothhostTest', function() {
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C, HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C,
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C
}; };
let ret = bluetooth.getRemoteDeviceClass("00:00:00:00:00:00"); let ret = bluetooth.getRemoteDeviceClass("00:00:00:00:00:00");
console.info('[bluetooth_js] getRemoteDeviceClass ret : ' + ret); console.info('[bluetooth_js] getRemoteDeviceClass ret : ' + ret);
console.info('[bluetooth_js] getRemoteDeviceClass ret2 : ' + JSON.stringify(ret)); console.info('[bluetooth_js] getRemoteDeviceClass ret2 : ' + JSON.stringify(ret));
...@@ -1954,6 +1649,41 @@ describe('bluetoothhostTest', function() { ...@@ -1954,6 +1649,41 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] majorMinorClass : ' + ret.majorMinorClass); console.info('[bluetooth_js] majorMinorClass : ' + ret.majorMinorClass);
console.info('[bluetooth_js] classOfDevice : ' + ret.classOfDevice); console.info('[bluetooth_js] classOfDevice : ' + ret.classOfDevice);
console.info('[bluetooth_js] getRemoteDeviceClass end.'); console.info('[bluetooth_js] getRemoteDeviceClass end.');
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_sppReadOn_test_001', 0, async function (done) {
try {
console.info('[bluetooth_js] sppReadOn test start');
console.info('bluetooth sppReadOn test start ...');
await bluetooth.on("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOn json_result -> " + JSON.stringify(result));
console.info("[bluetooth_js] sppReadOn result -> " + result);
expect(true).assertEqual(result !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] sppReadOff test start ...');
await bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
console.info("[bluetooth_js] sppReadOff result -> " + result);
expect(true).assertEqual(result ==null);
});
}catch(e) {
expect(null).assertFail();
}
done(); done();
}) })
...@@ -1966,14 +1696,293 @@ describe('bluetoothhostTest', function() { ...@@ -1966,14 +1696,293 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('bluetooth_cancelPairedDevice_test', 0, function (done) { it('bluetooth_cancelPairedDevice_test', 0, function () {
console.info('[bluetooth_js] cancelPairedDevice start'); console.info('[bluetooth_js] cancelPairedDevice start');
let ret = bluetooth.cancelPairedDevice("00:00:00:00:00:00"); let ret = bluetooth.cancelPairedDevice("00:00:00:00:00:00");
console.info('[bluetooth_js] cancelPairedDevice ret : ' + ret); console.info('[bluetooth_js] cancelPairedDevice ret : ' + ret);
console.info('[bluetooth_js] cancelPairedDevice ret2 : ' + JSON.stringify(ret)); console.info('[bluetooth_js] cancelPairedDevice ret2 : ' + JSON.stringify(ret));
expect(ret).assertEqual(false); expect(ret).assertFalse();
console.info('bluetooth cancelPairedDevice end.'); console.info('bluetooth cancelPairedDevice end.');
done(); })
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0001
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name1', 0, async function () {
console.info('[bluetooth_js] set localname start');
var state = bluetooth.getState();
console.info('[bluetooth_js] getState step1 = '+ JSON.stringify(state));
var name = bluetooth.setLocalName('');
console.info('[bluetooth_js] setLocalName result1 = '+ JSON.stringify(name));
expect(name).assertFalse();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result1 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0002
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name2', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName();
console.info('[bluetooth_js] setLocalName result2 = '+ JSON.stringify(name));
expect(name).assertNull();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result2 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0003
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name3', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('012345678901234567890123456789012345678901234567890123'
+'45678901234567890123456789012345678901234567890123456789012345678901234567');
console.info('[bluetooth_js] setLocalName result3 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result3 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0004
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name4', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('01234567890123456789012345678901234567890123456'
+'7890123456789012345678901234567890123456789012345678901234567890123456789012345678');
console.info('[bluetooth_js] setLocalName result4 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result4 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0005
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name5', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
console.info('[bluetooth_js] setLocalName result5 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result5 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0006
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name6', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('测试蓝牙名称是否正常测试蓝牙名称是否正常测试蓝牙');
console.info('[bluetooth_js] setLocalName result6 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result6 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0007
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name7', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('*^_^* 、。·ˉˇ¨〃々—~‖·‘’“”〔③〈《「『』〖❂【±×'
+'÷∶∧∨∑∏∪∩∈∷√⊥‖∠⌒⊙∫∮≡≌≈∽∝≠♂♀°℃$¤¢£‰§№☆★○●◎◇□■△※→←↑↓〓');
console.info('[bluetooth_js] setLocalName result7 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result7 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0008
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name8', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('测试蓝常测试蓝牙\'名称是否[666]aaw');
console.info('[bluetooth_js] setLocalName result8 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result8 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_0009
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name9', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('——◎◇◆□■△▲测试蓝牙');
console.info('[bluetooth_js] setLocalName result9 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result9 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00010
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name10', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('78453-、、。。◎◇◆□■△▲');
console.info('[bluetooth_js] setLocalName result10 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result10 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00011
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name11', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('hhhfdf-、、。。◎◇◆□■△▲');
console.info('[bluetooth_js] setLocalName result11 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result11 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00012
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name12', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('#01-5@<>?/;:!@$%^&*(1[{【‘’“”~·0bu测试=》《\'[666]');
console.info('[bluetooth_js] setLocalName result12 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result12 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00013
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name13', 0, function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('#01-567890@<>?/;:5675ASDF012345678!@'
+'$%^&*()9012378901[]{}【】566~·67890blue');
console.info('[bluetooth_js] setLocalName result13 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result13 = ' + JSON.stringify(localName));
console.info('[bluetooth_js] setLocalName end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00014
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_set_local_name14', 0, async function () {
console.info('[bluetooth_js] set localname start');
var name = bluetooth.setLocalName('0123456789012345678901234567890123456789012345678901'
+'23456789012345678901234567890123456789012345678901234567890123456789012345678012'
+'345678901234567890123456789012345678901234567890123456789012367890123456789012345568');
console.info('[bluetooth_js] setLocalName result14 = '+ JSON.stringify(name));
expect(name).assertTrue();
var localName = bluetooth.getLocalName();
console.info('[bluetooth_js] getLocalName result14 = ' + JSON.stringify(localName));
let disable = bluetooth.disableBluetooth();
console.info('[bluetooth_js] disable:' + JSON.stringify(disable));
expect(disable).assertTrue();
await sleep(2000);
console.info('[bluetooth_js] setLocalName end');
}) })
}) })
...@@ -26,23 +26,22 @@ export default { ...@@ -26,23 +26,22 @@ export default {
}, },
onShow() { onShow() {
console.info('onShow finish') console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
const core = Core.getInstance() const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
'id': 'extend' 'id': 'extend'
}) })
core.addService('expect', expectExtend) core.addService('expect', expectExtend)
// core.addService('report', instrumentLog)
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = 600000
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
core.execute() core.execute()
},
onReady() {
}, },
} }
...@@ -201,7 +201,7 @@ describe('ACTS_WifiTest', function() { ...@@ -201,7 +201,7 @@ describe('ACTS_WifiTest', function() {
it('SUB_Communication_WiFi_Sta_Config_0001', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Config_0001', 0, async function(done) {
console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0001]"); console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0001]");
console.info("[wifi_test] create a OPEN SecurityType wifi device config start."); console.info("[wifi_test] create a OPEN SecurityType wifi device config start.");
var remov = wifi.removeAllNetwork(); wifi.removeAllNetwork();
var wifiDeviceConfig1 = { var wifiDeviceConfig1 = {
"ssid": "TEST_OPEN", "ssid": "TEST_OPEN",
"bssid": "", "bssid": "",
...@@ -287,71 +287,6 @@ describe('ACTS_WifiTest', function() { ...@@ -287,71 +287,6 @@ describe('ACTS_WifiTest', function() {
done() done()
}) })
/**
* @tc.number Config_0005
* @tc.name SUB_Communication_WiFi_Sta_Config_0005
* @tc.desc Test remove all wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0005', 0, async function(done) {
console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0005]");
console.info("[wifi_test] create multiple valid wifi device config and add it.");
var wifiDeviceConfig1 = {
"ssid": "TESTWgr1",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": "false",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
};
var wifiDeviceConfig2 = {
"ssid": "TESTWgr2",
"bssid": "",
"preSharedKey": "",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
};
let promiseOne = new Promise((resolve, reject) => {
wifi.addDeviceConfig(wifiDeviceConfig1,
(err,netWorkId1) => {
if(err) {
console.info("[wifi_test]add callback failed : " + JSON.stringify(err));
return;
}
console.info("[wifi_test] wifi addDeviceconfig1 callback:" + JSON.stringify(netWorkId1));
expect(true).assertEqual(netWorkId1 != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length >= 1);
resolve()
});
})
let promiseTwo = new Promise((resolve, reject) => {
wifi.addDeviceConfig(wifiDeviceConfig2,
(err,netWorkId2) => {
if(err) {
console.info("[wifi_test]add callback failed : " + JSON.stringify(err));
return;
}
console.info("[wifi_test] wifi addDeviceconfig2 callback : " + JSON.stringify(netWorkId2));
expect(true).assertEqual(netWorkId2 != -1);
console.info("[wifi_test] check add device configs successfully ");
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length >= 1);
console.info("[wifi_test] remove all configs");
var isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
var configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove configs,current get Configs : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
resolve()
});
})
Promise.all([promiseOne, promiseTwo]).then(done)
})
/** /**
* @tc.number Config_0007 * @tc.number Config_0007
* @tc.name SUB_Communication_WiFi_Sta_Config_0007 * @tc.name SUB_Communication_WiFi_Sta_Config_0007
...@@ -601,7 +536,122 @@ describe('ACTS_WifiTest', function() { ...@@ -601,7 +536,122 @@ describe('ACTS_WifiTest', function() {
expect(true).assertEqual(configs.length == 0); expect(true).assertEqual(configs.length == 0);
done() done()
}) })
/**
* @tc.number wifiStateChange_0001
* @tc.name SUB_Communication_WiFi_Sta_wifiStateChange_0001
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiStateChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) {
console.info('[wifi_test] OnWifiStateChange test start ...');
await wifi.on('wifiStateChange', result => {
console.info("onwifiStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiStateChange test start ...');
wifi.off('wifiStateChange', result => {
console.info("offwifiStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiConnectionChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiConnectionChange_0002', 0, async function (done) {
console.info('[wifi_test] OnwifiConnectionChange test start...');
await wifi.on('wifiConnectionChange', result => {
console.info("onwifiConnectionChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiConnectionChange test start ...');
wifi.off('wifiConnectionChange', result => {
console.info("offwifiConnectionChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
/**
* @tc.number wifiConnectionChange_0002
* @tc.name SUB_Communication_WiFi_Sta_wifiConnectionChange_0002
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiConnectionChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiScanStateChange_0003', 0, async function (done) {
console.info('[wifi_test] OnwifiScanStateChange test start...');
await wifi.on('wifiScanStateChange', result => {
console.info("onwifiScanStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiScanStateChange test start ...');
wifi.off('wifiScanStateChange', result => {
console.info("offwifiScanStateChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
/**
* @tc.number wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0003
* @tc.author wudangping wwx1075776
* @tc.desc Test wifiRssiChange callback
*/
it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) {
console.info('[wifi_test] OnwifiRssiChange test start...');
await wifi.on('wifiRssiChange', result => {
console.info("onwifiRssiChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offwifiRssiChange test start ...');
wifi.off('wifiRssiChange', result => {
console.info("offwifiRssiChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
/**
* @tc.number streamChange_0004
* @tc.name SUB_Communication_WiFi_Sta_streamChange_0003
* @tc.author wudangping wwx1075776
* @tc.desc Test streamChange callback
*/
it('SUB_Communication_WiFi_Sta_streamChange_0005', 0, async function (done) {
console.info('[wifi_test] OnstreamChange test start...');
await wifi.on('streamChange', result => {
console.info("onstreamChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null);
done();
});
setTimeout(function() {
console.info('[wifi_test] offstreamChange test start ...');
wifi.off('streamChange', result => {
console.info("offstreamChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}, 2 * 1000);
done();
})
console.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.
先完成此消息的编辑!
想要评论请 注册