aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-03-16 18:45:39 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-19 10:49:21 +0100
commit6deb3ceffa209d710570ffeb361e95c988e6e7cd (patch)
treec0d7972e3b03771667dc7def07b421bb3763f2dd /tests/auto/quick/qquicklistview
parentf079f789c593996b0023afd6318d60d18ac66578 (diff)
Resetting a model can cause a crash in views with header/footer.
Geometry listeners were called for deleted header/footer. Change-Id: I47854178232f8a4ab5e19a931901b49741fec388 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicklistview')
-rw-r--r--tests/auto/quick/qquicklistview/data/headerfooter.qml2
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp39
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/headerfooter.qml b/tests/auto/quick/qquicklistview/data/headerfooter.qml
index 8e8463d645..4c3eeca328 100644
--- a/tests/auto/quick/qquicklistview/data/headerfooter.qml
+++ b/tests/auto/quick/qquicklistview/data/headerfooter.qml
@@ -6,6 +6,8 @@ ListView {
property bool rtl: false
width: 240
height: 320
+
+ model: testModel
orientation: horizontal ? ListView.Horizontal : ListView.Vertical
header: Rectangle {
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 335fc3c6e2..202f5164af 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -3529,6 +3529,45 @@ void tst_QQuickListView::headerFooter()
delete canvas;
}
+ {
+ // Reset model
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 4; i++)
+ model.addItem("Item" + QString::number(i), "");
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->y(), 30.*4);
+
+ model.reset();
+
+ header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->y(), 30.*4);
+
+ delete canvas;
+ }
}
void tst_QQuickListView::resizeView()