summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-08-25 23:19:37 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-08-25 23:19:37 (GMT)
commit08df2a17f4f0ed9b5ce69ad91e3849260acda092 (patch)
tree1fbe5503d5cd32124edcbf3fdaf0b391cab01c3b /tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
parentaab53973d060b744d54017464af226207c5a4d42 (diff)
downloadQt-08df2a17f4f0ed9b5ce69ad91e3849260acda092.zip
Qt-08df2a17f4f0ed9b5ce69ad91e3849260acda092.tar.gz
Qt-08df2a17f4f0ed9b5ce69ad91e3849260acda092.tar.bz2
Add test for VisualItemModel layoutChanged() handling
Task-number: QTBUG-13146
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;