Index: unittests/tst_canbus.cpp =================================================================== diff -u -rfeb3423b373dc2a2c4267ef9fcb4d924d738423d -re1605219ac2baf49ef21d0889f845ac53d59c3c1 --- unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision feb3423b373dc2a2c4267ef9fcb4d924d738423d) +++ unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision e1605219ac2baf49ef21d0889f845ac53d59c3c1) @@ -42,28 +42,28 @@ void tst_canbus::tst_CanInterface_Connect_Error_Interface() { QString mTr = tr("Error: Connection"); - Can::_CanInterface->_canInterface = "can1"; - Can::_CanInterface ->init(); - Can::_CanInterface ->enableConsoleOut(false); - QCOMPARE(Can::_CanInterface->status().left(mTr.length()), mTr); + Can::_CanInterface ._canInterface = "can1"; + Can::_CanInterface .init(); + Can::_CanInterface .enableConsoleOut(false); + QCOMPARE(Can::_CanInterface.status().left(mTr.length()), mTr); } void tst_canbus::tst_CanInterface_Connect_NoError() { - Can::_CanInterface->_canInterface = "can0"; - Can::_CanInterface ->init(); - Can::_CanInterface ->enableConsoleOut(true); + Can::_CanInterface._canInterface = "can0"; + Can::_CanInterface.init(); + Can::_CanInterface.enableConsoleOut(true); QString mTr = tr("Connected"); - QCOMPARE(Can::_CanInterface->status().left(mTr.length()), mTr); + QCOMPARE(Can::_CanInterface.status().left(mTr.length()), mTr); - Can::_CanInterface->onFrameReceive (); + Can::_CanInterface.onFrameReceive (); } void tst_canbus::tst_FrameInterface_Init() { - Can::_FrameInterface->init(); - Can::_MessageDispatcher->init(); - Can::_MessageDispatcher->enableConsoleOut(true); + Can::_FrameInterface .init(); + Can::_MessageDispatcher .init(); + Can::_MessageDispatcher .enableConsoleOut(true); connect(Can::_MessageDispatcher, &Can::MessageDispatcher::didFrameTransmit, [=](Can_Id vCanId , const QByteArray &vPayload) { _emited = true; @@ -87,38 +87,38 @@ void tst_canbus::tst_FrameInterface_ActionTransmit_KeepAlive() { _expected = "A5.07.00.00.E3.00.00.00"; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::KeepAlive, {}); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::KeepAlive, {}); QVERIFY(_emited); } void tst_canbus::tst_FrameInterface_TransmitFrame_LongerData() { _expected = QByteArray("123456789"); - _FrameInterface->transmitFrame(Can_Id::eChlid_HD, _expected); + _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" } void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff_Accepted() { _expected = "A5.01.00.01.01.5E.00.00"; QVariantList mData {static_cast(Gui::GuiActionData::Accepted)}; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::PowerOff, mData); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::PowerOff, mData); QVERIFY(_emited); } void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff_Rejected() { _expected = "A5.01.00.01.02.0D.00.00"; QVariantList mData {static_cast(Gui::GuiActionData::Rejected)}; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::PowerOff, mData); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::PowerOff, mData); QVERIFY(_emited); } void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff() { _expected = "A5.01.00.01.00.6F.00.00"; QVariantList mData {static_cast(Gui::GuiActionData::NoData)}; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::PowerOff, mData); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::PowerOff, mData); QVERIFY(_emited); } @@ -128,14 +128,14 @@ // which can be as long as 255 byte. _expected = "A5.FF.FF.03.41.42.43.EF"; QVariantList mData {"ABC"}; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::String, mData); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::String, mData); QVERIFY(_emited); } void tst_canbus::tst_FrameInterface_ActionTransmit_Unknown() { _expected = ""; - _MessageDispatcher->onActionTransmit(Gui::GuiActionType::Unknown, {}); + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::Unknown, {}); QCOMPARE(_emited, false); // should not emit the signal due to unknown action } @@ -148,7 +148,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD); mPayload = "A5.01.00.01.00.6F.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QVERIFY(_emited); } @@ -161,7 +161,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD); mPayload = "A5.01.00.01.01.5E.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QVERIFY(_emited); } @@ -174,7 +174,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD_DG); mPayload = "A5.01.00.01.01.5E.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QCOMPARE(_emited, false); // should not be emitted due to not listening channel } @@ -187,7 +187,7 @@ mFrame.setFrameId(0x999); mPayload = "A5.01.00.01.01.5E.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QCOMPARE(_emited, false); // should not be emitted due to not listening channel } @@ -200,7 +200,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD); mPayload = "A5.01.00.01.00.66.00.00"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QCOMPARE(_emited, false); // Should not emit due to crc error } @@ -213,7 +213,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD); mPayload = "A5.01.00.01.00.6F"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QVERIFY(_emited); // Should not emit due to crc error } @@ -226,7 +226,7 @@ mFrame.setFrameId(Can::Can_Id::eChlid_HD); mPayload = "A5.01.00.01.00.6F.FF.FF.FF"; mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); QVERIFY(_emited); // Should not emit due to crc error } @@ -245,7 +245,7 @@ }; for ( QString payload : mPayloadList ) { mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); } QVERIFY(_emited); // Should not emit due to crc error } @@ -264,7 +264,7 @@ }; for ( QString payload : mPayloadList ) { mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); - emit Can::_CanInterface->didFrameReceive(mFrame); + emit Can::_CanInterface.didFrameReceive(mFrame); } QCOMPARE(_emited, false); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0500'" } @@ -280,7 +280,7 @@ void tst_canbus::cleanupTestCase() { - Can::_CanInterface->quit(); + Can::_CanInterface.quit(); QString mTr = tr("Disconnected"); - QCOMPARE(Can::_CanInterface->status().left(mTr.length()), mTr); + QCOMPARE(Can::_CanInterface.status().left(mTr.length()), mTr); }