Fix tst_QGuiShortcutwithQApplication::windowShortcut flakiness

tst_QGuiShortcutWithQApplication::windowShortcut() is flaky on Linux.
When it fails, the key event is not properly received properly by the
window w as it is not active.

Verify that the window w is active before sending the keyEvent, to fix
the flakiness on Linux.

Change-Id: I98961cdfa9a4f46e83f0725ef1cabc91c0f8b055
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Frédéric Lefebvre 2025-03-24 14:26:38 +01:00
parent 0b85624480
commit 76bc2dd390

View File

@ -53,6 +53,7 @@ void tst_QShortcut::windowShortcut()
QEXPECT_FAIL("", "It failed on Wayland, QTBUG-120334", Abort);
QTRY_VERIFY(QGuiApplication::applicationState() == Qt::ApplicationActive);
QTRY_VERIFY(w.isActive());
QTest::sendKeyEvent(QTest::Click, &w, Qt::Key_Q, 'q', Qt::ControlModifier);
QTRY_VERIFY(!w.isVisible());
}