summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2022-01-18 19:37:33 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2022-01-19 19:35:23 +0200
commit9f6f3da8eb5da4718f601cc768d5baba404ef1a6 (patch)
tree034cf21a5f25f5b2a54e5d08f832468336cce686 /tests/auto/corelib/kernel
parent552d1c91669ac22006a9ccc3146efb4c4f2c49d6 (diff)
tst_qeventdispatcher: avoid influence between test functions
When some test function fails (even as expected), it can leave the event dispatcher in an inconsistent state where the posted events queue might not be empty. As a result, this may break the internal logic of the next test function that is run. So, calling eventDispatcher->processEvents() after each completed function resets the event dispatcher to its initial state, which fixes the problem. Pick-to: 6.2 6.3 Change-Id: I5a54f892d09a6eca73c8fc82875ce3b9ce4a3242 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index a3732f2d95..2fff160ceb 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -65,6 +65,8 @@ public:
private slots:
void initTestCase();
+ void cleanup();
+
void registerTimer();
/* void registerSocketNotifier(); */ // Not implemented here, see tst_QSocketNotifier instead
@@ -111,6 +113,12 @@ void tst_QEventDispatcher::initTestCase()
}
}
+// consume pending posted events to avoid impact on the next test function
+void tst_QEventDispatcher::cleanup()
+{
+ eventDispatcher->processEvents(QEventLoop::AllEvents);
+}
+
class TimerManager {
Q_DISABLE_COPY(TimerManager)