diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-08-25 23:19:37 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-08-25 23:19:37 (GMT) |
commit | 08df2a17f4f0ed9b5ce69ad91e3849260acda092 (patch) | |
tree | 1fbe5503d5cd32124edcbf3fdaf0b391cab01c3b /tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp | |
parent | aab53973d060b744d54017464af226207c5a4d42 (diff) | |
download | Qt-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.cpp | 35 |
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; |