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>
This commit is contained in:
Friedemann Kleint 2011-12-12 16:54:09 +01:00 committed by Qt by Nokia
parent c4e36728bc
commit f54916697a

View File

@ -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