summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-10-16 15:04:49 +0200
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-10-26 13:12:35 +0000
commit2f402e4d099c0175cf79e95b624dedad7384062d (patch)
tree9962851839ac989d0e6e0e6635994cd155bc913b /tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
parentd669bde4bf32b19e317b6f58077f406a7d0e12e0 (diff)
Ensure QWindow::create() creates parent hierarchy before creating self
To be able to create a platform window for a given QWindow we need to sync up the parent hierarchy first, so that the newly created window can be placed into that hierarchy. Without creating the parent hierarchy first, the QPlatformWindow will end up thinking it's a top level window, when in reality is represents the platform backing of a child QWindow. Change-Id: I2cad7759fbc118b04718e7a27ec7570ce1238757 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/gui/kernel/qwindow/tst_qwindow.cpp')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 2219306b81..71ff9aaf42 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -58,6 +58,7 @@ class tst_QWindow: public QObject
Q_OBJECT
private slots:
+ void create();
void eventOrderOnShow();
void resizeEventAfterResize();
void mapGlobal();
@@ -124,6 +125,36 @@ void tst_QWindow::cleanup()
QVERIFY(QGuiApplication::allWindows().isEmpty());
}
+void tst_QWindow::create()
+{
+ QWindow a;
+ QVERIFY2(!a.handle(), "QWindow should lazy init the platform window");
+
+ a.create();
+ QVERIFY2(a.handle(), "Explicitly creating a platform window should never fail");
+
+ QWindow b;
+ QWindow c(&b);
+ b.create();
+ QVERIFY(b.handle());
+ QVERIFY2(!c.handle(), "Creating a parent window should not automatically create children");
+
+ QWindow d;
+ QWindow e(&d);
+ e.create();
+ QVERIFY(e.handle());
+ QVERIFY2(d.handle(), "Creating a child window should automatically create parents");
+
+ QWindow f;
+ QWindow g(&f);
+ f.create();
+ QVERIFY(f.handle());
+ QPlatformWindow *platformWindow = f.handle();
+ g.create();
+ QVERIFY(g.handle());
+ QVERIFY2(f.handle() == platformWindow, "Creating a child window should not affect parent if already created");
+}
+
void tst_QWindow::mapGlobal()
{
QWindow a;