forked from quickshell/quickshell
io/process: mask the "QProcess destroyed for running process" warn
This commit is contained in:
parent
f681e2016f
commit
86591f122d
5 changed files with 88 additions and 3 deletions
|
|
@ -1,7 +1,8 @@
|
|||
function (qs_test name)
|
||||
add_executable(${name} ${ARGN})
|
||||
target_link_libraries(${name} PRIVATE Qt::Quick Qt::Network Qt::Test quickshell-io)
|
||||
target_link_libraries(${name} PRIVATE Qt::Quick Qt::Network Qt::Test quickshell-io quickshell-core quickshell-window quickshell-ui)
|
||||
add_test(NAME ${name} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMAND $<TARGET_FILE:${name}>)
|
||||
endfunction()
|
||||
|
||||
qs_test(datastream datastream.cpp ../datastream.cpp)
|
||||
qs_test(process process.cpp ../process.cpp ../datastream.cpp ../processcore.cpp)
|
||||
|
|
|
|||
47
src/io/test/process.cpp
Normal file
47
src/io/test/process.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "process.hpp"
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qsignalspy.h>
|
||||
#include <qtest.h>
|
||||
#include <qtestcase.h>
|
||||
|
||||
#include "../process.hpp"
|
||||
|
||||
void TestProcess::startAfterReload() {
|
||||
auto process = Process();
|
||||
auto startedSpy = QSignalSpy(&process, &Process::started);
|
||||
auto exitedSpy = QSignalSpy(&process, &Process::exited);
|
||||
|
||||
process.setCommand({"true"});
|
||||
process.setRunning(true);
|
||||
|
||||
QVERIFY(!process.isRunning());
|
||||
QCOMPARE(startedSpy.count(), 0);
|
||||
|
||||
process.onPostReload();
|
||||
|
||||
QVERIFY(process.isRunning());
|
||||
QVERIFY(startedSpy.wait(100));
|
||||
}
|
||||
|
||||
void TestProcess::testExec() {
|
||||
auto process = Process();
|
||||
auto startedSpy = QSignalSpy(&process, &Process::started);
|
||||
auto exitedSpy = QSignalSpy(&process, &Process::exited);
|
||||
|
||||
process.onPostReload();
|
||||
|
||||
process.setCommand({"sleep", "30"});
|
||||
process.setRunning(true);
|
||||
|
||||
QVERIFY(process.isRunning());
|
||||
QVERIFY(startedSpy.wait(100));
|
||||
|
||||
process.exec({"true"});
|
||||
|
||||
QVERIFY(exitedSpy.wait(100));
|
||||
QVERIFY(startedSpy.wait(100));
|
||||
QVERIFY(process.isRunning());
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestProcess);
|
||||
12
src/io/test/process.hpp
Normal file
12
src/io/test/process.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class TestProcess: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
private slots:
|
||||
static void startAfterReload();
|
||||
static void testExec();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue