From 8a139f0e3dfffc4fef7ab72288391b9704caecea Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 30 Mar 2025 14:35:28 -0400 Subject: [PATCH] refactor: port CommandProcessTests to QtTests --- src/unittests/gui/CMakeLists.txt | 2 ++ src/unittests/gui/core/CMakeLists.txt | 9 +++++++++ .../gui/core/CommandProcessTests.cpp | 12 +++++++----- src/unittests/gui/core/CommandProcessTests.h | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 src/unittests/gui/core/CMakeLists.txt rename src/{test/integtests => unittests}/gui/core/CommandProcessTests.cpp (72%) create mode 100644 src/unittests/gui/core/CommandProcessTests.h diff --git a/src/unittests/gui/CMakeLists.txt b/src/unittests/gui/CMakeLists.txt index f5d35097c..73bd98cea 100644 --- a/src/unittests/gui/CMakeLists.txt +++ b/src/unittests/gui/CMakeLists.txt @@ -1,6 +1,8 @@ # SPDX-FileCopyrightText: 2025 Deskflow Developers # SPDX-License-Identifier: MIT +add_subdirectory(core) + create_test( NAME DotEnvTests DEPENDS gui diff --git a/src/unittests/gui/core/CMakeLists.txt b/src/unittests/gui/core/CMakeLists.txt new file mode 100644 index 000000000..06b23dc93 --- /dev/null +++ b/src/unittests/gui/core/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2025 Deskflow Developers +# SPDX-License-Identifier: MIT + +create_test( + NAME CommandProcessTests + DEPENDS gui + SOURCE CommandProcessTests.cpp + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/gui" +) diff --git a/src/test/integtests/gui/core/CommandProcessTests.cpp b/src/unittests/gui/core/CommandProcessTests.cpp similarity index 72% rename from src/test/integtests/gui/core/CommandProcessTests.cpp rename to src/unittests/gui/core/CommandProcessTests.cpp index 1d6ce8b86..3c6dc5bfd 100644 --- a/src/test/integtests/gui/core/CommandProcessTests.cpp +++ b/src/unittests/gui/core/CommandProcessTests.cpp @@ -1,16 +1,16 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception */ -#include "gui/core/CommandProcess.h" +#include "CommandProcessTests.h" -#include +#include "../../../lib/gui/core/CommandProcess.h" -TEST(CommandProcessTests, run_commandSucceeds_returnsOutput) +void CommandProcessTests::runCommand() { - // it seems that on windows, you can sometimes just call echo (this worked // with windows 2022), but on windows 10 you can't call echo directly. #if defined(Q_OS_WIN) @@ -27,5 +27,7 @@ TEST(CommandProcessTests, run_commandSucceeds_returnsOutput) const QString actual = commandProcess.run(); - EXPECT_EQ("Hello, World!", actual.toStdString()); + QCOMPARE(actual.toStdString(), "Hello, World!"); } + +QTEST_MAIN(CommandProcessTests) diff --git a/src/unittests/gui/core/CommandProcessTests.h b/src/unittests/gui/core/CommandProcessTests.h new file mode 100644 index 000000000..c2edfa28a --- /dev/null +++ b/src/unittests/gui/core/CommandProcessTests.h @@ -0,0 +1,16 @@ +/* + * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello + * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception + */ + +#include + +class CommandProcessTests : public QObject +{ + Q_OBJECT +private slots: + // Test are run in order top to bottom + // void initTestCase(); + void runCommand(); +};