Relax timing constraints when checking timeout in tst_timeout

This commit is contained in:
Peter Würtz 2018-05-18 00:23:24 +02:00 committed by Simon Brunel
parent efb6001b9d
commit 8da467e9da
2 changed files with 13 additions and 5 deletions

View File

@ -34,8 +34,12 @@ void tst_qpromise_delay::fulfilled()
QCOMPARE(waitForValue(p, -1), 42);
QCOMPARE(p.isFulfilled(), true);
QVERIFY(elapsed >= 1000 * 0.95); // Qt::CoarseTimer (default) Coarse timers try to
QVERIFY(elapsed <= 1000 * 1.05); // keep accuracy within 5% of the desired interval.
// Qt::CoarseTimer (default) Coarse timers try to
// keep accuracy within 5% of the desired interval.
// Require accuracy within 6% for passing the test.
QVERIFY(elapsed >= 1000 * 0.94);
QVERIFY(elapsed <= 1000 * 1.06);
}
void tst_qpromise_delay::rejected()
@ -51,5 +55,5 @@ void tst_qpromise_delay::rejected()
QCOMPARE(waitForError(p, QString()), QString("foo"));
QCOMPARE(p.isRejected(), true);
QVERIFY(elapsed < 5);
QVERIFY(elapsed <= 10);
}

View File

@ -87,6 +87,10 @@ void tst_qpromise_timeout::timeout()
QCOMPARE(waitForValue(p, -1), -1);
QCOMPARE(p.isRejected(), true);
QCOMPARE(failed, true);
QVERIFY(elapsed >= 2000 * 0.95); // Qt::CoarseTimer (default) Coarse timers try to
QVERIFY(elapsed <= 2000 * 1.05); // keep accuracy within 5% of the desired interval.
// Qt::CoarseTimer (default) Coarse timers try to
// keep accuracy within 5% of the desired interval.
// Require accuracy within 6% for passing the test.
QVERIFY(elapsed >= 2000 * 0.94);
QVERIFY(elapsed <= 2000 * 1.06);
}