aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp73
1 files changed, 46 insertions, 27 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
index 0158d864c4..2a9ec272fa 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
@@ -223,6 +223,7 @@ public:
private slots:
void initTestCase();
+ void touchEventDelivery_data();
void touchEventDelivery();
void mouseEventDelivery();
void touchReleaseOutside_data();
@@ -274,16 +275,23 @@ void tst_PointerHandlers::createView(QScopedPointer<QQuickView> &window, const c
void tst_PointerHandlers::initTestCase()
{
- // This test assumes that we don't get synthesized mouse events from QGuiApplication
- qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
-
QQmlDataTest::initTestCase();
qmlRegisterType<EventItem>("Qt.test", 1, 0, "EventItem");
qmlRegisterType<EventHandler>("Qt.test", 1, 0, "EventHandler");
}
+void tst_PointerHandlers::touchEventDelivery_data()
+{
+ QTest::addColumn<bool>("synthMouse"); // AA_SynthesizeMouseForUnhandledTouchEvents
+ QTest::newRow("no synth") << false;
+ QTest::newRow("synth") << true;
+}
+
void tst_PointerHandlers::touchEventDelivery()
{
+ QFETCH(bool, synthMouse);
+ qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, synthMouse);
+
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "singleitem.qml");
QQuickView * window = windowPtr.data();
@@ -295,19 +303,20 @@ void tst_PointerHandlers::touchEventDelivery()
QPoint p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(eventItem1->eventList.size(), 3);
+ QTRY_COMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 3);
+ QCOMPARE_EVENT(eventItem1->eventList.size() - 1, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 5);
- QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 5 : 4);
+ QCOMPARE_EVENT(eventItem1->eventList.size() - 1, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
eventItem1->eventList.clear();
// Accept touch
@@ -343,33 +352,42 @@ void tst_PointerHandlers::touchEventDelivery()
p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 3);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive);
- QCOMPARE(window->mouseGrabberItem(), eventItem1);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE(window->mouseGrabberItem(), synthMouse ? eventItem1 : nullptr);
QPointF localPos = eventItem1->mapFromScene(p1);
QPointF scenePos = p1; // item is at 0,0
QCOMPARE(eventItem1->eventList.at(1).posWrtItem, localPos);
QCOMPARE(eventItem1->eventList.at(1).posWrtScene, scenePos);
- QCOMPARE(eventItem1->eventList.at(2).posWrtItem, localPos);
- QCOMPARE(eventItem1->eventList.at(2).posWrtScene, scenePos);
+ if (synthMouse) {
+ QCOMPARE(eventItem1->eventList.at(2).posWrtItem, localPos);
+ QCOMPARE(eventItem1->eventList.at(2).posWrtScene, scenePos);
+ }
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 6);
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
- QCOMPARE_EVENT(4, Event::TouchDestination, QEvent::TouchUpdate, Qt::TouchPointMoved, NoGrab);
- QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, Qt::TouchPointMoved, QQuickEventPoint::GrabExclusive);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 6 : 3);
+ if (synthMouse) {
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE_EVENT(4, Event::TouchDestination, QEvent::TouchUpdate, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, Qt::TouchPointMoved, QQuickEventPoint::GrabExclusive);
+ }
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 10);
- QCOMPARE_EVENT(6, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(7, Event::TouchDestination, QEvent::TouchEnd, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(8, Event::MouseDestination, QEvent::MouseButtonRelease, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, Qt::TouchPointReleased, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 10 : 4);
+ if (synthMouse) {
+ QCOMPARE_EVENT(6, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(7, Event::TouchDestination, QEvent::TouchEnd, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(8, Event::MouseDestination, QEvent::MouseButtonRelease, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, Qt::TouchPointReleased, QQuickEventPoint::UngrabExclusive);
+ } else {
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ }
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -382,18 +400,19 @@ void tst_PointerHandlers::touchEventDelivery()
p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 3);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 3);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 5);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 5 : 4);
eventItem1->eventList.clear();
// wait to avoid getting a double click event