aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/popup
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-04-29 15:24:13 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-05-03 07:59:10 +0000
commit10d3752a2639d11d470a1b888cc6e92c627cb0d7 (patch)
tree3ae84a1897cafdd076036509b9573e0d028c7772 /tests/auto/popup
parent22bc04cf151d008e7bc1f825c5b55744144a0374 (diff)
QQuickPopup: listen to parent item's window changes
Emitting windowChanged() only in setParentItem() is unreliable, because the item might not yet have a window. Therefore we must listen to the parent item's windowChanged() signal. Change-Id: I237f81e0b06319516428c3c5d42352b228e753f5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/popup')
-rw-r--r--tests/auto/popup/tst_popup.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index 9ae08d93..fe0717d2 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -53,6 +53,7 @@ class tst_popup : public QQmlDataTest
private slots:
void visible();
void overlay();
+ void windowChange();
void closePolicy_data();
void closePolicy();
};
@@ -132,6 +133,31 @@ void tst_popup::overlay()
QVERIFY(!popup->isVisible());
}
+void tst_popup::windowChange()
+{
+ QQuickPopup popup;
+ QSignalSpy spy(&popup, SIGNAL(windowChanged(QQuickWindow*)));
+ QVERIFY(spy.isValid());
+
+ QQuickItem item;
+ popup.setParentItem(&item);
+ QVERIFY(!popup.window());
+ QCOMPARE(spy.count(), 0);
+
+ QQuickWindow window;
+ item.setParentItem(window.contentItem());
+ QCOMPARE(popup.window(), &window);
+ QCOMPARE(spy.count(), 1);
+
+ item.setParentItem(nullptr);
+ QVERIFY(!popup.window());
+ QCOMPARE(spy.count(), 2);
+
+ popup.setParentItem(window.contentItem());
+ QCOMPARE(popup.window(), &window);
+ QCOMPARE(spy.count(), 3);
+}
+
Q_DECLARE_METATYPE(QQuickPopup::ClosePolicy)
void tst_popup::closePolicy_data()