From 3059ccd4cbf41188fb7936cb591ca2ddb6a688a6 Mon Sep 17 00:00:00 2001 From: quanli Date: Mon, 25 Jul 2022 17:00:34 +0800 Subject: [PATCH] addnewintereface Signed-off-by: quanli --- .../src/main/js/test/BluetoothOn.test.js | 140 +++++++++++++++++- .../src/main/js/test/BluetoothHid.test.js | 20 +++ 2 files changed, 159 insertions(+), 1 deletion(-) diff --git a/communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js b/communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js index 5d6cd4267..0ca895761 100644 --- a/communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js +++ b/communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js @@ -505,6 +505,144 @@ describe('bluetoothhostTest', function() { done(); }) +/** + * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011 + * @tc.name testClassicStartBLEScan + * @tc.desc Test ClassicStartBLEScan api. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011', 0, async function (done) { + console.info('[bluetooth_js] BLE scan11 test start'); + await sleep(1000); + await tryToEnableBt(); + function onReceiveEvent(data) + { + console.info('[bluetooth_js] BLE scan device find result11 = '+ JSON.stringify(data)); + expect(true).assertTrue(data.length > 0); + } + bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) + bluetooth.BLE.startBLEScan([{ + serviceUuid:"00001812-0000-1000-8000-00805F9B34FB", + serviceUuidMask:"0000FFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", + }]); + await sleep(1000); + console.info('[bluetooth_js] BLE scan off11 '); + bluetooth.BLE.off('BLEDeviceFind'); + bluetooth.BLE.stopBLEScan(); + done(); + + }) + + + /** + * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012 + * @tc.name testClassicStartBLEScan + * @tc.desc Test ClassicStartBLEScan api. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012', 0, async function (done) { + console.info('[bluetooth_js] BLE scan14 test start'); + await sleep(1000); + await tryToEnableBt(); + function onReceiveEvent(data) + { + console.info('[bluetooth_js] BLE scan device find result12 = '+ JSON.stringify(data)); + expect(true).assertTrue(data.length > 0); + } + bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) + bluetooth.BLE.startBLEScan([{ + serviceSolicitationUuid:"00000101-0000-1000-8000-00805F9B34FB", + serviceSolicitationUuidMask:"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", + + }]); + await sleep(1000); + console.info('[bluetooth_js] BLE scan off12 '); + bluetooth.BLE.off('BLEDeviceFind'); + bluetooth.BLE.stopBLEScan(); + done(); + + }) + + /** + * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013 + * @tc.name testClassicStartBLEScan + * @tc.desc Test ClassicStartBLEScan api. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013', 0, async function (done) { + console.info('[bluetooth_js] BLE scan13 test start'); + await sleep(1000); + await tryToEnableBt(); + function onReceiveEvent(data) + { + console.info('[bluetooth_js] BLE scan device find result13 = '+ JSON.stringify(data)); + expect(true).assertTrue(data.length > 0); + } + bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) + const serviceDataArrayBuffer = new ArrayBuffer(1); + const serviceDataMaskArrayBuffer = new ArrayBuffer(1); + const serviceDataValue = new Uint8Array(serviceDataArrayBuffer); + const serviceDataMaskValue = new Uint8Array(serviceDataMaskArrayBuffer); + serviceDataValue[0] = '0xFF'; + serviceDataMaskValue[0] = '0xFF'; + bluetooth.BLE.startBLEScan([{ + serviceData:serviceDataValue, + serviceDataMask:serviceDataMaskValue, + }]); + await sleep(1000); + console.info('[bluetooth_js] BLE scan off13 '); + bluetooth.BLE.off('BLEDeviceFind'); + bluetooth.BLE.stopBLEScan(); + done(); + + }) + + /** + * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014 + * @tc.name testClassicStartBLEScan + * @tc.desc Test ClassicStartBLEScan api. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014', 0, async function (done) { + console.info('[bluetooth_js] BLE scan18 test start'); + await sleep(1000); + await tryToEnableBt(); + function onReceiveEvent(data) + { + console.info('[bluetooth_js] BLE scan device find result14 = '+ JSON.stringify(data)); + expect(true).assertTrue(data.length > 0); + } + bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) + const manufactureDataArrayBuffer = new ArrayBuffer(29); + const manufactureDataMaskArrayBuffer = new ArrayBuffer(29); + const manufactureDataValue = new Uint8Array(manufactureDataArrayBuffer); + const manufactureDataMaskValue = new Uint8Array(manufactureDataMaskArrayBuffer); + for (let i = 0; i < 29; i++) { + manufactureDataValue[i] = '0xFF'; + } + for (let i = 0; i < 29; i++) { + manufactureDataMaskValue[i] = '0xFF'; + } + bluetooth.BLE.startBLEScan([{ + manufactureData:manufactureDataValue, + manufactureDataMask:manufactureDataMaskValue, + + }]); + await sleep(1000); + console.info('[bluetooth_js] BLE scan off14 '); + bluetooth.BLE.off('BLEDeviceFind'); + bluetooth.BLE.stopBLEScan(); + done(); + }) + /** * @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001 @@ -555,7 +693,7 @@ describe('bluetoothhostTest', function() { BOND_STATE_BONDING : 1, BOND_STATE_BONDED : 2 }; - let enable4 = bluetooth.pairDevice("00:00:00:00:00:00") + expect(BondState.BOND_STATE_INVALID == 0).assertTrue(); expect(BondState.BOND_STATE_BONDING == 1).assertTrue(); expect(BondState.BOND_STATE_BONDED == 2).assertTrue(); diff --git a/communication/bluetooth_profile/src/main/js/test/BluetoothHid.test.js b/communication/bluetooth_profile/src/main/js/test/BluetoothHid.test.js index 77a5953c8..350b0e046 100644 --- a/communication/bluetooth_profile/src/main/js/test/BluetoothHid.test.js +++ b/communication/bluetooth_profile/src/main/js/test/BluetoothHid.test.js @@ -227,4 +227,24 @@ describe('bluetoothhostTest_host_2', function () { }) + /** + * @tc.number SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001 + * @tc.name testonsppReadOn + * @tc.desc Test sppReadOn api . + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001', 0, async function (done) { + await tryToEnableBt(); + console.info('[bluetooth_js] tethering test start'); + let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK); + let ret = panProfile.setTethering(false); + console.info("[bluetooth_js] setTethering false result "+JSON.stringify(ret)); + let result = panProfile.isTetheringOn(); + console.info("[bluetooth_js] setTethering getTetheringOn result1 false== "+JSON.stringify(result)); + expect(result).assertFalse(); + done(); + }) + } -- GitLab