Make sure the test window has focus
authorAlbert Astals Cid <albert.astals@canonical.com>
Thu, 16 Jan 2014 10:55:54 +0000 (11:55 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 16 Jan 2014 16:47:47 +0000 (17:47 +0100)
Some setups like xvfb-run under Linux do not focus windows
after showing them, this means that any focus based test will
fail since the windows itself is unfocused. This makes sure
the test window will be shown and focused.

Change-Id: I1903b7cdf88b772e1ca15acd4899695b49615712
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qmltest/quicktest.cpp

index c210c21..bb6eec3 100644 (file)
@@ -365,7 +365,8 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
                 view->resize(200, 200);
             }
             view->show();
-            QTest::qWaitForWindowExposed(view);
+            view->requestActivate();
+            QTest::qWaitForWindowActive(view);
             if (view->isExposed())
                 QTestRootObject::instance()->setWindowShown(true);
             if (!QTestRootObject::instance()->hasQuit && QTestRootObject::instance()->hasTestCase())