aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-05-24 15:01:37 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-26 14:51:45 +0000
commitb01f1fbe81bb42c5635152fd957ac670ddc146c4 (patch)
tree311a12bc2d33b1801c80aab253aba58fdeabd1b0
parentc83b3b6e85a218022d94db298fea93c5b0b0834d (diff)
Add MouseArea autotest with second touchpoint while first is held
- Touch first finger - Touch and release second finger - Release first finger QQuickMouseArea::pressed() must be emitted only once; QQuickMouseArea::released() must be emitted at the end. Task-number: QTBUG-103766 Change-Id: I849bbbad67c4739bea0a241b396bf4cbbebdd2e0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5680f42a979778455508b4bd076457a353becda5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 50cc536795..f6080d94cd 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -158,6 +158,7 @@ private slots:
void negativeZStackingOrder();
void containsMouseAndVisibility();
void doubleClickToHide();
+ void releaseFirstTouchAfterSecond();
private:
int startDragDistance() const {
@@ -2400,6 +2401,25 @@ void tst_QQuickMouseArea::doubleClickToHide()
QCOMPARE(window.rootObject()->property("clicked").toInt(), 2);
}
+void tst_QQuickMouseArea::releaseFirstTouchAfterSecond() // QTBUG-103766
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("simple.qml")));
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>();
+ QVERIFY(mouseArea);
+ QSignalSpy pressSpy(mouseArea, SIGNAL(pressed(QQuickMouseEvent*)));
+ QSignalSpy releaseSpy(mouseArea, &QQuickMouseArea::released);
+
+ QTest::touchEvent(&window, device).press(0, {20, 20});
+ QTRY_COMPARE(pressSpy.count(), 1);
+ QTest::touchEvent(&window, device).stationary(0).press(1, {100, 20});
+ QCOMPARE(pressSpy.count(), 1); // touchpoint 0 is the touchmouse, touchpoint 1 is ignored
+ QTest::touchEvent(&window, device).stationary(0).release(1, {100, 20});
+ QCOMPARE(releaseSpy.count(), 0); // touchpoint 0 is the touchmouse, and remains pressed
+ QTest::touchEvent(&window, device).release(0, {20, 20});
+ QTRY_COMPARE(releaseSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"