Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 3eb9a34f authored by David Edmundson's avatar David Edmundson Committed by Kurt Hindenburg

Re-add DBus test

Summary:
Ported from KProcess::startDetached to a QProcess we can kill should the
window not exit when closed.

On the KDE CI where the window isn't quitting on close the test might
fail, but it will give us output where we can investigate.

Test Plan: Passes locally

Reviewers: #konsole, #frameworks, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D16919
parent dd03c26a
......@@ -17,19 +17,12 @@ ecm_mark_nongui_executable(CharacterWidthTest)
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)
......
......@@ -20,13 +20,16 @@
// Own
#include "DBusTest.h"
#include "../Session.h"
#include <KProcess>
#include <QProcess>
#include <QSignalSpy>
using namespace Konsole;
/* Exec a new Konsole and grab its dbus */
void DBusTest::initTestCase()
{
qRegisterMetaType<QProcess::ExitStatus>();
const QString interfaceName = QStringLiteral("org.kde.konsole");
QDBusConnectionInterface *bus = nullptr;
QStringList konsoleServices;
......@@ -50,9 +53,11 @@ void DBusTest::initTestCase()
}
// 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 @@ void DBusTest::cleanupTestCase()
{
// 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 @@ void DBusTest::cleanupTestCase()
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()
......
......@@ -28,6 +28,8 @@
#include <unistd.h>
class QProcess;
namespace Konsole
{
......@@ -46,6 +48,7 @@ protected Q_SLOTS:
private:
QString _interfaceName;
QProcess *_process = nullptr;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment