aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-06-12 11:54:40 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-12 15:40:13 +0200
commit14e15458a53ea5de16d829dd0dce0d9d0c4f1611 (patch)
treebbd0f7b1df539ad06f252196a2fd1bdbd7f5a1e6 /tests
parenteacbc7805e937e64b7e117705919b214aed4f736 (diff)
Fix view delegate parent binding regression.
762b4d90110465aeceb96f44cd06dcda229dfe89 introduced a regression by setting the item parent after completion. This was to avoid rendering an incubated object before completion. However this breaks bindings. Restore setting the item parent before completion, and ensure items are not rendered until completed. Change-Id: Ifc9d0c34ee62e687889c32ffab7c091b4c8cc470 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklistview/data/parentBinding.qml17
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp39
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/parentBinding.qml b/tests/auto/quick/qquicklistview/data/parentBinding.qml
new file mode 100644
index 0000000000..b56372888d
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/parentBinding.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.0
+
+ListView {
+ width: 320; height: 480
+ model: ListModel {}
+ cacheBuffer: 300
+ delegate: Rectangle {
+ objectName: "wrapper"
+ width: parent.width
+ height: parent.parent.height/12
+ color: index % 2 ? "red" : "blue"
+ }
+ Component.onCompleted: {
+ for (var i = 0; i < 100; ++i)
+ model.append({"foo":"bar"+i})
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index b1ba5bb71f..4997e5062c 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -209,6 +209,8 @@ private slots:
void flickBeyondBounds();
void destroyItemOnCreation();
+ void parentBinding();
+
private:
template <class T> void items(const QUrl &source, bool forceLayout);
template <class T> void changed(const QUrl &source, bool forceLayout);
@@ -261,10 +263,18 @@ private:
}
#endif
+ static void errorMsgHandler(QtMsgType, const char *)
+ {
+ ++m_errorCount;
+ }
+
QQuickView *m_view;
QString testForView;
+ static int m_errorCount;
};
+int tst_QQuickListView::m_errorCount = 0;
+
class TestObject : public QObject
{
Q_OBJECT
@@ -6712,6 +6722,35 @@ void tst_QQuickListView::destroyItemOnCreation()
delete canvas;
}
+void tst_QQuickListView::parentBinding()
+{
+ QQuickView *canvas = createView();
+
+ m_errorCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(errorMsgHandler);
+
+ canvas->setSource(testFileUrl("parentBinding.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->width(), listview->width());
+ QCOMPARE(item->height(), listview->height()/12);
+
+ // there should be no transient binding error
+ QVERIFY(!m_errorCount);
+
+ qInstallMsgHandler(old);
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"