aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-11-07 17:48:27 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-12-13 21:38:51 +0000
commit12f89fb8dda86c61277e3814912013873b1657e6 (patch)
tree0e68ede778bd21bfa1e269c778014084d9387087 /tests
parent358a72b6ecd0fef69edf5355f299af10225a6c8b (diff)
TapHandler: clean up when wantsEventPoint returns false
We already emitted grabCanceled() to inform QML callbacks, but we didn't call reset(). It seems more proper to do everything that would normally be done when grab is canceled. TapHandler should not give up its passive grab yet though, because that prevents delivery to any parent Flickable that might be filtering events. A parent Flickable should be able to start flicking after the drag threshold is exceeded (it happens to be exactly when TapHandler gives up). Fixes: QTBUG-71466 Fixes: QTBUG-71970 Change-Id: Ibba1b0de92cfd88547eeb44edb095d019de76a94 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml2
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp54
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
index ba22e434ce..221e7df139 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
@@ -35,6 +35,7 @@ Rectangle {
property bool checked: false
property alias gesturePolicy: tap.gesturePolicy
signal tapped
+ signal canceled
width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0
border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true
@@ -52,6 +53,7 @@ Rectangle {
tapFlash.start()
root.tapped()
}
+ onCanceled: root.canceled()
}
Text {
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index 467c964001..187ade58d5 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -59,6 +59,7 @@ private slots:
void touchGesturePolicyDragThreshold();
void mouseGesturePolicyDragThreshold();
+ void touchMouseGesturePolicyDragThreshold();
void touchGesturePolicyWithinBounds();
void mouseGesturePolicyWithinBounds();
void touchGesturePolicyReleaseWithinBounds();
@@ -179,6 +180,59 @@ void tst_TapHandler::mouseGesturePolicyDragThreshold()
QCOMPARE(dragThresholdTappedSpy.count(), 0);
}
+void tst_TapHandler::touchMouseGesturePolicyDragThreshold()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "buttons.qml");
+ QQuickView * window = windowPtr.data();
+
+ QQuickItem *buttonDragThreshold = window->rootObject()->findChild<QQuickItem*>("DragThreshold");
+ QVERIFY(buttonDragThreshold);
+ QSignalSpy tappedSpy(buttonDragThreshold, SIGNAL(tapped()));
+ QSignalSpy canceledSpy(buttonDragThreshold, SIGNAL(canceled()));
+
+ // Press mouse, drag it outside the button, release
+ QPoint p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
+ QPoint p2 = p1 + QPoint(int(buttonDragThreshold->height()), 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::mouseMove(window, p2);
+ QTRY_COMPARE(canceledSpy.count(), 1);
+ QCOMPARE(tappedSpy.count(), 0);
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p2);
+
+ // Press and release touch, verify that it still works (QTBUG-71466)
+ QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
+ QCOMPARE(tappedSpy.count(), 1);
+
+ // Press touch, drag it outside the button, release
+ QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::touchEvent(window, touchDevice).move(1, p2, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+ QTest::touchEvent(window, touchDevice).release(1, p2, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(canceledSpy.count(), 2);
+ QCOMPARE(tappedSpy.count(), 1); // didn't increase
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+
+ // Press and release mouse, verify that it still works
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_COMPARE(tappedSpy.count(), 2);
+ QCOMPARE(canceledSpy.count(), 2); // didn't increase
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+}
+
void tst_TapHandler::touchGesturePolicyWithinBounds()
{
QScopedPointer<QQuickView> windowPtr;