diff options
authorSimon Hausmann <>2019-10-01 11:32:55 +0200
committerLiang Qi <>2019-10-03 15:09:16 +0000
commitdcecaeb7b95f673bfae55c4cee1056bfc6e903d9 (patch)
parentd448f2ecb8bca7de1e69f9f6f10d0ffb8c3d1beb (diff)
Prospective fix to stabilize tst_qwindow::isActive() on Windows 10
It is conceivable that during the try-compare loop of processing windowing system events we loose and regain the focus. That would explain the occasional test failure where instead of the expected 3 focus in events, we have received four. Task-number: QTBUG-77769 Change-Id: I2221440d09a74d4d18a72f7786232b4491cf45a8 Reviewed-by: Tor Arne Vestbø <> (cherry picked from commit 56f084781e2b8891929eca0070212fd7a32b32fc) Reviewed-by: Edward Welbourne <>
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 4f26950192..60f89fcb4e 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -893,7 +893,13 @@ void tst_QWindow::isActive()
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1);
- QTRY_COMPARE(window.received(QEvent::FocusIn), 3);
+ // We should be checking for exactly three, but since this is a try-compare _loop_, we might
+ // loose and regain focus multiple times in the event of a system popup. This has been observed
+ // to fail on Windows, see QTBUG-77769.
+ QTRY_VERIFY2(window.received(QEvent::FocusIn) >= 3,
+ qPrintable(
+ QStringLiteral("Expected more than three focus in events, received: %1")
+ .arg(window.received(QEvent::FocusIn))));