From d419377d2041b35639a5ab81688a0bc30b5e2994 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 10 Jul 2017 13:52:35 -0500 Subject: Fix ListView::StrictlyEnforceRange with resizing delegate When fixupPosition is called for a ListView with StrictlyEnforceRange, the original reason for the move is lost, and the fixup is applied immediately. There are already checks for whether the view is moving, so expand these checks to include movement caused by highlight. Change-Id: I25f771b9a529d31dc28acb9f91fcd2b582428200 Task-number: QTBUG-33568 Reviewed-by: Robin Burchell --- .../quick/qquicklistview/tst_qquicklistview.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp') diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 98c628068d..2eb87b9431 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -182,6 +182,7 @@ private slots: void snapOneItemCurrentIndexRemoveAnimation(); void QTBUG_9791(); + void QTBUG_33568(); void QTBUG_11105(); void QTBUG_21742(); @@ -3470,6 +3471,29 @@ void tst_QQuickListView::QTBUG_9791() QTRY_COMPARE(listview->contentX(), 590.0); } +void tst_QQuickListView::QTBUG_33568() +{ + QScopedPointer window(createView()); + window->setSource(testFileUrl("strictlyenforcerange-resize.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast(window->rootObject()); + QVERIFY(listview != 0); + + // we want to verify that the change animates smoothly, rather than jumping into place + QSignalSpy spy(listview, SIGNAL(contentYChanged())); + + listview->incrementCurrentIndex(); + QTRY_COMPARE(listview->contentY(), -100.0); + QVERIFY(spy.count() > 1); + + spy.clear(); + listview->incrementCurrentIndex(); + QTRY_COMPARE(listview->contentY(), -50.0); + QVERIFY(spy.count() > 1); +} + void tst_QQuickListView::manualHighlight() { QQuickView *window = new QQuickView(0); -- cgit v1.2.3