summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qthread/tst_qthread.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-12 16:54:09 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-14 23:26:15 +0100
commitf54916697a361549256330b35029d5251d3e1407 (patch)
tree5f6925d24e7a449bf95c3e9b9f0354d798137d36 /tests/auto/corelib/thread/qthread/tst_qthread.cpp
parentc4e36728bc00339070f8107d5880d4af5de93a28 (diff)
QThread-test: Fix test on Windows (timer inaccuracy).
- Tolerate WaitTime - 1 (799ms when expecting 800ms). - Remove commented-out code. Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Change-Id: Ibe246d47ab7667692386b0f9333150c195948282 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/corelib/thread/qthread/tst_qthread.cpp')
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index a8e04db2a0..7fc8710ccf 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -1074,17 +1074,14 @@ void tst_QThread::wait2()
thread.start();
timer.start();
QVERIFY(!thread.wait(Waiting_Thread::WaitTime));
- qint64 elapsed = timer.elapsed();
-
- QVERIFY(elapsed >= Waiting_Thread::WaitTime);
- //QVERIFY(elapsed < Waiting_Thread::WaitTime * 1.4);
+ qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 1).
+ QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
timer.start();
thread.cond1.wakeOne();
QVERIFY(thread.wait(/*Waiting_Thread::WaitTime * 1.4*/));
elapsed = timer.elapsed();
- QVERIFY(elapsed >= Waiting_Thread::WaitTime);
- //QVERIFY(elapsed < Waiting_Thread::WaitTime * 1.4);
+ QVERIFY2(elapsed - Waiting_Thread::WaitTime >= -1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
}
@@ -1116,9 +1113,7 @@ void tst_QThread::wait3_slowDestructor()
timer.start();
QVERIFY(!thread.wait(Waiting_Thread::WaitTime));
qint64 elapsed = timer.elapsed();
-
- QVERIFY(elapsed >= Waiting_Thread::WaitTime);
- //QVERIFY(elapsed < Waiting_Thread::WaitTime * 1.4);
+ QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
slow.cond.wakeOne();
//now the thread should finish quickly