summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-10-18 12:36:47 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-22 10:46:21 +0200
commit72a7882cec07a9ad187c9e1772fb08f59a4b9519 (patch)
tree40e57146d54e551837c0b1ff7ccac65a3a5a8d25 /tests/auto
parentc9ad904af9b6009205f5d02779c407fcd65b8d12 (diff)
Better QWindowContainer by not relying on native widgets.
We change the behavior slightly from the initial implementation in 5.1. Forcing the use of native child widgets is causing massive performance issues so instead, we attach the embedded QWindow directly to the root window. The only exception is QScrollArea and QMdiArea which still enforces native windows for the entire parent chain to make clipping and stacking work. Task-number: QTBUG-34138 Change-Id: If713637bd4dce630552ace2f8ad6b2e86c063721 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp62
1 files changed, 58 insertions, 4 deletions
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 2d9cb98e27..c17a03e058 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -68,8 +68,6 @@ public:
int numberOfObscures;
};
-
-
class tst_QWindowContainer: public QObject
{
Q_OBJECT
@@ -81,6 +79,7 @@ private slots:
void testBehindTheScenesDeletion();
void testUnparenting();
void testActivation();
+ void testAncestorChange();
};
@@ -188,6 +187,7 @@ void tst_QWindowContainer::testActivation()
root.show();
root.activateWindow();
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
QVERIFY(QTest::qWaitForWindowActive(root.windowHandle()));
QVERIFY(QGuiApplication::focusWindow() == root.windowHandle());
@@ -204,8 +204,7 @@ void tst_QWindowContainer::testActivation()
QTest::qWait(100);
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == window);
// Verify that all states in the root widget still indicate it is active
QVERIFY(root.windowHandle()->isActive());
@@ -231,6 +230,61 @@ void tst_QWindowContainer::testUnparenting()
QVERIFY(!window->isVisible());
}
+void tst_QWindowContainer::testAncestorChange()
+{
+ QWidget root;
+ QWidget *left = new QWidget(&root);
+ QWidget *right = new QWidget(&root);
+
+ root.setGeometry(0, 0, 200, 100);
+ left->setGeometry(0, 0, 100, 100);
+ right->setGeometry(100, 0, 100, 100);
+
+ QWindow *window = new QWindow();
+ QWidget *container = QWidget::createWindowContainer(window, left);
+ container->setGeometry(0, 0, 100, 100);
+
+ // Root
+ // + left
+ // | + container
+ // | + window
+ // + right
+ root.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+ QCOMPARE(window->geometry(), QRect(0, 0, 100, 100));
+
+ container->setParent(right);
+ // Root
+ // + left
+ // + right
+ // + container
+ // + window
+ QCOMPARE(window->geometry(), QRect(100, 0, 100, 100));
+
+ QWidget *newRoot = new QWidget(&root);
+ newRoot->setGeometry(50, 50, 200, 200);
+ right->setParent(newRoot);
+ // Root
+ // + left
+ // + newRoot
+ // + right
+ // + container
+ // + window
+ QCOMPARE(window->geometry(), QRect(150, 50, 100, 100));
+ newRoot->move(0, 0);
+ QCOMPARE(window->geometry(), QRect(100, 0, 100, 100));
+
+ newRoot->setParent(0);
+ newRoot->setGeometry(100, 100, 200, 200);
+ newRoot->show();
+ QVERIFY(QTest::qWaitForWindowExposed(newRoot));
+ // newRoot
+ // + right
+ // + container
+ // + window
+ QCOMPARE(window->geometry(), QRect(100, 0, 100, 100));
+}
+
QTEST_MAIN(tst_QWindowContainer)
#include "tst_qwindowcontainer.moc"