QChronoTimer: add test for interval (u)int overflow
Now when we ported all dispatchers to QAbstractEventDispatcherV2 interface, we can reliably verify that we support timers with > 24 days intervals. Also add a 50 days test to check for uint overflows. Adding larger intervals requires test adjustments, because for coarse timers the actual interval may be up to 5% larger then specified. Amends 0d0b346322f6b078e6fe60cd3612e8d08a0d5f00. Task-number: QTBUG-132388 Change-Id: I152cb305c8460801f16bba0c5cd6758c366bce84 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
def4f827da
commit
453d8797f7
@ -252,10 +252,14 @@ void tst_QChronoTimer::remainingTimeInitial_data()
|
||||
QTest::addRow("precisetiemr-0ns") << 0ns << Qt::PreciseTimer;
|
||||
QTest::addRow("precisetimer-1ms") << nanoseconds{1ms} << Qt::PreciseTimer;
|
||||
QTest::addRow("precisetimer-10ms") <<nanoseconds{10ms} << Qt::PreciseTimer;
|
||||
QTest::addRow("precisetimer-25days") << nanoseconds{25 * 24h} << Qt::PreciseTimer;
|
||||
QTest::addRow("precisetimer-50days") << nanoseconds{50 * 24h} << Qt::PreciseTimer;
|
||||
|
||||
QTest::addRow("coarsetimer-0ns") << 0ns << Qt::CoarseTimer;
|
||||
QTest::addRow("coarsetimer-1ms") << nanoseconds{1ms} << Qt::CoarseTimer;
|
||||
QTest::addRow("coarsetimer-10ms") << nanoseconds{10ms} << Qt::CoarseTimer;
|
||||
QTest::addRow("coarsetimer-25days") << nanoseconds{25 * 24h} << Qt::CoarseTimer;
|
||||
QTest::addRow("coarsetimer-50days") << nanoseconds{50 * 24h} << Qt::CoarseTimer;
|
||||
}
|
||||
|
||||
void tst_QChronoTimer::remainingTimeInitial()
|
||||
@ -272,7 +276,14 @@ void tst_QChronoTimer::remainingTimeInitial()
|
||||
|
||||
const std::chrono::nanoseconds rt = timer.remainingTime();
|
||||
QCOMPARE_GE(rt, 0ns);
|
||||
QCOMPARE_LE(rt, startTimeNs);
|
||||
if (timerType != Qt::PreciseTimer) {
|
||||
// For coarse timers the calculated interval might be up to 5% larger
|
||||
// then specified
|
||||
auto largerStartTime = std::chrono::nanoseconds{startTimeNs + startTimeNs / 20};
|
||||
QCOMPARE_LE(rt, largerStartTime);
|
||||
} else {
|
||||
QCOMPARE_LE(rt, startTimeNs);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QChronoTimer::remainingTimeDuringActivation_data()
|
||||
|
Loading…
x
Reference in New Issue
Block a user