diff options
author | Alberto Mardegan <info@mardy.it> | 2015-07-11 15:24:53 +0300 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-20 19:30:43 +0000 |
commit | 134d980a7fcf61c5440019bcfb3fdfc39c3f5f3c (patch) | |
tree | 4057dc82065edfaea18d7bc8f13d523b31e2b0f0 /tests | |
parent | 49874ec12a821c165ab31ec90d98eb5c4dec30dc (diff) |
Don't change the currentItem after a viewport resize
When highlightRangeMode is set to StrictlyEnforceRange and the view gets
resized, we don't want the currentIndex to change.
The code touched by this patch was introduced by commit
I08b7e61496a79f71c3b40fafaca985ae90f88503 back in Qt 4.7 times, and
never changed since then.
Task-number: QTBUG-43555
Change-Id: Ie67faa6898f13a1f7b0f1c4ae6c29721cb7dfa41
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/snapOneItemResize.qml | 16 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 32 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml new file mode 100644 index 0000000000..7ecc833a64 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +ListView { + id: list + currentIndex: 5 + snapMode: ListView.SnapOneItem + orientation: ListView.Horizontal + highlightRangeMode: ListView.StrictlyEnforceRange + highlightFollowsCurrentItem: true + model: 10 + spacing: 10 + delegate: Item { + width: ListView.view.width + height: ListView.view.height + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 6377650696..0c0e9115c5 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -179,6 +179,7 @@ private slots: void creationContext(); void snapToItem_data(); void snapToItem(); + void snapOneItemResize_QTBUG_43555(); void snapOneItem_data(); void snapOneItem(); @@ -5203,6 +5204,37 @@ void tst_QQuickListView::snapToItem() releaseView(window); } +void tst_QQuickListView::snapOneItemResize_QTBUG_43555() +{ + QQuickView *window = createView(); + window->resize(QSize(100, 320)); + window->setResizeMode(QQuickView::SizeRootObjectToView); + QQuickViewTestUtil::moveMouseAway(window); + + window->setSource(testFileUrl("snapOneItemResize.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); + QTRY_VERIFY(listview != 0); + + QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(listview->currentIndex(), 5); + currentIndexSpy.clear(); + + window->resize(QSize(400, 320)); + + QTRY_COMPARE(int(listview->width()), 400); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QTRY_COMPARE(listview->currentIndex(), 5); + QCOMPARE(currentIndexSpy.count(), 0); + + delete window; +} + void tst_QQuickListView::qAbstractItemModel_package_items() { items<QaimModel>(testFileUrl("listviewtest-package.qml")); |