diff options
author | Michael Brasser <mbrasser@ford.com> | 2018-06-14 20:41:40 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2018-06-29 16:41:18 +0000 |
commit | 55a269407222763c2920d6322511b349a7e701a9 (patch) | |
tree | 152f37fdb9c33c7fb78795a355d9f4a1ca300a93 /tests/auto | |
parent | 8b3113725fda334e86f0a103572e29352941c060 (diff) |
Fix SnapOneItem/Row behavior for mid-range flicks
Previously small and large flicks would go to the next item, but there
was a small range just under halfway where it would snap to the previous
position (most easily hit with smaller delegates). Get rid of this
blindspot.
Change-Id: Ib8d026cad9427b2d209a9646b3ea515f578457ae
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquickgridview/tst_qquickgridview.cpp | 27 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 32 |
2 files changed, 39 insertions, 20 deletions
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 915b9b43ea..3643374c8f 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -4387,24 +4387,30 @@ void tst_QQuickGridView::snapOneRow_data() QTest::addColumn<qreal>("snapAlignment"); QTest::addColumn<qreal>("endExtent"); QTest::addColumn<qreal>("startExtent"); + QTest::addColumn<qreal>("flickSlowdown"); QTest::newRow("vertical, left to right") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0 << 1.0; QTest::newRow("horizontal, left to right") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0 << 1.0; QTest::newRow("horizontal, right to left") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0 << 1.0; QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0 << 1.0; QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0 << 1.0; QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0 << 1.0; + + // Using e.g. 120 rather than 95 always went to the next row. + // Ensure this further movement has the same behavior + QTest::newRow("vertical, left to right, no more blindspot") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 160) << QPoint(20, 95) << 100.0 << 240.0 << 0.0 << 4.0; } void tst_QQuickGridView::snapOneRow() @@ -4417,6 +4423,9 @@ void tst_QQuickGridView::snapOneRow() QFETCH(qreal, snapAlignment); QFETCH(qreal, endExtent); QFETCH(qreal, startExtent); + QFETCH(qreal, flickSlowdown); + + qreal flickDuration = 180 * flickSlowdown; QQuickView *window = getView(); QQuickViewTestUtil::moveMouseAway(window); @@ -4439,7 +4448,7 @@ void tst_QQuickGridView::snapOneRow() QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged())); // confirm that a flick hits next row boundary - flick(window, flickStart, flickEnd, 180); + flick(window, flickStart, flickEnd, flickDuration); QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops if (flow == QQuickGridView::FlowLeftToRight) QCOMPARE(gridview->contentY(), snapAlignment); @@ -4453,7 +4462,7 @@ void tst_QQuickGridView::snapOneRow() // flick to end do { - flick(window, flickStart, flickEnd, 180); + flick(window, flickStart, flickEnd, flickDuration); QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops } while (flow == QQuickGridView::FlowLeftToRight ? !gridview->isAtYEnd() @@ -4471,7 +4480,7 @@ void tst_QQuickGridView::snapOneRow() // flick to start do { - flick(window, flickEnd, flickStart, 180); + flick(window, flickEnd, flickStart, flickDuration); QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops } while (flow == QQuickGridView::FlowLeftToRight ? !gridview->isAtYBeginning() diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 5d6708a765..6e28256697 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -5514,38 +5514,45 @@ void tst_QQuickListView::snapOneItem_data() QTest::addColumn<qreal>("snapAlignment"); QTest::addColumn<qreal>("endExtent"); QTest::addColumn<qreal>("startExtent"); + QTest::addColumn<qreal>("flickSlowdown"); QTest::newRow("vertical, top to bottom") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; + << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0 << 1.0; QTest::newRow("vertical, bottom to top") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -560.0 - 240.0 << -240.0; + << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -560.0 - 240.0 << -240.0 << 1.0; QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; + << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0 << 1.0; QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0; + << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0 << 1.0; QTest::newRow("vertical, top to bottom, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; + << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0 << 1.0; QTest::newRow("vertical, bottom to top, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -580.0 - 240.0 << -220.0; + << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -580.0 - 240.0 << -220.0 << 1.0; QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; + << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0 << 1.0; QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0; + << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0 << 1.0; + + // Using e.g. 120 rather than 95 always went to the next item. + // Ensure this further movement has the same behavior + QTest::newRow("vertical, top to bottom, no more blindspot") + << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 200) << QPoint(20, 95) << 180.0 << 560.0 << 0.0 << 6.0; } void tst_QQuickListView::snapOneItem() @@ -5559,6 +5566,9 @@ void tst_QQuickListView::snapOneItem() QFETCH(qreal, snapAlignment); QFETCH(qreal, endExtent); QFETCH(qreal, startExtent); + QFETCH(qreal, flickSlowdown); + + qreal flickDuration = 180 * flickSlowdown; QQuickView *window = getView(); QQuickViewTestUtil::moveMouseAway(window); @@ -5583,7 +5593,7 @@ void tst_QQuickListView::snapOneItem() QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); // confirm that a flick hits the next item boundary - flick(window, flickStart, flickEnd, 180); + flick(window, flickStart, flickEnd, flickDuration); QTRY_VERIFY(listview->isMoving() == false); // wait until it stops if (orientation == QQuickListView::Vertical) QCOMPARE(listview->contentY(), snapAlignment); @@ -5597,7 +5607,7 @@ void tst_QQuickListView::snapOneItem() // flick to end do { - flick(window, flickStart, flickEnd, 180); + flick(window, flickStart, flickEnd, flickDuration); QTRY_VERIFY(listview->isMoving() == false); // wait until it stops } while (orientation == QQuickListView::Vertical ? verticalLayoutDirection == QQuickItemView::TopToBottom ? !listview->isAtYEnd() : !listview->isAtYBeginning() @@ -5615,7 +5625,7 @@ void tst_QQuickListView::snapOneItem() // flick to start do { - flick(window, flickEnd, flickStart, 180); + flick(window, flickEnd, flickStart, flickDuration); QTRY_VERIFY(listview->isMoving() == false); // wait until it stops } while (orientation == QQuickListView::Vertical ? verticalLayoutDirection == QQuickItemView::TopToBottom ? !listview->isAtYBeginning() : !listview->isAtYEnd() |