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>
This commit is contained in:
parent
aa29de37a7
commit
3fbe201d21
@ -10138,6 +10138,8 @@ void tst_QWidget::enterLeaveOnWindowShowHide()
|
|||||||
secondary->show();
|
secondary->show();
|
||||||
if (!QTest::qWaitForWindowExposed(secondary))
|
if (!QTest::qWaitForWindowExposed(secondary))
|
||||||
QEXPECT_FAIL("", "Secondary window failed to show, test will fail", Abort);
|
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));
|
QTest::mouseClick(&widget, Qt::LeftButton, {}, widget.mapFromGlobal(cursorPos));
|
||||||
++expectedLeave;
|
++expectedLeave;
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(widget.numLeaveEvents, expectedLeave, 500);
|
QTRY_COMPARE_WITH_TIMEOUT(widget.numLeaveEvents, expectedLeave, 1000);
|
||||||
QVERIFY(!widget.underMouse());
|
QVERIFY(!widget.underMouse());
|
||||||
|
QTRY_VERIFY(QApplication::activeModalWidget() || QApplication::activePopupWidget());
|
||||||
if (QApplication::activeModalWidget())
|
if (QApplication::activeModalWidget())
|
||||||
QApplication::activeModalWidget()->close();
|
QApplication::activeModalWidget()->close();
|
||||||
else if (QApplication::activePopupWidget())
|
else if (QApplication::activePopupWidget())
|
||||||
QApplication::activePopupWidget()->close();
|
QApplication::activePopupWidget()->close();
|
||||||
++expectedEnter;
|
++expectedEnter;
|
||||||
// Use default timeout, the test is flaky on Windows otherwise.
|
// 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.
|
// 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.
|
// This seems to depend on timing, so we tolerate that flakiness for now.
|
||||||
if (widget.numEnterEvents > expectedEnter && QGuiApplication::platformName() == "cocoa")
|
if (widget.numEnterEvents > expectedEnter && QGuiApplication::platformName() == "cocoa")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user