1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-22 12:47:44 +00:00

Add ProcessWatcher test

This commit is contained in:
Joshua Goins 2024-08-22 17:59:05 -04:00
parent 2ee0606a56
commit 99555830d6
3 changed files with 44 additions and 5 deletions

View file

@ -7,6 +7,12 @@ 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

View file

@ -0,0 +1,33 @@
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include <QtTest/QtTest>
#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"

View file

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