diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index d6cd2a1..0e92075 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -7,8 +7,14 @@ ecm_add_test(patchlisttest.cpp NAME_PREFIX "astra-" ) +ecm_add_test(processwatchertest.cpp + TEST_NAME processwatchertest + LINK_LIBRARIES astra_static Qt::Test + NAME_PREFIX "astra-" +) + ecm_add_test(utilitytest.cpp TEST_NAME utilitytest LINK_LIBRARIES astra_static Qt::Test NAME_PREFIX "astra-" -) \ No newline at end of file +) diff --git a/autotests/processwatchertest.cpp b/autotests/processwatchertest.cpp new file mode 100644 index 0000000..8705d84 --- /dev/null +++ b/autotests/processwatchertest.cpp @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2024 Joshua Goins +// SPDX-License-Identifier: GPL-3.0-or-later + +#include + +#include "processwatcher.h" + +class ProcessWatcherTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testWatcher() + { + QProcess process; + process.setProgram(QStringLiteral("echo")); + process.start(); + + const auto watcher = new ProcessWatcher(process.processId()); + + const QSignalSpy spy(watcher, &ProcessWatcher::finished); + + QVERIFY(spy.isValid()); + QCOMPARE(spy.count(), 0); + + process.kill(); + + QTRY_COMPARE(spy.count(), 1); + } +}; + +QTEST_MAIN(ProcessWatcherTest) +#include "processwatchertest.moc" diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index bcf520b..521fd09 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -29,13 +29,16 @@ ecm_qt_declare_logging_category(astra_static target_sources(astra_static PRIVATE include/patchlist.h + include/processwatcher.h include/utility.h src/patchlist.cpp + src/processwatcher.cpp src/utility.cpp) target_include_directories(astra_static PUBLIC include) target_link_libraries(astra_static PUBLIC Qt6::Core - Qt6::Network) + Qt6::Network + KF6::CoreAddons) add_executable(astra) @@ -59,7 +62,6 @@ target_sources(astra PRIVATE include/logger.h include/patcher.h include/processlogger.h - include/processwatcher.h include/profile.h include/profilemanager.h include/sapphirelogin.h @@ -82,7 +84,6 @@ target_sources(astra PRIVATE src/main.cpp src/patcher.cpp src/processlogger.cpp - src/processwatcher.cpp src/profile.cpp src/profilemanager.cpp src/sapphirelogin.cpp @@ -157,7 +158,6 @@ target_link_libraries(astra PRIVATE KF6::I18n KF6::ConfigCore KF6::ConfigGui - KF6::CoreAddons KF6::Archive QCoro::Core QCoro::Network