summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2022-11-01 10:44:33 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2022-11-11 17:48:50 +0100
commita45a1b8674d0982828d75440041a67fdb3da74f9 (patch)
tree185564e91df544151be17aeab338826d2034a4e7 /tests/auto/widgets/kernel/qwidget
parent436467134e6087ec5a0e360e1837aac4da2ce9ca (diff)
Stabilize flakiness in tst_QWidget::raise()
The test function raise() occasionally failed because of unexpected paint events being counted. This is due to a QTRY_VERIFY returning after consumption of the first paint event. If more than one paint event got posted, it will be delivered and counted when no more paint events are expected. This patch ensures that all paint events are consumed before resetting the count and expecting no more paint events. Fixes: QTBUG-68175 Pick-to: 6.2 6.4 Change-Id: I3e91a34e851da4bd01c7429e824d2b9101077a06 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 1e58b35e88..11289ac274 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -3719,7 +3719,8 @@ void tst_QWidget::raise()
for (int i = 0; i < 5; ++i)
child2->raise();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowExposed(child2));
+ QApplication::processEvents(); // process events that could be triggered by raise();
for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child2 ? 1 : 0;
@@ -3748,6 +3749,7 @@ void tst_QWidget::raise()
onTop->show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QTRY_VERIFY(onTop->numPaintEvents > 0);
+ QApplication::processEvents(); // process remaining paint events if there's more than one
onTop->reset();
// Reset all the children.
@@ -3756,7 +3758,8 @@ void tst_QWidget::raise()
for (int i = 0; i < 5; ++i)
child3->raise();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowExposed(child3));
+ QApplication::processEvents(); // process events that could be triggered by raise();
QCOMPARE(onTop->numPaintEvents, 0);
QCOMPARE(onTop->numZOrderChangeEvents, 0);