From b01f1fbe81bb42c5635152fd957ac670ddc146c4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 24 May 2022 15:01:37 +0200 Subject: 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 (cherry picked from commit 5680f42a979778455508b4bd076457a353becda5) Reviewed-by: Qt Cherry-pick Bot --- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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(); + 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" -- cgit v1.2.3