diff --git a/src/autotests/CMakeLists.txt b/src/autotests/CMakeLists.txt --- a/src/autotests/CMakeLists.txt +++ b/src/autotests/CMakeLists.txt @@ -17,19 +17,12 @@ add_test(CharacterWidthTest CharacterWidthTest) target_link_libraries(CharacterWidthTest ${KONSOLE_TEST_LIBS}) -# This test fails on kf5-qt5 SUSEQt5.9 buildbot since Oct 28, 2018 -# Believed due to frameworks regession; disable to avoid sysadmins having -# to fix for every build -# https://mail.kde.org/pipermail/kde-frameworks-devel/2018-November/073078.html -# https://phabricator.kde.org/T9948 -if (0) if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_executable(DBusTest DBusTest.cpp) ecm_mark_as_test(DBusTest) add_test(DBusTest DBusTest) target_link_libraries(DBusTest ${KONSOLE_TEST_LIBS} Qt5::DBus) endif() -endif() add_executable(HistoryTest HistoryTest.cpp) ecm_mark_as_test(HistoryTest) diff --git a/src/autotests/DBusTest.h b/src/autotests/DBusTest.h --- a/src/autotests/DBusTest.h +++ b/src/autotests/DBusTest.h @@ -28,6 +28,8 @@ #include +class QProcess; + namespace Konsole { @@ -46,6 +48,7 @@ private: QString _interfaceName; + QProcess *_process = nullptr; }; } diff --git a/src/autotests/DBusTest.cpp b/src/autotests/DBusTest.cpp --- a/src/autotests/DBusTest.cpp +++ b/src/autotests/DBusTest.cpp @@ -20,13 +20,16 @@ // Own #include "DBusTest.h" #include "../Session.h" -#include +#include +#include using namespace Konsole; /* Exec a new Konsole and grab its dbus */ void DBusTest::initTestCase() { + qRegisterMetaType(); + const QString interfaceName = QStringLiteral("org.kde.konsole"); QDBusConnectionInterface *bus = nullptr; QStringList konsoleServices; @@ -50,9 +53,11 @@ } // Create a new Konsole with a separate process id - int pid = KProcess::startDetached(QStringLiteral("konsole"), - QStringList(QStringLiteral("--separate"))); - if (pid == 0) { + _process = new QProcess; + _process->setProcessChannelMode(QProcess::ForwardedChannels); + _process->start(QStringLiteral("konsole"), QStringList(QStringLiteral("--separate"))); + + if (!_process->waitForStarted()) { QFAIL(QStringLiteral("Unable to exec a new Konsole").toLatin1().data()); } @@ -93,6 +98,7 @@ { // Need to take care of when user has CloseAllTabs=False otherwise // they will get a popup dialog when we try to close this. + QSignalSpy quitSpy(_process, SIGNAL(finished(int,QProcess::ExitStatus))); QDBusInterface iface(_interfaceName, QStringLiteral("/konsole/MainWindow_1"), @@ -103,6 +109,9 @@ if (!instanceReply.isValid()) { QFAIL(QStringLiteral("Unable to close Konsole: %1").arg(instanceReply.error().message()).toLatin1().data()); } + QVERIFY(quitSpy.wait()); + _process->kill(); + _process->deleteLater(); } void DBusTest::testSessions()