diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-07-13 14:55:50 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-07-13 14:56:18 +0000 |
commit | 73eceacfaceff0b860a32da2da9e04f3065931b8 (patch) | |
tree | 4e50d6859b8d68a186d6923a3f7bdf1965ca07fa /tests/auto/quick/qquickwindow | |
parent | eb3496167543753b6e8f5e85c69a1a77f95674b0 (diff) |
add tst_qquickwindow::eventPointCount
Change-Id: I552cf69fa179d8b1260a5502e37553fa57bf32cf
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickwindow')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 0985198d65..2a3f54fcd8 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -370,6 +370,9 @@ private slots: void testRenderJob(); void testHoverChildMouseEventFilter(); + + void pointerEventTypeAndPointCount(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2326,6 +2329,52 @@ void tst_qquickwindow::testHoverChildMouseEventFilter() QCOMPARE(middleItem->eventCount(QEvent::HoverEnter), 0); } +void tst_qquickwindow::pointerEventTypeAndPointCount() +{ + QQuickPointerEvent pe; + QMouseEvent me(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QTouchEvent te(QEvent::TouchBegin, touchDevice, Qt::NoModifier, Qt::TouchPointPressed, + QList<QTouchEvent::TouchPoint>() << QTouchEvent::TouchPoint(1)); + + QVERIFY(!pe.isValid()); + + pe.reset(&me); + QVERIFY(pe.isValid()); + QVERIFY(pe.isMouseEvent()); + QVERIFY(!pe.isTouchEvent()); + QVERIFY(!pe.isTabletEvent()); + QVERIFY(pe.asMouseEvent()); + QVERIFY(!pe.asTouchEvent()); +// QVERIFY(!pe.asTabletEvent()); // TODO + QCOMPARE(pe.pointCount(), 1); + + pe.reset(&te); + QVERIFY(pe.isValid()); + QVERIFY(!pe.isMouseEvent()); + QVERIFY(pe.isTouchEvent()); + QVERIFY(!pe.isTabletEvent()); + QVERIFY(!pe.asMouseEvent()); + QVERIFY(pe.asTouchEvent()); +// QVERIFY(!pe.asTabletEvent()); // TODO + QCOMPARE(pe.pointCount(), 1); + QCOMPARE(pe.touchPointById(1)->id(), 1); + QVERIFY(!pe.touchPointById(0)); + + te.setTouchPoints(QList<QTouchEvent::TouchPoint>() << QTouchEvent::TouchPoint(1) << QTouchEvent::TouchPoint(2)); + pe.reset(&te); + QCOMPARE(pe.pointCount(), 2); + QCOMPARE(pe.touchPointById(1)->id(), 1); + QCOMPARE(pe.touchPointById(2)->id(), 2); + QVERIFY(!pe.touchPointById(0)); + + te.setTouchPoints(QList<QTouchEvent::TouchPoint>() << QTouchEvent::TouchPoint(2)); + pe.reset(&te); + QCOMPARE(pe.pointCount(), 1); + QCOMPARE(pe.touchPointById(2)->id(), 2); + QVERIFY(!pe.touchPointById(1)); + QVERIFY(!pe.touchPointById(0)); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" |