aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-04-21 08:37:07 +0300
committerJ-P Nurmi <jpnurmi@qt.io>2017-04-21 15:15:26 +0000
commit20d1bdc650dfcaa1c84d297f412fe7c836972990 (patch)
treefc765aec3bcc3a3db75a9451e8ca0146bd54d0f5 /tests/auto
parent7301f73ce019aca49e7c9367e22733022bc3680c (diff)
Fix QQuickPopup::isComponentComplete()
It has to default to true to ensure that a QQuickPopup instantiated in C++ is not stuck to false forever. When instantiated by the QML engine, it is set to false during the QML component initialization phase from classBegin() to componentComple(). NOTE: QQuickPopupItem's visibility has to be now set outside of QQuickPopupItem constructor, because QQuickPopupItem::itemChange() calls back to QQuickPopup::itemChange(). At that point QQuickPopupPrivate::popupItem should be set. Change-Id: I96fa4ab4b2f29344c4a0d5bce5f8c7642e9db1a6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/popup/tst_popup.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index ab96869a..a6de0c03 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -73,6 +73,7 @@ private slots:
void nested();
void grabber();
void cursorShape();
+ void componentComplete();
};
void tst_popup::visible_data()
@@ -754,6 +755,28 @@ void tst_popup::cursorShape()
QTRY_VERIFY(!popup->isVisible());
}
+class FriendlyPopup : public QQuickPopup
+{
+ friend class tst_popup;
+};
+
+void tst_popup::componentComplete()
+{
+ FriendlyPopup cppPopup;
+ QVERIFY(cppPopup.isComponentComplete());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick.Controls 2.2; Popup { }", QUrl());
+
+ FriendlyPopup *qmlPopup = static_cast<FriendlyPopup *>(component.beginCreate(engine.rootContext()));
+ QVERIFY(qmlPopup);
+ QVERIFY(!qmlPopup->isComponentComplete());
+
+ component.completeCreate();
+ QVERIFY(qmlPopup->isComponentComplete());
+}
+
QTEST_MAIN(tst_popup)
#include "tst_popup.moc"