Index: unittests/tst_acknow.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -rb798668f16ad0967ab97e96f5f9a2cdd821e899f --- unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision b798668f16ad0967ab97e96f5f9a2cdd821e899f) @@ -1,14 +1,14 @@ /*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * copyright + * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, * IN PART OR IN WHOLE, * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * - * file tst_acknow.cpp - * date 01/21/2020 - * author Behrouz NematiPour + * \file tst_acknow.cpp + * \date 01/21/2020 + * \author Behrouz NematiPour * */ #include "tst_acknow.h" @@ -126,6 +126,40 @@ _MessageDispatcher._needsAcknow.removeOne(Gui::GuiActionType::KeepAlive); } +/*! + * \brief tst_acknow::tst_AcknowModel_Receive_Normal + * \details UI receives a message which doesn't require Acknow + */ +void tst_acknow::tst_AcknowModel_onAcknowReceive_Correct() +{ + QCOMPARE( _MessageAcknowModel._acknowList.count(), 1 ); + _action = Gui::GuiActionType::KeepAlive; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.03.00.FF.FF.01.00.91"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + qDebug() << "#" << mFrame.toString(); + emit _CanInterface.didFrameReceive(mFrame); + QCOMPARE( _MessageAcknowModel._acknowList.count(), 0 ); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect + * \details Tries to remove a seq from acknow model which is not expected + * (there was no message send with this seq which required qcknow) + * and the seq should not exist before and after removal + * this is a test for qt hash test used for acknow model + * \param vSequence + */ +void tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect() +{ + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); + _MessageAcknowModel.onAcknowReceive(9999); + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); +} + void tst_acknow::cleanupTestCase() { _CanInterface.quitDevice();