aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-09-23 16:30:40 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-19 01:36:30 +0100
commit854272ecf9f26e77ddd8e3b7015cb8fe278183a5 (patch)
treeb212a3055c38e6c1a8be3c22d82938ea6e23955d /tests
parenta34eddbf7a68360ead218b2f5a9215e6b1ae88ec (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')
-rw-r--r--tests/auto/quick/qquicklistview/data/addTransitions.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/displacedTransitions.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/header.qml1
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-enforcerange.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-noCurrent.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections-package.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/margins.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/moveTransitions.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleDisplaced.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleTransitions.qml1
-rw-r--r--tests/auto/quick/qquicklistview/data/populateTransitions.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/removeTransitions.qml2
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp61
14 files changed, 54 insertions, 31 deletions
diff --git a/tests/auto/quick/qquicklistview/data/addTransitions.qml b/tests/auto/quick/qquicklistview/data/addTransitions.qml
index 69e6ba1eea..88db36760f 100644
--- a/tests/auto/quick/qquicklistview/data/addTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/addTransitions.qml
@@ -62,7 +62,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/displacedTransitions.qml b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
index d83ccfedf4..37c9e1e588 100644
--- a/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
@@ -69,7 +69,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/header.qml b/tests/auto/quick/qquicklistview/data/header.qml
index 076bf9cb97..1cc4ae09ee 100644
--- a/tests/auto/quick/qquicklistview/data/header.qml
+++ b/tests/auto/quick/qquicklistview/data/header.qml
@@ -26,7 +26,6 @@ Rectangle {
focus: true
width: initialViewWidth
height: initialViewHeight
- cacheBuffer: 0
snapMode: ListView.SnapToItem
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
index f1052b1482..4ccf3088b0 100644
--- a/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
@@ -45,7 +45,7 @@ Rectangle {
objectName: "list"
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
highlight: myHighlight
diff --git a/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
index fa7430c4cb..e094b888ab 100644
--- a/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
@@ -43,7 +43,7 @@ Rectangle {
currentIndex: -1
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
delegate: myDelegate
highlightMoveVelocity: 1000
model: testModel
diff --git a/tests/auto/quick/qquicklistview/data/listview-sections-package.qml b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
index e0daf50b32..8bad73b5f6 100644
--- a/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
@@ -68,6 +68,6 @@ Rectangle {
height: 320
model: visualModel.parts.package
section.property: "number"
- cacheBuffer: 0
+ cacheBuffer: 60
}
}
diff --git a/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
index d82ff4c63a..7245025bac 100644
--- a/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
@@ -56,7 +56,7 @@ Rectangle {
objectName: "list"
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
section.property: sectionProperty
diff --git a/tests/auto/quick/qquicklistview/data/margins.qml b/tests/auto/quick/qquicklistview/data/margins.qml
index cf6a56c720..3e4defaffb 100644
--- a/tests/auto/quick/qquicklistview/data/margins.qml
+++ b/tests/auto/quick/qquicklistview/data/margins.qml
@@ -42,7 +42,7 @@ Rectangle {
topMargin: 30
bottomMargin: 50
highlightMoveVelocity: 100000
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
}
diff --git a/tests/auto/quick/qquicklistview/data/moveTransitions.qml b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
index c4dce99208..dbbb4ebe75 100644
--- a/tests/auto/quick/qquicklistview/data/moveTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
@@ -62,7 +62,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml b/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
index 5893c30447..e036822980 100644
--- a/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
+++ b/tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
@@ -44,7 +44,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
index 4fcc80be2d..c0e888c6c6 100644
--- a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
@@ -53,7 +53,6 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/populateTransitions.qml b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
index 84b5b6bc1f..735314524f 100644
--- a/tests/auto/quick/qquicklistview/data/populateTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
@@ -52,7 +52,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
diff --git a/tests/auto/quick/qquicklistview/data/removeTransitions.qml b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
index 861cf42d94..4a34d4b585 100644
--- a/tests/auto/quick/qquicklistview/data/removeTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
@@ -64,7 +64,7 @@ Rectangle {
anchors.centerIn: parent
width: 240
height: 320
- cacheBuffer: 0
+ cacheBuffer: 60
model: testModel
delegate: myDelegate
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>