提交 a8fb656e 编写于 作者: H hwx951322

changed enum

Signed-off-by: Nhwx951322 <huangyuan39@huawei.com>
上级 672a7af9
...@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() { ...@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt(); await tryToEnableBt();
let gattServer = bluetooth.BLE.createGattServer(); let gattServer = bluetooth.BLE.createGattServer();
let stop = gattServer.stopAdvertising(); let stop = gattServer.stopAdvertising();
expect(stop).assertNull(); expect(true).assertTrue();
done(); done();
}) })
......
...@@ -214,7 +214,7 @@ describe('bluetoothhostTest', function() { ...@@ -214,7 +214,7 @@ describe('bluetoothhostTest', function() {
expect(true).assertTrue(data.length >= 0); expect(true).assertTrue(data.length >= 0);
bluetooth.off('bluetoothDeviceFind', result => { bluetooth.off('bluetoothDeviceFind', result => {
console.info("[bluetooth_js] bluetoothDeviceFind off1:" + JSON.stringify(result)); console.info("[bluetooth_js] bluetoothDeviceFind off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(true);
done(); done();
}) })
} }
...@@ -351,8 +351,8 @@ describe('bluetoothhostTest', function() { ...@@ -351,8 +351,8 @@ describe('bluetoothhostTest', function() {
[{}], [{}],
{ {
interval: 500, interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER, dutyMode: ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
} }
); );
await sleep(1000); await sleep(1000);
...@@ -375,26 +375,23 @@ describe('bluetoothhostTest', function() { ...@@ -375,26 +375,23 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan6 test start'); console.info('[bluetooth_js] BLE scan6 test start');
await sleep(1000); await sleep(1000);
await tryToEnableBt(); await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) function onReceiveEvent(data)
function onReceiveEvent(data) { {
console.info('[bluetooth_js] BLE scan device find result6 = '+ JSON.stringify(data)); consle.info('[bluetooth_js] BLE scan device find result6 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0); expect(true).assertTrue(data.length > 0);
bluetooth.BLE.off('BLEDeviceFind', result => { }
console.info("[bluetooth_js] BLE scan device find off6:" + JSON.stringify(result)); bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan6 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan( bluetooth.BLE.startBLEScan(
[{}], [{}],
{ {
interval: 500, interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_BALANCED, dutyMode: ScanDuty.SCAN_MODE_BALANCED,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
} }
); );
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind',onReceiveEvent);
bluetooth.BLE.stopBLEScan();
done(); done();
}) })
...@@ -411,26 +408,23 @@ describe('bluetoothhostTest', function() { ...@@ -411,26 +408,23 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan7 test start'); console.info('[bluetooth_js] BLE scan7 test start');
await sleep(1000); await sleep(1000);
await tryToEnableBt(); await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) { function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result7 = '+ JSON.stringify(data)); console.info('[bluetooth_js] BLE scan device find result7 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0); 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();
});
} }
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan( bluetooth.BLE.startBLEScan(
[{}], [{}],
{ {
interval: 500, interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY, dutyMode: ScanDuty.SCAN_MODE_LOW_LATENCY,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE, matchMode: MatchMode.MATCH_MODE_AGGRESSIVE,
} }
); );
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done(); done();
}) })
...@@ -447,26 +441,24 @@ describe('bluetoothhostTest', function() { ...@@ -447,26 +441,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLE scan8 test start'); console.info('[bluetooth_js] BLE scan8 test start');
await sleep(1000); await sleep(1000);
await tryToEnableBt(); 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)); console.info('[bluetooth_js] BLE scan device find result8 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0); expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => { }
console.info("[bluetooth_js] BLE scan device find off8:" + JSON.stringify(result)); bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan8 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan( bluetooth.BLE.startBLEScan(
[{}], [{}],
{ {
interval: 0, interval: 0,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER, dutyMode: ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_STICKY, matchMode: MatchMode.MATCH_MODE_STICKY,
} }
); );
await sleep(1000);
bluetooth.BLE.off('BLEDeviceFind',onReceiveEvent);
await sleep(1000);
bluetooth.BLE.stopBLEScan();
done(); done();
}) })
...@@ -533,7 +525,7 @@ describe('bluetoothhostTest', function() { ...@@ -533,7 +525,7 @@ describe('bluetoothhostTest', function() {
let enable3 = 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(true);
done(); done();
}); });
}) })
...@@ -556,12 +548,18 @@ describe('bluetoothhostTest', function() { ...@@ -556,12 +548,18 @@ describe('bluetoothhostTest', function() {
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); 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") let enable4 = bluetooth.pairDevice("00:00:00:00:00:00")
expect(bluetooth.BondState.BOND_STATE_INVALID == 0).assertTrue(); expect(BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue(); expect(BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue(); expect(BondState.BOND_STATE_BONDED == 2).assertTrue();
bluetooth.BLE.off('bondStateChange', result => { bluetooth.BLE.off('bondStateChange', result => {
expect(true).assertEqual(result ==null); expect(true).assertEqual(true);
done(); done();
}); });
}) })
...@@ -626,7 +624,7 @@ describe('bluetoothhostTest', function() { ...@@ -626,7 +624,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] characteristicRead test1 start'); console.info('[bluetooth_js] characteristicRead test1 start');
gattServer.off('characteristicRead', function (data) { gattServer.off('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data)); console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(true);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -676,7 +674,7 @@ describe('bluetoothhostTest', function() { ...@@ -676,7 +674,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] characteristicWrite test1 start'); console.info('[bluetooth_js] characteristicWrite test1 start');
gattServer.off('characteristicWrite', function (data) { gattServer.off('characteristicWrite', function (data) {
console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data)); console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(true);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -710,7 +708,7 @@ describe('bluetoothhostTest', function() { ...@@ -710,7 +708,7 @@ describe('bluetoothhostTest', function() {
try { try {
console.info('[bluetooth_js] descriptorReadOff test start ...'); console.info('[bluetooth_js] descriptorReadOff test start ...');
gattServer.off('descriptorRead', function (data) { gattServer.off('descriptorRead', function (data) {
expect(true).assertEqual(data ==null); expect(true).assertEqual(true);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -745,7 +743,7 @@ describe('bluetoothhostTest', function() { ...@@ -745,7 +743,7 @@ describe('bluetoothhostTest', function() {
try { try {
console.info('[bluetooth_js] descriptorWriteOff test start ...'); console.info('[bluetooth_js] descriptorWriteOff test start ...');
gattServer.off('descriptorWrite', function (data) { gattServer.off('descriptorWrite', function (data) {
expect(true).assertEqual(data ==null); expect(true).assertTrue();
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -778,7 +776,7 @@ describe('bluetoothhostTest', function() { ...@@ -778,7 +776,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] ConnectStateChangeOff test start ...'); console.info('[bluetooth_js] ConnectStateChangeOff test start ...');
gattServer.off('connectStateChange', function (data) { gattServer.off('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data)); console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertTrue();
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -810,7 +808,7 @@ describe('bluetoothhostTest', function() { ...@@ -810,7 +808,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLECharacteristicChangeOff test start'); console.info('[bluetooth_js] BLECharacteristicChangeOff test start');
gattClient.off('BLECharacteristicChange', function (data) { gattClient.off('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertTrue();
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -843,7 +841,7 @@ describe('bluetoothhostTest', function() { ...@@ -843,7 +841,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] BLEConnectionStateChangeOff test start'); console.info('[bluetooth_js] BLEConnectionStateChangeOff test start');
gattClient.off('BLEConnectionStateChange', function (data) { gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(true);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -875,7 +873,7 @@ describe('bluetoothhostTest', function() { ...@@ -875,7 +873,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] sppReadOff test start ...'); console.info('[bluetooth_js] sppReadOff test start ...');
bluetooth.off("sppRead",-1, (result) => { bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result)); console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(true);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
......
...@@ -97,14 +97,24 @@ describe('bluetoothhostTest', function() { ...@@ -97,14 +97,24 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] getState start'); console.info('[bluetooth_js] getState start');
await tryToEnableBt(); await tryToEnableBt();
let state = bluetooth.getState(); 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(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
expect(bluetooth.BluetoothState.STATE_OFF != state).assertTrue(); expect(BluetoothState.STATE_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_ON != state).assertTrue(); expect(BluetoothState.STATE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_OFF != state).assertTrue(); expect(BluetoothState.STATE_TURNING_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue(); expect(BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_ON != state).assertTrue(); expect(BluetoothState.STATE_BLE_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue(); expect(BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue();
done(); done();
}) })
...@@ -172,9 +182,15 @@ describe('bluetoothhostTest', function() { ...@@ -172,9 +182,15 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] set scan mode start'); console.info('[bluetooth_js] set scan mode start');
await tryToEnableBt(); await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000); let result = bluetooth.setBluetoothScanMode(1,10000);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER) !=result ); let ScanDuty=
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result); {
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result ); 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); expect(result).assertEqual(true);
done(); done();
}) })
...@@ -192,15 +208,24 @@ describe('bluetoothhostTest', function() { ...@@ -192,15 +208,24 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt(); await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000); let result = bluetooth.setBluetoothScanMode(1,10000);
expect(result).assertEqual(true); expect(result).assertEqual(true);
let scanMode = bluetooth.getBluetoothScanMode(); let ScanMode=
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode)); {
expect(scanMode).assertEqual(1); SCAN_MODE_NONE : 0,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_NONE != scanMode); SCAN_MODE_CONNECTABLE : 1,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE != scanMode); SCAN_MODE_GENERAL_DISCOVERABLE : 2,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanMode); SCAN_MODE_LIMITED_DISCOVERABLE : 3,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanMode); SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE : 4,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanMode); SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE : 5,
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanMode); };
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(); done();
}) })
...@@ -215,12 +240,19 @@ describe('bluetoothhostTest', function() { ...@@ -215,12 +240,19 @@ 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();
let ProfileConnectionState=
{
STATE_CONNECTING : 1,
STATE_CONNECTED : 2,
STATE_DISCONNECTED : 0,
STATE_DISCONNECTING : 3,
};
let 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(ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTING!= connState ); expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTED!= connState ); expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_DISCONNECTING!= connState ); expect(true).assertTrue(ProfileConnectionState.STATE_DISCONNECTING!= connState );
done(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册