aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp')
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp54
1 files changed, 54 insertions, 0 deletions
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;