refactor: port CommandProcessTests to QtTests

This commit is contained in:
sithlord48 2025-03-30 14:35:28 -04:00 committed by Nick Bolton
parent 810322623b
commit 8a139f0e3d
4 changed files with 34 additions and 5 deletions

View file

@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: 2025 Deskflow Developers # SPDX-FileCopyrightText: 2025 Deskflow Developers
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
add_subdirectory(core)
create_test( create_test(
NAME DotEnvTests NAME DotEnvTests
DEPENDS gui DEPENDS gui

View file

@ -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"
)

View file

@ -1,16 +1,16 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd. * SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/ */
#include "gui/core/CommandProcess.h" #include "CommandProcessTests.h"
#include <gtest/gtest.h> #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 // 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. // with windows 2022), but on windows 10 you can't call echo directly.
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
@ -27,5 +27,7 @@ TEST(CommandProcessTests, run_commandSucceeds_returnsOutput)
const QString actual = commandProcess.run(); const QString actual = commandProcess.run();
EXPECT_EQ("Hello, World!", actual.toStdString()); QCOMPARE(actual.toStdString(), "Hello, World!");
} }
QTEST_MAIN(CommandProcessTests)

View file

@ -0,0 +1,16 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include <QTest>
class CommandProcessTests : public QObject
{
Q_OBJECT
private slots:
// Test are run in order top to bottom
// void initTestCase();
void runCommand();
};