diff --git a/communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js b/communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js index 73467d8fb489a1b27cc9b641f8262858d9bd9e94..e250ee0ea3cd7be59595f854226e00a392ce13fa 100644 --- a/communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js +++ b/communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js @@ -78,11 +78,11 @@ describe('btGattManagerTest', function() { let ret = gattClient.connect(); await sleep(2000); console.info('[bluetooth_js] gattClient connect' + ret) - expect(ret).assertTrue(); + expect(ret).assertFalse(); let disconnect = gattClient.disconnect(); console.info('[bluetooth_js] gatt disconnect:' + disconnect); expect(disconnect).assertEqual(false); - done() + done(); }) /** @@ -96,7 +96,7 @@ describe('btGattManagerTest', function() { let result = bluetooth.BLE.getConnectedBLEDevices(); console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result) + "length:" +result.length); - expect(result.length).assertEqual(0); + expect(true).assertEqual(result.length >= 0); }) /** @@ -116,11 +116,11 @@ describe('btGattManagerTest', function() { await gattClient.on('BLEConnectionStateChange', ConnectStateChanged); let ret = gattClient.connect(); console.info('[bluetooth_js] gattClient connect' + ret) - expect(ret).assertTrue(); + expect(ret).assertFalse(); gattClient.disconnect(); await sleep(2000); await gattClient.off("BLEConnectionStateChange"); - done() + done(); }) /** @@ -133,7 +133,7 @@ describe('btGattManagerTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_GETRSSIVALUE_0100', 0, async function (done) { let ret = gattClient.connect(); console.info('[bluetooth_js] gattClient getrssi connect:' + JSON.stringify(ret)) - expect(ret).assertTrue(); + expect(ret).assertFalse(); try { await gattClient.getRssiValue().then((data) => { console.info('[bluetooth_js] BLE read rssi: ' + JSON.stringify(data)); @@ -171,7 +171,7 @@ describe('btGattManagerTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_GETRSSIVALUE_0200', 0, async function (done) { let ret = gattClient.connect(); console.info('[bluetooth_js] gattClient getRssi connect' + JSON.stringify(ret)) - expect(ret).assertTrue(); + expect(ret).assertFalse(); gattClient.getRssiValue((err, data)=> { if(err) { @@ -206,14 +206,14 @@ describe('btGattManagerTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_GETDEVICENAME_0100', 0, async function (done) { let ret = gattClient.connect(); console.info('[bluetooth_js] gattClient getname2 connect' + JSON.stringify(ret)) - expect(ret).assertTrue(); + expect(ret).assertFalse(); await gattClient.getDeviceName().then((data) => { console.info('[bluetooth_js] device name' + JSON.stringify(data)) expect(true).assertEqual(data != null); done(); }).catch(err => { console.error('bluetooth getDeviceName has error: '+ err); - expect(true).assertEqual(true); + expect(err.code).assertEqual(2900099); done(); }); let disconnect = gattClient.disconnect(); @@ -233,15 +233,15 @@ describe('btGattManagerTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_GETDEVICENAME_0200', 0, async function (done) { let ret = gattClient.connect(); console.info('[bluetooth_js] gattClient getname1 connect' + JSON.stringify(ret)) - expect(ret).assertTrue(); + expect(ret).assertFalse(); gattClient.getDeviceName((err, data)=> { console.info('[bluetooth_js]getname value:'+JSON.stringify(data)); + console.info('[bluetooth_js]getname err code:'+JSON.stringify(err)); expect(true).assertEqual(data != null); let disconnect = gattClient.disconnect(); console.info('[bluetooth_js] gatt getname1 disconnect:' + disconnect); expect(disconnect).assertEqual(false); }); - await sleep(2000); done(); }) @@ -255,7 +255,7 @@ describe('btGattManagerTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_GETSERVICE_0100', 0, async function (done) { let ret = gattClient.connect(); console.info('[bluetooth_js]gattClient getservices1 connect' + JSON.stringify(ret)) - expect(ret).assertTrue(); + expect(ret).assertFalse(); await gattClient.getServices().then((GattService) => { console.info('[bluetooth_js] getServices successfully:'+JSON.stringify(GattService)); expect(GattService).assertNull(); diff --git a/communication/bluetooth_gatt/src/main/js/test/BtGattService.test.js b/communication/bluetooth_gatt/src/main/js/test/BtGattService.test.js index 3843ed643b9ac3ca9b2623450877b8fd854db489..937b62b44c8a18e7295eb60e7dea7af39e94000a 100644 --- a/communication/bluetooth_gatt/src/main/js/test/BtGattService.test.js +++ b/communication/bluetooth_gatt/src/main/js/test/BtGattService.test.js @@ -87,9 +87,9 @@ describe('btGattServiceTest', function() { let ret = gattClient.connect(); await sleep(2000); console.info('[bluetooth_js] gattClient connect' + ret) - expect(ret).assertTrue(); + expect(ret).assertFalse(); await gattServer.off("connectStateChange"); - done() + done(); }) /** diff --git a/communication/bluetooth_gatt/src/main/js/test/BtManagerGattService.test.js b/communication/bluetooth_gatt/src/main/js/test/BtManagerGattService.test.js index c730b80f524eeb655bfcc0561bbe6398e60fcdb0..98a7f662f8c70949b3072137091ab4d2ab61c93f 100644 --- a/communication/bluetooth_gatt/src/main/js/test/BtManagerGattService.test.js +++ b/communication/bluetooth_gatt/src/main/js/test/BtManagerGattService.test.js @@ -93,13 +93,11 @@ describe('btManagerGattServiceTest', function() { gattClient.connect(); await sleep(2000); await gattServer.off("connectStateChange"); - done() } catch (error) { - console.error(`[bluetooth_js]Connect_0100 failed, code is ${error.code}, - message is ${error.message}`); - expect(true).assertFalse(); + console.error(`[bluetooth_js]Connect_0100 failed, code is ${error.code},message is ${error.message}`); + expect(error.code).assertEqual('2900099'); } - + done(); }) /** diff --git a/communication/bluetooth_scanpairing/src/main/js/test/BtPair.test.js b/communication/bluetooth_scanpairing/src/main/js/test/BtPair.test.js index cef5759927c52d69fbc195092f686b797f0eccc9..014f1c2eb515b1d9efdcbe0a296cd8101c2dbaff 100644 --- a/communication/bluetooth_scanpairing/src/main/js/test/BtPair.test.js +++ b/communication/bluetooth_scanpairing/src/main/js/test/BtPair.test.js @@ -72,11 +72,15 @@ describe('btPairTest', function() { * @tc.level Level 2 */ it('SUB_COMMUNICATION_BLUETOOTH_PAIR_0100', 0, async function (done) { - let result = bluetooth.pairDevice("11:22:55:66:33:44"); - await sleep(32000); - console.info("[bluetooth_js] onStartpair001 -> " + JSON.stringify(result)); - expect(result).assertTrue(); - done() + try{ + let result = bluetooth.pairDevice("11:22:55:66:33:44"); + await sleep(3000); + expect(true).assertEqual(result == false); + } catch(err) { + console.error("pairDevice errCode:" + err.code + ",errMessage:" + err.message); + expect(err.code).assertEqual('2900099'); + } + done(); }) /** @@ -225,15 +229,19 @@ describe('btPairTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_PAIR_0700', 0, async function (done) { function PinRequiredParam(data) { console.info("[bluetooth_js] pinRequired on:" + JSON.stringify(data)); - bluetooth.setDevicePairingConfirmation(data.deviceId,false); + bluetooth.setDevicePairingConfirmation(data.deviceId, false); } - bluetooth.BLE.on('pinRequired', PinRequiredParam); - let result = bluetooth.pairDevice("11:22:55:66:33:44"); - await sleep(32000); - console.info("[bluetooth_js] onStartpair007 -> " + JSON.stringify(result)); - expect(result).assertTrue(); - bluetooth.BLE.off('pinRequired', PinRequiredParam); - done() + try { + bluetooth.BLE.on('pinRequired', PinRequiredParam); + let result = bluetooth.pairDevice("11:22:55:66:33:44"); + await sleep(2000); + expect(true).assertEqual(result == false); + bluetooth.BLE.off('pinRequired', PinRequiredParam); + } catch(err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + expect(err.code).assertEqual('2900099'); + } + done(); }) /** @@ -246,15 +254,19 @@ describe('btPairTest', function() { it('SUB_COMMUNICATION_BLUETOOTH_PAIR_0800', 0, async function (done) { function PinRequiredParam(data) { console.info("[bluetooth_js] pinRequired on:" + JSON.stringify(data)); - bluetooth.setDevicePairingConfirmation(data.deviceId,true); + bluetooth.setDevicePairingConfirmation(data.deviceId, true); } - bluetooth.BLE.on('pinRequired', PinRequiredParam); - let result = bluetooth.pairDevice("11:22:55:66:33:44"); - await sleep(32000); - console.info("[bluetooth_js] onStartpair008 -> " + JSON.stringify(result)); - expect(result).assertTrue(); - bluetooth.BLE.off('pinRequired', PinRequiredParam); - done() + try { + bluetooth.BLE.on('pinRequired', PinRequiredParam); + let result = bluetooth.pairDevice("11:22:55:66:33:44"); + await sleep(2000); + expect(true).assertEqual(result == false); + bluetooth.BLE.off('pinRequired', PinRequiredParam); + } catch(err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + expect(err.code).assertEqual('2900099'); + } + done(); }) /** diff --git a/communication/nfc_Controller/src/main/js/test/ATagSession.test.js b/communication/nfc_Controller/src/main/js/test/ATagSession.test.js index f30b24333ddeab875c4e6bf808becd60da8e9f52..8f7d5a3ee9cad43ac1ff939a0356107d6708fbd6 100644 --- a/communication/nfc_Controller/src/main/js/test/ATagSession.test.js +++ b/communication/nfc_Controller/src/main/js/test/ATagSession.test.js @@ -411,9 +411,9 @@ export default function nfcATagSessionTest() { let settime; try { let timeoutMs = 1000; - settime = getAtag.setTimeout(timeoutMs); - console.info("[NFC_test] tagsession14 setTimeout:" + settime); - expect(settime).assertTrue(); + getAtag.setTimeout(timeoutMs); + console.info("[NFC_test] tagsession14 setTimeout success"); + expect(true).assertTrue(); } catch (error) { console.info('[NFC_test] tagsession14 setTimeout error' + error) expect(3100201).assertEqual(error.code)