diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-09-23 16:30:40 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-19 01:36:30 +0100 |
commit | 854272ecf9f26e77ddd8e3b7015cb8fe278183a5 (patch) | |
tree | b212a3055c38e6c1a8be3c22d82938ea6e23955d /tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | |
parent | a34eddbf7a68360ead218b2f5a9215e6b1ae88ec (diff) |
Fix positioning of item when first cacheBuffer item is removed.
When items prior to the first visible item are removed from the instantiated
items list the first item is moved forward by the size of the item removed so
it position remains correct relative to the visible items. But if the removed
item is the first instanitated item then it's size shouldn't contribute to the
offset as the next instatiated item is already offset by its size.
Task-number: QTBUG-33619
Change-Id: I05c33f505e2856afa08cd9cd89d8eae97c20679d
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index d207a7eadc..a0045a244f 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -736,6 +736,8 @@ void tst_QQuickListView::insertBeforeVisible() { QFETCH(int, insertIndex); QFETCH(int, insertCount); + QFETCH(int, removeIndex); + QFETCH(int, removeCount); QFETCH(int, cacheBuffer); QQuickText *name; @@ -775,14 +777,19 @@ void tst_QQuickListView::insertBeforeVisible() QVERIFY(item); QCOMPARE(item->y(), listview->contentY()); - QList<QPair<QString, QString> > newData; - for (int i=0; i<insertCount; i++) - newData << qMakePair(QString("value %1").arg(i), QString::number(i)); - model.insertItems(insertIndex, newData); - QTRY_COMPARE(listview->property("count").toInt(), model.count()); + if (removeCount > 0) + model.removeItems(removeIndex, removeCount); + + if (insertCount > 0) { + QList<QPair<QString, QString> > newData; + for (int i=0; i<insertCount; i++) + newData << qMakePair(QString("value %1").arg(i), QString::number(i)); + model.insertItems(insertIndex, newData); + QTRY_COMPARE(listview->property("count").toInt(), model.count()); + } // now, moving to the top of the view should position the inserted items correctly - int itemsOffsetAfterMove = -(insertCount * 20); + int itemsOffsetAfterMove = (removeCount - insertCount) * 20; listview->setCurrentIndex(0); QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); QTRY_COMPARE(listview->currentIndex(), 0); @@ -807,23 +814,41 @@ void tst_QQuickListView::insertBeforeVisible_data() { QTest::addColumn<int>("insertIndex"); QTest::addColumn<int>("insertCount"); + QTest::addColumn<int>("removeIndex"); + QTest::addColumn<int>("removeCount"); QTest::addColumn<int>("cacheBuffer"); - QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0; - QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100; - QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500; + QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0 << 0 << 0; + QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 0 << 0 << 100; + QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 0 << 0 << 500; + + QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0 << 0 << 0; + QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 0 << 0 << 100; + QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 0 << 0 << 500; + + QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0 << 0 << 0; + QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 0 << 0 << 100; + QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 0 << 0 << 500; + + QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0 << 0 << 0; + QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 0 << 0 << 100; + QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 0 << 0 << 500; + + QTest::newRow("remove 1 at 0, 0 buffer") << 0 << 0 << 0 << 1 << 0; + QTest::newRow("remove 1 at 0, 100 buffer") << 0 << 0 << 0 << 1 << 100; + QTest::newRow("remove 1 at 0, 500 buffer") << 0 << 0 << 0 << 1 << 500; - QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0; - QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100; - QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500; + QTest::newRow("remove 1 at 1, 0 buffer") << 0 << 0 << 1 << 1 << 0; + QTest::newRow("remove 1 at 1, 100 buffer") << 0 << 0 << 1 << 1 << 100; + QTest::newRow("remove 1 at 1, 500 buffer") << 0 << 0 << 1 << 1 << 500; - QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0; - QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100; - QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500; + QTest::newRow("remove multiple at 0, 0 buffer") << 0 << 0 << 0 << 3 << 0; + QTest::newRow("remove multiple at 0, 100 buffer") << 0 << 0 << 0 << 3 << 100; + QTest::newRow("remove multiple at 0, 500 buffer") << 0 << 0 << 0 << 3 << 500; - QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0; - QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100; - QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500; + QTest::newRow("remove multiple at 1, 0 buffer") << 0 << 0 << 1 << 3 << 0; + QTest::newRow("remove multiple at 1, 100 buffer") << 0 << 0 << 1 << 3 << 100; + QTest::newRow("remove multiple at 1, 500 buffer") << 0 << 0 << 1 << 3 << 500; } template <class T> |