diff options
author | Michael Brasser <michael.brasser@live.com> | 2014-12-18 10:20:37 -0600 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2015-01-13 16:07:25 +0100 |
commit | a38f9ec6c96559efa56e8f7346f74f5990810c3a (patch) | |
tree | 09c4728e11cca33e7cedcceca49305ce396f4345 /tests/auto/quick/qquicklistview | |
parent | 6c77a37bfcc5ebf30a126e5c937e8a0ca1773d24 (diff) |
Fix flick() with ListView.SnapToItem at bounds.
Previously flick() would not always allow flicking to the very end of
a ListView if ListView.SnapToItem were set. Stop ListView from adding
overshoot, and then incorrectly correcting, if we are flicking exactly
to the end of a list.
Change-Id: Iad56e433bc1ba7d62f0553c4355469c9861df919
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/quick/qquicklistview')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds2.qml | 14 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 25 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds2.qml b/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds2.qml new file mode 100644 index 0000000000..08870a46b9 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds2.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +ListView { + id: view + width: 200; height: 400 + + snapMode: ListView.SnapToItem + + model: 10 + delegate: Rectangle { + width: 200; height: 50 + color: index % 2 ? "red" : "green" + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 9e8a813d54..b29b2cf3a1 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -233,6 +233,7 @@ private slots: void QTBUG_38209(); void programmaticFlickAtBounds(); + void programmaticFlickAtBounds2(); void layoutChange(); @@ -7833,6 +7834,30 @@ void tst_QQuickListView::programmaticFlickAtBounds() QVERIFY(!spy.wait(100)); } +void tst_QQuickListView::programmaticFlickAtBounds2() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("programmaticFlickAtBounds2.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast<QQuickListView *>(window->rootObject()); + QVERIFY(listview); + + // move exactly one item + qreal velocity = -qSqrt(2 * 50 * listview->flickDeceleration()); + + // flick down + listview->flick(0, velocity); + + QTRY_COMPARE(listview->contentY(), qreal(50.0)); + + // flick down + listview->flick(0, velocity); + + QTRY_COMPARE(listview->contentY(), qreal(100.0)); +} + void tst_QQuickListView::layoutChange() { RandomSortModel *model = new RandomSortModel; |