tst_qstatusbar: Use a timer and remove some unnecessary waits to reduce test time.

Time taken by this testcase reduced from 7 seconds to 5.1 seconds for me.

Change-Id: I93b1c5fbc7d9d6515c9ce51a64fdd5c2ffbd54c8
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Robin Burchell 2014-08-18 16:15:14 +02:00
parent 2f9c00d9a0
commit 87bc094611

View File

@ -285,17 +285,16 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1000);
// Set display message for 2 seconds again
testWidget->showMessage("Ready", 2000);
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
// Set display message for 2 seconds
QElapsedTimer t;
t.start();
testWidget->showMessage("Ready 2000", 2000);
QCOMPARE(testWidget->currentMessage(), QString("Ready 2000"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1500);
// Message disappears after 2 seconds
QTRY_VERIFY(testWidget->currentMessage().isNull());
QVERIFY2(t.elapsed() >= 2000, qPrintable("Timer was " + QString::number(t.elapsed())));
QVERIFY(currentMessage.isNull());
// Set display message for 2 seconds first
@ -303,8 +302,6 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
QCOMPARE(testWidget->currentMessage(), QString("Ready 25492"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1000);
// Set display message forever again
testWidget->showMessage("Ready 25492", 0);
QCOMPARE(testWidget->currentMessage(), QString("Ready 25492"));