Index: sources/canbus/MessageInterpreter.h =================================================================== diff -u -r4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision 4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac) +++ sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -79,10 +79,6 @@ template bool notify (const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) __attribute_warn_unused_result__; - - // ---- Create Treatment Response Data - bool createTreatmentRespData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - public: explicit MessageInterpreter(QObject *parent = nullptr); Index: sources/model/hd/data/MPrimingData.h =================================================================== diff -u -r074b32b5cc08f41f2d9ce0d021f2151b76bba5ad -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- sources/model/hd/data/MPrimingData.h (.../MPrimingData.h) (revision 074b32b5cc08f41f2d9ce0d021f2151b76bba5ad) +++ sources/model/hd/data/MPrimingData.h (.../MPrimingData.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -11,6 +11,8 @@ class MPrimingData : public MAbstract { + // friends + friend class ::tst_models; QVariantList parameters() const override; Index: unittests/tst_messaging.cpp =================================================================== diff -u -r4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -535,7 +535,6 @@ QList actionTypes = { Gui::GuiActionType::ID_AlarmTriggered, Gui::GuiActionType::ID_AlarmCleared, - Gui::GuiActionType::ID_AlarmSilenceRsp, Gui::GuiActionType::ID_TreatmentStates, }; @@ -810,31 +809,6 @@ } /*! - * \brief tst_messaging::tst_MessageInterpreter_createTreatmentResp - * Tests that an invalid response message is detected properly - */ -void tst_messaging::tst_MessageInterpreter_createTreatmentResp() -{ - Can::MessageInterpreter interpreter; - Can::Message msg; - msg.actionId = Gui::GuiActionType::ID_CreateTreatmentRsp; - msg.data = {}; - QVariantList data; - QVERIFY(! interpreter.createTreatmentRespData(msg, data)); - - msg.actionId = Gui::GuiActionType::ID_CreateTreatmentReq; - QVERIFY(! interpreter.createTreatmentRespData(msg, data)); - - QVariantList variantList = QVariantList() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << 0 << 0 << 0; - QByteArray byteArray; - QVERIFY(interpreter.interpretMessage(msg.actionId, variantList, byteArray)); - - QVERIFY(!interpreter.interpretMessage(msg.actionId, QVariantList(), byteArray)); - -} - -/*! * \brief tst_messaging::tst_MessageBuilder_addActionId * \details Tests addActionId() method usage of MessageBuilder */ Index: unittests/tst_messaging.h =================================================================== diff -u -r4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- unittests/tst_messaging.h (.../tst_messaging.h) (revision 4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac) +++ unittests/tst_messaging.h (.../tst_messaging.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -99,7 +99,6 @@ void tst_MessageInterpreter_interpretMessage_DG_Unhandled(); void tst_MessageInterpreter_notify_fromByteArray(); - void tst_MessageInterpreter_createTreatmentResp(); void tst_MessageBuilder_addActionId(); void tst_MessageBuilder_addData_shorterLen(); Index: unittests/tst_models.cpp =================================================================== diff -u -rb635ddbc3ec048453e1c2f5a7565385ecdd78d74 -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- unittests/tst_models.cpp (.../tst_models.cpp) (revision b635ddbc3ec048453e1c2f5a7565385ecdd78d74) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -39,6 +39,7 @@ #include "MTreatmentTimeData.h" #include "MTreatmentPressureOcclusionData.h" #include "MTreatmentSalineData.h" +#include "MPrimingData.h" #include "MTreatmentAdjustUltrafiltrationStateResponse.h" #include "MTreatmentAdjustUltrafiltrationEditResponse.h" @@ -50,6 +51,7 @@ #include "MAlarmCleared.h" #include "MTreatmentParametersResp.h" +#include "MEndTreatmentResponse.h" // #define CONSOLEOUT @@ -1381,6 +1383,9 @@ } } + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp data definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MTreatmentParametersResp_data() { QTest::addColumn("errorIndex"); @@ -1460,7 +1465,7 @@ QTest::newRow("rinsebackFlowRate") << 18 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F" "40" "41" "42" "43" "44" "45" "46" "47")); } - +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp test definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MTreatmentParametersResp() { Model::MTreatmentParametersResponse mData; @@ -1591,6 +1596,91 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPrimingData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPrimingData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPrimingData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("currentState ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("currentState ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("currentState ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("currentState ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("secondsRemaining ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("secondsRemaining ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("secondsRemaining ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("secondsRemaining ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("secondsTotal ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("secondsTotal ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("secondsTotal ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("secondsTotal ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPrimingData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPrimingData() { + Model::MPrimingData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.currentState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.secondsRemaining ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.secondsTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEndTreatmentResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEndTreatmentResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MEndTreatmentResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("endTreatmentResponse") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("endTreatmentResponse") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("endTreatmentResponse") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("endTreatmentResponse") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEndTreatmentResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MEndTreatmentResponse() { + Model::MEndTreatmentResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.endTreatmentResponse ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // Index: unittests/tst_models.h =================================================================== diff -u -rb635ddbc3ec048453e1c2f5a7565385ecdd78d74 -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f --- unittests/tst_models.h (.../tst_models.h) (revision b635ddbc3ec048453e1c2f5a7565385ecdd78d74) +++ unittests/tst_models.h (.../tst_models.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) @@ -87,6 +87,8 @@ void tst_MPressureOcclusionData(); void tst_MPowerOff_data(); void tst_MPowerOff(); + void tst_MPrimingData_data(); + void tst_MPrimingData(); // Alarms void tst_MAlarmStatus_text(); @@ -109,4 +111,7 @@ void tst_MSalineBolusResponse_data(); void tst_MSalineBolusResponse(); + + void tst_MEndTreatmentResponse_data(); + void tst_MEndTreatmentResponse(); };