summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelistview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistview')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/footer.qml30
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp32
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/data/footer.qml b/tests/auto/declarative/qdeclarativelistview/data/footer.qml
new file mode 100644
index 0000000..11cbe16
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/footer.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+ footer: Text { objectName: "footer"; text: "Footer"; height: 30 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index e13bd94..9c24e03 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -97,6 +97,7 @@ private slots:
void QTBUG_9791();
void manualHighlight();
void QTBUG_11105();
+ void footer();
private:
template <class T> void items();
@@ -1558,6 +1559,37 @@ void tst_QDeclarativeListView::QTBUG_11105()
delete canvas;
}
+void tst_QDeclarativeListView::footer()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 3; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QDeclarativeText *footer = findItem<QDeclarativeText>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->y(), 60.0);
+
+ model.removeItem(1);
+ QTRY_COMPARE(footer->y(), 40.0);
+
+ model.clear();
+ QTRY_COMPARE(footer->y(), 0.0);
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();