From 3fbe201d21032a505afc45ce3746ac499e7b462e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 19 Mar 2022 15:38:40 +0100 Subject: 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 Reviewed-by: Heikki Halmet Reviewed-by: Oliver Wolff --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/auto/widgets') 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") -- cgit v1.2.3