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 d507d338 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Use Qt5 QSignalSpy::wait() instead of sleep()

I only noticed on DragonFlyBSD that the TerminalInterfaceTest failed
w/o this patch.

Differential Revision: https://phabricator.kde.org/D8420
parent 1feffb1f
......@@ -99,9 +99,6 @@ void TerminalInterfaceTest::testTerminalInterface()
// FIXME: find a way to verify this
// int terminalProcessId = terminal->terminalProcessId();
// Sleep is used to allow enough time for these to work
// In Qt5 we can use QSignalSpy::wait()
// Let's try using QSignalSpy
// http://techbase.kde.org/Development/Tutorials/Unittests
// QSignalSpy is really a QList of QLists, so we take the first
......@@ -119,7 +116,7 @@ void TerminalInterfaceTest::testTerminalInterface()
// #1A - Test signal currentDirectoryChanged(QString)
currentDirectory = QStringLiteral("/tmp");
terminal->sendInput(QStringLiteral("cd ") + currentDirectory + QLatin1Char('\n'));
sleep(2000);
stateSpy.wait(2000);
QCOMPARE(stateSpy.count(), 1);
// Correct result?
......@@ -134,7 +131,7 @@ void TerminalInterfaceTest::testTerminalInterface()
// #1B - Test signal currentDirectoryChanged(QString)
// Invalid directory - no signal should be emitted
terminal->sendInput(QStringLiteral("cd /usrADADFASDF\n"));
sleep(2000);
stateSpy.wait(2000);
QCOMPARE(stateSpy.count(), 0);
// Should be no change since the above cd didn't work
......@@ -144,7 +141,7 @@ void TerminalInterfaceTest::testTerminalInterface()
// Test starting a new program
QString command = QStringLiteral("top");
terminal->sendInput(command + QLatin1Char('\n'));
sleep(2000);
stateSpy.wait(2000);
// FIXME: find a good way to validate process id of 'top'
foregroundProcessId = terminal->foregroundProcessId();
QVERIFY(foregroundProcessId != -1);
......@@ -152,7 +149,7 @@ void TerminalInterfaceTest::testTerminalInterface()
QCOMPARE(foregroundProcessName, command);
terminal->sendInput(QStringLiteral("q"));
sleep(2000);
stateSpy.wait(2000);
// Nothing running in foreground
foregroundProcessId = terminal->foregroundProcessId();
......@@ -171,13 +168,6 @@ void TerminalInterfaceTest::testTerminalInterface()
QCOMPARE(destroyedSpy.count(), 1);
}
void TerminalInterfaceTest::sleep(int msecs)
{
QEventLoop loop;
QTimer::singleShot(msecs, &loop, SLOT(quit()));
loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
}
KParts::Part *TerminalInterfaceTest::createPart()
{
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("konsolepart"));
......
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