summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qdeadlinetimer
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-02-22 20:18:28 -0800
committerThiago Macieira <thiago.macieira@intel.com>2023-04-18 19:23:44 -0300
commitb498e1ae3a3c6f188952f02a5ba14d092fbd168b (patch)
treecebf3efd6100a46dfb0baa61e1730a63593f0e4b /tests/auto/corelib/kernel/qdeadlinetimer
parent5c95cb872297748398d2ee8fb77d061dfd102538 (diff)
QDeadlineTimer: use std::chrono::steady_clock everywhere
This matches the work that was done for QElapsedTimer. The QDeadlineTimer::t2 member is now always 0. This also removes the last distinction of timer types. Originally I had intended to use CLOCK_MONOTONIC_COARSE on Linux[1], but that created more problems than was worth, so I abandoned the idea in 2016. [1] https://codereview.qt-project.org/c/qt/qtbase/+/159933 Change-Id: Ieec322d73c1e40ad95c8fffd17468b313798ef79 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qdeadlinetimer')
-rw-r--r--tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
index dd132ea561..2627d6beca 100644
--- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
+++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
@@ -520,14 +520,15 @@ void tst_QDeadlineTimer::overflow()
// Make sure setRemainingTime underflows gracefully
deadline.setPreciseRemainingTime(std::numeric_limits<qint64>::min() / 10, 0, timerType);
- QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
+ QVERIFY(!deadline.isForever()); // The above underflows, so make sure we don't saturate to Forever
+ QCOMPARE(deadline.remainingTimeNSecs(), 0);
QVERIFY(deadline.remainingTime() == 0);
// If the timer is saturated we don't want to get a valid number of milliseconds
QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
// Check that the conversion to milliseconds and nanoseconds underflows gracefully
deadline.setPreciseDeadline(std::numeric_limits<qint64>::min() / 10, 0, timerType);
- QVERIFY(!deadline.isForever()); // On Win/macOS the above underflows, make sure we don't saturate to Forever
+ QVERIFY(!deadline.isForever()); // The above underflows, make sure we don't saturate to Forever
QVERIFY(deadline.deadline() == std::numeric_limits<qint64>::min());
QVERIFY(deadline.deadlineNSecs() == std::numeric_limits<qint64>::min());
}
@@ -630,16 +631,13 @@ void tst_QDeadlineTimer::stdchrono()
QTRY_VERIFY2_WITH_TIMEOUT(timersExecuted,
"Looks like timers didn't fire on time.", 4 * minResolution);
-#if defined(Q_OS_DARWIN) || defined(Q_OS_LINUX) || (defined(Q_CC_MSVC) && Q_CC_MSVC >= 1900)
{
- // We know for these OS/compilers that the std::chrono::steady_clock uses the same
- // reference time as QDeadlineTimer
qint64 before = duration_cast<nanoseconds>(steady_before.time_since_epoch()).count();
qint64 after = duration_cast<nanoseconds>(steady_after.time_since_epoch()).count();
QCOMPARE_GT(now.deadlineNSecs(), before);
QCOMPARE_LT(now.deadlineNSecs(), after);
}
-#endif
+
{
auto diff = duration_cast<milliseconds>(steady_after - steady_deadline);
QCOMPARE_GT(diff.count(), minResolution / 2);