aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qsglistview
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-10-07 13:06:26 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-07 05:55:18 +0200
commitcdf868033bbd7bf5a996c67fa56f8ac15e755115 (patch)
tree2e39f31248a7845fe8105e538b0a9c2b8eb55f10 /tests/auto/declarative/qsglistview
parentd517e9c541e5869e87006faeccd60be5690bee5b (diff)
Fix ListView components being unable to access context properties.
Where avaialable use the components creation context instead of the views context as the root context for the new item. Task-number: QTBUG-21865 Change-Id: I07e564548de57d58413dc0d7cd151bd8a90886e7 Reviewed-on: http://codereview.qt-project.org/6199 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qsglistview')
-rw-r--r--tests/auto/declarative/qsglistview/data/ComponentView.qml16
-rw-r--r--tests/auto/declarative/qsglistview/data/creationContext.qml5
-rw-r--r--tests/auto/declarative/qsglistview/tst_qsglistview.cpp24
3 files changed, 44 insertions, 1 deletions
diff --git a/tests/auto/declarative/qsglistview/data/ComponentView.qml b/tests/auto/declarative/qsglistview/data/ComponentView.qml
new file mode 100644
index 0000000000..3e87be8799
--- /dev/null
+++ b/tests/auto/declarative/qsglistview/data/ComponentView.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+ListView {
+ id: view
+
+ property string title
+
+ width: 100; height: 100;
+
+ model: 1
+ delegate: Text { objectName: "listItem"; text: view.title }
+ header: Text { objectName: "header"; text: view.title }
+ footer: Text { objectName: "footer"; text: view.title }
+ section.delegate: Text { objectName: "section"; text: view.title }
+ section.property: "modelData"
+}
diff --git a/tests/auto/declarative/qsglistview/data/creationContext.qml b/tests/auto/declarative/qsglistview/data/creationContext.qml
new file mode 100644
index 0000000000..79a682788b
--- /dev/null
+++ b/tests/auto/declarative/qsglistview/data/creationContext.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+ComponentView {
+ title: "Hello!"
+}
diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp
index 6e8b247848..cca6cd30c2 100644
--- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp
+++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp
@@ -134,6 +134,7 @@ private slots:
void rightToLeft();
void test_mirroring();
void margins();
+ void creationContext();
private:
template <class T> void items();
@@ -3712,6 +3713,28 @@ void tst_QSGListView::qAbstractItemModel_clear()
clear<TestModel2>();
}
+void tst_QSGListView::creationContext()
+{
+ QSGView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/creationContext.qml"));
+ qApp->processEvents();
+
+ QSGItem *rootItem = qobject_cast<QSGItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QSGItem *item;
+ QVERIFY(item = rootItem->findChild<QSGItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("section"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
QSGView *tst_QSGListView::createView()
{
QSGView *canvas = new QSGView(0);
@@ -3794,7 +3817,6 @@ void tst_QSGListView::dumpTree(QSGItem *parent, int depth)
}
}
-
QTEST_MAIN(tst_QSGListView)
#include "tst_qsglistview.moc"