diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-03-19 15:38:40 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-03-23 03:31:44 +0100 |
commit | 3fbe201d21032a505afc45ce3746ac499e7b462e (patch) | |
tree | 470e79f3073834b182b27423dca87afa61a25a57 /tests/auto/widgets | |
parent | aa29de37a71a60a474091d95025480ad791cd171 (diff) |
Try to stabilize QWidget::enterLeaveOnWindowShowHide
The test is very flaky on Windows 11. Make sure that we have a secondary
window to close before proceeding, and wait for fade effects to finish,
otherwise we might never get the leave event from the windowing system.
Also replace a QVERIFY(qWaitFor) construct with a simple QTRY_VERIFY.
With these changes, a local run of 20 repeats of this test on a stressed
VM improves from 75% to 100%.
Pick-to: 6.3 6.2
Fixes: QTBUG-98477
Change-Id: Iedcc175b336e3cab23817b954aba1736d02f1b9d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 7 |
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 040ad17c74..1d1b0a318a 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -10138,6 +10138,8 @@ void tst_QWidget::enterLeaveOnWindowShowHide() secondary->show(); if (!QTest::qWaitForWindowExposed(secondary)) QEXPECT_FAIL("", "Secondary window failed to show, test will fail", Abort); + if (secondaryWindowType == Qt::Dialog && QGuiApplication::platformName() == "windows") + QTest::qWait(250); // on Windows, we have to wait for fade-in effects } }; @@ -10164,15 +10166,16 @@ void tst_QWidget::enterLeaveOnWindowShowHide() QTest::mouseClick(&widget, Qt::LeftButton, {}, widget.mapFromGlobal(cursorPos)); ++expectedLeave; - QTRY_COMPARE_WITH_TIMEOUT(widget.numLeaveEvents, expectedLeave, 500); + QTRY_COMPARE_WITH_TIMEOUT(widget.numLeaveEvents, expectedLeave, 1000); QVERIFY(!widget.underMouse()); + QTRY_VERIFY(QApplication::activeModalWidget() || QApplication::activePopupWidget()); if (QApplication::activeModalWidget()) QApplication::activeModalWidget()->close(); else if (QApplication::activePopupWidget()) QApplication::activePopupWidget()->close(); ++expectedEnter; // Use default timeout, the test is flaky on Windows otherwise. - QVERIFY(QTest::qWaitFor([&]{ return widget.numEnterEvents >= expectedEnter; })); + QTRY_VERIFY(widget.numEnterEvents >= expectedEnter); // When a modal dialog closes we might get more than one enter event on macOS. // This seems to depend on timing, so we tolerate that flakiness for now. if (widget.numEnterEvents > expectedEnter && QGuiApplication::platformName() == "cocoa") |