Index: unittests/tst_canbus.cpp =================================================================== diff -u -r56d00a82669a7a2c00ab90109a89dbec8db27527 -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc --- unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision 56d00a82669a7a2c00ab90109a89dbec8db27527) +++ unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) @@ -1,6 +1,6 @@ /*! * - * Copyright (c) 2019-2019 Diality Inc. - All Rights Reserved. + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, * IN PART OR IN WHOLE, @@ -93,7 +93,7 @@ { _expected = QByteArray("123456789"); _FrameInterface.transmitFrame(Can_Id::eChlid_HD, _expected); - QCOMPARE(_emited, false); //there is no signal call - Code Coverage only : Error : "Payload can't be larger than 8 bytes" + QVERIFY( ! _emited ); //there is no signal call - Code Coverage only : Error : "Payload can't be larger than 8 bytes" } void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff_Accepted() @@ -134,7 +134,7 @@ { _expected = ""; _MessageDispatcher.onActionTransmit(Gui::GuiActionType::Unknown, {}); - QCOMPARE(_emited, false); // should not emit the signal due to unknown action + QVERIFY( ! _emited ); // should not emit the signal due to unknown action } void tst_canbus::tst_FrameInterface_FrameReceived_PowerOff() @@ -173,7 +173,7 @@ mPayload = "A5.01.00.01.01.5E.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); emit _CanInterface.didFrameReceive(mFrame); - QCOMPARE(_emited, false); // should not be emitted due to not listening channel + QVERIFY( ! _emited ); // should not be emitted due to not listening channel } void tst_canbus::tst_FrameInterface_FrameReceived_Channel_Incorrect() @@ -186,7 +186,7 @@ mPayload = "A5.01.00.01.01.5E.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); emit _CanInterface.didFrameReceive(mFrame); - QCOMPARE(_emited, false); // should not be emitted due to not listening channel + QVERIFY( ! _emited ); // should not be emitted due to not listening channel } void tst_canbus::tst_FrameInterface_FrameReceived_CRC_Error() @@ -264,9 +264,54 @@ mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); emit _CanInterface.didFrameReceive(mFrame); } - QCOMPARE(_emited, false); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0500'" + QVERIFY( ! _emited ); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0500'" } +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_AlarmStatus() +{ + _action = Gui::GuiActionType::AlarmStatus; + _data = { 2, 10, 60, 30, + false,true ,false,false, // 0100 + true ,false,false,false, // 1000 + true ,true ,false,false, // 1100 + false,false,false,false, // 0000 + }; + QCanBusFrame mFrame; + mFrame.setFrameId(Can_Id::eChlid_HD_Alarm); + QStringList mPayloadList { + "a5.02.00.12.02.00.00.00" , + "0a.00.00.00.3c.00.00.00" , + "1e.00.00.00.12.03.bb.00" , + }; + for ( QString payload : mPayloadList ) { + mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + } + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_AlarmStatus_LessData() +{ + _action = Gui::GuiActionType::AlarmStatus; + _data = { 2, 10, 60, 30, + false,true ,false,false, // 0100 + true ,false,false,false, // 1000 + true ,true ,false,false, // 1100 + false,false,false,false, // 0000 + }; + QCanBusFrame mFrame; + mFrame.setFrameId(Can_Id::eChlid_HD_Alarm); + QStringList mPayloadList { + "a5.02.00.12.02.00.00.00" , + "0a.00.00.00.3c.00.00.00" , + }; + for ( QString payload : mPayloadList ) { + mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + } + QVERIFY( ! _emited ); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0200'" +} + void tst_canbus::cleanup() { }