diff options
author | Volker Hilsheimer <[email protected]> | 2022-05-06 11:43:18 +0200 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2022-05-31 21:20:41 +0200 |
commit | fb8a88b05cd3f7663efaa9c5c5cf8143a1f2b66f (patch) | |
tree | f04a99ed538eb61f6765455b88bc350cfaab87ed | |
parent | 5adaa8d868b6718e07035152351b14449cea95d3 (diff) |
Use a precise timer in QTestEventLoop if timeout is sub-second
QTestEventLoop is used by QSignalSpy::wait. If tests want to verify
that a signal gets emitted within a second or less, we should use
a precise timer to reduce the chance of timer imprecision breaking
the test.
Change-Id: I2a2ca3bbdcaf032288f1fdc2aecc6afd05a6c76c
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r-- | src/testlib/qtesteventloop.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/testlib/qtesteventloop.h b/src/testlib/qtesteventloop.h index 32d186bd0e4..7a04c82da3f 100644 --- a/src/testlib/qtesteventloop.h +++ b/src/testlib/qtesteventloop.h @@ -64,7 +64,8 @@ inline void QTestEventLoop::enterLoopMSecs(int ms) return; QEventLoop l; - timerId = startTimer(ms); + // if tests want to measure sub-second precision, use a precise timer + timerId = startTimer(ms, ms < 1000 ? Qt::PreciseTimer : Qt::CoarseTimer); loop = &l; l.exec(); |