提交 8155db36 编写于 作者: Q quanli

master--beta2

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 a3e04919
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bluetoothsys from '@system.bluetooth';
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
......@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let gattServer = bluetooth.BLE.createGattServer();
let stop = gattServer.stopAdvertising();
expect(stop).assertNull();
expect(true).assertTrue();
done();
})
......@@ -790,7 +790,7 @@ describe('bluetoothhostTest', function() {
let gattServer = bluetooth.BLE.createGattServer()
let result = gattServer.close();
console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result));
expect(result).assertTrue();
expect(true).assertTrue();
}catch(error){
console.info("[bluetooth_js] GattserverClose err:" + JSON.stringify(error));
expect(null).assertFail();
......@@ -839,4 +839,64 @@ describe('bluetoothhostTest', function() {
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
* @tc.name testsubscribeBLEFound
* @tc.desc Test subscribeBLEFound api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001', 0, async function (done) {
console.info('[bluetooth_js] subscribeBLEFound start');
tryToEnableBt();
setTimeout(async ()=>{
bluetoothsys.startBLEScan({
interval:0,
success() {
bluetoothsys.subscribeBLEFound({
success(data) {
console.log('[bluetooth_js] bluetooth.subscribeBLEFound1 success.');
const [device] = data.devices;
console.log('[bluetooth_js] devices:'+ JSON.stringify(data.devices) + 'length:' + data.devices.length);
expect(true).assertTrue(data.devices.length >=0);
for (let i = 0; i < data.devices.length; i++) {
console.log(`subscribeBLEFound device, addrType: ${data.devices[i].addrType}`);
console.log(`subscribeBLEFound device, addr: ${data.devices[i].addr}`);
console.log(`subscribeBLEFound device, rssi: ${data.devices[i].rssi}`);
console.log(`subscribeBLEFound device, txpower: ${data.devices[i].txpower}`);
console.log(`subscribeBLEFound device, data: ${data.devices[i].data}`);
}
},
fail(code, data) {
console.log('[bluetooth_js] subscribeBLEFound1 failed code:'+ code + 'data:'+data);
}
});
sleep(3000);
bluetoothsys.unsubscribeBLEFound();
bluetoothsys.stopBLEScan({
success() {
console.log('[bluetooth_js] stopBLEScan success.');
},
fail(data, code) {
console.log('[bluetooth_js] stopBLEScan failed code:'+ code + 'data:'+data);
},
complete() {
console.log('[bluetooth_js] stopBLEScan complete.');
}
});
},
fail(code, data) {
console.log('[bluetooth_js] startBLEScan1 failed code:'+ code + 'data:'+data);
},
complete() {
console.log('[bluetooth_js] startBLEScan1 complete.');
}
});
},1000);
done();
})
})
......@@ -106,6 +106,18 @@ let MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C
};
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_LOW_LATENCY : 2,
};
let MatchMode=
{
MATCH_MODE_AGGRESSIVE : 1,
MATCH_MODE_STICKY : 2,
};
describe('bluetoothhostTest', function() {
......@@ -195,17 +207,17 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] discovery1 start');
await sleep(1000);
await tryToEnableBt();
bluetooth.on("bluetoothDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
function onReceiveEvent(data)
{
console.info('[bluetooth_js] Device' + JSON.stringify(data)+ 'length' + data.length)
expect(true).assertTrue(data.length >= 0);
bluetooth.off('bluetoothDeviceFind', result => {
console.info("[bluetooth_js] bluetoothDeviceFind off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done();
})
}
bluetooth.on("bluetoothDeviceFind", onReceiveEvent)
bluetooth.startBluetoothDiscovery();
await sleep(1000);
bluetooth.off('bluetoothDeviceFind');
bluetooth.stopBluetoothDiscovery();
done();
})
......@@ -221,23 +233,21 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan1 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result1 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan1 -> " + JSON.stringify(result1));
done();
});
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result1 = '+JSON.stringify(data));
except(true).assertTrue(data.length>0);
}
bluetooth.BLE.on("BLEDeviceFind",onReceiveEvent);
bluetooth.BLE.startBLEScan([{}]);
await sleep(1000);
console.info('[bluetooth_js] BLE SCAN OFF01');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0002
* @tc.name testClassicStartBLEScan
......@@ -250,19 +260,17 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan2 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result2 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan2 -> " + JSON.stringify(result1));
done();
});
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result2 = '+JSON.stringify(data ));
except(true).assertTrue(data.length>0);
}
bluetooth.BLE.startBLEScan([{deviceId:"00:00:00:00:00:00"}]);
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan([{deviceId:"00:11:22:33:44:55"}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off2');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -279,19 +287,17 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan3 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off3:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan3 -> " + JSON.stringify(result1));
done();
});
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result3 = '+JSON.stringify(data));
except(true).assertTrue(data.length>0);
}
bluetooth.BLE.startBLEScan([{name:"bluetooth_test"}]);
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan([{name:"blue_test"}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off3');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -308,19 +314,15 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan4 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result4 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off4:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan4 -> " + JSON.stringify(result1));
done();
});
}
expect(true).assertTrue(data.length >= 0);}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan([{serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan device find off4:');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -337,26 +339,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan5 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result5 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off5:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan5 -> " + JSON.stringify(result1));
done();
});
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
dutyMode: ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
await sleep(1000);
bluetooth.BLE.off("BLEDeviceFind");
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -373,26 +373,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan6 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result6 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off6:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan6 -> " + JSON.stringify(result1));
done();
});
function onReceiveEvent(data)
{
consle.info('[bluetooth_js] BLE scan device find result6 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_BALANCED,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
dutyMode: ScanDuty.SCAN_MODE_BALANCED,
matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -408,26 +406,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan7 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result7 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off7:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan7 -> " + JSON.stringify(result1));
done();
});
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
dutyMode: ScanDuty.SCAN_MODE_LOW_LATENCY,
matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind');
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -443,29 +439,27 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan8 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result8 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off8:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan8 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.on("BLEDeviceFind",onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 0,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_STICKY,
dutyMode: ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: MatchMode.MATCH_MODE_STICKY,
}
);
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind');
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0009
* @tc.name testClassicStartBLEScan
......@@ -508,6 +502,145 @@ describe('bluetoothhostTest', function() {
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011', 0, async function (done) {
console.info('[bluetooth_js] BLE scan11 test start');
await sleep(1000);
await tryToEnableBt();
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result11 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan([{
serviceUuid:"00001812-0000-1000-8000-00805F9B34FB",
serviceUuidMask:"0000FFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off11 ');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012', 0, async function (done) {
console.info('[bluetooth_js] BLE scan14 test start');
await sleep(1000);
await tryToEnableBt();
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result12 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan([{
serviceSolicitationUuid:"00000101-0000-1000-8000-00805F9B34FB",
serviceSolicitationUuidMask:"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off12 ');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013', 0, async function (done) {
console.info('[bluetooth_js] BLE scan13 test start');
await sleep(1000);
await tryToEnableBt();
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result13 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
const serviceDataArrayBuffer = new ArrayBuffer(1);
const serviceDataMaskArrayBuffer = new ArrayBuffer(1);
const serviceDataValue = new Uint8Array(serviceDataArrayBuffer);
const serviceDataMaskValue = new Uint8Array(serviceDataMaskArrayBuffer);
serviceDataValue[0] = '0xFF';
serviceDataMaskValue[0] = '0xFF';
bluetooth.BLE.startBLEScan([{
serviceData:serviceDataValue,
serviceDataMask:serviceDataMaskValue,
}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off13 ');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014', 0, async function (done) {
console.info('[bluetooth_js] BLE scan18 test start');
await sleep(1000);
await tryToEnableBt();
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLE scan device find result14 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length > 0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
const manufactureDataArrayBuffer = new ArrayBuffer(29);
const manufactureDataMaskArrayBuffer = new ArrayBuffer(29);
const manufactureDataValue = new Uint8Array(manufactureDataArrayBuffer);
const manufactureDataMaskValue = new Uint8Array(manufactureDataMaskArrayBuffer);
for (let i = 0; i < 29; i++) {
manufactureDataValue[i] = '0xFF';
}
for (let i = 0; i < 29; i++) {
manufactureDataMaskValue[i] = '0xFF';
}
bluetooth.BLE.startBLEScan([{
manufactureData:manufactureDataValue,
manufactureDataMask:manufactureDataMaskValue,
}]);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off14 ');
bluetooth.BLE.off('BLEDeviceFind');
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
......@@ -528,7 +661,7 @@ describe('bluetoothhostTest', function() {
let enable3 = bluetooth.pairDevice("00:00:00:00:00:00")
bluetooth.BLE.off('pinRequired', result => {
console.info("[bluetooth_js] pinRequired off:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
expect(true).assertEqual(true);
done();
});
})
......@@ -551,12 +684,18 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null);
done();
});
let enable4 = bluetooth.pairDevice("00:00:00:00:00:00")
expect(bluetooth.BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue();
let BondState=
{
BOND_STATE_INVALID : 0,
BOND_STATE_BONDING : 1,
BOND_STATE_BONDED : 2
};
expect(BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(BondState.BOND_STATE_BONDED == 2).assertTrue();
bluetooth.BLE.off('bondStateChange', result => {
expect(true).assertEqual(result ==null);
expect(true).assertEqual(true);
done();
});
})
......@@ -621,7 +760,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] characteristicRead test1 start');
gattServer.off('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -671,7 +810,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] characteristicWrite test1 start');
gattServer.off('characteristicWrite', function (data) {
console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data));
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -705,7 +844,7 @@ describe('bluetoothhostTest', function() {
try {
console.info('[bluetooth_js] descriptorReadOff test start ...');
gattServer.off('descriptorRead', function (data) {
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -740,7 +879,7 @@ describe('bluetoothhostTest', function() {
try {
console.info('[bluetooth_js] descriptorWriteOff test start ...');
gattServer.off('descriptorWrite', function (data) {
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -773,7 +912,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ConnectStateChangeOff test start ...');
gattServer.off('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -805,7 +944,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLECharacteristicChangeOff test start');
gattClient.off('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -838,7 +977,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLEConnectionStateChangeOff test start');
gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......@@ -870,7 +1009,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] sppReadOff test start ...');
bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
expect(true).assertEqual(result ==null);
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
......
......@@ -223,6 +223,25 @@ describe('bluetoothhostTest_host_2', function () {
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001', 0, async function (done) {
await tryToEnableBt();
console.info('[bluetooth_js] tethering test start');
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let ret = panProfile.setTethering(false);
console.info("[bluetooth_js] setTethering false result "+JSON.stringify(ret));
let result = panProfile.isTetheringOn();
console.info("[bluetooth_js] setTethering getTetheringOn result1 false== "+JSON.stringify(result));
expect(result).assertFalse();
done();
})
})
......@@ -97,13 +97,23 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let state = bluetooth.getState();
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
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();
let BluetoothState=
{
STATE_OFF : 0,
STATE_TURNING_ON : 1,
STATE_ON : 2,
STATE_TURNING_OFF : 3,
STATE_BLE_TURNING_ON : 4,
STATE_BLE_ON : 5,
STATE_BLE_TURNING_OFF : 6,
} ;
expect(state).assertEqual(BluetoothState.STATE_ON);
expect(BluetoothState.STATE_OFF != state).assertTrue();
expect(BluetoothState.STATE_TURNING_ON != state).assertTrue();
expect(BluetoothState.STATE_TURNING_OFF != state).assertTrue();
expect(BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue();
expect(BluetoothState.STATE_BLE_ON != state).assertTrue();
expect(BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue();
done();
})
......@@ -170,10 +180,16 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) {
console.info('[bluetooth_js] set scan mode start');
await tryToEnableBt();
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_BALANCED : 2,
};
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_BALANCED) != result);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result );
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_LOW_POWER) !=result );
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_BALANCED) != result);
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_BALANCED) != result );
expect(result).assertEqual(true);
done();
})
......@@ -191,15 +207,24 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000);
expect(result).assertEqual(true);
let scanMode = bluetooth.getBluetoothScanMode();
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode));
expect(scanMode).assertEqual(1);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_NONE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanMode);
let ScanMode=
{
SCAN_MODE_NONE : 0,
SCAN_MODE_CONNECTABLE : 1,
SCAN_MODE_GENERAL_DISCOVERABLE : 2,
SCAN_MODE_LIMITED_DISCOVERABLE : 3,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE : 4,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE : 5,
};
let scanModeResult = bluetooth.getBluetoothScanMode();
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanModeResult));
expect(scanModeResult).assertEqual(1);
expect(true).assertTrue(ScanMode.SCAN_MODE_NONE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanModeResult);
done();
})
......@@ -214,12 +239,19 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get connection state start');
await tryToEnableBt();
let ProfileConnectionState=
{
STATE_CONNECTING : 1,
STATE_CONNECTED : 2,
STATE_DISCONNECTED : 0,
STATE_DISCONNECTING : 3,
};
let connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(bluetooth.ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_DISCONNECTING!= connState );
expect(connState).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_DISCONNECTING!= connState );
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册