提交 8ec6336c 编写于 作者: Q q00313334 提交者: 权力

fixed 5ea9ccfc from https://gitee.com/quanli125/xts_acts/pulls/2796

3516quanli1@huawei.com
Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 4749c98a
......@@ -16,7 +16,7 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var MajorMinorClass = {
let MajorMinorClass = {
COMPUTER_UNCATEGORIZED : 0x0100,
COMPUTER_DESKTOP : 0x0104,
COMPUTER_SERVER : 0x0108,
......@@ -106,10 +106,11 @@ var MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C
};
describe('bluetoothhostTest', function() {
var gattServer = null;
var gattClient = null;
let gattServer = null;
let gattClient = null;
beforeAll(function () {
console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer();
......@@ -131,11 +132,10 @@ describe('bluetoothhostTest', function() {
}
async function tryToEnableBt() {
var sta = bluetooth.getState();
let sta = bluetooth.getState();
switch(sta){
case 0:
var enable = bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
......@@ -146,8 +146,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta));
break;
case 3:
var enable = bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
......@@ -159,7 +158,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -174,7 +172,7 @@ describe('bluetoothhostTest', function() {
}
}
await tryToEnableBt();
var state = bluetooth.getState();
let state = bluetooth.getState();
expect(state).assertEqual(2);
await bluetooth.off('stateChange', result => {
expect(true).assertEqual(result ==null);
......@@ -187,7 +185,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -215,7 +212,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -236,7 +232,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result ==null);
done();
});
var result = bluetooth.BLE.stopBLEScan();
let result = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result));
console.info('[bluetooth_js] BLE scan start end');
resolve()
......@@ -250,7 +246,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -264,7 +259,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null);
done();
});
var enable = bluetooth.pairDevice("00:00:00:00:00:00")
let enable3 = bluetooth.pairDevice("00:00:00:00:00:00")
bluetooth.BLE.off('pinRequired', result => {
console.info("[bluetooth_js] pinRequired off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
......@@ -276,7 +271,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -290,7 +284,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null);
done();
});
var enable = bluetooth.pairDevice("00:00:00:00:00:00")
let enable4 = bluetooth.pairDevice("00:00:00:00:00:00")
expect(bluetooth.BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue();
......@@ -305,7 +299,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen
* @tc.desc Test SppListen api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -332,7 +325,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001
* @tc.name testonCharacteristicReadOn
* @tc.desc Test CharacteristicReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -345,14 +337,14 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
var serverResponse = {
let serverResponse = {
"deviceId": data.deviceId,
"transId": data.transId,
"status": 0,
"offset": data.offset,
"value": str2ab("characteristic read response", data.offset),
};
var result = gattServer.sendResponse(serverResponse);
let result = gattServer.sendResponse(serverResponse);
expect(JSON.stringify(result)).assertContain("true");
});
}catch(e) {
......@@ -375,7 +367,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn
* @tc.desc Test CharacteristicwriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -397,14 +388,14 @@ describe('bluetoothhostTest', function() {
return;
}
console.log(`data.value is ArraryBuffer: ${ab2hex(data.value)}`)
var serverResponse = {
let serverResponse = {
"deviceId": data.deviceId,
"transId": data.transId,
"status": 0,
"offset": data.offset,
"value": data.value,
};
var result = gattServer.sendResponse(serverResponse);
let result = gattServer.sendResponse(serverResponse);
expect(JSON.stringify(result)).assertContain("true");
});
}catch(e) {
......@@ -427,7 +418,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn
* @tc.desc Test DescriptorReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -464,7 +454,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn
* @tc.desc Test DescriptorWriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -501,7 +490,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn
* @tc.desc Test ConnectStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -536,7 +524,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn
* @tc.desc Test BLECharacteristicChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -570,7 +557,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn
* @tc.desc Test BLEConnectionStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -605,7 +591,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
......@@ -635,4 +620,3 @@ describe('bluetoothhostTest', function() {
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册