summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-01 03:06:05 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-01 03:06:05 (GMT)
commit91cb226780d05f0f7d8fd1875121427ade52c1a8 (patch)
treed0e8764e164cfefb8c6c7b7d14502c48cb988a5a /tests/auto
parent41e4f2207008888803920df85cdaa6b0af31d428 (diff)
downloadQt-91cb226780d05f0f7d8fd1875121427ade52c1a8.zip
Qt-91cb226780d05f0f7d8fd1875121427ade52c1a8.tar.gz
Qt-91cb226780d05f0f7d8fd1875121427ade52c1a8.tar.bz2
Avoid refilling view during model change.
The view position is reset to 0 after clear()ing, but this results in refill() being called, effectively undoing the clear(). Fix is to make the model invalid before resetting position. Task-number: QTBUG-11105
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 203760e..2aef9bb 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -91,6 +91,7 @@ private slots:
void modelChanges();
void QTBUG_9791();
void manualHighlight();
+ void QTBUG_11105();
private:
template <class T> void items();
@@ -1493,6 +1494,53 @@ void tst_QDeclarativeListView::manualHighlight()
QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
}
+void tst_QDeclarativeListView::QTBUG_11105()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QTRY_VERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->positionViewAtIndex(20, QDeclarativeListView::Beginning);
+ QCOMPARE(listview->contentY(), 280.);
+
+ TestModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();