diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea44d5855..eec683153 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest + run: ctest --output-on-failure env: QT_QPA_PLATFORM: offscreen @@ -135,7 +135,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest + run: ctest --output-on-failure env: QT_QPA_PLATFORM: offscreen @@ -183,7 +183,7 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=OFF -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)/lib/cmake" + run: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)/lib/cmake" env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} @@ -191,6 +191,12 @@ jobs: working-directory: ${{github.workspace}}/build run: make -j4 + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest --output-on-failure + env: + QT_QPA_PLATFORM: offscreen + - name: Create packages if: startsWith(github.ref, 'refs/heads/') working-directory: ${{github.workspace}}/build @@ -260,7 +266,13 @@ jobs: - name: Build working-directory: ${{github.workspace}}/build - run: cmake --build . --config Release + run: cmake --build . --config Release -- /m + + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -C Release --output-on-failure + env: + QT_QPA_PLATFORM: offscreen - name: Create Packages if: startsWith(github.ref, 'refs/heads/') diff --git a/3rdParty/CANdb b/3rdParty/CANdb index 06731dec5..150c42a8c 160000 --- a/3rdParty/CANdb +++ b/3rdParty/CANdb @@ -1 +1 @@ -Subproject commit 06731dec5f35e6c0328a85d526913158198a6e73 +Subproject commit 150c42a8cdfc0748915f09d2cd0c5a68591263a7 diff --git a/3rdParty/catch b/3rdParty/catch index 9ccea82d7..5c88067bd 160000 --- a/3rdParty/catch +++ b/3rdParty/catch @@ -1 +1 @@ -Subproject commit 9ccea82d7f9967689633b82d7d969db22cfe22f1 +Subproject commit 5c88067bd339465513af4aec606bd2292f1b594a diff --git a/3rdParty/fakeit b/3rdParty/fakeit index c0551414b..514ca290b 160000 --- a/3rdParty/fakeit +++ b/3rdParty/fakeit @@ -1 +1 @@ -Subproject commit c0551414b1ec30f7c19c4d6ee07cd9eb93013904 +Subproject commit 514ca290b78d15f4fb46e1696f47189cf2524376 diff --git a/3rdParty/nodeeditor b/3rdParty/nodeeditor index 9abffe510..89cdae6c8 160000 --- a/3rdParty/nodeeditor +++ b/3rdParty/nodeeditor @@ -1 +1 @@ -Subproject commit 9abffe51055e88abcb2a89097ad15eae339350ae +Subproject commit 89cdae6c87a1aa070ab396a6b776b4d3c41c4424 diff --git a/3rdParty/qtCannelloniCanBus b/3rdParty/qtCannelloniCanBus index 5361c5660..21770d7a8 160000 --- a/3rdParty/qtCannelloniCanBus +++ b/3rdParty/qtCannelloniCanBus @@ -1 +1 @@ -Subproject commit 5361c5660f2c8f5a7e456ae9221f7b8375f2db5b +Subproject commit 21770d7a83952c5313a4784b7200d51cbd632284 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cdfe1d81..6481a5a0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(CANdevStudio CXX) set(VERSION_MAJOR 1) set(VERSION_MINOR 2) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) @@ -17,6 +17,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) option(WITH_COVERAGE "Build with coverage" OFF) +option(WITH_TESTS "Build with test" ON) option(WITH_TOOLS "Build tools directory" OFF) option(DEV_BUILD "Development build will include GIT hash and branch to versioning" ON) option(STANDALONE "Builds self containing package including Qt libs" OFF) @@ -27,7 +28,6 @@ endif() message(STATUS "CMAKE_INSTALL_LIBDIR: '${CMAKE_INSTALL_LIBDIR}'") if(UNIX) - option(WITH_TESTS "Build with test" ON) if(STANDALONE) set(INSTALL_DEST_LIB CANdevStudio) set(INSTALL_DEST_BIN CANdevStudio) @@ -38,14 +38,12 @@ if(UNIX) set(INSTALL_DEST_PLUG ${CMAKE_INSTALL_LIBDIR}/qt/plugins/canbus) endif() else() - option(WITH_TESTS "Build with test" OFF) - set(GUI_TYPE WIN32) set(INSTALL_DEST_LIB CANdevStudio) set(INSTALL_DEST_BIN CANdevStudio) endif() -set(QT_REQUIRED_VERSION "5.6") +set(QT_REQUIRED_VERSION "5.12") find_package(Qt5Core ${QT_REQUIRED_VERSION} REQUIRED) find_package(Qt5SerialBus ${QT_REQUIRED_VERSION} REQUIRED) find_package(Qt5Widgets ${QT_REQUIRED_VERSION} REQUIRED) diff --git a/README.md b/README.md index 709a86842..bd79577db 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ If CMake failed to find Qt in your system: ``` cd CANdevStudio/build rm -rf * -cmake .. -DCMAKE_PREFIX_PATH=/home/genivi/Qt5.8.0/5.8/gcc_64 +cmake .. -DCMAKE_PREFIX_PATH=/home/genivi/Qt5.12.0/5.12.0/gcc_64 make ``` ### Windows @@ -310,7 +310,6 @@ CanDevice component can be configured using "configuration" property: * Keys names are case sensitive, values are case insensitive * Configuration keys are taken from [ConfigurationKey enum](https://doc.qt.io/qt-5/qcanbusdevice.html#ConfigurationKey-enum). * RawFilterKey and ErrorFilterKey are currently not supported -* DataBitRateKey is available since Qt 5.9 * Whitespaces are ignored E.g. diff --git a/src/common/propertyfields.h b/src/common/propertyfields.h index 620e36092..1b7bc2deb 100644 --- a/src/common/propertyfields.h +++ b/src/common/propertyfields.h @@ -95,8 +95,8 @@ class PropertyFieldCombo : public PropertyField { _cb->setEditable(editable); _cb->setFrame(false); layout()->addWidget(_cb); - connect(_cb, static_cast(&QComboBox::currentIndexChanged), this, - &PropertyFieldCombo::currentTextChanged); + connect(_cb, static_cast(&QComboBox::currentIndexChanged), + [this](int) { emit currentTextChanged(_cb->currentText()); }); } void setPropText(const QString& text) override diff --git a/src/components/candevice/tests/candevice_test.cpp b/src/components/candevice/tests/candevice_test.cpp index 02e529175..ab4660fed 100644 --- a/src/components/candevice/tests/candevice_test.cpp +++ b/src/components/candevice/tests/candevice_test.cpp @@ -54,6 +54,7 @@ TEST_CASE("Initialization succeeded", "[candevice]") Mock deviceMock; std::function rcvCbk; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); When(Method(deviceMock, setFramesReceivedCbk)).AlwaysDo([&](auto&& fn) { rcvCbk = fn; }); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -79,6 +80,7 @@ TEST_CASE("Start failed", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); When(Method(deviceMock, setFramesWrittenCbk)).Do([](const auto& cb) { cb(100); }); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -96,6 +98,7 @@ TEST_CASE("Start failed - could not connect to device", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -128,6 +131,7 @@ TEST_CASE("Start succeeded", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); When(Method(deviceMock, setFramesWrittenCbk)).Do([](const auto& cb) { cb(100); }); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -146,6 +150,7 @@ TEST_CASE("Stop uninitialized", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setParent)); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -158,6 +163,7 @@ TEST_CASE("Stop initialized", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); When(Method(deviceMock, setFramesWrittenCbk)).Do([](const auto& cb) { cb(100); }); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -178,6 +184,7 @@ TEST_CASE("Config changed", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); When(Method(deviceMock, setFramesWrittenCbk)).Do([](const auto& cb) { cb(100); }); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -199,6 +206,7 @@ TEST_CASE("writeFrame results in error", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -221,6 +229,7 @@ TEST_CASE("sendFrame, writeframe returns true, no signal emitted", "[candevice]" using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -260,6 +269,7 @@ TEST_CASE("sendFrame defers FrameSent until backend emits frameWritten", "[cande const auto frame = QCanBusFrame{ 0x12345678, QByteArray{ "\x50\x30\10" } }; CanDeviceInterface::framesWritten_t writtenCbk; + Fake(Dtor(deviceMock)); When(Method(deviceMock, setFramesWrittenCbk)).Do([&](auto&& fn) { writtenCbk = fn; }); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -291,6 +301,7 @@ TEST_CASE("Emits all available frames when notified by backend", "[candevice]") auto currentFrame = frames.begin(); CanDeviceInterface::framesReceived_t receivedCbk; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); When(Method(deviceMock, setFramesReceivedCbk)).Do([&](auto&& fn) { receivedCbk = fn; }); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -326,6 +337,7 @@ TEST_CASE("WriteError causes emitting frameSent with frameSent=false", "[candevi const auto frame = QCanBusFrame{ 0x12345678, QByteArray{ "\x50\x30\10" } }; CanDeviceInterface::errorOccurred_t errorCbk; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); Fake(Method(deviceMock, setFramesReceivedCbk)); When(Method(deviceMock, setErrorOccurredCbk)).Do([&](auto&& fn) { errorCbk = fn; }); @@ -351,10 +363,11 @@ TEST_CASE("read configuration to json format", "[candevice]") { using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setParent)); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; QJsonObject config = canDevice.getConfig(); - REQUIRE(config.count() == canDevice.getSupportedProperties().size()); + REQUIRE(config.count() == static_cast(canDevice.getSupportedProperties().size())); } TEST_CASE("setConfig using JSON read with QObject", "[candevice]") @@ -362,6 +375,7 @@ TEST_CASE("setConfig using JSON read with QObject", "[candevice]") using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setParent)); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -386,6 +400,7 @@ TEST_CASE("Stubbed methods", "[candevice]") { using namespace fakeit; Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setParent)); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -393,11 +408,11 @@ TEST_CASE("Stubbed methods", "[candevice]") REQUIRE(canDevice.mainWidgetDocked() == true); } -auto prepareConfigTestMock(std::vector>& ver) +void prepareConfigTestMock(fakeit::Mock& deviceMock, std::vector>& ver) { using namespace fakeit; - Mock deviceMock; + Fake(Dtor(deviceMock)); Fake(Method(deviceMock, setFramesWrittenCbk)); Fake(Method(deviceMock, setFramesReceivedCbk)); Fake(Method(deviceMock, setErrorOccurredCbk)); @@ -408,7 +423,6 @@ auto prepareConfigTestMock(std::vector>& ver) When(Method(deviceMock, setConfigurationParameter)).AlwaysDo([&](int key, const QVariant& v) { ver.push_back(std::make_pair(key, v)); }); - return deviceMock; } void testConfig(fakeit::Mock& deviceMock, CanDevice& canDevice, const QString& configStr) @@ -440,7 +454,8 @@ TEST_CASE("Config parameter - invalid format and unsupported", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -458,7 +473,8 @@ TEST_CASE("Config parameter - LoopbackKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -482,7 +498,8 @@ TEST_CASE("Config parameter - ReceiveOwnKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -506,7 +523,8 @@ TEST_CASE("Config parameter - CanFdKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -530,7 +548,8 @@ TEST_CASE("Config parameter - BitRateKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -551,7 +570,8 @@ TEST_CASE("Config parameter - UserKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -575,7 +595,8 @@ TEST_CASE("Config parameter - DataBitRateKey", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; @@ -598,7 +619,8 @@ TEST_CASE("Config parameter - multiple keys", "[candevice]") { using namespace fakeit; std::vector> v; - auto&& deviceMock = prepareConfigTestMock(v); + Mock deviceMock; + prepareConfigTestMock(deviceMock, v); CanDevice canDevice{ CanDeviceCtx(&deviceMock.get()) }; diff --git a/src/components/canrawfilter/tests/canrawfilter_test.cpp b/src/components/canrawfilter/tests/canrawfilter_test.cpp index 66aa664bc..c3ae621a6 100644 --- a/src/components/canrawfilter/tests/canrawfilter_test.cpp +++ b/src/components/canrawfilter/tests/canrawfilter_test.cpp @@ -37,6 +37,7 @@ TEST_CASE("setConfig - json", "[canrawfilter]") { using namespace fakeit; Mock mock; + Fake(Dtor(mock)); Fake(Method(mock, mainWidget)); Fake(Method(mock, setTxListCbk)); Fake(Method(mock, setRxListCbk)); @@ -128,6 +129,7 @@ TEST_CASE("default accept list RX", "[canrawfilter]") template void setupMock(M& mock, TX& txCbk, RX& rxCbk) { using namespace fakeit; + Fake(Dtor(mock)); Fake(Method(mock, mainWidget)); When(Method(mock, setTxListCbk)).AlwaysDo([&](auto&& fn) { txCbk = fn; }); When(Method(mock, setRxListCbk)).AlwaysDo([&](auto&& fn) { rxCbk = fn; }); @@ -166,7 +168,7 @@ TEST_CASE("custom list RX", "[canrawfilter]") c.startSimulation(); - auto idTest = [&](uint32_t start, uint32_t end, uint32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { + auto idTest = [&](uint32_t start, uint32_t end, int32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { spy.clear(); rxCbk(list); @@ -250,7 +252,7 @@ TEST_CASE("custom list TX", "[canrawfilter]") c.startSimulation(); - auto idTest = [&](uint32_t start, uint32_t end, uint32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { + auto idTest = [&](uint32_t start, uint32_t end, int32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { spy.clear(); txCbk(list); @@ -351,7 +353,7 @@ TEST_CASE("Payload filtering", "[canrawfilter]") addFrame("AAbbCCddEE"); addFrame("AAbbCCddEEff"); - auto payloadTest = [&](uint32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { + auto payloadTest = [&](int32_t cnt, CanRawFilterGuiInt::AcceptList_t&& list) { spyRx.clear(); spyTx.clear(); diff --git a/src/components/canrawlogger/tests/canrawlogger_test.cpp b/src/components/canrawlogger/tests/canrawlogger_test.cpp index 804eaa3a4..9584e1b96 100644 --- a/src/components/canrawlogger/tests/canrawlogger_test.cpp +++ b/src/components/canrawlogger/tests/canrawlogger_test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include std::shared_ptr kDefaultLogger; // needed for QSignalSpy cause according to qtbug 49623 comments @@ -104,18 +105,23 @@ TEST_CASE("logging - directories", "[canrawlogger]") c.stopSimulation(); - dirName = "/dummy"; - dir.setPath(dirName); + // On Windows it is hard to determine a path were user will not have an access to. + // Using WINDIR seems fail on GitHub Actions so skip this for Windows... + if (QSysInfo::kernelType() != "winnt") { + dirName = "/dummy"; - REQUIRE(dir.exists() == false); + dir.setPath(dirName); - obj.setProperty("directory", dirName); - c.setConfig(obj); - c.startSimulation(); + REQUIRE(dir.exists() == false); - REQUIRE(dir.exists() == false); + obj.setProperty("directory", dirName); + c.setConfig(obj); + c.startSimulation(); - c.stopSimulation(); + REQUIRE(dir.exists() == false); + + c.stopSimulation(); + } } TEST_CASE("logging - filenames", "[canrawlogger]") @@ -257,14 +263,14 @@ TEST_CASE("logging - send/receive, removed file", "[canrawlogger]") auto fileList = dir.entryList({ "*" }); REQUIRE(fileList.size() == 3); + c.stopSimulation(); + QFile rmFile(dirName + "/" + fileList[2]); REQUIRE(rmFile.remove()); c.frameReceived(frame); c.frameReceived(frame); c.frameReceived(frame); - - c.stopSimulation(); } TEST_CASE("logging - send/receive while stopped", "[canrawlogger]") diff --git a/src/components/canrawplayer/tests/canrawplayer_test.cpp b/src/components/canrawplayer/tests/canrawplayer_test.cpp index 1e0a40f5b..aa1a3f4b5 100644 --- a/src/components/canrawplayer/tests/canrawplayer_test.cpp +++ b/src/components/canrawplayer/tests/canrawplayer_test.cpp @@ -160,7 +160,7 @@ TEST_CASE("Send test", "[canrawplayer]") th.start(); - std::this_thread::sleep_for(200ms); + std::this_thread::sleep_for(1000ms); th.quit(); th.wait(); diff --git a/src/components/canrawsender/CMakeLists.txt b/src/components/canrawsender/CMakeLists.txt index d0746df7d..d863f833f 100644 --- a/src/components/canrawsender/CMakeLists.txt +++ b/src/components/canrawsender/CMakeLists.txt @@ -22,8 +22,5 @@ if(WITH_TESTS) target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) - set(CONFIG_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles) - set(CONFIG_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/configfiles) - add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CONFIG_SOURCE} ${CONFIG_DESTINATION}) + add_definitions(-DCRS_TEST_CONFIG_FILES="${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles") endif() diff --git a/src/components/canrawsender/tests/canrawsender_test.cpp b/src/components/canrawsender/tests/canrawsender_test.cpp index 85f0da9ab..9986f4613 100644 --- a/src/components/canrawsender/tests/canrawsender_test.cpp +++ b/src/components/canrawsender/tests/canrawsender_test.cpp @@ -56,6 +56,7 @@ TEST_CASE("Add and remove frame test", "[canrawsender]") Mock nlmFactoryMock; helpTestClass mHelp; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); When(Method(nlmLineEditMock, mainWidget)).AlwaysDo([&]() { return reinterpret_cast(&nlmLineEditMock.get()); @@ -67,8 +68,11 @@ TEST_CASE("Add and remove frame test", "[canrawsender]") Fake(Method(nlmLineEditMock, getText)); Fake(Method(nlmLineEditMock, setText)); Fake(Method(nlmLineEditMock, editingFinishedCbk)); + + Fake(Dtor(nlmFactoryMock)); When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); When(Method(nlmCheckBoxMock, mainWidget)).AlwaysReturn(reinterpret_cast(&nlmCheckBoxMock.get())); Fake(Method(nlmCheckBoxMock, getState)); @@ -76,6 +80,7 @@ TEST_CASE("Add and remove frame test", "[canrawsender]") Fake(Method(nlmCheckBoxMock, setDisabled)); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); When(Method(nlmPushButtonMock, pressedCbk)).AlwaysDo([&](auto&& fn) { sendPressed = fn; }); Fake(Method(nlmPushButtonMock, setDisabled)); @@ -87,6 +92,7 @@ TEST_CASE("Add and remove frame test", "[canrawsender]") When(Method(nlmPushButtonMock, mainWidget)).AlwaysReturn(reinterpret_cast(&nlmPushButtonMock.get())); When(Method(nlmFactoryMock, createPushButton)).AlwaysReturn(&nlmPushButtonMock.get()); + Fake(Dtor(crsMock)); When(Method(crsMock, setAddCbk)).Do([&](auto&& fn) { addLineCbk = fn; }); When(Method(crsMock, setRemoveCbk)).Do([&](auto&& fn) { removeLineCbk = fn; }); Fake(Method(crsMock, setDockUndockCbk)); @@ -115,6 +121,7 @@ TEST_CASE("Add and remove frame test", "[canrawsender]") TEST_CASE("Can raw sender save configuration test", "[canrawsender]") { Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -124,6 +131,7 @@ TEST_CASE("Can raw sender save configuration test", "[canrawsender]") Fake(Method(crsMock, setIndexWidget)); Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); CanRawSender canRawSender{ CanRawSenderCtx(&crsMock.get(), &nlmFactoryMock.get()) }; @@ -157,6 +165,9 @@ class commonTestClass { commonTestClass() = delete; commonTestClass(const QString& id, const QString& data, bool remote, const QString& interval, bool loop) { + Fake(Dtor(nlmFactoryMock)); + + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -165,6 +176,7 @@ class commonTestClass { Fake(Method(crsMock, getSelectedRows)); Fake(Method(crsMock, setIndexWidget)); + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); Fake(Method(nlmLineEditMock, editingFinishedCbk)); Fake(Method(nlmLineEditMock, init)); @@ -177,12 +189,14 @@ class commonTestClass { }); When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); When(Method(nlmCheckBoxMock, getState)).Return(true, true, loop, remote); Fake(Method(nlmCheckBoxMock, setState)); When(Method(nlmCheckBoxMock, mainWidget)).AlwaysReturn(reinterpret_cast(&nlmCheckBoxMock.get())); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); Fake(Method(nlmPushButtonMock, pressedCbk)); When(Method(nlmPushButtonMock, mainWidget)).Return(reinterpret_cast(&nlmPushButtonMock.get())); @@ -207,7 +221,7 @@ class commonTestClass { TEST_CASE("Can raw sender restore configuration test - pass", "[canrawsender]") { - QDir dir("configfiles"); + QDir dir(CRS_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("canrawsenderconfig.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); @@ -232,7 +246,7 @@ TEST_CASE("Can raw sender restore configuration test - pass", "[canrawsender]") TEST_CASE("Can raw sender restore configuration test - column name incorrect", "[canrawsender]") { - QDir dir("configfiles"); + QDir dir(CRS_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("canrawsenderconfig_badcolumns.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); @@ -257,7 +271,7 @@ TEST_CASE("Can raw sender restore configuration test - column name incorrect", " TEST_CASE("Can raw sender restore configuration test - Id incorrect", "[canrawsender]") { - QDir dir("configfiles"); + QDir dir(CRS_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("canrawsenderconfig_badId.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); @@ -282,7 +296,7 @@ TEST_CASE("Can raw sender restore configuration test - Id incorrect", "[canrawse TEST_CASE("Can raw sender restore configuration test - Data incorrect", "[canrawsender]") { - QDir dir("configfiles"); + QDir dir(CRS_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("canrawsenderconfig_badData.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); @@ -307,7 +321,7 @@ TEST_CASE("Can raw sender restore configuration test - Data incorrect", "[canraw TEST_CASE("Can raw sender restore configuration test - Interval incorrect", "[canrawsender]") { - QDir dir("configfiles"); + QDir dir(CRS_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("canrawsenderconfig_badInterval.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); @@ -554,6 +568,7 @@ TEST_CASE("Dock/Undock", "[canrawsender]") CRSGuiInterface::dockUndock_t dockUndock; Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); When(Method(crsMock, setDockUndockCbk)).Do([&](auto&& fn) { dockUndock = fn; }); @@ -563,6 +578,7 @@ TEST_CASE("Dock/Undock", "[canrawsender]") Fake(Method(crsMock, setIndexWidget)); Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); CanRawSender canRawSender{ CanRawSenderCtx(&crsMock.get(), &nlmFactoryMock.get()) }; QSignalSpy dockSpy(&canRawSender, &CanRawSender::mainWidgetDockToggled); diff --git a/src/components/canrawsender/tests/newlinemanager_test.cpp b/src/components/canrawsender/tests/newlinemanager_test.cpp index 81ac5cb23..07ff561f4 100644 --- a/src/components/canrawsender/tests/newlinemanager_test.cpp +++ b/src/components/canrawsender/tests/newlinemanager_test.cpp @@ -39,6 +39,7 @@ TEST_CASE("Constructor with correct arguments", "[newlinemanager]") using namespace fakeit; Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -48,8 +49,10 @@ TEST_CASE("Constructor with correct arguments", "[newlinemanager]") Fake(Method(crsMock, setIndexWidget)); Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); Mock nlmLineEditMock; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); Fake(Method(nlmLineEditMock, init)); Fake(Method(nlmLineEditMock, setPlaceholderText)); @@ -58,10 +61,12 @@ TEST_CASE("Constructor with correct arguments", "[newlinemanager]") When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); Mock nlmCheckBoxMock; + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); Mock nlmPushButtonMock; + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); Fake(Method(nlmPushButtonMock, pressedCbk)); When(Method(nlmFactoryMock, createPushButton)).Return(&nlmPushButtonMock.get()); @@ -77,8 +82,10 @@ TEST_CASE("Send button clicked - send one frame test", "[newlinemanager]") PushButtonInterface::pressed_t pressedCbk; Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -88,6 +95,7 @@ TEST_CASE("Send button clicked - send one frame test", "[newlinemanager]") Fake(Method(crsMock, setIndexWidget)); Mock nlmLineEditMock; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); Fake(Method(nlmLineEditMock, editingFinishedCbk)); Fake(Method(nlmLineEditMock, mainWidget)); @@ -98,12 +106,14 @@ TEST_CASE("Send button clicked - send one frame test", "[newlinemanager]") When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); Mock nlmCheckBoxMock; + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); Fake(Method(nlmCheckBoxMock, mainWidget)); When(Method(nlmCheckBoxMock, getState)).AlwaysReturn(false); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); Mock nlmPushButtonMock; + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); When(Method(nlmPushButtonMock, pressedCbk)).Do([&](auto&& fn) { pressedCbk = fn; }); Fake(Method(nlmPushButtonMock, mainWidget)); @@ -131,8 +141,10 @@ TEST_CASE("Send button clicked - send several frame test", "[newlinemanager]") PushButtonInterface::pressed_t pressedCbk; Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -142,6 +154,7 @@ TEST_CASE("Send button clicked - send several frame test", "[newlinemanager]") Fake(Method(crsMock, setIndexWidget)); Mock nlmLineEditMock; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); Fake(Method(nlmLineEditMock, editingFinishedCbk)); Fake(Method(nlmLineEditMock, mainWidget)); @@ -154,6 +167,7 @@ TEST_CASE("Send button clicked - send several frame test", "[newlinemanager]") When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); Mock nlmCheckBoxMock; + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); Fake(Method(nlmCheckBoxMock, mainWidget)); When(Method(nlmCheckBoxMock, getState)).Return(true); @@ -161,6 +175,7 @@ TEST_CASE("Send button clicked - send several frame test", "[newlinemanager]") When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); Mock nlmPushButtonMock; + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); When(Method(nlmPushButtonMock, pressedCbk)).Do([&](auto&& fn) { pressedCbk = fn; }); Fake(Method(nlmPushButtonMock, mainWidget)); @@ -186,6 +201,7 @@ TEST_CASE("Get columns wigdet test", "[newlinemanager]") using namespace fakeit; Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -195,8 +211,10 @@ TEST_CASE("Get columns wigdet test", "[newlinemanager]") Fake(Method(crsMock, setIndexWidget)); Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); Mock nlmLineEditMock; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); Fake(Method(nlmLineEditMock, editingFinishedCbk)); Fake(Method(nlmLineEditMock, init)); @@ -208,11 +226,13 @@ TEST_CASE("Get columns wigdet test", "[newlinemanager]") When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); Mock nlmCheckBoxMock; + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); When(Method(nlmCheckBoxMock, mainWidget)).AlwaysReturn(reinterpret_cast(&nlmCheckBoxMock.get())); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); Mock nlmPushButtonMock; + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); Fake(Method(nlmPushButtonMock, pressedCbk)); When(Method(nlmPushButtonMock, mainWidget)).Return(reinterpret_cast(&nlmPushButtonMock.get())); @@ -236,8 +256,10 @@ TEST_CASE("EditionFinished", "[newlinemanager]") std::vector validOut; Mock nlmFactoryMock; + Fake(Dtor(nlmFactoryMock)); Mock crsMock; + Fake(Dtor(crsMock)); Fake(Method(crsMock, setAddCbk)); Fake(Method(crsMock, setRemoveCbk)); Fake(Method(crsMock, setDockUndockCbk)); @@ -247,6 +269,7 @@ TEST_CASE("EditionFinished", "[newlinemanager]") Fake(Method(crsMock, setIndexWidget)); Mock nlmLineEditMock; + Fake(Dtor(nlmLineEditMock)); Fake(Method(nlmLineEditMock, textChangedCbk)); When(Method(nlmLineEditMock, editingFinishedCbk)).Do([&](auto&& fn) { editFinCbk = fn; }); Fake(Method(nlmLineEditMock, mainWidget)); @@ -263,12 +286,14 @@ TEST_CASE("EditionFinished", "[newlinemanager]") When(Method(nlmFactoryMock, createLineEdit)).AlwaysDo([&]() { return &nlmLineEditMock.get(); }); Mock nlmCheckBoxMock; + Fake(Dtor(nlmCheckBoxMock)); Fake(Method(nlmCheckBoxMock, toggledCbk)); Fake(Method(nlmCheckBoxMock, mainWidget)); When(Method(nlmCheckBoxMock, getState)).Return(false); When(Method(nlmFactoryMock, createCheckBox)).AlwaysReturn(&nlmCheckBoxMock.get()); Mock nlmPushButtonMock; + Fake(Dtor(nlmPushButtonMock)); Fake(Method(nlmPushButtonMock, init)); Fake(Method(nlmPushButtonMock, pressedCbk)); Fake(Method(nlmPushButtonMock, mainWidget)); diff --git a/src/components/canrawview/tests/canrawview_test.cpp b/src/components/canrawview/tests/canrawview_test.cpp index 7dd9736ea..a3a6b172d 100644 --- a/src/components/canrawview/tests/canrawview_test.cpp +++ b/src/components/canrawview/tests/canrawview_test.cpp @@ -26,7 +26,7 @@ class CanRawViewPrivate; TEST_CASE("Initialize table", "[canrawview]") { Mock crvMock; - + Fake(Dtor(crvMock)); Fake(Method(crvMock, setClearCbk)); Fake(Method(crvMock, setDockUndockCbk)); Fake(Method(crvMock, setSectionClikedCbk)); @@ -226,6 +226,7 @@ TEST_CASE("Dock/Undock", "[canrawview]") CRVGuiInterface::dockUndock_t dockUndock; Mock crvMock; + Fake(Dtor(crvMock)); Fake(Method(crvMock, setClearCbk)); Fake(Method(crvMock, setSectionClikedCbk)); Fake(Method(crvMock, setFilterCbk)); @@ -256,6 +257,7 @@ TEST_CASE("Section clicked", "[canrawview]") QAbstractItemModel* model = nullptr; Mock crvMock; + Fake(Dtor(crvMock)); Fake(Method(crvMock, setClearCbk)); When(Method(crvMock, setSectionClikedCbk)).AlwaysDo([&](auto&& fn) { sectionClicked = fn; }); Fake(Method(crvMock, setFilterCbk)); @@ -321,6 +323,7 @@ TEST_CASE("Filter callback", "[canrawview]") QAbstractItemModel* model = nullptr; Mock crvMock; + Fake(Dtor(crvMock)); Fake(Method(crvMock, setClearCbk)); When(Method(crvMock, setFilterCbk)).Do([&](auto&& fn) { filter = fn; }); Fake(Method(crvMock, setSectionClikedCbk)); @@ -373,6 +376,7 @@ TEST_CASE("Stress test", "[canrawview]") CRVGuiInterface::filter_t filter; Mock crvMock; + Fake(Dtor(crvMock)); Fake(Method(crvMock, setClearCbk)); When(Method(crvMock, setFilterCbk)).Do([&](auto&& fn) { filter = fn; }); Fake(Method(crvMock, setSectionClikedCbk)); diff --git a/src/components/cansignaldata/cansignaldata_p.cpp b/src/components/cansignaldata/cansignaldata_p.cpp index 0bbdfe993..2c79be91c 100644 --- a/src/components/cansignaldata/cansignaldata_p.cpp +++ b/src/components/cansignaldata/cansignaldata_p.cpp @@ -107,10 +107,10 @@ CanSignalDataPrivate::msgSettings_t CanSignalDataPrivate::getMsgSettings() void CanSignalDataPrivate::setMsgSettings(const msgSettings_t& msgSettings) { // Clear current settings - for (std::pair>&& msg : _messages) { + std::for_each(std::begin(_messages), std::end(_messages), [](std::pair> && msg) { msg.first.updateCycle = 0; msg.first.initValue = ""; - } + }); for (const auto& msg : msgSettings) { auto msgDb = findInDb(msg.first); diff --git a/src/components/cansignaldata/tests/cansignaldata_test.cpp b/src/components/cansignaldata/tests/cansignaldata_test.cpp index 6108a10b7..dcce21eee 100644 --- a/src/components/cansignaldata/tests/cansignaldata_test.cpp +++ b/src/components/cansignaldata/tests/cansignaldata_test.cpp @@ -27,6 +27,7 @@ TEST_CASE("Stubbed methods", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initSearch)); Fake(Method(guiInt, setMsgView)); Fake(Method(guiInt, setMsgViewCbk)); @@ -230,6 +231,7 @@ TEST_CASE("dock/undock", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initSearch)); Fake(Method(guiInt, setMsgView)); Fake(Method(guiInt, setMsgViewCbk)); @@ -261,6 +263,7 @@ TEST_CASE("View switch test", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initSearch)); When(Method(guiInt, setMsgView)).AlwaysDo([&](auto&& model) { msgModel = &model; }); When(Method(guiInt, setSigView)).AlwaysDo([&](auto&& model) { sigModel = &model; }); @@ -294,6 +297,7 @@ TEST_CASE("settings callback", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initSearch)); When(Method(guiInt, setMsgView)).AlwaysDo([&](auto&& model) { auto proxy = dynamic_cast(&model); @@ -352,6 +356,7 @@ TEST_CASE("Filter test", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initSearch)); When(Method(guiInt, setMsgView)).AlwaysDo([&](auto&& model) { msgModel = dynamic_cast(&model); }); When(Method(guiInt, setSigView)).AlwaysDo([&](auto&& model) { sigModel = dynamic_cast(&model); }); diff --git a/src/components/cansignaldecoder/tests/cansignaldecoder_test.cpp b/src/components/cansignaldecoder/tests/cansignaldecoder_test.cpp index 9f758fa67..bab4d5e2b 100644 --- a/src/components/cansignaldecoder/tests/cansignaldecoder_test.cpp +++ b/src/components/cansignaldecoder/tests/cansignaldecoder_test.cpp @@ -658,7 +658,8 @@ TEST_CASE("Signal caching", "[cansignaldecoder]") REQUIRE(sigSndSpy.at(2).at(0).toString() == "0x003_StW_Angl"); REQUIRE(sigSndSpy.at(2).at(1).type() == QVariant::Double); REQUIRE(sigSndSpy.at(3).at(0).toString() == "0x003_StW_AnglSens_Id"); - REQUIRE((QMetaType::Type)sigSndSpy.at(3).at(1).type() == QMetaType::Long); + REQUIRE((((QMetaType::Type)sigSndSpy.at(3).at(1).type() == QMetaType::Long) || + ((QMetaType::Type)sigSndSpy.at(3).at(1).type() == QMetaType::LongLong))); REQUIRE(sigSndSpy.at(4).at(0).toString() == "0x003_StW_Angl"); REQUIRE(sigSndSpy.at(4).at(1).type() == QVariant::Double); } diff --git a/src/components/cansignalsender/cansignalsender_p.cpp b/src/components/cansignalsender/cansignalsender_p.cpp index 5e77d3c78..6f925d614 100644 --- a/src/components/cansignalsender/cansignalsender_p.cpp +++ b/src/components/cansignalsender/cansignalsender_p.cpp @@ -23,7 +23,7 @@ CanSignalSenderPrivate::CanSignalSenderPrivate(CanSignalSender* q, CanSignalSend _ui.setRemoveCbk([this] { QModelIndexList IndexList = _ui.getSelectedRows(); - std::list tmp = IndexList.toStdList(); + std::list tmp(IndexList.begin(), IndexList.end()); tmp.sort(); // List must to be sorted and reversed because erasing started from last row tmp.reverse(); diff --git a/src/components/cansignalsender/gui/cansignalsenderguiimpl.h b/src/components/cansignalsender/gui/cansignalsenderguiimpl.h index 413fe66dc..7c7816c30 100644 --- a/src/components/cansignalsender/gui/cansignalsenderguiimpl.h +++ b/src/components/cansignalsender/gui/cansignalsenderguiimpl.h @@ -39,8 +39,8 @@ class SigIdDelegate : public QStyledItemDelegate { cb->setCurrentText(_model->data(index).toString()); - connect(cb, static_cast(&QComboBox::activated), - [cb](const QString&) { cb->clearFocus(); }); + connect(cb, static_cast(&QComboBox::activated), + [cb](int) { cb->clearFocus(); }); // QOverload is not supported by MSVC 2015 connect(cb, static_cast(&QComboBox::currentTextChanged), @@ -104,8 +104,8 @@ class SigNameDelegate : public QStyledItemDelegate { cb->setCurrentText(_model->data(index).toString()); - connect(cb, static_cast(&QComboBox::activated), - [cb](const QString&) { cb->clearFocus(); }); + connect(cb, static_cast(&QComboBox::activated), + [cb](int) { cb->clearFocus(); }); return cb; } diff --git a/src/components/cansignalsender/tests/cansignalsender_test.cpp b/src/components/cansignalsender/tests/cansignalsender_test.cpp index 121c16819..86edbfac1 100644 --- a/src/components/cansignalsender/tests/cansignalsender_test.cpp +++ b/src/components/cansignalsender/tests/cansignalsender_test.cpp @@ -37,6 +37,7 @@ TEST_CASE("setConfig - json", "[cansignalsender]") { using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initTv)); Fake(Method(guiInt, setRemoveCbk)); Fake(Method(guiInt, setAddCbk)); @@ -138,6 +139,7 @@ TEST_CASE("row removing", "[cansignalsender]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); When(Method(guiInt, initTv)).AlwaysDo([&](auto&& m, auto&&) { model = &m; }); When(Method(guiInt, setRemoveCbk)).AlwaysDo([&](auto&& cbk) { removeCbk = cbk; }); Fake(Method(guiInt, setAddCbk)); @@ -194,6 +196,7 @@ TEST_CASE("dock/undock", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initTv)); Fake(Method(guiInt, setRemoveCbk)); Fake(Method(guiInt, setAddCbk)); @@ -223,6 +226,7 @@ TEST_CASE("signal sending", "[cansignaldata]") using namespace fakeit; Mock guiInt; + Fake(Dtor(guiInt)); Fake(Method(guiInt, initTv)); Fake(Method(guiInt, setRemoveCbk)); Fake(Method(guiInt, setAddCbk)); diff --git a/src/components/cansignalviewer/tests/cansignalviewer_test.cpp b/src/components/cansignalviewer/tests/cansignalviewer_test.cpp index 9478e1bd4..347b0f53f 100644 --- a/src/components/cansignalviewer/tests/cansignalviewer_test.cpp +++ b/src/components/cansignalviewer/tests/cansignalviewer_test.cpp @@ -72,6 +72,7 @@ TEST_CASE("sort", "[cansignalviewer]") Mock guiInt; CanSignalViewerGuiInt::sectionClicked_t sectionClicked; + Fake(Dtor(guiInt)); Fake(Method(guiInt, setClearCbk)); Fake(Method(guiInt, setDockUndockCbk)); When(Method(guiInt, setSectionClikedCbk)).Do([&](auto&& fn) { sectionClicked = fn; }); @@ -121,6 +122,7 @@ TEST_CASE("dock/undock", "[cansignalviewer]") Mock guiInt; CanSignalViewerGuiInt::dockUndock_t dockUndock; + Fake(Dtor(guiInt)); Fake(Method(guiInt, setClearCbk)); When(Method(guiInt, setDockUndockCbk)).Do([&](auto&& fn) { dockUndock = fn; }); Fake(Method(guiInt, setSectionClikedCbk)); @@ -172,7 +174,7 @@ TEST_CASE("Start/Stop", "[cansignalviewer]") CanSignalViewerGuiInt::clear_t clearCbk = nullptr; Mock guiMock; - + Fake(Dtor(guiMock)); When(Method(guiMock, setClearCbk)).Do([&](auto&& fn) { clearCbk = fn; }); Fake(Method(guiMock, setDockUndockCbk)); Fake(Method(guiMock, setSectionClikedCbk)); @@ -236,7 +238,7 @@ TEST_CASE("Standard/Unique test", "[cansignalviewer]") CanSignalViewerGuiInt::clear_t clearCbk = nullptr; Mock guiMock; - + Fake(Dtor(guiMock)); When(Method(guiMock, setClearCbk)).Do([&](auto&& fn) { clearCbk = fn; }); Fake(Method(guiMock, setDockUndockCbk)); Fake(Method(guiMock, setSectionClikedCbk)); @@ -358,7 +360,7 @@ TEST_CASE("Overrun", "[cansignalviewer]") CanSignalViewerGuiInt::clear_t clearCbk = nullptr; Mock guiMock; - + Fake(Dtor(guiMock)); When(Method(guiMock, setClearCbk)).Do([&](auto&& fn) { clearCbk = fn; }); Fake(Method(guiMock, setDockUndockCbk)); Fake(Method(guiMock, setSectionClikedCbk)); @@ -394,11 +396,11 @@ TEST_CASE("Overrun", "[cansignalviewer]") REQUIRE(sModel->rowCount() == 2000); REQUIRE(uModel->rowCount() == 3000); - for (int i = 0; i < 2000; ++i) { + for (uint32_t i = 0; i < 2000; ++i) { REQUIRE(sModel->data(sModel->index(i, 3)).toString().toUInt(nullptr, 16) == i + 4000); } - for (int i = 0; i < 3000; ++i) { + for (uint32_t i = 0; i < 3000; ++i) { REQUIRE(uModel->data(uModel->index(i, 3)).toString().toUInt(nullptr, 16) == i + 3000); } } diff --git a/src/components/qmlexecutor/tests/qmlexecutormodel_test.cpp b/src/components/qmlexecutor/tests/qmlexecutormodel_test.cpp index 5173e72a9..60619a62e 100644 --- a/src/components/qmlexecutor/tests/qmlexecutormodel_test.cpp +++ b/src/components/qmlexecutor/tests/qmlexecutormodel_test.cpp @@ -271,7 +271,7 @@ TEST_CASE("outData_frame", "[qmlexecutorModel]") { QMLExecutorModel cm; - int frameId = 21; + uint32_t frameId = 21; QByteArray frameData = QByteArray("ab\0cd", 5); int count{ 0 }; diff --git a/src/gui/projectconfig/CMakeLists.txt b/src/gui/projectconfig/CMakeLists.txt index f3c6e7748..053f7f1fc 100644 --- a/src/gui/projectconfig/CMakeLists.txt +++ b/src/gui/projectconfig/CMakeLists.txt @@ -26,8 +26,5 @@ if(WITH_TESTS) target_link_libraries(${COMPONENT_NAME}_test_noqrc ${COMPONENT_NAME} Qt5::Test fakeit) add_test(NAME ProjectConfigTestNoQrc COMMAND ${COMPONENT_NAME}_test_noqrc) - set(CONFIG_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles) - set(CONFIG_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/configfiles) - add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CONFIG_SOURCE} ${CONFIG_DESTINATION}) + add_definitions(-DPC_TEST_CONFIG_FILES="${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles") endif() diff --git a/src/gui/projectconfig/dragwidget.cpp b/src/gui/projectconfig/dragwidget.cpp index 0f14d8eb2..29c71415c 100644 --- a/src/gui/projectconfig/dragwidget.cpp +++ b/src/gui/projectconfig/dragwidget.cpp @@ -1,7 +1,10 @@ +#define QT_DISABLE_DEPRECATED_BEFORE 0x051500 + #include #include "dragwidget.h" #include +#include DragWidget::DragWidget(QWidget* parent) : QFrame(parent) @@ -23,6 +26,14 @@ void DragWidget::dragEnterEvent(QDragEnterEvent* event) } } +template +auto get_value(T t) { + if constexpr (std::is_pointer_v) + return *t; + else + return t; +} + void DragWidget::mousePressEvent(QMouseEvent* event) { QWidget* el = childAt(event->pos()); @@ -42,7 +53,8 @@ void DragWidget::mousePressEvent(QMouseEvent* event) return; } - const QPixmap* pixmap = child->pixmap(); + // pixmap() returns QPixmap since Qt5.15 rather than QPixmap* as it was before + auto pixmap = child->pixmap(); if (!pixmap) return; @@ -55,13 +67,13 @@ void DragWidget::mousePressEvent(QMouseEvent* event) QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); - drag->setPixmap(*pixmap); + drag->setPixmap(get_value(pixmap)); drag->setHotSpot({ 0, 0 }); if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction) { child->close(); } else { child->show(); - child->setPixmap(*pixmap); + child->setPixmap(get_value(pixmap)); } } diff --git a/src/gui/projectconfig/tests/projectconfig_test.cpp b/src/gui/projectconfig/tests/projectconfig_test.cpp index 57b55b085..2cfd1c869 100644 --- a/src/gui/projectconfig/tests/projectconfig_test.cpp +++ b/src/gui/projectconfig/tests/projectconfig_test.cpp @@ -25,7 +25,7 @@ std::shared_ptr kDefaultLogger; TEST_CASE("Loading and saving", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig.cds")); ProjectConfig pc(new QWidget); QByteArray outConfig; @@ -41,7 +41,7 @@ TEST_CASE("Loading and saving", "[projectconfig]") TEST_CASE("Color mode", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig.cds")); ProjectConfig pc(new QWidget); @@ -71,7 +71,7 @@ TEST_CASE("Validation schema parse error", "[projectconfig]") TEST_CASE("Validation JSON format error", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig_wrong.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); auto inConfig = file.read(40); @@ -81,7 +81,7 @@ TEST_CASE("Validation JSON format error", "[projectconfig]") TEST_CASE("Validation schema validation failed", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig_wrong.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); auto inConfig = file.readAll(); @@ -91,7 +91,7 @@ TEST_CASE("Validation schema validation failed", "[projectconfig]") TEST_CASE("Validation succeeded", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); auto inConfig = file.readAll(); @@ -101,7 +101,7 @@ TEST_CASE("Validation succeeded", "[projectconfig]") TEST_CASE("Validator validate", "[projectconfig]") { - QDir dir("configfiles"); + QDir dir(PC_TEST_CONFIG_FILES); QFile file(dir.absoluteFilePath("projectconfig.cds")); REQUIRE(file.open(QIODevice::ReadOnly) == true); auto inConfig = file.readAll(); @@ -122,7 +122,7 @@ TEST_CASE("callbacks test", "[projectconfig]") QtNodes::FlowScene* fs; Mock pcMock; - + Fake(Dtor(pcMock)); When(Method(pcMock, setNodeCreatedCallback)).Do([&](auto flow, auto&& fn) { fs = flow; nodeCreated = fn;