提交 d4a9e27f 编写于 作者: Q q00313334

quanli1@huawei.com

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 92ffde9b
......@@ -100,10 +100,10 @@ describe('bluetoothhostTest', function() {
default:
console.info('[bluetooth_js] enable success');
}
await sleep(2000);
await sleep(3000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
console.info('bluetooth enable done');
expect(state).assertEqual(2);
done();
})
......@@ -148,20 +148,60 @@ describe('bluetoothhostTest', function() {
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_STOP_BLESCAN_0001
* @tc.name testClassicStopBLEScan
* @tc.desc Test ClassicStopBLEScan api.
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_START_ADVERTISING_0001
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_ble_stop_scan', 0, function () {
console.info('[bluetooth_js] BLE stop scan start');
var result = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result));
expect(result).assertNull();
console.info('[bluetooth_js] BLE stop scan end');
it('bluetooth_ble_start_advertising', 0, async function (done) {
console.info('BLE advertising start');
var manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2;
manufactureValueBuffer[2] = 3;
manufactureValueBuffer[3] = 4;
var serviceValueBuffer = new Uint8Array(4);
serviceValueBuffer[0] = 4;
serviceValueBuffer[1] = 6;
serviceValueBuffer[2] = 7;
serviceValueBuffer[3] = 8;
console.info('manufactureValueBuffer = '+ JSON.stringify(manufactureValueBuffer))
console.info('serviceValueBuffer = '+ JSON.stringify(serviceValueBuffer))
let promise = new Promise((resolve) => {
var gattServer = bluetooth.BLE.createGattServer()
gattServer.startAdvertising({
interval:150,
txPower:60,
connectable:true,
},{
serviceUuids:["12"],
manufactureData:[{
manufactureId:4567,
manufactureValue:manufactureValueBuffer.buffer
}],
serviceData:[{
serviceUuid:"1234",
serviceValue:serviceValueBuffer.buffer
}],
},{
serviceUuids:["12"],
manufactureData:[{
manufactureId:1789,
manufactureValue:manufactureValueBuffer.buffer
}],
serviceData:[{
serviceUuid:"1794",
serviceValue:serviceValueBuffer.buffer
}],
});
resolve()
})
await promise.then(done)
done();
})
/**
......@@ -180,6 +220,25 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE stop advertising end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_connect', 0, function () {
console.info('[bluetooth_js] gatt connect start');
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.connect();
console.info('[bluetooth_js] gatt connect ret : ' + ret);
expect(ret).assertEqual(false);
console.info('[bluetooth_js] gatt connect end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEVICE_NAME_PROMISE_0001
* @tc.name testGetDeviceName
......@@ -251,24 +310,6 @@ describe('bluetoothhostTest', function() {
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_gatt_connect', 0, function () {
console.info('[bluetooth_js] gatt connect start');
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.connect();
console.info('[bluetooth_js] gatt connect ret : ' + ret);
expect(ret).assertEqual(true);
console.info('[bluetooth_js] gatt connect end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_CALLBACK_0001
......@@ -667,7 +708,6 @@ describe('bluetoothhostTest', function() {
}
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
......@@ -685,7 +725,6 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] gatt disconnect end');
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose
......@@ -713,6 +752,4 @@ describe('bluetoothhostTest', function() {
}
})
})
......@@ -86,9 +86,10 @@ describe('bluetoothhostTest', function() {
default:
console.info('[bluetooth_js] enable success');
}
await sleep(2000);
await sleep(3000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
expect(state).assertEqual(2);
await bluetooth.off('stateChange', result => {
console.info("stateChange off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
......@@ -138,24 +139,30 @@ describe('bluetoothhostTest', function() {
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_ble_start_scan_without_param', 0, async function (done) {
it('bluetooth_ble_start_scan_without_param_001', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start without scan options start');
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On1 = '+ JSON.stringify(state));
await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data))
expect(data.length).assertLarger(0);
done();
}
bluetooth.BLE.startBLEScan([{}]);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
});
console.info('[bluetooth_js] BLE scan start end');
let promise = new Promise((resolve) => {
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data));
expect(data.length).assertLarger(0);
done();
}
bluetooth.BLE.startBLEScan([{}]);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
});
var result = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result));
console.info('[bluetooth_js] BLE scan start end');
resolve()
})
await promise.then(done)
done();
})
......@@ -435,7 +442,6 @@ describe('bluetoothhostTest', function() {
console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data));
console.info("[bluetooth_js] desWriOn data:" + data);
expect(true).assertEqual(data !=null);
console.info('[bluetooth_js] desWrite callback data ->');
console.info('[bluetooth_js] desWriOn deviceId: ' + data.deviceId);
console.info('[bluetooth_js] desWriOn transId: ' + data.transId);
......@@ -635,4 +641,3 @@ describe('bluetoothhostTest', function() {
})
......@@ -93,9 +93,10 @@ describe('bluetoothhostTest', function() {
default:
console.info('[bluetooth_js] enable success');
}
await sleep(2000);
await sleep(3000);
var state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
expect(state).assertEqual(2);
console.info('[bluetooth_js]state on:' + JSON.stringify(bluetooth.BluetoothState.STATE_ON));
console.info('[bluetooth_js]off :' + JSON.stringify(bluetooth.BluetoothState.STATE_OFF));
console.info('[bluetooth_js] turning on :'
......@@ -869,7 +870,6 @@ describe('bluetoothhostTest', function() {
* @tc.type Function
* @tc.level Level 2
*/
it('bluetooth_classic_disable_bluetooth', 0, function () {
console.info('[bluetooth_js] disable test start');
let disable = bluetooth.disableBluetooth();
......@@ -881,4 +881,3 @@ describe('bluetoothhostTest', function() {
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册