提交 5ea9ccfc 编写于 作者: Q q00313334

3516quanli1@huawei.com

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 a8edc778
...@@ -17,16 +17,16 @@ import bluetooth from '@ohos.bluetooth'; ...@@ -17,16 +17,16 @@ import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var SppType = { let SppType = {
SPP_RFCOMM : 0 SPP_RFCOMM : 0
} }
var MatchMode = { let MatchMode = {
MATCH_MODE_AGGRESSIVE : 1, MATCH_MODE_AGGRESSIVE : 1,
MATCH_MODE_STICKY : 2 MATCH_MODE_STICKY : 2
} }
var MajorClass = { let MajorClass = {
MAJOR_MISC : 0x0000, MAJOR_MISC : 0x0000,
MAJOR_COMPUTER : 0x0100, MAJOR_COMPUTER : 0x0100,
MAJOR_PHONE : 0x0200, MAJOR_PHONE : 0x0200,
...@@ -40,10 +40,11 @@ var MajorClass = { ...@@ -40,10 +40,11 @@ var MajorClass = {
MAJOR_UNCATEGORIZED : 0x1F00 MAJOR_UNCATEGORIZED : 0x1F00
} }
describe('bluetoothhostTest', function() { describe('bluetoothhostTest', function() {
var gattServer = null; let gattServer = null;
var gattClient = null; let gattClient = null;
beforeAll(function () { beforeAll(function () {
console.info('beforeAll called') console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
...@@ -65,15 +66,13 @@ describe('bluetoothhostTest', function() { ...@@ -65,15 +66,13 @@ describe('bluetoothhostTest', function() {
} }
async function tryToEnableBt() { async function tryToEnableBt() {
var sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
expect(enable).assertTrue();
await sleep(3000); await sleep(3000);
break; break;
case 1: case 1:
expect(JSON.stringify(sta)).assertTrue(1);
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000); await sleep(3000);
break; break;
...@@ -81,8 +80,7 @@ describe('bluetoothhostTest', function() { ...@@ -81,8 +80,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
await sleep(3000); await sleep(3000);
break; break;
default: default:
...@@ -94,7 +92,6 @@ describe('bluetoothhostTest', function() { ...@@ -94,7 +92,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth * @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise. * @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -102,7 +99,7 @@ describe('bluetoothhostTest', function() { ...@@ -102,7 +99,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) {
console.info('[bluetooth_js] enable start'); console.info('[bluetooth_js] enable start');
await tryToEnableBt(); await tryToEnableBt();
var state = bluetooth.getState(); let state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state)); console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
expect(state).assertEqual(2); expect(state).assertEqual(2);
done(); done();
...@@ -113,7 +110,6 @@ describe('bluetoothhostTest', function() { ...@@ -113,7 +110,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001
* @tc.name testGetConnectedBLEDevices * @tc.name testGetConnectedBLEDevices
* @tc.desc Test getConnectedBLEDevices api . * @tc.desc Test getConnectedBLEDevices api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -121,7 +117,7 @@ describe('bluetoothhostTest', function() { ...@@ -121,7 +117,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001', 0, async function (done) {
console.info('[bluetooth_js] getConnectedBLEDevices test start ...'); console.info('[bluetooth_js] getConnectedBLEDevices test start ...');
await tryToEnableBt(); await tryToEnableBt();
var result = bluetooth.BLE.getConnectedBLEDevices(); let result = bluetooth.BLE.getConnectedBLEDevices();
console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)+ "length:" +result.length); console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)+ "length:" +result.length);
expect(result.length).assertEqual(0); expect(result.length).assertEqual(0);
done(); done();
...@@ -132,7 +128,6 @@ describe('bluetoothhostTest', function() { ...@@ -132,7 +128,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001
* @tc.name testCreateGattServer * @tc.name testCreateGattServer
* @tc.desc Test CreateGattServer api . * @tc.desc Test CreateGattServer api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -140,8 +135,8 @@ describe('bluetoothhostTest', function() { ...@@ -140,8 +135,8 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001', 0, async function (done) {
console.info('[bluetooth_js] createGattServer test start ...'); console.info('[bluetooth_js] createGattServer test start ...');
await tryToEnableBt(); await tryToEnableBt();
var result = bluetooth.BLE.createGattServer(); let result = bluetooth.BLE.createGattServer();
var resultLength = Object.keys(result).length; let resultLength = Object.keys(result).length;
console.info("[bluetooth_js] createGattServer:" + JSON.stringify(result) + "length:" + resultLength); console.info("[bluetooth_js] createGattServer:" + JSON.stringify(result) + "length:" + resultLength);
expect(resultLength).assertEqual(1); expect(resultLength).assertEqual(1);
done(); done();
...@@ -152,7 +147,6 @@ describe('bluetoothhostTest', function() { ...@@ -152,7 +147,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001
* @tc.name testStartAdvertising * @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api. * @tc.desc Test StartAdvertising api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -160,19 +154,19 @@ describe('bluetoothhostTest', function() { ...@@ -160,19 +154,19 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001', 0, async function (done) {
console.info('[bluetooth_js] BLE advertising start'); console.info('[bluetooth_js] BLE advertising start');
await tryToEnableBt(); await tryToEnableBt();
var manufactureValueBuffer = new Uint8Array(4); let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1; manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2; manufactureValueBuffer[1] = 2;
manufactureValueBuffer[2] = 3; manufactureValueBuffer[2] = 3;
manufactureValueBuffer[3] = 4; manufactureValueBuffer[3] = 4;
var serviceValueBuffer = new Uint8Array(4); let serviceValueBuffer = new Uint8Array(4);
serviceValueBuffer[0] = 4; serviceValueBuffer[0] = 4;
serviceValueBuffer[1] = 6; serviceValueBuffer[1] = 6;
serviceValueBuffer[2] = 7; serviceValueBuffer[2] = 7;
serviceValueBuffer[3] = 8; serviceValueBuffer[3] = 8;
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
var gattServer = bluetooth.BLE.createGattServer() let gattServer = bluetooth.BLE.createGattServer()
var start = gattServer.startAdvertising({ let start = gattServer.startAdvertising({
interval:150, interval:150,
txPower:60, txPower:60,
connectable:true, connectable:true,
...@@ -209,7 +203,6 @@ describe('bluetoothhostTest', function() { ...@@ -209,7 +203,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001 * @tc.number SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001
* @tc.name testStopAdvertising * @tc.name testStopAdvertising
* @tc.desc Test StopAdvertising api. * @tc.desc Test StopAdvertising api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -217,8 +210,8 @@ describe('bluetoothhostTest', function() { ...@@ -217,8 +210,8 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001', 0, async function (done) {
console.info('[bluetooth_js] BLE stop advertising start'); console.info('[bluetooth_js] BLE stop advertising start');
await tryToEnableBt(); await tryToEnableBt();
var gattServer = bluetooth.BLE.createGattServer(); let gattServer = bluetooth.BLE.createGattServer();
var stop = gattServer.stopAdvertising(); let stop = gattServer.stopAdvertising();
expect(stop).assertNull(); expect(stop).assertNull();
done(); done();
}) })
...@@ -227,7 +220,6 @@ describe('bluetoothhostTest', function() { ...@@ -227,7 +220,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CONNRCT_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_CONNRCT_0001
* @tc.name testConnect * @tc.name testConnect
* @tc.desc Test Connect api. * @tc.desc Test Connect api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -246,7 +238,6 @@ describe('bluetoothhostTest', function() { ...@@ -246,7 +238,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_CALLBACK * @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_CALLBACK
* @tc.name testGetRssiValue * @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by callback. * @tc.desc Test GetRssiValue api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -255,7 +246,7 @@ describe('bluetoothhostTest', function() { ...@@ -255,7 +246,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE get rssi1 start'); console.info('[bluetooth_js] BLE get rssi1 start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getRssiValue((err, data)=> { gattClient.getRssiValue((err, data)=> {
console.info('[bluetooth_js] rssi err:' + JSON.stringify(err)+'value:'+JSON.stringify(data)); console.info('[bluetooth_js] rssi err:' + JSON.stringify(err)+'value:'+JSON.stringify(data));
expect(data).assertNull(); expect(data).assertNull();
...@@ -271,7 +262,6 @@ describe('bluetoothhostTest', function() { ...@@ -271,7 +262,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_PROMISE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_PROMISE_0001
* @tc.name testGetRssiValue * @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by promise. * @tc.desc Test GetRssiValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -280,13 +270,13 @@ describe('bluetoothhostTest', function() { ...@@ -280,13 +270,13 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE get rssi start'); console.info('[bluetooth_js] BLE get rssi start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getRssiValue().then((data) => { gattClient.getRssiValue().then((data) => {
if (data != null) { if (data != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
} else { } else {
console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(data)); console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(data));
var rssiLength = Object.keys(data).length; let rssiLength = Object.keys(data).length;
expect(rssiLength).assertEqual(0); expect(rssiLength).assertEqual(0);
} }
}).catch(err => { }).catch(err => {
...@@ -304,7 +294,6 @@ describe('bluetoothhostTest', function() { ...@@ -304,7 +294,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_PROMISE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_PROMISE_0001
* @tc.name testGetDeviceName * @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by promise. * @tc.desc Test GetDeviceName api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -313,7 +302,7 @@ describe('bluetoothhostTest', function() { ...@@ -313,7 +302,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE get device name promise start'); console.info('[bluetooth_js] BLE get device name promise start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getDeviceName().then((data) => { gattClient.getDeviceName().then((data) => {
console.info('[bluetooth_js] device name' + JSON.stringify(data)) console.info('[bluetooth_js] device name' + JSON.stringify(data))
expect(data).assertNull(); expect(data).assertNull();
...@@ -329,7 +318,6 @@ describe('bluetoothhostTest', function() { ...@@ -329,7 +318,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.name testGetServices * @tc.name testGetServices
* @tc.desc Test GetServices api by callback. * @tc.desc Test GetServices api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -337,19 +325,23 @@ describe('bluetoothhostTest', function() { ...@@ -337,19 +325,23 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001', 0, async function (done) {
console.info('[bluetooth_js] getServices callback start'); console.info('[bluetooth_js] getServices callback start');
await tryToEnableBt(); await tryToEnableBt();
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getServices((err, data)=> { gattClient.getServices((err, data)=> {
console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err) +'name1' + JSON.stringify(data)); console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err) +'name1' + JSON.stringify(data));
expect(true).assertEqual(err.code == -1); expect(true).assertEqual(err.code == -1);
done(); done();
}) })
resolve()
})
await promise.then(done)
done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001
* @tc.name testGetServices * @tc.name testGetServices
* @tc.desc Test GetServices api by promise. * @tc.desc Test GetServices api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -357,8 +349,9 @@ describe('bluetoothhostTest', function() { ...@@ -357,8 +349,9 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001', 0, async function (done) {
console.info('[bluetooth_js] getServices promise start'); console.info('[bluetooth_js] getServices promise start');
await tryToEnableBt(); await tryToEnableBt();
var gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00"); let promise = new Promise((resolve) => {
await gattClient.getServices().then((object) => { let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getServices().then((object) => {
if (object != null) { if (object != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
} else { } else {
...@@ -371,13 +364,16 @@ describe('bluetoothhostTest', function() { ...@@ -371,13 +364,16 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
resolve()
})
await promise.then(done)
done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001
* @tc.name testReadCharacteristicValue * @tc.name testReadCharacteristicValue
* @tc.desc Test ReadCharacteristicValue api by promise. * @tc.desc Test ReadCharacteristicValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -385,6 +381,7 @@ describe('bluetoothhostTest', function() { ...@@ -385,6 +381,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] readCharacteristicValue start'); console.info('[bluetooth_js] readCharacteristicValue start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => {
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -398,6 +395,7 @@ describe('bluetoothhostTest', function() { ...@@ -398,6 +395,7 @@ describe('bluetoothhostTest', function() {
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors}; characteristicValue: arrayBufferCCC, descriptors:descriptors};
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.readCharacteristicValue(characteristic).then((object) => { gattClient.readCharacteristicValue(characteristic).then((object) => {
if (object != null) { if (object != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
...@@ -411,13 +409,16 @@ describe('bluetoothhostTest', function() { ...@@ -411,13 +409,16 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
resolve()
})
await promise.then(done)
done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
* @tc.name testReadDescriptorValue * @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise. * @tc.desc Test ReadDescriptorValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -425,11 +426,13 @@ describe('bluetoothhostTest', function() { ...@@ -425,11 +426,13 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] readDescriptorValue start'); console.info('[bluetooth_js] readDescriptorValue start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => {
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11; desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', 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 gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.readDescriptorValue(descriptor).then((object) => { gattClient.readDescriptorValue(descriptor).then((object) => {
if (object != null) { if (object != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
...@@ -443,13 +446,17 @@ describe('bluetoothhostTest', function() { ...@@ -443,13 +446,17 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
resolve()
})
await promise.then(done)
done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
* @tc.name testWriteCharacteristicValue * @tc.name testWriteCharacteristicValue
* @tc.desc Test WriteCharacteristicValue api. * @tc.desc Test WriteCharacteristicValue api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -457,6 +464,7 @@ describe('bluetoothhostTest', function() { ...@@ -457,6 +464,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] writeCharacteristicValue start'); console.info('[bluetooth_js] writeCharacteristicValue start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => {
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -470,17 +478,21 @@ describe('bluetoothhostTest', function() { ...@@ -470,17 +478,21 @@ describe('bluetoothhostTest', function() {
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors}; characteristicValue: arrayBufferCCC, descriptors:descriptors};
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.writeCharacteristicValue(characteristic); let ret = gattClient.writeCharacteristicValue(characteristic);
console.info('[bluetooth_js] writeCharacteristicValue ret : ' + ret); console.info('[bluetooth_js] writeCharacteristicValue ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
resolve()
})
await promise.then(done)
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001
* @tc.name testWriteDescriptorValue * @tc.name testWriteDescriptorValue
* @tc.desc Test WriteDescriptorValue api. * @tc.desc Test WriteDescriptorValue api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -488,22 +500,27 @@ describe('bluetoothhostTest', function() { ...@@ -488,22 +500,27 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] writeDescriptorValue start'); console.info('[bluetooth_js] writeDescriptorValue start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => {
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11; desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', 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 gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.writeDescriptorValue(descriptor); let ret = gattClient.writeDescriptorValue(descriptor);
console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret); console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
resolve()
})
await promise.then(done)
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001
* @tc.name testSetBLEMtuSize * @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api. * @tc.desc Test SetBLEMtuSize api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -511,6 +528,7 @@ describe('bluetoothhostTest', function() { ...@@ -511,6 +528,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001', 0, async function (done) {
console.info('[bluetooth_js] setBLEMtuSize start'); console.info('[bluetooth_js] setBLEMtuSize start');
await tryToEnableBt(); await tryToEnableBt();
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.setBLEMtuSize(128); let ret = gattClient.setBLEMtuSize(128);
console.info('[bluetooth_js] bluetooth setBLEMtuSize ret:' + ret); console.info('[bluetooth_js] bluetooth setBLEMtuSize ret:' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
...@@ -521,7 +539,6 @@ describe('bluetoothhostTest', function() { ...@@ -521,7 +539,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -529,6 +546,7 @@ describe('bluetoothhostTest', function() { ...@@ -529,6 +546,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001', 0, async function (done) {
console.info('[bluetooth_js] setNotifyCharacteristicChanged start'); console.info('[bluetooth_js] setNotifyCharacteristicChanged start');
await tryToEnableBt(); await tryToEnableBt();
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -560,7 +578,6 @@ describe('bluetoothhostTest', function() { ...@@ -560,7 +578,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001
* @tc.name testAddService * @tc.name testAddService
* @tc.desc Test AddService api. * @tc.desc Test AddService api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -568,7 +585,7 @@ describe('bluetoothhostTest', function() { ...@@ -568,7 +585,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001', 0, async function (done) {
console.info('[bluetooth_js] addService start'); console.info('[bluetooth_js] addService start');
await tryToEnableBt(); await tryToEnableBt();
gattServer = bluetooth.BLE.createGattServer(); let gattServer = bluetooth.BLE.createGattServer();
let descriptors = []; let descriptors = [];
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer); let desValue = new Uint8Array(arrayBuffer);
...@@ -598,7 +615,6 @@ describe('bluetoothhostTest', function() { ...@@ -598,7 +615,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001
* @tc.name testRemoveService * @tc.name testRemoveService
* @tc.desc Test RemoveService api. * @tc.desc Test RemoveService api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -606,7 +622,7 @@ describe('bluetoothhostTest', function() { ...@@ -606,7 +622,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001', 0, async function (done) {
console.info('[bluetooth_js] removeService start'); console.info('[bluetooth_js] removeService start');
await tryToEnableBt(); await tryToEnableBt();
gattServer = bluetooth.BLE.createGattServer(); let gattServer = bluetooth.BLE.createGattServer();
let ret = gattServer.removeService('00001810-0000-1000-8000-008000000000'); let ret = gattServer.removeService('00001810-0000-1000-8000-008000000000');
console.info('[bluetooth_js] removeService ret : ' + ret); console.info('[bluetooth_js] removeService ret : ' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
...@@ -617,7 +633,6 @@ describe('bluetoothhostTest', function() { ...@@ -617,7 +633,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001
* @tc.name testNotifyCharacteristicChanged * @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api. * @tc.desc Test NotifyCharacteristicChanged api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -625,6 +640,7 @@ describe('bluetoothhostTest', function() { ...@@ -625,6 +640,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001', 0, async function (done) {
console.info('[bluetooth_js] notifyCharacteristicChanged start'); console.info('[bluetooth_js] notifyCharacteristicChanged start');
await tryToEnableBt(); await tryToEnableBt();
let gattServer = bluetooth.BLE.createGattServer()
let descriptors = []; let descriptors = [];
let arrayBufferDesc = new ArrayBuffer(8); let arrayBufferDesc = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBufferDesc); let desValue = new Uint8Array(arrayBufferDesc);
...@@ -657,7 +673,6 @@ describe('bluetoothhostTest', function() { ...@@ -657,7 +673,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001
* @tc.name testSendResponse * @tc.name testSendResponse
* @tc.desc Test SendResponse api. * @tc.desc Test SendResponse api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -665,6 +680,7 @@ describe('bluetoothhostTest', function() { ...@@ -665,6 +680,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001', 0, async function (done) {
console.info('[bluetooth_js] sendResponse start'); console.info('[bluetooth_js] sendResponse start');
await tryToEnableBt(); await tryToEnableBt();
let gattServer = bluetooth.BLE.createGattServer()
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
let value = new Uint8Array(arrayBuffer); let value = new Uint8Array(arrayBuffer);
value[0] = 1; value[0] = 1;
...@@ -682,7 +698,6 @@ describe('bluetoothhostTest', function() { ...@@ -682,7 +698,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_GATTSERVER_CLOSE_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_GATTSERVER_CLOSE_0001
* @tc.name testBlePeripheralManagerClose * @tc.name testBlePeripheralManagerClose
* @tc.desc Test BlePeripheralManagerClose api . * @tc.desc Test BlePeripheralManagerClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -691,7 +706,8 @@ describe('bluetoothhostTest', function() { ...@@ -691,7 +706,8 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] GattserverClose test start ...'); console.info('[bluetooth_js] GattserverClose test start ...');
await tryToEnableBt(); await tryToEnableBt();
try{ try{
var result = gattServer.close(); let gattServer = bluetooth.BLE.createGattServer()
let result = gattServer.close();
console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result)); console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result));
expect(result).assertTrue(); expect(result).assertTrue();
}catch(error){ }catch(error){
...@@ -705,7 +721,6 @@ describe('bluetoothhostTest', function() { ...@@ -705,7 +721,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001
* @tc.name testDisConnect * @tc.name testDisConnect
* @tc.desc Test DisConnect api. * @tc.desc Test DisConnect api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -713,6 +728,7 @@ describe('bluetoothhostTest', function() { ...@@ -713,6 +728,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001', 0, async function (done) {
console.info('[bluetooth_js] gatt disconnect start'); console.info('[bluetooth_js] gatt disconnect start');
await tryToEnableBt(); await tryToEnableBt();
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.disconnect(); let ret = gattClient.disconnect();
console.info('[bluetooth_js] gatt disconnect ret:' + ret); console.info('[bluetooth_js] gatt disconnect ret:' + ret);
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
...@@ -723,7 +739,6 @@ describe('bluetoothhostTest', function() { ...@@ -723,7 +739,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CLIENT_CLOSE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose * @tc.name testGattClientClose
* @tc.desc Test GattClientClose api . * @tc.desc Test GattClientClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -732,7 +747,8 @@ describe('bluetoothhostTest', function() { ...@@ -732,7 +747,8 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] GattclientClose test start ...'); console.info('[bluetooth_js] GattclientClose test start ...');
await tryToEnableBt(); await tryToEnableBt();
try{ try{
var result = gattClient.close(); let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let result = gattClient.close();
console.info("[bluetooth_js] GattclientClose result:" + JSON.stringify(result)); console.info("[bluetooth_js] GattclientClose result:" + JSON.stringify(result));
expect(result).assertTrue(); expect(result).assertTrue();
}catch(error){ }catch(error){
...@@ -743,4 +759,3 @@ describe('bluetoothhostTest', function() { ...@@ -743,4 +759,3 @@ describe('bluetoothhostTest', function() {
}) })
}) })
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import bluetooth from '@ohos.bluetooth'; import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var MajorMinorClass = { let MajorMinorClass = {
COMPUTER_UNCATEGORIZED : 0x0100, COMPUTER_UNCATEGORIZED : 0x0100,
COMPUTER_DESKTOP : 0x0104, COMPUTER_DESKTOP : 0x0104,
COMPUTER_SERVER : 0x0108, COMPUTER_SERVER : 0x0108,
...@@ -106,10 +106,11 @@ var MajorMinorClass = { ...@@ -106,10 +106,11 @@ var MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C
}; };
describe('bluetoothhostTest', function() { describe('bluetoothhostTest', function() {
var gattServer = null; let gattServer = null;
var gattClient = null; let gattClient = null;
beforeAll(function () { beforeAll(function () {
console.info('beforeAll called') console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer(); gattServer = bluetooth.BLE.createGattServer();
...@@ -131,11 +132,10 @@ describe('bluetoothhostTest', function() { ...@@ -131,11 +132,10 @@ describe('bluetoothhostTest', function() {
} }
async function tryToEnableBt() { async function tryToEnableBt() {
var sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
await sleep(3000); await sleep(3000);
break; break;
case 1: case 1:
...@@ -146,8 +146,7 @@ describe('bluetoothhostTest', function() { ...@@ -146,8 +146,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
await sleep(3000); await sleep(3000);
break; break;
default: default:
...@@ -159,7 +158,6 @@ describe('bluetoothhostTest', function() { ...@@ -159,7 +158,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth * @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise. * @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -174,7 +172,7 @@ describe('bluetoothhostTest', function() { ...@@ -174,7 +172,7 @@ describe('bluetoothhostTest', function() {
} }
} }
await tryToEnableBt(); await tryToEnableBt();
var state = bluetooth.getState(); let state = bluetooth.getState();
expect(state).assertEqual(2); expect(state).assertEqual(2);
await bluetooth.off('stateChange', result => { await bluetooth.off('stateChange', result => {
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
...@@ -187,7 +185,6 @@ describe('bluetoothhostTest', function() { ...@@ -187,7 +185,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery * @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api. * @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -215,7 +212,6 @@ describe('bluetoothhostTest', function() { ...@@ -215,7 +212,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan * @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api. * @tc.desc Test ClassicStartBLEScan api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -236,7 +232,7 @@ describe('bluetoothhostTest', function() { ...@@ -236,7 +232,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
done(); done();
}); });
var result = bluetooth.BLE.stopBLEScan(); let result = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result)); console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result));
console.info('[bluetooth_js] BLE scan start end'); console.info('[bluetooth_js] BLE scan start end');
resolve() resolve()
...@@ -250,7 +246,6 @@ describe('bluetoothhostTest', function() { ...@@ -250,7 +246,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice * @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api. * @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -264,7 +259,7 @@ describe('bluetoothhostTest', function() { ...@@ -264,7 +259,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); 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 => { bluetooth.BLE.off('pinRequired', result => {
console.info("[bluetooth_js] pinRequired off:" + JSON.stringify(result)); console.info("[bluetooth_js] pinRequired off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
...@@ -276,7 +271,6 @@ describe('bluetoothhostTest', function() { ...@@ -276,7 +271,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002 * @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002
* @tc.name testClassicPairDevice * @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api. * @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -290,7 +284,7 @@ describe('bluetoothhostTest', function() { ...@@ -290,7 +284,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); 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_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue(); expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue(); expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue();
...@@ -305,7 +299,6 @@ describe('bluetoothhostTest', function() { ...@@ -305,7 +299,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen * @tc.name testSppListen
* @tc.desc Test SppListen api by callback. * @tc.desc Test SppListen api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -332,7 +325,6 @@ describe('bluetoothhostTest', function() { ...@@ -332,7 +325,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001
* @tc.name testonCharacteristicReadOn * @tc.name testonCharacteristicReadOn
* @tc.desc Test CharacteristicReadOn api . * @tc.desc Test CharacteristicReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -345,14 +337,14 @@ describe('bluetoothhostTest', function() { ...@@ -345,14 +337,14 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId + console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' + 'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid); data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
var serverResponse = { let serverResponse = {
"deviceId": data.deviceId, "deviceId": data.deviceId,
"transId": data.transId, "transId": data.transId,
"status": 0, "status": 0,
"offset": data.offset, "offset": data.offset,
"value": str2ab("characteristic read response", 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"); expect(JSON.stringify(result)).assertContain("true");
}); });
}catch(e) { }catch(e) {
...@@ -375,7 +367,6 @@ describe('bluetoothhostTest', function() { ...@@ -375,7 +367,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn * @tc.name testonCharacteristicwriteOn
* @tc.desc Test CharacteristicwriteOn api . * @tc.desc Test CharacteristicwriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -397,14 +388,14 @@ describe('bluetoothhostTest', function() { ...@@ -397,14 +388,14 @@ describe('bluetoothhostTest', function() {
return; return;
} }
console.log(`data.value is ArraryBuffer: ${ab2hex(data.value)}`) console.log(`data.value is ArraryBuffer: ${ab2hex(data.value)}`)
var serverResponse = { let serverResponse = {
"deviceId": data.deviceId, "deviceId": data.deviceId,
"transId": data.transId, "transId": data.transId,
"status": 0, "status": 0,
"offset": data.offset, "offset": data.offset,
"value": data.value, "value": data.value,
}; };
var result = gattServer.sendResponse(serverResponse); let result = gattServer.sendResponse(serverResponse);
expect(JSON.stringify(result)).assertContain("true"); expect(JSON.stringify(result)).assertContain("true");
}); });
}catch(e) { }catch(e) {
...@@ -427,7 +418,6 @@ describe('bluetoothhostTest', function() { ...@@ -427,7 +418,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn * @tc.name testDescriptorReadOn
* @tc.desc Test DescriptorReadOn api . * @tc.desc Test DescriptorReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -464,7 +454,6 @@ describe('bluetoothhostTest', function() { ...@@ -464,7 +454,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn * @tc.name testDescriptorWriteOn
* @tc.desc Test DescriptorWriteOn api . * @tc.desc Test DescriptorWriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -501,7 +490,6 @@ describe('bluetoothhostTest', function() { ...@@ -501,7 +490,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn * @tc.name testConnectStateChangeOn
* @tc.desc Test ConnectStateChangeOn api . * @tc.desc Test ConnectStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -536,7 +524,6 @@ describe('bluetoothhostTest', function() { ...@@ -536,7 +524,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn * @tc.name testBLECharacteristicChangeOn
* @tc.desc Test BLECharacteristicChangeOn api . * @tc.desc Test BLECharacteristicChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -570,7 +557,6 @@ describe('bluetoothhostTest', function() { ...@@ -570,7 +557,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn * @tc.name testBLEConnectionStateChangeOn
* @tc.desc Test BLEConnectionStateChangeOn api . * @tc.desc Test BLEConnectionStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -605,7 +591,6 @@ describe('bluetoothhostTest', function() { ...@@ -605,7 +591,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001
* @tc.name testonsppReadOn * @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api . * @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -635,4 +620,3 @@ describe('bluetoothhostTest', function() { ...@@ -635,4 +620,3 @@ describe('bluetoothhostTest', function() {
}) })
}) })
...@@ -17,7 +17,7 @@ import bluetooth from '@ohos.bluetooth'; ...@@ -17,7 +17,7 @@ import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var Btname = { let Btname = {
NUM_TEST :'012345678901234567890123456789012345678901234567890123'+ NUM_TEST :'012345678901234567890123456789012345678901234567890123'+
'45678901234567890123456789012345678901234567890123456789012345678901234567', '45678901234567890123456789012345678901234567890123456789012345678901234567',
NUM_TEST1 :'01234567890123456789012345678901234567890123456' NUM_TEST1 :'01234567890123456789012345678901234567890123456'
...@@ -59,11 +59,10 @@ describe('bluetoothhostTest', function() { ...@@ -59,11 +59,10 @@ describe('bluetoothhostTest', function() {
} }
async function tryToEnableBt() { async function tryToEnableBt() {
var sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
await sleep(3000); await sleep(3000);
break; break;
case 1: case 1:
...@@ -74,8 +73,7 @@ describe('bluetoothhostTest', function() { ...@@ -74,8 +73,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta)); console.info('[bluetooth_js] state is On:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
var enable = bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
console.info('[bluetooth_js] enable0 = '+ JSON.stringify(enable));
await sleep(3000); await sleep(3000);
break; break;
default: default:
...@@ -85,52 +83,33 @@ describe('bluetoothhostTest', function() { ...@@ -85,52 +83,33 @@ describe('bluetoothhostTest', function() {
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_STATE_0001
* @tc.name testEnableBluetooth * @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise. * @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) {
console.info('[bluetooth_js] enable start');
await tryToEnableBt();
var state = bluetooth.getState();
expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
expect(bluetooth.BluetoothState.STATE_OFF == 0).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_ON == 1).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_OFF == 3).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_ON == 4).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_ON == 5).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF == 6).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_STATE_0001
* @tc.name testGetState
* @tc.desc Test GetState api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_GET_STATE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GET_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get state start'); console.info('[bluetooth_js] getState start');
await tryToEnableBt(); await tryToEnableBt();
var state = bluetooth.getState(); let state = bluetooth.getState();
console.info('get bluetooth state end');
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state)); console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON); expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
expect(bluetooth.BluetoothState.STATE_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue();
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001
* @tc.name testClassicSetLocalName * @tc.name testClassicSetLocalName
* @tc.desc Test ClassicSetLocalName api. * @tc.desc Test ClassicSetLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -138,7 +117,7 @@ describe('bluetoothhostTest', function() { ...@@ -138,7 +117,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001', 0, async function (done) {
console.info('[bluetooth_js] set localname start'); console.info('[bluetooth_js] set localname start');
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName('bluetooth_test'); let name = bluetooth.setLocalName('bluetooth_test');
console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name)); console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name));
expect(name).assertEqual(true); expect(name).assertEqual(true);
done(); done();
...@@ -148,7 +127,6 @@ describe('bluetoothhostTest', function() { ...@@ -148,7 +127,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_PAIR_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_PAIR_0001
* @tc.name testStartpair * @tc.name testStartpair
* @tc.desc Test Startpair api by promise. * @tc.desc Test Startpair api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -156,7 +134,7 @@ describe('bluetoothhostTest', function() { ...@@ -156,7 +134,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_START_PAIR_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_START_PAIR_0001', 0, async function (done) {
console.info('[bluetooth_js] Startpair test start ...'); console.info('[bluetooth_js] Startpair test start ...');
await tryToEnableBt(); await tryToEnableBt();
var result = bluetooth.pairDevice("00:00:00:00:00:00"); let result = bluetooth.pairDevice("00:00:00:00:00:00");
console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result)); console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result));
expect(result).assertFalse(); expect(result).assertFalse();
done(); done();
...@@ -166,7 +144,6 @@ describe('bluetoothhostTest', function() { ...@@ -166,7 +144,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001
* @tc.name testClassicGetLocalName * @tc.name testClassicGetLocalName
* @tc.desc Test ClassicGetLocalName api. * @tc.desc Test ClassicGetLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -174,7 +151,7 @@ describe('bluetoothhostTest', function() { ...@@ -174,7 +151,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001', 0, async function (done) {
console.info('[bluetooth_js] get localName start'); console.info('[bluetooth_js] get localName start');
await tryToEnableBt(); await tryToEnableBt();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName)); console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName));
expect(localName).assertEqual('bluetooth_test'); expect(localName).assertEqual('bluetooth_test');
done(); done();
...@@ -184,7 +161,6 @@ describe('bluetoothhostTest', function() { ...@@ -184,7 +161,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicSetBluetoothScanMode * @tc.name testClassicSetBluetoothScanMode
* @tc.desc Test ClassicSetBluetoothScanMode api. * @tc.desc Test ClassicSetBluetoothScanMode api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -192,7 +168,7 @@ describe('bluetoothhostTest', function() { ...@@ -192,7 +168,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) {
console.info('[bluetooth_js] set scan mode start'); console.info('[bluetooth_js] set scan mode start');
await tryToEnableBt(); await tryToEnableBt();
var result = bluetooth.setBluetoothScanMode(1,10000); let result = bluetooth.setBluetoothScanMode(1,10000);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER) !=result ); expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER) !=result );
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result); expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result ); expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result );
...@@ -204,7 +180,6 @@ describe('bluetoothhostTest', function() { ...@@ -204,7 +180,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicGetBluetoothScanMode * @tc.name testClassicGetBluetoothScanMode
* @tc.desc Test ClassicGetBluetoothScanMode api. * @tc.desc Test ClassicGetBluetoothScanMode api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -212,9 +187,9 @@ describe('bluetoothhostTest', function() { ...@@ -212,9 +187,9 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) {
console.info('[bluetooth_js] get scan mode start'); console.info('[bluetooth_js] get scan mode start');
await tryToEnableBt(); await tryToEnableBt();
var result = bluetooth.setBluetoothScanMode(1,10000); let result = bluetooth.setBluetoothScanMode(1,10000);
expect(result).assertEqual(true); expect(result).assertEqual(true);
var scanMode = bluetooth.getBluetoothScanMode(); let scanMode = bluetooth.getBluetoothScanMode();
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode)); console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode));
expect(scanMode).assertEqual(1); expect(scanMode).assertEqual(1);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_NONE != scanMode); expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_NONE != scanMode);
...@@ -230,7 +205,6 @@ describe('bluetoothhostTest', function() { ...@@ -230,7 +205,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
* @tc.name testClassicGetBtConnectionState * @tc.name testClassicGetBtConnectionState
* @tc.desc Test ClassicGetBtConnectionState api. * @tc.desc Test ClassicGetBtConnectionState api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -238,7 +212,7 @@ describe('bluetoothhostTest', function() { ...@@ -238,7 +212,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get connection state start'); console.info('[bluetooth_js] get connection state start');
await tryToEnableBt(); await tryToEnableBt();
var connState = bluetooth.getBtConnectionState(); let connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState)); console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED); expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTING!= connState ); expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTING!= connState );
...@@ -251,7 +225,6 @@ describe('bluetoothhostTest', function() { ...@@ -251,7 +225,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery * @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api. * @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -269,7 +242,6 @@ describe('bluetoothhostTest', function() { ...@@ -269,7 +242,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_BLUETOOTH_DISCOVERY_0001 * @tc.number SUB_COMMUNACATION_bluetooth_STOP_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStopBluetoothDiscovery * @tc.name testClassicStopBluetoothDiscovery
* @tc.desc Test ClassicStopBluetoothDiscovery api. * @tc.desc Test ClassicStopBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -287,7 +259,6 @@ describe('bluetoothhostTest', function() { ...@@ -287,7 +259,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001
* @tc.name testClassicGetPairedDevices * @tc.name testClassicGetPairedDevices
* @tc.desc Test ClassicGetPairedDevices api. * @tc.desc Test ClassicGetPairedDevices api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -295,7 +266,7 @@ describe('bluetoothhostTest', function() { ...@@ -295,7 +266,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001', 0, async function (done) {
console.info('[bluetooth_js] get paired devices start'); console.info('[bluetooth_js] get paired devices start');
await tryToEnableBt(); await tryToEnableBt();
var devices = bluetooth.getPairedDevices(); let devices = bluetooth.getPairedDevices();
console.info('[bluetooth_js] get paired devices:' + JSON.stringify(devices) +'length:' + devices.length); console.info('[bluetooth_js] get paired devices:' + JSON.stringify(devices) +'length:' + devices.length);
expect(devices.length).assertEqual(0); expect(devices.length).assertEqual(0);
done(); done();
...@@ -306,7 +277,6 @@ describe('bluetoothhostTest', function() { ...@@ -306,7 +277,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen * @tc.name testSppListen
* @tc.desc Test SppListen api by callback. * @tc.desc Test SppListen api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -332,7 +302,6 @@ describe('bluetoothhostTest', function() { ...@@ -332,7 +302,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_ACCEPT_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_ACCEPT_0001
* @tc.name testSppAccept * @tc.name testSppAccept
* @tc.desc Test SppAccept api by callbck. * @tc.desc Test SppAccept api by callbck.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -355,7 +324,6 @@ describe('bluetoothhostTest', function() { ...@@ -355,7 +324,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CLOSE_SERVER_SOCKET_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_CLOSE_SERVER_SOCKET_0001
* @tc.name testSppCloseServerSocket * @tc.name testSppCloseServerSocket
* @tc.desc Test SppCloseServerSocket api. * @tc.desc Test SppCloseServerSocket api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -373,7 +341,6 @@ describe('bluetoothhostTest', function() { ...@@ -373,7 +341,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CONNECT_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_CONNECT_0001
* @tc.name testSppConnect * @tc.name testSppConnect
* @tc.desc Test SppConnect api by callback. * @tc.desc Test SppConnect api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -398,7 +365,6 @@ describe('bluetoothhostTest', function() { ...@@ -398,7 +365,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_WRITE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SPP_WRITE_0001
* @tc.name testSppWrite * @tc.name testSppWrite
* @tc.desc Test SppWrite api. * @tc.desc Test SppWrite api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -419,7 +385,6 @@ describe('bluetoothhostTest', function() { ...@@ -419,7 +385,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_NAME_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_NAME_0001
* @tc.name testGetRemoteDeviceName * @tc.name testGetRemoteDeviceName
* @tc.desc Test GetRemoteDeviceName api. * @tc.desc Test GetRemoteDeviceName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -437,7 +402,6 @@ describe('bluetoothhostTest', function() { ...@@ -437,7 +402,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_CLASS_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_CLASS_0001
* @tc.name testGetRemoteDeviceClass * @tc.name testGetRemoteDeviceClass
* @tc.desc Test GetRemoteDeviceClass api. * @tc.desc Test GetRemoteDeviceClass api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -457,7 +421,6 @@ describe('bluetoothhostTest', function() { ...@@ -457,7 +421,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_CANCEL_PAIRED_DEV_0001 * @tc.number SUB_COMMUNACATION_bluetooth_CANCEL_PAIRED_DEV_0001
* @tc.name testCancelPairedDevice * @tc.name testCancelPairedDevice
* @tc.desc Test CancelPairedDevice api. * @tc.desc Test CancelPairedDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -476,18 +439,17 @@ describe('bluetoothhostTest', function() { ...@@ -476,18 +439,17 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var state = bluetooth.getState(); let state = bluetooth.getState();
expect(true).assertTrue(JSON.stringify(bluetooth.BluetoothState.STATE_ON)==state); expect(true).assertTrue(JSON.stringify(bluetooth.BluetoothState.STATE_ON)==state);
var name = bluetooth.setLocalName(''); let name = bluetooth.setLocalName('');
expect(name).assertFalse(); expect(name).assertFalse();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(localName==name); expect(true).assertTrue(localName==name);
console.info('[bluetooth_js] getLocalName result1 = ' + JSON.stringify(localName)); console.info('[bluetooth_js] getLocalName result1 = ' + JSON.stringify(localName));
done(); done();
...@@ -498,15 +460,14 @@ describe('bluetoothhostTest', function() { ...@@ -498,15 +460,14 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
var name = bluetooth.setLocalName(); let name = bluetooth.setLocalName();
console.info('[bluetooth_js] getName result2 = '+ JSON.stringify(localName) + console.info('[bluetooth_js] getName result2 = '+ JSON.stringify(localName) +
'setName result2 =' + JSON.stringify(name)); 'setName result2 =' + JSON.stringify(name));
expect(name).assertNull(); expect(name).assertNull();
...@@ -517,16 +478,15 @@ describe('bluetoothhostTest', function() { ...@@ -517,16 +478,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.NUM_TEST); let name = bluetooth.setLocalName(Btname.NUM_TEST);
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.NUM_TEST == JSON.stringify(localName)); expect(true).assertTrue(Btname.NUM_TEST == JSON.stringify(localName));
done(); done();
}) })
...@@ -535,16 +495,15 @@ describe('bluetoothhostTest', function() { ...@@ -535,16 +495,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.NUM_TEST1); let name = bluetooth.setLocalName(Btname.NUM_TEST1);
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.NUM_TEST1 == JSON.stringify(localName)); expect(true).assertTrue(Btname.NUM_TEST1 == JSON.stringify(localName));
done(); done();
}) })
...@@ -553,16 +512,15 @@ describe('bluetoothhostTest', function() { ...@@ -553,16 +512,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.LETTERS_TEST); let name = bluetooth.setLocalName(Btname.LETTERS_TEST);
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.LETTERS_TEST == JSON.stringify(localName)); expect(true).assertTrue(Btname.LETTERS_TEST == JSON.stringify(localName));
done(); done();
}) })
...@@ -572,16 +530,15 @@ describe('bluetoothhostTest', function() { ...@@ -572,16 +530,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.CHINESES_TEST); let name = bluetooth.setLocalName(Btname.CHINESES_TEST);
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.CHINESES_TEST == JSON.stringify(localName)); expect(true).assertTrue(Btname.CHINESES_TEST == JSON.stringify(localName));
done(); done();
}) })
...@@ -591,17 +548,16 @@ describe('bluetoothhostTest', function() { ...@@ -591,17 +548,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.SYMBOL_TEST); let name = bluetooth.setLocalName(Btname.SYMBOL_TEST);
console.info('[bluetooth_js] setLocalName result7 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result7 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.SYMBOL_TEST == JSON.stringify(localName)); expect(true).assertTrue(Btname.SYMBOL_TEST == JSON.stringify(localName));
done(); done();
}) })
...@@ -610,17 +566,16 @@ describe('bluetoothhostTest', function() { ...@@ -610,17 +566,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES); let name = bluetooth.setLocalName(Btname.MIXES);
console.info('[bluetooth_js] setLocalName result8 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result8 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES == JSON.stringify(localName));
done(); done();
}) })
...@@ -629,17 +584,16 @@ describe('bluetoothhostTest', function() { ...@@ -629,17 +584,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES2); let name = bluetooth.setLocalName(Btname.MIXES2);
console.info('[bluetooth_js] setLocalName result9 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result9 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES2 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES2 == JSON.stringify(localName));
done(); done();
}) })
...@@ -648,17 +602,16 @@ describe('bluetoothhostTest', function() { ...@@ -648,17 +602,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES3); let name = bluetooth.setLocalName(Btname.MIXES3);
console.info('[bluetooth_js] setLocalName result10 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result10 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES3 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES3 == JSON.stringify(localName));
done(); done();
}) })
...@@ -667,17 +620,16 @@ describe('bluetoothhostTest', function() { ...@@ -667,17 +620,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES4); let name = bluetooth.setLocalName(Btname.MIXES4);
console.info('[bluetooth_js] setLocalName result11 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result11 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES4 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES4 == JSON.stringify(localName));
done(); done();
}) })
...@@ -686,17 +638,16 @@ describe('bluetoothhostTest', function() { ...@@ -686,17 +638,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES5); let name = bluetooth.setLocalName(Btname.MIXES5);
console.info('[bluetooth_js] setLocalName result12 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result12 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES5 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES5 == JSON.stringify(localName));
done(); done();
}) })
...@@ -705,17 +656,16 @@ describe('bluetoothhostTest', function() { ...@@ -705,17 +656,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES6); let name = bluetooth.setLocalName(Btname.MIXES6);
console.info('[bluetooth_js] setLocalName result13 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result13 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES6 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES6 == JSON.stringify(localName));
done(); done();
}) })
...@@ -725,17 +675,16 @@ describe('bluetoothhostTest', function() { ...@@ -725,17 +675,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014
* @tc.name testsetLocalName * @tc.name testsetLocalName
* @tc.desc Test setLocalName api. * @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014', 0, async function (done) {
await tryToEnableBt(); await tryToEnableBt();
var name = bluetooth.setLocalName(Btname.MIXES7); let name = bluetooth.setLocalName(Btname.MIXES7);
console.info('[bluetooth_js] setLocalName result14 = '+ JSON.stringify(name)); console.info('[bluetooth_js] setLocalName result14 = '+ JSON.stringify(name));
expect(name).assertTrue(); expect(name).assertTrue();
var localName = bluetooth.getLocalName(); let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES7 == JSON.stringify(localName)); expect(true).assertTrue(Btname.MIXES7 == JSON.stringify(localName));
done(); done();
}) })
...@@ -746,7 +695,6 @@ describe('bluetoothhostTest', function() { ...@@ -746,7 +695,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DISABLE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DISABLE_0001
* @tc.name testdisablebluetooth * @tc.name testdisablebluetooth
* @tc.desc Test disablebluetooth api. * @tc.desc Test disablebluetooth api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
...@@ -757,10 +705,9 @@ describe('bluetoothhostTest', function() { ...@@ -757,10 +705,9 @@ describe('bluetoothhostTest', function() {
let disable = bluetooth.disableBluetooth(); let disable = bluetooth.disableBluetooth();
console.info('[bluetooth_js] disable:' + JSON.stringify(disable)); console.info('[bluetooth_js] disable:' + JSON.stringify(disable));
expect(disable).assertTrue(); expect(disable).assertTrue();
var state = bluetooth.getState(); let state = bluetooth.getState();
console.info('[bluetooth_js] bt state:' + JSON.stringify(state)); console.info('[bluetooth_js] bt state:' + JSON.stringify(state));
done(); done();
}) })
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册