summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qtouchevent
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-21 22:08:36 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-08-06 10:23:56 +0200
commit6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 (patch)
tree1cf102bc85019cf61a6b398c6b1fae0de367759d /tests/auto/gui/kernel/qtouchevent
parentb9873b7dde4042445dbb5ff3c46cea96b2dea4aa (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/gui/kernel/qtouchevent')
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp34
1 files changed, 34 insertions, 0 deletions
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>() <<
+ 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>() <<
+ 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>() <<
+ 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