diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmltimer/tst_qqmltimer.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp index 0168663cf2..a05b03ca64 100644 --- a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp +++ b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp @@ -45,23 +45,6 @@ void consistentWait(int ms) QTest::qWait(20); } -void eventLoopWait(int ms) -{ - // QTest::qWait() always calls sendPostedEvents before exiting, so we can't use it to stop - // between an event is posted and it is received; But we can use an event loop instead - - QPauseAnimation waitTimer(ms); - waitTimer.start(); - while (waitTimer.state() == QAbstractAnimation::Running) - { - QTimer timer; - QEventLoop eventLoop; - timer.start(0); - timer.connect(&timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit); - eventLoop.exec(); - } -} - class tst_qqmltimer : public QObject { Q_OBJECT @@ -419,7 +402,9 @@ void tst_qqmltimer::stopWhenEventPosted() connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); QCOMPARE(helper.count, 0); - eventLoopWait(200); + // Use QThread::msleep() as QTest::qWait() always calls sendPostedEvents before + // exiting, so we can't use it to stop between an event is posted and it is received. + QThread::msleep(200); QCOMPARE(helper.count, 0); QVERIFY(timer->isRunning()); timer->stop(); @@ -441,7 +426,9 @@ void tst_qqmltimer::restartWhenEventPosted() connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); QCOMPARE(helper.count, 0); - eventLoopWait(200); + // Use QThread::msleep() as QTest::qWait() always calls sendPostedEvents before + // exiting, so we can't use it to stop between an event is posted and it is received. + QThread::msleep(200); QCOMPARE(helper.count, 0); timer->restart(); |