From 6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 21 Jul 2020 22:08:36 +0200 Subject: Add QPointerEvent::is[Press|Update|Release]Event accessors QQuickPointerEvent had them, so despite how trivial they look, it's very convenient to keep using them in QQuickWindow rather than duplicating these kinds of checks in various places, and for multiple event types too. Change-Id: I32ad8110fd2361e69de50a679ddbdb2a2db7ecee Reviewed-by: Fabian Kosmale --- .../gui/kernel/qtouchevent/tst_qtouchevent.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/auto/gui/kernel/qtouchevent') diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 08c8dd3f78..d3d8eba34d 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -217,6 +217,7 @@ public: private slots: void cleanup(); void qPointerUniqueId(); + void state(); void touchDisabledByDefault(); void touchEventAcceptedByDefault(); void touchBeginPropagatesWhenIgnored(); @@ -290,6 +291,39 @@ void tst_QTouchEvent::qPointerUniqueId() QCOMPARE(set.size(), 2); } +void tst_QTouchEvent::state() +{ + QTouchEvent touchEvent(QEvent::TouchBegin, touchScreenDevice, + Qt::NoModifier, QList() << + QEventPoint(0, QEventPoint::State::Stationary, {}, {}) << + QEventPoint(1, QEventPoint::State::Pressed, {}, {})); + QCOMPARE(touchEvent.touchPointStates(), QEventPoint::State::Stationary | QEventPoint::State::Pressed); + QCOMPARE(touchEvent.pointCount(), 2); + QVERIFY(touchEvent.isPressEvent()); + QVERIFY(!touchEvent.isUpdateEvent()); + QVERIFY(!touchEvent.isReleaseEvent()); + + touchEvent = QTouchEvent(QEvent::TouchBegin, touchScreenDevice, + Qt::NoModifier, QList() << + QEventPoint(0, QEventPoint::State::Updated, {}, {}) << + QEventPoint(1, QEventPoint::State::Pressed, {}, {})); + QCOMPARE(touchEvent.touchPointStates(), QEventPoint::State::Updated | QEventPoint::State::Pressed); + QCOMPARE(touchEvent.pointCount(), 2); + QVERIFY(touchEvent.isPressEvent()); + QVERIFY(!touchEvent.isUpdateEvent()); + QVERIFY(!touchEvent.isReleaseEvent()); + + touchEvent = QTouchEvent(QEvent::TouchBegin, touchScreenDevice, + Qt::NoModifier, QList() << + QEventPoint(0, QEventPoint::State::Updated, {}, {}) << + QEventPoint(1, QEventPoint::State::Released, {}, {})); + QCOMPARE(touchEvent.touchPointStates(), QEventPoint::State::Updated | QEventPoint::State::Released); + QCOMPARE(touchEvent.pointCount(), 2); + QVERIFY(!touchEvent.isPressEvent()); + QVERIFY(!touchEvent.isUpdateEvent()); + QVERIFY(touchEvent.isReleaseEvent()); +} + void tst_QTouchEvent::touchDisabledByDefault() { // QWidget -- cgit v1.2.3