diff --git a/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js b/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js index 96f4ea54a886692c5233c9a5a1fd0db4d6cc1ae7..dae9d6a55c3cd3f3e011e2d684d18dc7fb2164fe 100644 --- a/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js +++ b/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js @@ -16,6 +16,31 @@ import bluetooth from '@ohos.bluetooth'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + + +var SppType = { + SPP_RFCOMM : 0 +} + +var MatchMode = { + MATCH_MODE_AGGRESSIVE : 1, + MATCH_MODE_STICKY : 2 +} + +var MajorClass = { + MAJOR_MISC : 0x0000, + MAJOR_COMPUTER : 0x0100, + MAJOR_PHONE : 0x0200, + MAJOR_NETWORKING : 0x0300, + MAJOR_AUDIO_VIDEO : 0x0400, + MAJOR_PERIPHERAL : 0x0500, + MAJOR_IMAGING : 0x0600, + MAJOR_WEARABLE : 0x0700, + MAJOR_TOY : 0x0800, + MAJOR_HEALTH : 0x0900, + MAJOR_UNCATEGORIZED : 0x1F00 + } + describe('bluetoothhostTest', function() { var gattServer = null; @@ -26,15 +51,15 @@ describe('bluetoothhostTest', function() { setTimeout(function(){ console.debug('==createGattServer==timeout') },5000); - console.info('[bluetooth_js] gattServer beforeAll is--<-!!!->' + JSON.stringify(gattServer)); - console.info('[bluetooth_js] gattServer type beforeAll is--<-!!!->' + 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"); setTimeout(function(){ console.debug('==createGattClientDevice==timeout') },5000); - console.info('[bluetooth_js] GattClientDevice beforeAll is -> ' + JSON.stringify(gattClient)); - console.info('[bluetooth_js] GattClientDevice type beforeAll is--<-!!!->' + gattClient); + console.info('[bluetooth_js] GattClientDevice beforeAll is:' + JSON.stringify(gattClient)); + console.info('[bluetooth_js] GattClientDevice type beforeAll is:' + gattClient); }) beforeEach(function () { console.info('beforeEach called') @@ -57,19 +82,31 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetooth_classic_enable_bluetooth', 0, async function (done) { - console.info('bluetooth enable start'); - console.info('bluetooth enable register'); + it('bluetooth_classic_enable_bluetooth_001', 0, async function (done) { + console.info('[bluetooth_js] enable start'); + console.info('[bluetooth_js] enable register'); await bluetooth.on("stateChange", onReceiveEvent); function onReceiveEvent(data) { - console.info('[bluetooth_js] enable data = '+ JSON.stringify(data)) - console.info('[bluetooth_js] state on :' + JSON.stringify(bluetooth.BluetoothState.STATE_ON)); + console.info('[bluetooth_js] enable data = '+ JSON.stringify(data)); if (data == bluetooth.BluetoothState.STATE_ON) { console.info('enable bluetooth'); - done() + done(); } } + 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] turning on :' + + JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_ON)); + console.info('[bluetooth_js] turning off :' + + JSON.stringify(bluetooth.BluetoothState.STATE_TURNING_OFF)); + console.info('[bluetooth_js] ble turning on :' + + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_ON)); + console.info('[bluetooth_js] ble on:' + + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_ON)); + console.info('[bluetooth_js] ble turning off :' + + JSON.stringify(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF)); await bluetooth.enableBluetooth(); + expect(enable).assertEqual(true); console.info('bluetooth enable done'); }) @@ -83,13 +120,13 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_get_state', 0, async function (done) { - console.info('get bluetooth state start'); + console.info('[bluetooth_js] get state start'); var state = bluetooth.getState(); console.info('get bluetooth state end'); console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state)); expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON); done(); - + await(3000); }) /** @@ -102,13 +139,64 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_set_local_name', 0, async function (done) { - console.info('set localname start'); - var enable = bluetooth.setLocalName('bluetooth_test'); - console.info('set localname end'); - console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(enable)); - expect(enable).assertEqual(true); + console.info('[bluetooth_js] set localname start'); + var name = bluetooth.setLocalName('bluetooth_test'); + console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name)); + expect(name).assertEqual(true); + 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'); + }) + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_PAIR_0001 + * @tc.name testStartpair + * @tc.desc Test Startpair api by promise. + * @tc.author quanli 00313334 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_Startpair_test_001', 0, function () { + console.info('[bluetooth_js] Startpair test start ...'); + var result = bluetooth.pairDevice("32:15:00:19:42:F6"); + console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result)); + expect(result).assertFalse(); }) /** @@ -121,13 +209,13 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_get_local_name', 0, async function (done) { - console.info('get localName start'); + console.info('[bluetooth_js] get localName start'); var localName = bluetooth.getLocalName(); - console.info('get localName end'); console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName)); expect(localName).assertEqual('bluetooth_test'); + console.info('[bluetooth_js] get localName end'); done(); - + await(3000); }) /** @@ -140,13 +228,18 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_set_scan_mode', 0, async function (done) { - console.info('set bluetooth scan mode start'); + console.info('[bluetooth_js] set scan mode start'); var result = bluetooth.setBluetoothScanMode(1,10000); - console.info('set bluetooth scan mode end'); - 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 :' + + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER)); + console.info('[bluetooth_js] balanced :' + + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED)); + console.info('[bluetooth_js] low latency:' + + JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY)); expect(result).assertEqual(true); done(); - + await(3000); }) /** @@ -159,17 +252,28 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_get_scan_mode', 0, async function (done) { - console.info('get bluetooth scan mode start'); + console.info('[bluetooth_js] get scan mode start'); var result = bluetooth.setBluetoothScanMode(1,10000); - console.info('set bluetooth scan mode end'); - console.info('[bluetooth_js] set bluetooth scan mode result1 = ' + JSON.stringify(result)); + + console.info('[bluetooth_js] get scan mode result1 = ' + JSON.stringify(result)); expect(result).assertEqual(true); var scanMode = bluetooth.getBluetoothScanMode(); - console.info('get bluetooth scan mode end'); - console.info('[bluetooth_js] get bluetooth scan mode result2 = ' + JSON.stringify(scanMode)); + console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode)); expect(scanMode).assertEqual(1); + console.info('[bluetooth_js] mode1:' + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_NONE)); + console.info('[bluetooth_js] mode2:' + + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE)); + console.info('[bluetooth_js] mode3:' + + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE)); + console.info('[bluetooth_js] mode4:' + + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE)); + console.info('[bluetooth_js] mode5:' + + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE)); + console.info('[bluetooth_js] mode6:' + + JSON.stringify(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE)); + console.info('[bluetooth_js] get scan mode end'); done(); - + await(3000); }) /** @@ -182,13 +286,21 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_get_connection', 0, async function (done) { - console.info('get bt connection state start'); + console.info('[bluetooth_js] get connection state start'); var connState = bluetooth.getBtConnectionState(); - console.info('get bt connection state end'); console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState)); expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED); + console.info('[bluetooth_js] pr1:' + + JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTED)); + console.info('[bluetooth_js] pr2:' + + JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTING)); + console.info('[bluetooth_js] pr3:' + + JSON.stringify(bluetooth.ProfileConnectionState.STATE_CONNECTED)); + console.info('[bluetooth_js] pr4:' + + JSON.stringify(bluetooth.ProfileConnectionState.STATE_DISCONNECTING)); + console.info('[bluetooth_js] get connection end'); done(); - + await(3000); }) /** @@ -201,18 +313,19 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_start_discovery', 0, async function (done) { - console.info('start bluetooth discovery start'); + console.info('[bluetooth_js] discovery start'); await bluetooth.on("bluetoothDeviceFind", onReceiveEvent) - console.info('bluetooth bluetoothDeviceFind register'); + console.info('[bluetooth_js] DeviceFind register'); function onReceiveEvent(data) { - console.info('[bluetooth_js] bluetooth discovery bluetoothDeviceFind '+ JSON.stringify(data)); + console.info('[bluetooth_js] start discovery bluetoothDeviceFind '+ JSON.stringify(data)) console.info("[bluetooth_js] bluetooth discovery length -> " + data.length); expect(data.length).assertLarger(0); - done() + done(); } await bluetooth.startBluetoothDiscovery(); - console.info('start bluetooth discovery done'); - + console.info('[bluetooth_js] discovery end'); + done(); + await(3000); }) /** @@ -225,16 +338,17 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_stop_discovery', 0, async function (done) { - console.info('stop bluetooth discovery start'); + console.info('[bluetooth_js] stop discovery start'); bluetooth.stopBluetoothDiscovery(); await bluetooth.off("bluetoothDeviceFind", onReceiveEvent) function onReceiveEvent(data) { console.info('[bluetooth_js] stop bluetooth discovery result = '+ JSON.stringify(data)); expect(data).assertNull(); - done() + done(); } - console.info('stop bluetooth discovery done'); - + console.info('[bluetooth_js] stop discovery end'); + done(); + await(3000); }) /** @@ -247,49 +361,16 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_get_paired_devices', 0, async function (done) { - console.info('get paired devices start'); + console.info('[bluetooth_js] get paired devices start'); var devices = bluetooth.getPairedDevices(); - console.info('[bluetooth_js] get paired devices result = ' + JSON.stringify(devices)); - done(); - console.info("[bluetooth_js] getConnectedDevices length -> " + devices.length); + console.info('[bluetooth_js] get paired devices result:' + JSON.stringify(devices)); + console.info("[bluetooth_js] getConnectedDevices length:" + devices.length); expect(devices.length).assertEqual(0); - console.info('get paired devices end'); - + console.info('[bluetooth_js] get paired devices 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('pair device start'); - await bluetooth.on("pinRequired", onReceiveEvent) - await bluetooth.on("bondStateChange", onReceivePairStateEvent) - var device; - function onReceiveEvent(data) { - console.info('pin required = '+ JSON.stringify(data)) - bluetooth.setDevicePariringConfirmation(data,false); - } - - function onReceivePairStateEvent(data) { - console.info('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'); - },500); - console.info('pair device end'); - }) /** * @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_GET_CONNECTED_BLEDEVICES_0001 @@ -300,12 +381,13 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetooth_getConnectedBLEDevices_test_001', 0, function () { - console.info('bluetooth getConnectedBLEDevices test start ...'); + 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); + console.info("[bluetooth_js] getConnectedBLEDevices:" + JSON.stringify(result)); + console.info("[bluetooth_js] getConnectedBLEDevices length:" + result.length); expect(result.length).assertEqual(0); + done(); }) /** @@ -318,15 +400,15 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetoothble_stopBLEScan_test_001', 0, function () { - console.info('bluetoothble onStopBLEScan test start ...'); + console.info('[bluetooth_js] StopBLEScan test start ...'); try{ var result = bluetooth.BLE.stopBLEScan(); - console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result)); + console.info("[bluetooth_js] StopBLEScan:" + JSON.stringify(result)); expect(result).assertNull(); - console.info("[bluetooth_js] onStopBLEScan ."); + console.info("[bluetooth_js] StopBLEScan end"); }catch(error){ expect(null).assertFail(); - console.info("[bluetooth_js] onStopBLEScan error" + JSON.stringify(error)); + console.info("[bluetooth_js] StopBLEScan err:" + JSON.stringify(error)); } }) @@ -340,59 +422,31 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_createGattServer_test_001', 0, function () { - console.info('bluetooth createGattServer test start ...'); + console.info('[bluetooth_js] createGattServer test start ...'); var result = bluetooth.BLE.createGattServer(); - console.info("[bluetooth_js] createGattServer -> " + JSON.stringify(result)); + console.info("[bluetooth_js] createGattServer:" + JSON.stringify(result)); var resultLength = Object.keys(result).length; - console.info("[bluetooth_js] createGattServer length -> " + resultLength); + console.info("[bluetooth_js] createGattServer length:" + resultLength); expect(resultLength).assertEqual(1); }) /** - * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_BLESCAN_WITH_FILTER_0001 - * @tc.name testClassicStartBLEScan - * @tc.desc Test ClassicStartBLEScan api. - * @tc.author quanli 00313334 + * @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_ble_start_scan_with_filter', 0, async function (done) { - console.info('BLE scan start'); - await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) - function onReceiveEvent(data) { - console.info('[bluetooth_js] BLE scan device find result1'+ JSON.stringify(data)); - expect(data.length).assertLarger(0); - done() - } - let ScanFilter = [{ - deviceId:"789", - name:"test", - serviceUuid:"1234564" - }]; - for (var key in ScanFilter ){ - console.info('[bluetooth_js] ScanFilter:'+ ScanFilter[key]); - } - - let ScanOptions = { - interval: 500, - dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER, - matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, - }; - for (var key in ScanOptions ){ - console.info('[bluetooth_js] ScanOptions:'+ ScanOptions[key]); - } - bluetooth.BLE.startBLEScan(ScanFilter,ScanOptions); - - console.info('[bluetooth_js] BLEDevFind callback data ->'); - console.info('[bluetooth_js] BLEDevFind deviceId:' + data.deviceId); - console.info('[bluetooth_js] BLEDevFind rssi:' + data.rssi); - console.info('[bluetooth_js] BLEDevFind data: ' + data.data); - - console.info('[bluetooth_js] BLE scan end'); - setTimeout(function(){ - console.debug('========bluetooth_ble_start_scan=======timeout') - },1000); + 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); }) /** @@ -405,11 +459,14 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_start_scan_no_filter', 0, async function (done) { - console.info('BLE scan start'); + console.info('[bluetooth_js] BLE scan start'); await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) function onReceiveEvent(data) { - console.info('[bluetooth_js] BLE scan device find result2 = '+ JSON.stringify(data)); + console.info('[bluetooth_js] BLE scan device find result2 = '+ JSON.stringify(data)) expect(data.length).assertLarger(0); + console.info('[bluetooth_js] BLEDevFind deviceId:' + data.deviceId); + console.info('[bluetooth_js] BLEDevFind rssi:' + data.rssi); + console.info('[bluetooth_js] BLEDevFind data: ' + data.data); done() } bluetooth.BLE.startBLEScan( @@ -420,10 +477,9 @@ describe('bluetoothhostTest', function() { matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, } ); - console.info('BLE scan end'); - setTimeout(function(){ - console.debug('========bluetooth_ble_start_scan_no_filter=======timeout') - },1000); + console.info('[bluetooth_js] BLE scan2 end'); + done(); + await(3000); }) /** @@ -436,18 +492,19 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_start_scan_without_param', 0, async function (done) { - console.info('BLE scan start without scan options'); + console.info('[bluetooth_js] BLE scan start without scan options start'); await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) function onReceiveEvent(data) { console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data)) expect(data.length).assertLarger(0); bluetooth.BLE.stopBLEScan(); - done() + done(); } bluetooth.BLE.startBLEScan([{}]); console.info('[bluetooth_js] BLE scan start end'); + done(); setTimeout(function(){ - console.debug('========bluetooth_ble_start_scan_without_param=======timeout') + console.debug('========bluetooth_ble_stop_scan=======timeout') },1000); }) @@ -461,16 +518,16 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_stop_scan', 0, async function (done) { - console.info('BLE stop scan start'); + console.info('[bluetooth_js] BLE stop scan start'); await bluetooth.off("BLEDeviceFind", onReceiveEvent) function onReceiveEvent(data) { - console.info('[bluetooth_js] BLE scan device find result4 = '+ JSON.stringify(data)) + console.info('[bluetooth_js] BLE scan device find result4 ='+ JSON.stringify(data)) } var result = bluetooth.BLE.stopBLEScan(); console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result)); expect(result).assertNull(); console.info('[bluetooth_js] BLE stop scan end'); - done() + done(); setTimeout(function(){ console.debug('========bluetooth_ble_stop_scan=======timeout') },1000); @@ -486,7 +543,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_start_advertising', 0, async function (done) { - console.info('BLE advertising start'); + console.info('[bluetooth_js] BLE advertising start'); var manufactureValueBuffer = new Uint8Array(4); manufactureValueBuffer[0] = 1; manufactureValueBuffer[1] = 2; @@ -530,10 +587,12 @@ describe('bluetoothhostTest', function() { serviceValue:serviceValueBuffer.buffer }], }); - done() + console.info('[bluetooth_js] BLE start advertising end'); + done(); setTimeout(function(){ - console.debug('========bluetooth_ble_start_advertising=======timeout') - },1000); + console.debug('====bluetooth_ble_start_advertising====timeout') + },5000); + await(3000); }) /** @@ -546,14 +605,15 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_stop_advertising', 0, async function (done) { - console.info('BLE stop advertising start'); - var gattServer = bluetooth.BLE.createGattServer() - gattServer.stopAdvertising() - console.info('BLE stop advertising end'); - done() + console.info('[bluetooth_js] BLE stop advertising start'); + var gattServer = bluetooth.BLE.createGattServer(); + gattServer.stopAdvertising(); + console.info('[bluetooth_js] BLE stop advertising end'); + done(); setTimeout(function(){ - console.debug('========bluetooth_ble_stop_advertising=======timeout') + console.debug('====bluetooth_ble_stop_advertising====timeout') },1000); + await(3000); }) /** @@ -565,17 +625,17 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetooth_ble_get_device_name_callback', 0, async function (done) { - console.info('BLE get device name callback start'); - var gattClient = gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); + 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 err ' + JSON.stringify(err)) - console.info('[bluetooth_js] device name' + JSON.stringify(data)) + console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err)); + console.info('[bluetooth_js] device name1' + JSON.stringify(data)); done(); }) - console.info('BLE get device name callback end') + console.info('[bluetooth_js] get device name callback end'); setTimeout(function(){ - console.debug('========bluetooth_ble_get_device_name_callback=======timeout') + console.debug('=====bluetooth_ble_get_device_name_callback1====timeout') },1000); }) @@ -602,7 +662,7 @@ describe('bluetoothhostTest', function() { }) /** - * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_RSSI_VALUE_CALLBACK_0001 + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_RSSI_VALUE_CALLBACK * @tc.name testGetRssiValue * @tc.desc Test GetRssiValue api by callback. * @tc.author quanli 00313334 @@ -611,14 +671,15 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_read_rssi', 0, async function (done) { - console.info('BLE get rssi start'); - var gattClient = gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); - var rssi = gattClient.getRssiValue((err, data)=> { - console.info('[bluetooth_js] rssi err ' + JSON.stringify(err)) - console.info('[bluetooth_js] rssi value' + JSON.stringify(data)) + console.info('[bluetooth_js] BLE get rssi1 start'); + var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); + await gattClient.getRssiValue((err, data)=> { + console.info('[bluetooth_js] rssi err:' + JSON.stringify(err)); + console.info('[bluetooth_js] rssi value:' + JSON.stringify(data)); + expect(data).assertNull(); done(); - }) - console.info('BLE read rssi end'); + }); + console.info('[bluetooth_js] BLE read rssi1 end'); setTimeout(function(){ console.debug('========bluetooth_ble_read_rssi=======timeout') },1000); @@ -634,19 +695,29 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_ble_read_rssi_promise', 0, async function (done) { - console.info('BLE get rssi start'); - var gattClient = gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); - var rssi = gattClient.getRssiValue().then((data) => { - console.info('rssi' + JSON.stringify(data)) + console.info('[bluetooth_js] BLE get rssi start'); + var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); + await gattClient.getRssiValue().then((data) => { + if (data != null) { + console.info('[bluetooth_js] rssi' + JSON.stringify(data)); + done(); + expect(true).assertEqual(true); + } else { + console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(data)); + var rssiLength = Object.keys(data).length; + console.info("[bluetooth_js] ble rssi_length -> " + rssiLength); + expect(rssiLength).assertEqual(0); + done(); + } + }).catch(err => { + console.error(`bluetooth getDeviceName has error: ${err}`); + expect(true).assertEqual(true); done(); - }) - console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(rssi)); - var rssiLength = Object.keys(rssi).length; - console.info("[bluetooth_js] ble rssi_length -> " + rssiLength); - expect(rssiLength).assertEqual(0); + }); setTimeout(function(){ - console.debug('========bluetooth_ble_stop_advertising=======timeout') + console.debug('====bluetooth_ble_stop_advertising====timeout') },1000); + await(3000); }) /** @@ -659,27 +730,32 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_classic_disable_bluetooth', 0, async function (done) { - console.info('disable bluetooth start'); + console.info('[bluetooth_js] disable bluetooth start'); bluetooth.off("pinRequired", onPinRequiredReceiveEvent) function onPinRequiredReceiveEvent(data) { - console.info('[bluetooth_js] pin required = '+ JSON.stringify(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 = '+ 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() + 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('disable bluetooth end'); + console.info('[bluetooth_js] disable bluetooth end'); + await(3000); }) /** @@ -692,17 +768,15 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_connect', 0, function (done) { - console.info('bluetooth connect start'); + console.info('[bluetooth_js] gatt connect start'); gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); - let ret = gattClient.connect(); - console.info('[bluetooth_js] bluetooth connect ret : ' + ret); + console.info('[bluetooth_js] gatt connect ret : ' + ret); expect(ret).assertEqual(false); - console.info('bluetooth connect end'); + console.info('[bluetooth_js] gatt connect end'); done(); }) - /** * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001 * @tc.name testDisConnect @@ -713,33 +787,56 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_disconnect', 0, function (done) { - console.info('bluetooth disconnect start'); - + console.info('[bluetooth_js] gatt disconnect start'); let ret = gattClient.disconnect(); - console.info('[bluetooth_js] bluetooth disconnect ret : ' + ret); + console.info('[bluetooth_js] gatt disconnect ret:' + ret); expect(ret).assertEqual(false); - console.info('bluetooth disconnect end'); + console.info('[bluetooth_js] gatt disconnect end'); done(); }) /** - * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_0001 + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_CALLBACK_0001 * @tc.name testGetServices - * @tc.desc Test GetServices api by promise. + * @tc.desc Test GetServices api by callback. * @tc.author quanli 00313334 * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 */ - it('bluetooth_gatt_getServices', 0, async function (done) { - console.info('bluetooth getServices start'); + it('bluetooth_ble_get_services_callback_001', 0, async function (done) { + console.info('[bluetooth_js] getServices callback start'); + var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); + var services = gattClient.getServices((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] getServices callback end'); + setTimeout(function(){ + console.debug('=====bluetooth_ble_getServices_callback====timeout') + },1000); + }) - gattClient.getServices().then((object) => { + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_PROMISE_0001 + * @tc.name testGetServices + * @tc.desc Test GetServices api by promise. + * @tc.author quanli 00313334 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_gatt_getServices_promise', 0, async function (done) { + console.info('[bluetooth_js] getServices promise start'); + var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); + await gattClient.getServices().then((object) => { if (object != null) { - console.info('[bluetooth_js] bluetooth getServices is null'); + console.info('[bluetooth_js] getServices is null'); expect(true).assertEqual(true); } else { - console.info('[bluetooth_js] bluetooth getServices is successfully'); + console.info('[bluetooth_js] getServices is successfully'); + console.info('[bluetooth_js] getServices data:' + JSON.stringify(object)); expect(null).assertFail(); } done(); @@ -748,6 +845,7 @@ describe('bluetoothhostTest', function() { expect(true).assertEqual(true); done(); }); + await(3000); }) /** @@ -760,7 +858,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_readCharacteristicValue', 0, async function (done) { - console.info('bluetooth readCharacteristicValue start'); + console.info('[bluetooth_js] readCharacteristicValue start'); let descriptors = []; let arrayBuffer = new ArrayBuffer(8); @@ -785,7 +883,8 @@ describe('bluetoothhostTest', function() { console.info('[bluetooth_js] bluetooth BLECharacteristic is null'); expect(true).assertEqual(true); } else { - console.info('[bluetooth_js] bluetooth BLECharacteristic uuid is successfully'); + console.info('[bluetooth_js] BLECharacteristic uuid is successfully'); + console.info('[bluetooth_js] readCharacValue data:' + JSON.stringify(data)); expect(null).assertFail(); } done(); @@ -794,6 +893,7 @@ describe('bluetoothhostTest', function() { expect(true).assertEqual(true); done(); }); + await(3000); }) /** @@ -806,22 +906,19 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_readDescriptorValue', 0, function (done) { - console.info('bluetooth readDescriptorValue start'); - + console.info('[bluetooth_js] readDescriptorValue start'); let arrayBuffer = new ArrayBuffer(8); let desValue = new Uint8Array(arrayBuffer); desValue[0] = 11; - let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; - - gattClient.readDescriptorValue(descriptor).then((object) => { if (object != null) { - console.info('bluetooth BLEDescriptor is null'); + console.info('[bluetooth_js] BLEDescriptor is null'); expect(true).assertEqual(true); } else { - console.info('bluetooth BLEDescriptor uuid is successfully'); + console.info('[bluetooth_js] BLEDescriptor uuid is successfully'); + console.info('[bluetooth_js] BLEDescriptor data:' + JSON.stringify(object)); expect(null).assertFail(); } done(); @@ -842,17 +939,14 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_writeCharacteristicValue', 0, function (done) { - console.info('bluetooth writeCharacteristicValue start'); - + console.info('[bluetooth_js] writeCharacteristicValue start'); let descriptors = []; let arrayBuffer = new ArrayBuffer(8); let desValue = new Uint8Array(arrayBuffer); desValue[0] = 11; - let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; - let arrayBufferCCC = new ArrayBuffer(8); let cccValue = new Uint8Array(arrayBufferCCC); cccValue[0] = 32; @@ -866,8 +960,7 @@ describe('bluetoothhostTest', function() { let ret = gattClient.writeCharacteristicValue(characteristic); console.info('[bluetooth_js] bluetooth writeCharacteristicValue ret : ' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth writeCharacteristicValue end'); + console.info('[bluetooth_js] writeCharacteristicValue end'); done(); }) @@ -881,21 +974,18 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_writeDescriptorValue', 0, function (done) { - console.info('bluetooth writeDescriptorValue start'); - + console.info('[bluetooth_js] writeDescriptorValue start'); let arrayBuffer = new ArrayBuffer(8); let desValue = new Uint8Array(arrayBuffer); desValue[0] = 11; - let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; - let ret = gattClient.writeDescriptorValue(descriptor); console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth writeDescriptorValue end'); + console.info('[bluetooth_js] writeDescriptorValue end'); done(); + }) /** @@ -908,13 +998,11 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_setBLEMtuSize', 0, function (done) { - console.info('bluetooth setBLEMtuSize start'); - + console.info('[bluetooth_js] setBLEMtuSize start'); let ret = gattClient.setBLEMtuSize(128); console.info('[bluetooth_js] bluetooth setBLEMtuSize ret : ' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth setBLEMtuSize end'); + console.info('[bluetooth_js] setBLEMtuSize end'); done(); }) @@ -928,39 +1016,35 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_setNotifyCharacteristicChanged', 0, function (done) { - console.info('bluetooth setNotifyCharacteristicChanged start'); - + console.info('[bluetooth_js] setNotifyCharacteristicChanged start'); let descriptors = []; let arrayBuffer = new ArrayBuffer(8); let desValue = new Uint8Array(arrayBuffer); desValue[0] = 11; - let arrayBufferNotify = new ArrayBuffer(8); let descNotifyValue = new Uint8Array(arrayBufferNotify); descNotifyValue[0] = 1 - let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', + descriptorValue: arrayBuffer}; let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBufferNotify}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', + descriptorValue: arrayBufferNotify}; descriptors[0] = descriptor; descriptors[1] = descriptorNotify; - let arrayBufferCCC = new ArrayBuffer(8); let cccValue = new Uint8Array(arrayBufferCCC); cccValue[0] = 1; let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferCCC, descriptors:descriptors}; - let ret = gattClient.setNotifyCharacteristicChanged(characteristic, false); - console.info('[bluetooth_js] bluetooth setNotifyCharacteristicChanged ret : ' + ret); + console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth setNotifyCharacteristicChanged end'); + console.info('[bluetooth_js] setNotifyCharacteristicChanged end'); done(); }) - + /** * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_ADD_SERVICE_0001 * @tc.name testAddService @@ -971,7 +1055,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_addService', 0, function (done) { - console.info('bluetooth addService start'); + console.info('[bluetooth_js] addService start'); gattServer = bluetooth.BLE.createGattServer(); let descriptors = []; @@ -1003,8 +1087,9 @@ describe('bluetoothhostTest', function() { console.info('[bluetooth_js] bluetooth addService ret : ' + ret); expect(ret).assertEqual(false); - console.info('bluetooth addService end'); + console.info('[bluetooth_js] addService end'); done(); + }) /** @@ -1017,14 +1102,12 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_removeService', 0, function (done) { - console.info('bluetooth removeService start'); + console.info('[bluetooth_js] removeService start'); gattServer = bluetooth.BLE.createGattServer(); - let ret = gattServer.removeService('00001810-0000-1000-8000-008000000000'); - console.info('[bluetooth_js] bluetooth removeService ret : ' + ret); + console.info('[bluetooth_js] removeService ret : ' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth removeService end'); + console.info('[bluetooth_js] removeService end'); done(); }) @@ -1038,17 +1121,14 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_notifyCharacteristicChanged', 0, function (done) { - console.info('bluetooth notifyCharacteristicChanged start'); - + console.info('[bluetooth_js] notifyCharacteristicChanged start'); let descriptors = []; let arrayBufferDesc = new ArrayBuffer(8); let desValue = new Uint8Array(arrayBufferDesc); desValue[0] = 11; - let arrayBufferNotifyDesc = new ArrayBuffer(8); let descNotifyValue = new Uint8Array(arrayBufferNotifyDesc); descNotifyValue[0] = 1 - let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: desValue}; @@ -1069,10 +1149,9 @@ describe('bluetoothhostTest', function() { console.info('[bluetooth_js] notifyCharChanged:' + characteristic[key]); } let ret = gattServer.notifyCharacteristicChanged('00:00:00:00:00:00', characteristic); - console.info('[bluetooth_js] bluetooth notifyCharacteristicChanged ret : ' + ret); + console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret); expect(ret).assertEqual(false); - - console.info('bluetooth notifyCharacteristicChanged end'); + console.info('[bluetooth_js] notifyCharacteristicChanged end'); done(); }) @@ -1086,22 +1165,21 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_gatt_sendResponse', 0, function (done) { - console.info('bluetooth sendResponse start'); - + console.info('[bluetooth_js] sendResponse start'); let arrayBuffer = new ArrayBuffer(8); let value = new Uint8Array(arrayBuffer); value[0] = 1; - let serverResponse = {deviceId: '00:00:00:00:00', transId: 1, status: 0, offset: 0, value: arrayBuffer}; for (var key in serverResponse ){ console.info('[bluetooth_js] serverResponse:'+ serverResponse[key]); } let ret = gattServer.sendResponse(serverResponse); - console.info('[bluetooth_js] bluetooth sendResponse ret : ' + ret); + console.info('[bluetooth_js] sendResponse ret : ' + ret); expect(ret).assertEqual(false); - console.info('bluetooth sendResponse end'); + console.info('[bluetooth_js] sendResponse end'); done(); + }) /** @@ -1114,26 +1192,27 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_spp_listen', 0, function (done) { - console.log("bluetooth: spp listen start"); + console.log("[bluetooth_js]: spp listen start"); let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', - secure: true, type: 0}; + secure: false, type: 0}; for (var key in sppOption ){ console.info('[bluetooth_js] sppListen:'+ sppOption[key]); } - bluetooth.sppListen('server1', sppOption, function(code, serverSocketNumber) { if (code.code == 0) { - console.info('bluetooth code is success'); - console.info('bluetooth code is: ' + code.code); + console.info('[bluetooth_js] code is success'); + console.info('[bluetooth_js] code is: ' + code.code); expect(true).assertEqual(true); done(); } else { - console.info('bluetooth code is failed'); - console.info('bluetooth code is: ' + code.code); + console.info('[bluetooth_js] code is failed'); + console.info('[bluetooth_js] code is: ' + code.code); expect(true).assertEqual(false); done(); } }); + console.log("[bluetooth_js] spp listen end"); + done(); }) /** @@ -1146,21 +1225,21 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_spp_Accept', 0, function (done) { - console.log("bluetooth: spp accept start"); - + console.log("[bluetooth_js] spp accept start"); bluetooth.sppAccept(-1, function(code, clientSocketNumber) { if (code.code == 0) { - console.info('bluetooth code is success'); - console.info('bluetooth code is: ' + code.code); + console.info('[bluetooth_js] code is success'); + console.info('[bluetooth_js] code is: ' + code.code); expect(true).assertEqual(true); } else { - console.info('bluetooth code is failed'); - console.info('bluetooth code is: ' + code.code); + console.info('[bluetooth_js] code is failed'); + console.info('[bluetooth_js] code is: ' + code.code); expect(true).assertEqual(false); } }); - console.log("bluetooth: spp accept end"); + console.log("[bluetooth_js] spp accept end"); done(); + }) /** @@ -1173,13 +1252,11 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_spp_closeServerSocket', 0, function (done) { - console.log("bluetooth: spp closeServerSocket start"); - + console.log("[bluetooth_js] spp closeServerSocket start"); let ret = bluetooth.sppCloseServerSocket(-1); - console.info('[bluetooth_js] bluetooth sppCloseServerSocket ret : ' + ret); expect(ret).assertEqual(false); - console.log("bluetooth: spp closeServerSocket end"); + console.log("[bluetooth_js] spp closeServerSocket end"); done(); }) @@ -1193,8 +1270,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_spp_connect', 0, function (done) { - console.info('bluetooth spp_connect start'); - + console.info('[bluetooth_js] spp_connect start'); let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: true, type: 0}; bluetooth.sppConnect(55, sppOption, function(code, clientSocketNumber) { @@ -1206,7 +1282,7 @@ describe('bluetoothhostTest', function() { expect(true).assertEqual(false); } }); - console.info('bluetooth spp_connect end'); + console.info('[bluetooth_js] spp_connect end'); done(); }) @@ -1220,17 +1296,16 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetooth_spp_write', 0, function (done) { - console.info('bluetooth spp write start'); - + console.info('[bluetooth_js] spp write start'); let arrayBuffer = new ArrayBuffer(8); let data = new Uint8Array(arrayBuffer); data[0] = 123; - let ret = bluetooth.sppWrite(-1, arrayBuffer); console.info('[bluetooth_js] bluetooth sppWrite ret : ' + ret); expect(ret).assertEqual(false); - console.info('bluetooth spp write end'); + console.info('[bluetooth_js] spp write end'); done(); + }) /** @@ -1243,13 +1318,13 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetoothble_CharacteristicReadOn_test_001', 0, function () { - console.info('bluetoothble onCharacteristicReadOn test start ...'); + console.info('[bluetooth_js] CharacteristicReadOn test start'); if (gattServer == null) { - console.info("[bluetooth_js] onBlePerManager: please click onCreateGattServer first!"); + console.info("[bluetooth_js] BlePerManager: please click CreateGattServer first!"); } gattServer.on('characteristicRead', (err, data) => { if (err) { - console.info("[bluetooth_js] charaRead callback error -> " + JSON.stringify(err)); + console.info("[bluetooth_js] charaRead callback err:" + JSON.stringify(err)); } else { console.info('[bluetooth_js] charRead callback data ->'); console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId); @@ -1272,29 +1347,6 @@ describe('bluetoothhostTest', function() { }); }) - /** - * @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_READ_OFF_0001 - * @tc.name testCharacteristicReadOff - * @tc.desc Test CharacteristicReadOff api . - * @tc.author zhangyujie zwx1079266 - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('bluetoothble_CharacteristicReadOff_test_001', 0, function () { - console.info('bluetoothble CharacteristicReadOff test start ...'); - if (gattServer == null) { - console.info("[bluetooth_js] CharacteristicReadOn: please click onCreateGattServer first!"); - } - console.info('gattServer is--<-!!!->' + JSON.stringify(gattServer)); - var result = gattServer.off(); - console.info("[bluetooth_js] CharacteristicReadOff -> " + JSON.stringify(result)); - var resultLength = Object.keys(result).length; - console.info("[bluetooth_js] CharacteristicReadOff length -> " + resultLength); - expect(resultLength).assertEqual(0); - console.info("[bluetooth_js] CharacteristicReadOff ."); - }) - /** * @tc.number SUB_COMMUNACATION_bluetoothble_DEVICE_JS_CHARAC_WRITE_ON_0001 * @tc.name testonCharacteristicwriteOn @@ -1305,13 +1357,13 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ it('bluetoothble_CharacteristicwriteOn_test_001', 0, function () { - console.info('bluetoothble CharacteristicwriteOn test start ...'); + console.info('[bluetooth_js] CharacteristicwriteOn test start ...'); if (gattServer == null) { - console.info("[bluetooth_js] CharacteristicwriteOn: please click onCreateGattServer first!"); + console.info("[bluetooth_js] Charwrite: please click CreateGattServer first!"); } gattServer.on('characteristicWrite', (err, data) => { if (err) { - console.info("[bluetooth_js] characteristicWrite callback error -> " + JSON.stringify(err)); + console.info("[bluetooth_js] characteristic callback error" + JSON.stringify(err)); } else { console.info('[bluetooth_js] characteristicWrite callback data ->'); console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId); @@ -1339,13 +1391,13 @@ describe('bluetoothhostTest', function() { "value": data.value, }; var result = gattServer.sendResponse(serverResponse); - console.info("[bluetooth_js] sendResponse -> " + JSON.stringify(result)); + console.info("[bluetooth_js] sendResponse:" + JSON.stringify(result)); expect(JSON.stringify(result)).assertContain("true"); - console.info("[bluetooth_js] characteristicWrite ."); + console.info("[bluetooth_js] characteristicWrite end"); } }); - }) + }) /** * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DESC_READ_ON_0001 @@ -1358,14 +1410,14 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_descriptorRead_On_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] descriptorReadOn test start ...'); if (gattServer == null) { - console.info("[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!"); + console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!"); } gattServer.on('descriptorRead', function (data) { console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data)); console.info("[bluetooth_js] DesRedon data:" + data); expect(true).assertEqual(data !=null); - console.info('[bluetooth_js] desRead callback data ->'); console.info('[bluetooth_js] DesRedReq deviceId:' + data.deviceId); console.info('[bluetooth_js] DesRedReq transId:' + data.transId); @@ -1375,7 +1427,6 @@ describe('bluetoothhostTest', function() { console.info('[bluetooth_js] DesRedReq serUuid:' + data.serviceUuid); }); await(3000); - }catch(e) { expect(null).assertFail(); } @@ -1393,8 +1444,9 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_descriptorRead_Off_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] descriptorReadOff test start ...'); if (gattServer == null) { - console.info("[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!"); + console.info("[bluetooth_js] onAddServiceHelper:click onCreateGattServer first!"); } gattServer.off('descriptorRead', function (data) { console.info("[bluetooth_js] descriptorRead_off json_data-> " + JSON.stringify(data)); @@ -1419,8 +1471,9 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_descriptorWrite_On_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] descriptorWriteOn test start ...'); if (gattServer == null) { - console.info("[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!"); + console.info("[bluetooth_js] onAddServiceHelper: click onCreateGattServer first!"); } gattServer.on('descriptorWrite', function (data) { console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data)); @@ -1456,6 +1509,7 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_descriptorWrite_Off_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] descriptorWriteOff test start ...'); if (gattServer == null) { console.info("[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!"); } @@ -1471,7 +1525,6 @@ describe('bluetoothhostTest', function() { done(); }) - /** * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CONNE_STATE_CHANGE_ON_0001 * @tc.name testConnectStateChangeOn @@ -1483,8 +1536,9 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_connectStateChange_On_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] ConnectStateChangeOn test start ...'); if (gattServer == null) { - console.info("[bluetooth_js] onAddServiceHelper: please click CreateGattServer first!"); + console.info("[bluetooth_js] onAddServiceHelper: click CreateGattServer first!"); } gattServer.on('connectStateChange', function (data) { console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data)); @@ -1513,6 +1567,7 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_connectStateChange_Off_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] ConnectStateChangeOff test start ...'); if (gattServer == null) { console.info("[bluetooth_js] onAddServiceHelper: please click onCreateGattServer first!"); } @@ -1539,11 +1594,12 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_BLECharacteristicChange_On_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...'); if (gattClient == null) { - console.info("[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!"); + console.info("[bluetooth_js] OnGattclientClose:click onCreateGattClientDevice first!"); } gattClient.on('BLECharacteristicChange', function (data) { - console.info("[bluetooth_js] BLECharacteristicChange_on json_data -> " + JSON.stringify(data)); + console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharacteristicChange_on data -> " + data); expect(true).assertEqual(data !=null); }); @@ -1565,12 +1621,13 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_BLECharacteristicChange_Off_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] BLECharacteristicChangeOff test start'); if (gattClient == null) { - console.info("[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!"); + console.info("[bluetooth_js] OnGattclientClose: CreateGattClientDevice first!"); } gattClient.off('BLECharacteristicChange', function (data) { - console.info("[bluetooth_js] BLECharacteristicChange_off json_data-> " + JSON.stringify(data)); - console.info("[bluetooth_js] BLECharacteristicChange_off data -> " + data); + console.info("[bluetooth_js] BLECharcChange_off json_data-> " + JSON.stringify(data)); + console.info("[bluetooth_js] BLECharcChange_off data -> " + data); expect(true).assertEqual(data !=null); }); await(3000); @@ -1591,16 +1648,17 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_BLEConnectionStateChange_On_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] BLEConnectionStateChangeOn test start'); if (gattClient == null) { - console.info("[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!"); + console.info("[bluetooth_js] GattclientClose:CreateGattClientDevice first!"); } gattClient.on('BLEConnectionStateChange', function (data) { - console.info("[bluetooth_js] BLEConnectionStateChange_on json_data -> " + JSON.stringify(data)); - console.info("[bluetooth_js] BLEConnectionStateChange_on data -> " + data); + console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data)); + console.info("[bluetooth_js] BLEConneStateChange_on data -> " + data); expect(true).assertEqual(data !=null); - console.info('[bluetooth_js] BLEConnectionStateChange deviceId : ' + data.deviceId); - console.info('[bluetooth_js] BLEConnectionStateChange state : ' + data.state); + console.info('[bluetooth_js] BLEConneStateChange deviceId : ' + data.deviceId); + console.info('[bluetooth_js] BLEConneStateChange state : ' + data.state); }); await(3000); }catch(e) { @@ -1620,18 +1678,19 @@ describe('bluetoothhostTest', function() { */ it('bluetooth_BLEConnectionStateChange_Off_test_001', 0, async function (done) { try { + console.info('[bluetooth_js] BLEConnectionStateChangeOff test start'); if (gattClient == null) { - console.info("[bluetooth_js] OnGattclientClose: please click onCreateGattClientDevice first!"); + console.info("[bluetooth_js] GattclientClose:click CreateGattClientDevice first!"); } gattClient.on('BLEConnectionStateChange', function (result) { - console.info("[bluetooth_js] BLEConnectionStateChange_on1 json_result -> " + JSON.stringify(result)); - console.info("[bluetooth_js] BLEConnectionStateChange_on1 result -> " + result); - expect(true).assertEqual(data !=null); + 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] BLEConnectionStateChange_off json_data-> " + JSON.stringify(data)); - console.info("[bluetooth_js] BLEConnectionStateChange_off data -> " + data); + console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data)); + console.info("[bluetooth_js] BLEConneStateChange_off data -> " + data); expect(true).assertEqual(data !=null); }); await(3000); @@ -1650,24 +1709,40 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetoothble_sppReadOn_test_001', 0, function () { - console.info('bluetoothble sppReadOn test start ...'); - function dataRead(dataBuffer) { - let data = new Uint8Array(dataBuffer); - console.log('bluetooth data is: ' + data[0]); + 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(); } + done(); + }) - bluetooth.on('sppRead', -1, (err, data) => { - if (err) { - console.info("[bluetooth_js] sppReadOn error -> " + JSON.stringify(err)); - } else { - console.info('[bluetooth_js] sppReadOn data ->'+ data); - console.info("[bluetooth_js] sppReadOn data-> " + JSON.stringify(data)); - expect(data).assertEqual(true); - console.info("[bluetooth_js] onsppRead."); - 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); }) /** @@ -1679,20 +1754,226 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetoothble_sppReadOff_test_001', 0, function () { - console.info('bluetoothble sppReadOff test start ...'); - bluetooth.off('sppRead', -1, (err, data) => { - if (err) { - console.info("[bluetooth_js] sppReadOff error -> " + JSON.stringify(err)); - } else { - console.info('[bluetooth_js] sppReadOff data ->'+ data); - console.info("[bluetooth_js] sppReadOff data-> " + JSON.stringify(data)); - expect(data).assertEqual(true); - console.info("[bluetooth_js] offsppRead."); - done(); - } - }); + 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.name testBlePeripheralManagerClose + * @tc.desc Test BlePeripheralManagerClose api . + * @tc.author zhangyujie zwx1079266 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetoothble_gattserver_close_test_001', 0, function () { + console.info('[bluetooth_js] GattserverClose test start ...'); + if (gattServer == null) { + console.info("[bluetooth_js] GattserverClose: please click CreateGattServer first!"); + } + console.info('[bluetooth_js] gattclose_server is:' + JSON.stringify(gattServer)); + try{ + var result = gattServer.close(); + console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result)); + expect(result).assertTrue(); + console.info("[bluetooth_js] GattserverClose end."); + }catch(error){ + console.info("[bluetooth_js] GattserverClose err:" + JSON.stringify(error)); + expect(null).assertFail(); + } + }) + + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CLIENT_CLOSE_0001 + * @tc.name testGattClientClose + * @tc.desc Test GattClientClose api . + * @tc.author zhangyujie zwx1079266 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_gattclient_close_test_001', 0, function () { + console.info('[bluetooth_js] GattclientClose test start ...'); + if (gattClient == null) { + console.info("[bluetooth_js] GattclientClose: please click CreateGattClientDevice first!"); + } + console.info('[bluetooth_js] gattClient is:' + JSON.stringify(gattServer)); + try{ + var result = gattClient.close(); + console.info("[bluetooth_js] GattclientClose result: " + result); + console.info("[bluetooth_js] GattclientClose json_result:" + JSON.stringify(result)); + expect(result).assertTrue(); + console.info("[bluetooth_js] GattclientClose end."); + }catch(error){ + console.info("[bluetooth_js] GattclientClose err:" + JSON.stringify(error)); + expect(null).assertFail(); + } }) + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_REMO_DEV_NAME_0001 + * @tc.name testGetRemoteDeviceName + * @tc.desc Test GetRemoteDeviceName api. + * @tc.author quanli 00313334 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_getRemoteDeviceName_test', 0, function (done) { + console.info('[bluetooth_js] getRemoteDeviceName start'); + let ret = bluetooth.getRemoteDeviceName("00:00:00:00:00:00"); + console.info('[bluetooth_js] getRemoteDeviceName ret : ' + ret); + console.info('[bluetooth_js] getRemoteDeviceName ret2 : ' + JSON.stringify(ret)); + expect(ret.length).assertEqual(0); + console.info('[bluetooth_js] getRemoteDeviceName end.'); + done(); + }) + + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_REMO_DEV_CLASS_0001 + * @tc.name testGetRemoteDeviceClass + * @tc.desc Test GetRemoteDeviceClass api. + * @tc.author quanli 00313334 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_getRemoteDeviceClass_test', 0, function (done) { + console.info('[bluetooth_js] getRemoteDeviceClass start'); + var MajorMinorClass = { + COMPUTER_UNCATEGORIZED : 0x0100, + COMPUTER_DESKTOP : 0x0104, + COMPUTER_SERVER : 0x0108, + COMPUTER_LAPTOP : 0x010C, + COMPUTER_HANDHELD_PC_PDA : 0x0110, + COMPUTER_PALM_SIZE_PC_PDA : 0x0114, + COMPUTER_WEARABLE : 0x0118, + COMPUTER_TABLET : 0x011C, + PHONE_UNCATEGORIZED : 0x0200, + PHONE_CELLULAR : 0x0204, + PHONE_CORDLESS : 0x0208, + PHONE_SMART : 0x020C, + PHONE_MODEM_OR_GATEWAY : 0x0210, + PHONE_ISDN : 0x0214, + NETWORK_FULLY_AVAILABLE : 0x0300, + NETWORK_1_TO_17_UTILIZED : 0x0320, + NETWORK_17_TO_33_UTILIZED : 0x0340, + NETWORK_33_TO_50_UTILIZED : 0x0360, + NETWORK_60_TO_67_UTILIZED : 0x0380, + NETWORK_67_TO_83_UTILIZED : 0x03A0, + NETWORK_83_TO_99_UTILIZED : 0x03C0, + NETWORK_NO_SERVICE : 0x03E0, + AUDIO_VIDEO_UNCATEGORIZED : 0x0400, + AUDIO_VIDEO_WEARABLE_HEADSET : 0x0404, + AUDIO_VIDEO_HANDSFREE : 0x0408, + AUDIO_VIDEO_MICROPHONE : 0x0410, + AUDIO_VIDEO_LOUDSPEAKER : 0x0414, + AUDIO_VIDEO_HEADPHONES : 0x0418, + AUDIO_VIDEO_PORTABLE_AUDIO : 0x041C, + AUDIO_VIDEO_CAR_AUDIO : 0x0420, + AUDIO_VIDEO_SET_TOP_BOX : 0x0424, + AUDIO_VIDEO_HIFI_AUDIO : 0x0428, + AUDIO_VIDEO_VCR : 0x042C, + AUDIO_VIDEO_VIDEO_CAMERA : 0x0430, + AUDIO_VIDEO_CAMCORDER : 0x0434, + AUDIO_VIDEO_VIDEO_MONITOR : 0x0438, + AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER : 0x043C, + AUDIO_VIDEO_VIDEO_CONFERENCING : 0x0440, + AUDIO_VIDEO_VIDEO_GAMING_TOY : 0x0448, + PERIPHERAL_NON_KEYBOARD_NON_POINTING : 0x0500, + PERIPHERAL_KEYBOARD : 0x0540, + PERIPHERAL_POINTING_DEVICE : 0x0580, + PERIPHERAL_KEYBOARD_POINTING : 0x05C0, + PERIPHERAL_UNCATEGORIZED : 0x0500, + PERIPHERAL_JOYSTICK : 0x0504, + PERIPHERAL_GAMEPAD : 0x0508, + PERIPHERAL_REMOTE_CONTROL : 0x05C0, + PERIPHERAL_SENSING_DEVICE : 0x0510, + PERIPHERAL_DIGITIZER_TABLET : 0x0514, + PERIPHERAL_CARD_READER : 0x0518, + PERIPHERAL_DIGITAL_PEN : 0x051C, + PERIPHERAL_SCANNER_RFID : 0x0520, + PERIPHERAL_GESTURAL_INPUT : 0x0522, + + IMAGING_UNCATEGORIZED : 0x0600, + IMAGING_DISPLAY : 0x0610, + IMAGING_CAMERA : 0x0620, + IMAGING_SCANNER : 0x0640, + IMAGING_PRINTER : 0x0680, + + WEARABLE_UNCATEGORIZED : 0x0700, + WEARABLE_WRIST_WATCH : 0x0704, + WEARABLE_PAGER : 0x0708, + WEARABLE_JACKET : 0x070C, + WEARABLE_HELMET : 0x0710, + WEARABLE_GLASSES : 0x0714, + + TOY_UNCATEGORIZED : 0x0800, + TOY_ROBOT : 0x0804, + TOY_VEHICLE : 0x0808, + TOY_DOLL_ACTION_FIGURE : 0x080C, + TOY_CONTROLLER : 0x0810, + TOY_GAME : 0x0814, + + HEALTH_UNCATEGORIZED : 0x0900, + HEALTH_BLOOD_PRESSURE : 0x0904, + HEALTH_THERMOMETER : 0x0908, + HEALTH_WEIGHING : 0x090C, + HEALTH_GLUCOSE : 0x0910, + HEALTH_PULSE_OXIMETER : 0x0914, + HEALTH_PULSE_RATE : 0x0918, + HEALTH_DATA_DISPLAY : 0x091C, + HEALTH_STEP_COUNTER : 0x0920, + HEALTH_BODY_COMPOSITION_ANALYZER : 0x0924, + HEALTH_PEAK_FLOW_MOITOR : 0x0928, + HEALTH_MEDICATION_MONITOR : 0x092C, + HEALTH_KNEE_PROSTHESIS : 0x0930, + HEALTH_ANKLE_PROSTHESIS : 0x0934, + HEALTH_GENERIC_HEALTH_MANAGER : 0x0938, + HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C, + HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C + }; + + let ret = bluetooth.getRemoteDeviceClass("00:00:00:00:00:00"); + console.info('[bluetooth_js] getRemoteDeviceClass ret : ' + ret); + console.info('[bluetooth_js] getRemoteDeviceClass ret2 : ' + JSON.stringify(ret)); + expect(ret.majorClass).assertEqual(0); + console.info('[bluetooth_js] majorClass : ' + ret.majorClass); + console.info('[bluetooth_js] majorMinorClass : ' + ret.majorMinorClass); + console.info('[bluetooth_js] classOfDevice : ' + ret.classOfDevice); + console.info('[bluetooth_js] getRemoteDeviceClass end.'); + done(); + }) + + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_CANCEL_PAIRED_DEV_0001 + * @tc.name testCancelPairedDevice + * @tc.desc Test CancelPairedDevice api. + * @tc.author quanli 00313334 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('bluetooth_cancelPairedDevice_test', 0, function (done) { + console.info('[bluetooth_js] cancelPairedDevice start'); + let ret = bluetooth.cancelPairedDevice("00:00:00:00:00:00"); + console.info('[bluetooth_js] cancelPairedDevice ret : ' + ret); + console.info('[bluetooth_js] cancelPairedDevice ret2 : ' + JSON.stringify(ret)); + expect(ret).assertEqual(false); + console.info('bluetooth cancelPairedDevice end.'); + done(); + }) }) diff --git a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js index 6047a4a183bff5fcc1c40381f607a6e56a614955..4339d87443c4146b944369a80def98447b1134bd 100755 --- a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js +++ b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js @@ -501,6 +501,13 @@ describe('ACTS_WifiTest', function() { sleep(5000); console.log("[wifi_test] wifi reconnect result: " + result); expect(result).assertTrue(); + console.info("[wifi_test] remove config"); + var isRemoved = wifi.removeAllNetwork(); + console.info("[wifi_test] check remove configs successfully,result:" + isRemoved); + expect(isRemoved).assertTrue(); + var configs = wifi.getDeviceConfigs(); + console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs)); + expect(true).assertEqual(configs.length == 0); })