aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2014-01-18 16:45:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-19 19:13:35 +0100
commitc831a8e85afee6b257f8b3b1c5d86e4375b41e8c (patch)
treebf446d7ca42c871d3859d600e477be5e8426b2c0 /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
parent12e55eaa653107982de9b88f6459f0e16660a35e (diff)
Behavior fix when creating QML windows
When a QML window is created it is set visible after the QQuickWindowQmlImpl component is complete. This works fine for a single window, but because componentCompleted is called first for the last created windows, the behavior is not as the user might expect (and different compared to version 2.0 of the QML Window API). One of the results is e.g. that a window which is created as a child object in QML will have a lower z-Order than the parent. On some platforms (e.g. BlackBerry) an even bigger problem arises because the first created window acts as a container for the whole application and is always shown fullscreen. On other platforms (Linux) the initial window position and the window focus ares not set correctly. This patch postpones showing windows until the "transientParent" is visible. [Changelog][QtQuick] Making a QtQuick Window visible is postponed till its transient parent is visible Task-number: QTBUG-37440 Change-Id: I09a94ff038c066a5d3298c6c103dafde50bef1fa Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index fcab0c7ef2..b05146fa3a 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -341,6 +341,8 @@ private slots:
void requestActivate();
+ void testWindowVisibilityOrder();
+
void blockClosing();
void crashWhenHoverItemDeleted();
@@ -1589,7 +1591,8 @@ void tst_qquickwindow::requestActivate()
QVERIFY(windows.at(0)->objectName() == "window2");
window1->show();
- window1->requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(windows.at(0))); //We wait till window 2 comes up
+ window1->requestActivate(); // and then transfer the focus to window1
QTRY_VERIFY(QGuiApplication::focusWindow() == window1);
QVERIFY(window1->isActive() == true);
@@ -1615,6 +1618,54 @@ void tst_qquickwindow::requestActivate()
QTRY_VERIFY(QGuiApplication::focusWindow() == windows.at(0));
QVERIFY(windows.at(0)->isActive());
+ delete window1;
+}
+
+void tst_qquickwindow::testWindowVisibilityOrder()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("windoworder.qml"));
+ QQuickWindow *window1 = qobject_cast<QQuickWindow *>(component.create());
+ QQuickWindow *window2 = window1->property("win2").value<QQuickWindow*>();
+ QQuickWindow *window3 = window1->property("win3").value<QQuickWindow*>();
+ QQuickWindow *window4 = window1->property("win4").value<QQuickWindow*>();
+ QQuickWindow *window5 = window1->property("win5").value<QQuickWindow*>();
+ QVERIFY(window1);
+ QVERIFY(window2);
+ QVERIFY(window3);
+
+ QTest::qWaitForWindowExposed(window3);
+
+ QWindowList windows = QGuiApplication::topLevelWindows();
+ QTRY_COMPARE(windows.size(), 5);
+
+ QVERIFY(window3 == QGuiApplication::focusWindow());
+ QVERIFY(window1->isActive());
+ QVERIFY(window2->isActive());
+ QVERIFY(window3->isActive());
+
+ //Test if window4 is shown 2 seconds after the application startup
+ //with window4 visible window5 (transient child) should also become visible
+ QVERIFY(!window4->isVisible());
+ QVERIFY(!window5->isVisible());
+
+ window4->setVisible(true);
+
+ QTest::qWaitForWindowExposed(window5);
+ QVERIFY(window4->isVisible());
+ QVERIFY(window5->isVisible());
+ window4->hide();
+ window5->hide();
+
+ window3->hide();
+#if defined(Q_OS_OSX)
+ QEXPECT_FAIL("","Focus is not transferred to transient parent on window close (QTBUG-33423)", Continue);
+#endif
+ QTRY_COMPARE(window2 == QGuiApplication::focusWindow(), true);
+
+ window2->hide();
+ QTRY_COMPARE(window1 == QGuiApplication::focusWindow(), true);
}
void tst_qquickwindow::blockClosing()