summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index e0f32ea..3cd786f 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -83,6 +83,7 @@ public:
private slots:
void rootIndex();
+ void updateLayout();
void objectListModel();
private:
@@ -155,6 +156,40 @@ void tst_qdeclarativevisualdatamodel::rootIndex()
delete obj;
}
+void tst_qdeclarativevisualdatamodel::updateLayout()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+
+ model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+}
+
void tst_qdeclarativevisualdatamodel::objectListModel()
{
QDeclarativeView view;