summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestsystem.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-05-25 14:35:32 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-29 11:37:35 +0200
commit243a0660e10d13b8bd6eb4f90e5695aefab4611f (patch)
tree45d7dbd70a1ba5766e5fe5189683b2297c670f00 /src/testlib/qtestsystem.h
parent2e6b8b4734710377e25c199e3ff7865628e7d723 (diff)
Make qWaitForWindowShown more robust on X
Try ensuring the window has received its valid position from the WM. Change-Id: Ibd75bc19ae820765bfaadd30c22e77a19cd28849 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/testlib/qtestsystem.h')
-rw-r--r--src/testlib/qtestsystem.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h
index 095f791cac..31c9f481c5 100644
--- a/src/testlib/qtestsystem.h
+++ b/src/testlib/qtestsystem.h
@@ -88,6 +88,20 @@ namespace QTest
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QTest::qSleep(10);
}
+ // Try ensuring the platform window receives the real position.
+ // (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.
+ // If we just let things go, every mapTo/FromGlobal call the tests perform directly after
+ // qWaitForWindowShown() will generate bogus results.
+ if (window->isActive()) {
+ int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever
+ while (window->pos().isNull()) {
+ if (waitNo++ > timeout / 10)
+ break;
+ qWait(10);
+ }
+ }
return window->isActive();
}