diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-09-05 23:53:19 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-09-05 23:53:19 (GMT) |
commit | 0b5fa23dd25c78b71dfb0932008d226639a43445 (patch) | |
tree | 216092274ab073832106b9f45edd5b0fe50aea55 | |
parent | c1c04a016db5eefb3ee3dd26a20455aa14483713 (diff) | |
download | Qt-0b5fa23dd25c78b71dfb0932008d226639a43445.zip Qt-0b5fa23dd25c78b71dfb0932008d226639a43445.tar.gz Qt-0b5fa23dd25c78b71dfb0932008d226639a43445.tar.bz2 |
Add test for ListView positioning when all visible items are removed.
Task-number: QTBUG-12664
-rw-r--r-- | tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 377a9e5..e4b59a7 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -224,6 +224,13 @@ public: emit itemsRemoved(index, 1); } + void removeItems(int index, int count) { + int c = count; + while (c--) + list.removeAt(index); + emit itemsRemoved(index, count); + } + void moveItem(int from, int to) { list.move(from, to); emit itemsMoved(from, to, 1); @@ -290,6 +297,13 @@ public: emit endRemoveRows(); } + void removeItems(int index, int count) { + emit beginRemoveRows(QModelIndex(), index, index+count-1); + while (count--) + list.removeAt(index); + emit endRemoveRows(); + } + void moveItem(int from, int to) { emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); list.move(from, to); @@ -520,7 +534,7 @@ void tst_QDeclarativeListView::removed(bool animated) QDeclarativeView *canvas = createView(); T model; - for (int i = 0; i < 30; i++) + for (int i = 0; i < 50; i++) model.addItem("Item" + QString::number(i), ""); QDeclarativeContext *ctxt = canvas->rootContext(); @@ -643,6 +657,21 @@ void tst_QDeclarativeListView::removed(bool animated) QTRY_COMPARE(listview->currentIndex(), 7); QTRY_VERIFY(listview->currentItem() == oldCurrent); + listview->setContentY(80); + QTest::qWait(300); + + model.removeItems(1, 17); + QTest::qWait(300); + + // Confirm items positioned correctly + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i+2); + if (!item) qWarning() << "Item" << i+2 << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),80+i*20.0); + } + delete canvas; } |