Port tests away from KDELibs4Support

This consisted of KDialog->QDialog, kFatal->qFatal and linking to
KF5::Parts instead of KF5::KDELibs4Support.

Patch by Ragnar Thomsen rthomsen6 gmail com

Thanks!

REVIEW: 124683
wilder-portage
Kurt Hindenburg 11 years ago
parent ea7e36667b
commit 53bdb7fb44
  1. 11
      src/autotests/CMakeLists.txt
  2. 23
      src/autotests/DBusTest.cpp
  3. 7
      src/autotests/PartTest.cpp

@ -19,14 +19,13 @@ 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 KF5::KDELibs4Support)
target_link_libraries(DBusTest ${KONSOLE_TEST_LIBS} Qt5::DBus)
endif()
add_executable(HistoryTest HistoryTest.cpp)
ecm_mark_as_test(HistoryTest)
add_test(HistoryTest HistoryTest)
target_link_libraries(HistoryTest ${KONSOLE_TEST_LIBS} KF5::KDELibs4Support)
target_link_libraries(HistoryTest ${KONSOLE_TEST_LIBS} KF5::Parts)
add_executable(KeyboardTranslatorTest KeyboardTranslatorTest.cpp)
ecm_mark_as_test(KeyboardTranslatorTest)
@ -37,7 +36,7 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_executable(PartTest PartTest.cpp)
ecm_mark_as_test(PartTest)
add_test(PartTest PartTest)
target_link_libraries(PartTest KF5::XmlGui KF5::Parts KF5::Pty KF5::KDELibs4Support
target_link_libraries(PartTest KF5::XmlGui KF5::Parts KF5::Pty
${KONSOLE_TEST_LIBS})
endif()
@ -54,7 +53,7 @@ target_link_libraries(PtyTest KF5::Pty ${KONSOLE_TEST_LIBS})
add_executable(SessionTest SessionTest.cpp)
ecm_mark_as_test(SessionTest)
add_test(SessionTest SessionTest)
target_link_libraries(SessionTest ${KONSOLE_TEST_LIBS} KF5::KDELibs4Support)
target_link_libraries(SessionTest ${KONSOLE_TEST_LIBS} KF5::Parts)
add_executable(ShellCommandTest ShellCommandTest.cpp)
ecm_mark_as_test(ShellCommandTest)
@ -70,7 +69,7 @@ target_link_libraries(TerminalCharacterDecoderTest ${KONSOLE_TEST_LIBS})
add_executable(TerminalTest TerminalTest.cpp)
ecm_mark_as_test(TerminalTest)
add_test(TerminalTest TerminalTest)
target_link_libraries(TerminalTest ${KONSOLE_TEST_LIBS} KF5::KDELibs4Support)
target_link_libraries(TerminalTest ${KONSOLE_TEST_LIBS} KF5::Parts)
##add_executable(TerminalInterfaceTest TerminalInterfaceTest.cpp)
##ecm_mark_as_test(TerminalInterface)

@ -20,7 +20,7 @@
// Own
#include "DBusTest.h"
#include "../Session.h"
#include <KDebug>
#include <QtDebug>
#include <KProcess>
using namespace Konsole;
@ -34,11 +34,10 @@ void DBusTest::initTestCase()
if (!QDBusConnection::sessionBus().isConnected() ||
!(bus = QDBusConnection::sessionBus().interface()))
kFatal() << "Session bus not found";
QFAIL("Session bus not found");
QDBusReply<QStringList> serviceReply = bus->registeredServiceNames();
if (!serviceReply.isValid())
kFatal() << "SessionBus interfaces not available";
QVERIFY2(serviceReply.isValid(), "SessionBus interfaces not available");
// Find all current Konsoles' services running
QStringList allServices = serviceReply;
@ -52,7 +51,7 @@ void DBusTest::initTestCase()
// Create a new Konsole with a separate process id
int result = KProcess::execute("konsole");
if (result)
kFatal() << "Unable to exec a new Konsole : " << result;
QFAIL(QString("Unable to exec a new Konsole: %1").arg(result).toLatin1().data());
// Wait for above Konsole to finish starting
#if defined(HAVE_USLEEP)
@ -62,8 +61,7 @@ void DBusTest::initTestCase()
#endif
serviceReply = bus->registeredServiceNames();
if (!serviceReply.isValid())
kFatal() << "SessionBus interfaces not available";
QVERIFY2(serviceReply.isValid(), "SessionBus interfaces not available");
// Find dbus service of above Konsole
allServices = serviceReply;
@ -75,10 +73,8 @@ void DBusTest::initTestCase()
_interfaceName = service;
}
if (_interfaceName.isEmpty()) {
kFatal() << "This test will only work in a Konsole window with a new PID. A new Konsole PID can't be found.";
}
//kDebug()<< "Using service: " + _interfaceName.toLatin1();
QVERIFY2(!_interfaceName.isEmpty(),
"This test will only work in a Konsole window with a new PID. A new Konsole PID can't be found.");
QDBusInterface iface(_interfaceName,
QLatin1String("/Konsole"),
@ -96,12 +92,11 @@ void DBusTest::cleanupTestCase()
QDBusInterface iface(_interfaceName,
QLatin1String("/konsole/MainWindow_1"),
QLatin1String("org.qtproject.Qt.QWidget"));
if (!iface.isValid())
kFatal() << "Unable to get a dbus interface to Konsole!";
QVERIFY2(iface.isValid(), "Unable to get a dbus interface to Konsole!");
QDBusReply<void> instanceReply = iface.call("close");
if (!instanceReply.isValid())
kFatal() << "Unable to close Konsole :" << instanceReply.error();
QFAIL(QString("Unable to close Konsole: %1").arg(instanceReply.error().message()).toLatin1().data());
}
void DBusTest::testSessions()

@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QFileInfo>
#include <QTimer>
#include <QDialog>
// KDE
#include <KPluginLoader>
#include <KPluginFactory>
@ -32,7 +33,6 @@
#include <KParts/Part>
#include <KPtyProcess>
#include <KPtyDevice>
#include <KDialog>
#include <KMainWindow>
#include <qtest.h>
@ -84,9 +84,8 @@ void PartTest::testFd()
// as soon as it becomes available and the terminal will not display any output
ptyProcess.pty()->setSuspended(true);
QWeakPointer<KDialog> dialog = new KDialog();
dialog.data()->setButtons(0);
QVBoxLayout* layout = new QVBoxLayout(dialog.data()->mainWidget());
QWeakPointer<QDialog> dialog = new QDialog();
QVBoxLayout* layout = new QVBoxLayout(dialog.data());
layout->addWidget(new QLabel("Output of 'ping localhost' should appear in a terminal below for 5 seconds"));
layout->addWidget(terminalPart->widget());
QTimer::singleShot(5000, dialog.data(), SLOT(close()));

Loading…
Cancel
Save