aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-09-24 15:56:50 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-11-04 07:46:20 +0000
commitbbfa65d567ee7d2e27dae59162b377d4ba55cae7 (patch)
tree87e2603ea9728e66e3d69e5d54f75c3ca9170945 /tests
parent4c42cedf8211f88689e784d52265eae21ba1e4ca (diff)
Fix bug when highlight was not respected after currentIndex changed
QQuickListViewPrivate::fixup() seems to only do "fixup" if moveReason != QQuickListViewPrivate::SetIndex By default, moveReason is set to Other. In the snippet given in QTBUG-77418, this is why the highlight was respected when resizing the ListView initially. However, after the currentIndex was changed, moveReason was changed to SetIndex. When we then resized the ListView, it still had the value SetIndex, and would fail to "fixup" properly. Since the ListView preferredHighlightBegin is bound to width, we should set moveReason to Other in the property setters that are related to highlight. This is then consistent with how setCurrentIndex() does it (it similarly sets d->moveReason = QQuickItemViewPrivate::SetIndex;) Change-Id: I7edf77fc977e8c7e3fc656ff5bb22b4dd01afbe4 Task-number: QTBUG-77418 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index d956d89292..25212b06f6 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -1942,6 +1942,31 @@ void tst_QQuickListView::enforceRange()
QTRY_COMPARE(listview->currentIndex(), 6);
+ // Test for [QTBUG-77418] {
+ // explicit set current index
+ listview->setCurrentIndex(5);
+ QTRY_COMPARE(listview->contentY(), 0);
+
+ // then check if contentY changes if the highlight range is changed
+ listview->setPreferredHighlightBegin(80);
+ listview->setPreferredHighlightEnd(80);
+ QTRY_COMPARE(listview->contentY(), 20);
+
+ // verify that current index does not change with no highlight
+ listview->setHighlightRangeMode(QQuickListView::NoHighlightRange);
+ listview->setContentY(100);
+ QTRY_COMPARE(listview->currentIndex(), 5);
+
+ // explicit set current index, contentY should not change now
+ listview->setCurrentIndex(6);
+ QTRY_COMPARE(listview->contentY(), 100);
+ QTest::qWait(50); // This was needed in order to reproduce a failure for the following test
+
+ // verify that contentY changes if we turn on highlight again
+ listview->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ QTRY_COMPARE(listview->contentY(), 40);
+ // } Test for [QTBUG-77418]
+
// change model
QaimModel model2;
for (int i = 0; i < 5; i++)