未验证 提交 613a61a8 编写于 作者: O openharmony_ci 提交者: Gitee

!6467 【bluetooth】ble脚本优化

Merge pull request !6467 from 权力/myfeature1
...@@ -21,7 +21,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -21,7 +21,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
export default function bluetoothBLETest2() { export default function bluetoothBLETest2() {
describe('bluetoothBLETest2', function() { describe('bluetoothBLETest2', function() {
let gattServer = null; let gattServer = null;
let gattClient = null;
function sleep(delay) { function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
...@@ -53,7 +52,6 @@ describe('bluetoothBLETest2', function() { ...@@ -53,7 +52,6 @@ describe('bluetoothBLETest2', function() {
beforeAll(function () { beforeAll(function () {
console.info('beforeAll called') console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
}) })
beforeEach(async function (done) { beforeEach(async function (done) {
console.info('beforeEach called') console.info('beforeEach called')
...@@ -79,7 +77,6 @@ describe('bluetoothBLETest2', function() { ...@@ -79,7 +77,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -136,7 +133,6 @@ describe('bluetoothBLETest2', function() { ...@@ -136,7 +133,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -192,8 +188,7 @@ describe('bluetoothBLETest2', function() { ...@@ -192,8 +188,7 @@ describe('bluetoothBLETest2', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -250,7 +245,6 @@ describe('bluetoothBLETest2', function() { ...@@ -250,7 +245,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -307,7 +301,6 @@ describe('bluetoothBLETest2', function() { ...@@ -307,7 +301,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -364,7 +357,6 @@ describe('bluetoothBLETest2', function() { ...@@ -364,7 +357,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -421,7 +413,6 @@ describe('bluetoothBLETest2', function() { ...@@ -421,7 +413,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -478,7 +469,6 @@ describe('bluetoothBLETest2', function() { ...@@ -478,7 +469,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -535,7 +525,6 @@ describe('bluetoothBLETest2', function() { ...@@ -535,7 +525,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -592,7 +581,6 @@ describe('bluetoothBLETest2', function() { ...@@ -592,7 +581,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -649,7 +637,6 @@ describe('bluetoothBLETest2', function() { ...@@ -649,7 +637,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -706,7 +693,6 @@ describe('bluetoothBLETest2', function() { ...@@ -706,7 +693,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -763,7 +749,6 @@ describe('bluetoothBLETest2', function() { ...@@ -763,7 +749,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 1 * @tc.level Level 1
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1600', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1600', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -820,7 +805,6 @@ describe('bluetoothBLETest2', function() { ...@@ -820,7 +805,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -877,7 +861,6 @@ describe('bluetoothBLETest2', function() { ...@@ -877,7 +861,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -929,7 +912,6 @@ describe('bluetoothBLETest2', function() { ...@@ -929,7 +912,6 @@ describe('bluetoothBLETest2', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2100', 0, async function (done) {
let gattServer =bluetooth.BLE.createGattServer();
let manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
...@@ -982,7 +964,6 @@ describe('bluetoothBLETest2', function() { ...@@ -982,7 +964,6 @@ describe('bluetoothBLETest2', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400', 0, function () { it('SUB_COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400', 0, function () {
let isRet = true; let isRet = true;
try{ try{
let gattServer =bluetooth.BLE.createGattServer();
gattServer.stopAdvertising(); gattServer.stopAdvertising();
expect(isRet).assertTrue(); expect(isRet).assertTrue();
}catch(error){ }catch(error){
...@@ -995,4 +976,3 @@ describe('bluetoothBLETest2', function() { ...@@ -995,4 +976,3 @@ describe('bluetoothBLETest2', function() {
}) })
} }
...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
export default function bluetoothBLETest() { export default function bluetoothBLETest() {
describe('bluetoothBLETest', function() { describe('bluetoothBLETest', function() {
let gattServer = null; let gattServer = null;
let gattClient = null; let gattClient = null;
function sleep(delay) { function sleep(delay) {
...@@ -64,7 +63,7 @@ describe('bluetoothBLETest', function() { ...@@ -64,7 +63,7 @@ describe('bluetoothBLETest', function() {
}) })
afterAll(function () { afterAll(function () {
console.info('afterAll called') console.info('afterAll called')
gattServer.close(); gattClient.close();
}) })
/** /**
...@@ -539,7 +538,7 @@ describe('bluetoothBLETest', function() { ...@@ -539,7 +538,7 @@ describe('bluetoothBLETest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300', 0, async function (done) {
let arrayBufferCCC = new ArrayBuffer(8); let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC); let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1011; cccValue[0] = 1011;
...@@ -685,7 +684,7 @@ describe('bluetoothBLETest', function() { ...@@ -685,7 +684,7 @@ describe('bluetoothBLETest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300', 0, async function (done) {
let arrayBufferDesc = new ArrayBuffer(8); let arrayBufferDesc = new ArrayBuffer(8);
let descValue = new Uint8Array(arrayBufferDesc); let descValue = new Uint8Array(arrayBufferDesc);
function WriteDescriptorReq(DescriptorWriteReq) { function WriteDescriptorReq(DescriptorWriteReq) {
...@@ -696,7 +695,6 @@ describe('bluetoothBLETest', function() { ...@@ -696,7 +695,6 @@ describe('bluetoothBLETest', function() {
let needRsp = DescriptorWriteReq.needRsp; let needRsp = DescriptorWriteReq.needRsp;
let value = new Uint8Array(DescriptorWriteReq.value); let value = new Uint8Array(DescriptorWriteReq.value);
let descriptorUuid = DescriptorWriteReq.descriptorUuid; let descriptorUuid = DescriptorWriteReq.descriptorUuid;
descValue[0] = value[0]; descValue[0] = value[0];
let serverResponse = {deviceId: deviceId, transId: transId, let serverResponse = {deviceId: deviceId, transId: transId,
status: 0, offset: offset, value:arrayBufferDesc}; status: 0, offset: offset, value:arrayBufferDesc};
...@@ -720,7 +718,7 @@ describe('bluetoothBLETest', function() { ...@@ -720,7 +718,7 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -756,7 +754,7 @@ describe('bluetoothBLETest', function() { ...@@ -756,7 +754,7 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0200 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -792,7 +790,7 @@ describe('bluetoothBLETest', function() { ...@@ -792,7 +790,7 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -807,7 +805,7 @@ describe('bluetoothBLETest', function() { ...@@ -807,7 +805,7 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0400 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400
* @tc.name test BLECharacteristicChangeON * @tc.name test BLECharacteristicChangeON
* @tc.desc Test On and off api. * @tc.desc Test On and off api.
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -850,12 +848,12 @@ describe('bluetoothBLETest', function() { ...@@ -850,12 +848,12 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GattClose_0100
* @tc.name testSetNotifyCharacteristicChanged * @tc.name test gattClient close
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test close api.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_GattClose_0100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_GattClose_0100', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66"); let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
...@@ -868,3 +866,4 @@ describe('bluetoothBLETest', function() { ...@@ -868,3 +866,4 @@ describe('bluetoothBLETest', function() {
}) })
} }
...@@ -584,7 +584,7 @@ describe('bluetoothhostTest', function() { ...@@ -584,7 +584,7 @@ describe('bluetoothhostTest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1800
* @tc.name test gatt connect and disconnect * @tc.name test gatt connect and disconnect
* @tc.desc Test connect and disconnect api . * @tc.desc Test connect and disconnect api .
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -592,7 +592,7 @@ describe('bluetoothhostTest', function() { ...@@ -592,7 +592,7 @@ describe('bluetoothhostTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1800', 0, async function (done) {
async function onReceiveEvent(ScanResult) async function onReceiveEvent(ScanResult)
{ {
console.info('[bluetooth_js] BLEscan device result12'+JSON.stringify(ScanResult) console.info('[bluetooth_js] BLEscan device result12'+JSON.stringify(ScanResult)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册