Make qWaitForWindowActive more robust

Based on the information we got from Unity developers, we need
to check for window's frame geometry to be set, not just window's
position to be set. On various window managers, a window is
'ready' once the frame geometry is set. This fixes autotest
flakiness of tests that use qWaitForWindowActive.

Task-number: QTBUG-66216
Change-Id: Icb664e7b802b474919f3b058c00681574522ccbe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
bb10
Ville Voutilainen 2018-02-26 15:57:55 +02:00 committed by Simon Hausmann
parent 1f6bd8bfb2
commit 2eec3272c7
1 changed files with 2 additions and 2 deletions

View File

@ -114,7 +114,7 @@ namespace QTest
{
bool becameActive = qWaitFor([&]() { return window->isActive(); }, timeout);
// Try ensuring the platform window receives the real position.
// Try ensuring the platform window receives the real position and geometry.
// (i.e. that window->pos() reflects reality)
// isActive() ( == FocusIn in case of X) does not guarantee this. It seems some WMs randomly
// send the final ConfigureNotify (the one with the non-bogus 0,0 position) after the FocusIn.
@ -122,7 +122,7 @@ namespace QTest
// qWaitForWindowShown() will generate bogus results.
if (becameActive) {
int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever
while (window->position().isNull()) {
while (window->frameGeometry().isNull()) {
if (waitNo++ > timeout / 10)
break;
qWait(10);