diff --git a/src/autotests/TerminalInterfaceTest.cpp b/src/autotests/TerminalInterfaceTest.cpp --- a/src/autotests/TerminalInterfaceTest.cpp +++ b/src/autotests/TerminalInterfaceTest.cpp @@ -99,9 +99,6 @@ // 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 @@ // #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 @@ // #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,15 +141,15 @@ // 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); foregroundProcessName = terminal->foregroundProcessName(); QCOMPARE(foregroundProcessName, command); terminal->sendInput(QStringLiteral("q")); - sleep(2000); + stateSpy.wait(2000); // Nothing running in foreground foregroundProcessId = terminal->foregroundProcessId(); @@ -171,13 +168,6 @@ 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"));