aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-01-13 14:35:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-18 00:16:46 +0100
commit52c1d7a994216f0b37ac04a2fea4337bc0c7550b (patch)
treed5301c513511a2595ece9ce533a3eb78d507c2a7 /tests/auto
parent6a5b9cb96434b5e36646fdbe66b23d0c6a1bdcd1 (diff)
Insertions were calculating wrong insertion pos
After removes, and after each insertion, the view must adjust the visibleItems.first() position and call layoutVisibleItems() to ensure that the correct insertion position is calculated for insertions that follow. When applyInsertionChange() in GridView and ListView calculates the position for item insertion, it looks at the current positions of the items in visibleItems, so these positions must be updated prior to this calculation. Otherwise, insertions that follow a remove may not calculate this position correctly and will neglect to add some items, and multiple insertions may unnecessarily create items at positions that are not actually visible. resetFirstItemPosition() is changed to take a set position and it replaces resetItemPosition() since it can do the same thing. Task-number: QTBUG-23610 QTBUG-23609 Change-Id: I8839ee7d15853301435e80c0dc563f93fc3605cf Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp20
-rw-r--r--tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp21
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
index e2bcbfd420..132fa5fad3 100644
--- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
@@ -1302,6 +1302,26 @@ void tst_QQuickGridView::moved_data()
<< 0 << 6 << 3
<< 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 120.0
+ << 3 << 16 << 6
+ << 60.0; // top two rows removed, third row is now the first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 5
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first row -> last")
+ << 0.0
+ << 0 << 15 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 120.0
+ << 5+4 << 13+4 << 5
+ << 0.0;
+
QTest::newRow("move multiple forwards, from visible -> non-visible")
<< 0.0
<< 1 << 16 << 3
diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
index e165e7ed73..1953cf7e73 100644
--- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
@@ -1359,6 +1359,7 @@ void tst_QQuickListView::moved(const QUrl &source)
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != 0);
@@ -1496,6 +1497,26 @@ void tst_QQuickListView::moved_data()
<< 0 << 5 << 3
<< 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 40.0
+ << 1 << 16 << 2
+ << 20.0; // item 1,2 are removed, item 3 is now first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first->last")
+ << 0.0
+ << 0 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 80.0
+ << 5+4 << 13+4 << 3
+ << 0.0;
+
QTest::newRow("move multiple forwards, from visible -> non-visible")
<< 0.0
<< 1 << 16 << 3