summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qeventdispatcher
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-07-31 01:36:36 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-09-04 22:40:35 +0300
commit909893344c1aa2beb94bae6e592a299dc6221944 (patch)
tree3d9d1ca76484fa6e2241648a7360770c8a0d2ebc /tests/auto/corelib/kernel/qeventdispatcher
parent6d4385b697059f83fc92a2e33e030044188c5644 (diff)
tst_qeventdispatcher: port to QDeadlineTimer
Easier logic for these use-cases. Change-Id: I97a18c45d9bd8cfcfee5d379d271366276d5a435 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qeventdispatcher')
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index a14cd7141d..007988dd54 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -18,6 +18,10 @@ static bool glibDisabled = []() {
}();
#endif
+#include <chrono>
+
+using namespace std::chrono_literals;
+
enum {
PreciseTimerInterval = 10,
CoarseTimerInterval = 200,
@@ -87,11 +91,9 @@ bool tst_QEventDispatcher::event(QEvent *e)
// drain the system event queue after the test starts to avoid destabilizing the test functions
void tst_QEventDispatcher::initTestCase()
{
- QElapsedTimer elapsedTimer;
- elapsedTimer.start();
- while (!elapsedTimer.hasExpired(CoarseTimerInterval) && eventDispatcher->processEvents(QEventLoop::AllEvents)) {
- ;
- }
+ QDeadlineTimer deadline(CoarseTimerInterval * 1ms);
+ while (!deadline.hasExpired() && eventDispatcher->processEvents(QEventLoop::AllEvents))
+ ;
}
// consume pending posted events to avoid impact on the next test function
@@ -292,9 +294,8 @@ void tst_QEventDispatcher::sendPostedEvents()
QFETCH(int, processEventsFlagsInt);
QEventLoop::ProcessEventsFlags processEventsFlags = QEventLoop::ProcessEventsFlags(processEventsFlagsInt);
- QElapsedTimer elapsedTimer;
- elapsedTimer.start();
- while (!elapsedTimer.hasExpired(200)) {
+ QDeadlineTimer deadline(200ms);
+ while (!deadline.hasExpired()) {
receivedEventType = -1;
QCoreApplication::postEvent(this, new QEvent(QEvent::User));