aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview
diff options
context:
space:
mode:
authorShin-ichi Okada <shinichi.okada@qt.io>2019-11-14 16:16:39 +0900
committerShawn Rutledge <shawn.rutledge@qt.io>2019-12-04 14:53:03 +0100
commite394979d24c83f0b937c9c436173c6a573e5644a (patch)
treea1e0a081164e2f72e242b3ec844d4856220ebdfe /tests/auto/quick/qquickpathview
parent41dd68344c3d7d0a6a5afc93ab4a05157bed3d3c (diff)
Fix incorrect behavior of PathView with ungrabMouse()
When the grabbed Item is released and then grabbed again, if ungrabMouse () is called, the animation stops. In order to avoid this, when ungrabMouse () is called, if offset is different, it is modified to animate. Task-number: QTBUG-79592 Change-Id: I61cbd4dad90643722f12480f0dab3859ce116af8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickpathview')
-rw-r--r--tests/auto/quick/qquickpathview/data/ungrabNestedinFlickable.qml75
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp35
2 files changed, 110 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/data/ungrabNestedinFlickable.qml b/tests/auto/quick/qquickpathview/data/ungrabNestedinFlickable.qml
new file mode 100644
index 0000000000..4258d8fef4
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/ungrabNestedinFlickable.qml
@@ -0,0 +1,75 @@
+import QtQuick 2.9
+
+Flickable {
+ width: 480
+ height: 480
+ contentX: 0
+ contentWidth: width
+ contentHeight: height
+ leftMargin: 408
+ rightMargin: 36
+ maximumFlickVelocity: 0
+ boundsBehavior: Flickable.StopAtBounds
+ flickableDirection: Flickable.HorizontalFlick
+
+ PathView {
+ id:pathView
+ objectName: "pathView"
+
+ property int countclick: 0
+
+ readonly property int contentsWidth: 348
+ readonly property int contentsHeight: 480
+
+ width: contentsWidth
+ height: contentsHeight
+
+ interactive: true
+
+ cacheItemCount: 10
+ currentIndex: 2
+ pathItemCount: 4
+ highlightMoveDuration: 300
+ highlightRangeMode : PathView.StrictlyEnforceRange
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ snapMode : PathView.SnapOneItem
+
+ path: Path {
+ startX: pathView.contentsWidth / 2 - 800
+ startY: pathView.contentsHeight / 2 - 800
+
+ PathArc {
+ x: pathView.contentsWidth / 2 - 800
+ y: pathView.contentsHeight / 2 + 800
+ radiusX: 800
+ radiusY: 800
+ direction: PathArc.Clockwise
+ }
+ }
+
+ model: ListModel {
+ ListElement { objectName:"aqua"; name: "aqua" ;mycolor:"aqua"}
+ ListElement { objectName:"blue"; name: "blue" ;mycolor:"blue"}
+ ListElement { objectName:"blueviolet"; name: "blueviolet" ;mycolor:"blueviolet"}
+ ListElement { objectName:"brown"; name: "brown" ;mycolor:"brown"}
+ ListElement { objectName:"chartreuse"; name: "chartreuse" ;mycolor:"chartreuse"}
+ }
+
+ delegate: Item {
+ id: revolveritem
+ objectName: model.objectName
+
+ width: pathView.contentsWidth
+ height: pathView.contentsHeight
+
+ Rectangle
+ {
+ id:myRectangle
+ color: mycolor
+ width: pathView.contentsWidth -20
+ height: pathView.contentsHeight -20
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 4498548d45..f3119dd0f3 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -140,6 +140,7 @@ private slots:
void cacheItemCount();
void changePathDuringRefill();
void nestedinFlickable();
+ void ungrabNestedinFlickable();
void flickableDelegate();
void jsArrayChange();
void qtbug37815();
@@ -2411,6 +2412,40 @@ void tst_QQuickPathView::nestedinFlickable()
}
+void tst_QQuickPathView::ungrabNestedinFlickable()
+{
+ QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->setSource(testFileUrl("ungrabNestedinFlickable.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QCOMPARE(window.data(), qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(window->rootObject(), "pathView");
+ QVERIFY(pathview != nullptr);
+
+ double pathviewOffsetBefore = pathview->offset();
+
+ // Drag slowly upwards so that it does not flick, release, and let it start snapping back
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(200, 350));
+ for (int i = 0; i < 4; ++i)
+ QTest::mouseMove(window.data(), QPoint(200, 325 - i * 25), 500);
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(200, 250));
+ QCOMPARE(pathview->isMoving(), true);
+
+ // Press again to stop moving
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(200, 350));
+ QTRY_COMPARE(pathview->isMoving(), false);
+
+ // Cancel the grab, wait for movement to stop, and expect it to snap to
+ // the nearest delegate, which should be at the same offset as where we started
+ pathview->ungrabMouse();
+ QTRY_COMPARE(pathview->offset(), pathviewOffsetBefore);
+ QCOMPARE(pathview->isMoving(), false);
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(200, 350));
+}
+
void tst_QQuickPathView::flickableDelegate()
{
QScopedPointer<QQuickView> window(createView());