提交 a8fb656e 编写于 作者: H hwx951322

changed enum

Signed-off-by: Nhwx951322 <huangyuan39@huawei.com>
上级 672a7af9
......@@ -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();
})
......
......@@ -214,7 +214,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertTrue(data.length >= 0);
bluetooth.off('bluetoothDeviceFind', result => {
console.info("[bluetooth_js] bluetoothDeviceFind off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
expect(true).assertEqual(true);
done();
})
}
......@@ -351,8 +351,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
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);
......@@ -375,26 +375,23 @@ 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',onReceiveEvent);
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -411,26 +408,23 @@ 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', onReceiveEvent);
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -447,26 +441,24 @@ 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',onReceiveEvent);
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done();
})
......@@ -533,7 +525,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();
});
})
......@@ -556,12 +548,18 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null);
done();
});
let BondState=
{
BOND_STATE_INVALID : 0,
BOND_STATE_BONDING : 1,
BOND_STATE_BONDED : 2
};
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();
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();
});
})
......@@ -626,7 +624,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();
......@@ -676,7 +674,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();
......@@ -710,7 +708,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();
......@@ -745,7 +743,7 @@ describe('bluetoothhostTest', function() {
try {
console.info('[bluetooth_js] descriptorWriteOff test start ...');
gattServer.off('descriptorWrite', function (data) {
expect(true).assertEqual(data ==null);
expect(true).assertTrue();
});
}catch(e) {
expect(null).assertFail();
......@@ -778,7 +776,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).assertTrue();
});
}catch(e) {
expect(null).assertFail();
......@@ -810,7 +808,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).assertTrue();
});
}catch(e) {
expect(null).assertFail();
......@@ -843,7 +841,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();
......@@ -875,7 +873,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();
......
......@@ -97,14 +97,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] getState start');
await tryToEnableBt();
let state = bluetooth.getState();
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
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,
} ;
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();
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();
})
......@@ -172,9 +182,15 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] set scan mode start');
await tryToEnableBt();
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 );
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_BALANCED : 2,
};
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();
})
......@@ -192,15 +208,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 != scanMode);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE != scanMode);
expect(true).assertTrue(ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanMode);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanMode);
done();
})
......@@ -215,12 +240,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.
先完成此消息的编辑!
想要评论请 注册