diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-02-10 13:43:00 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-13 09:19:40 +0100 |
commit | c0100e28cadf8260769eddcc7a0306d832fed92b (patch) | |
tree | aca535d8884080fbfd7c1e200a81d9e57063ba50 /tests/auto | |
parent | a979bf5a4cb7aeb5b690957d77b84c9dc385d6d9 (diff) |
Add basic TouchCancel handling to canvas.
This makes sure that touchEvent() is properly called for all items in
the scene that have an active touch. It does not handle the cancel
event in any other special way.
Change-Id: Id66527ced8cb63d0b29f25f37c139e6d6aec9ba0
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp index 4a238429bb..eac0d851d5 100644 --- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp @@ -74,7 +74,8 @@ static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p return tp; } -static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QList<QTouchEvent::TouchPoint>& touchPoints) +static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0, + const QList<QTouchEvent::TouchPoint>& touchPoints = QList<QTouchEvent::TouchPoint>()) { TouchEventData d = { type, 0, w, states, touchPoints }; return d; @@ -197,6 +198,7 @@ private slots: void touchEvent_basic(); void touchEvent_propagation(); void touchEvent_propagation_data(); + void touchEvent_cancel(); void clearCanvas(); @@ -475,6 +477,37 @@ void tst_qquickcanvas::touchEvent_propagation_data() QTest::newRow("opacity of 0") << true << true << 0.0; } +void tst_qquickcanvas::touchEvent_cancel() +{ + TestTouchItem::clearMousePressCounter(); + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->show(); + + TestTouchItem *item = new TestTouchItem(canvas->rootItem()); + item->setPos(QPointF(50, 50)); + item->setSize(QSizeF(150, 150)); + + QPointF pos(10, 10); + QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas); + QCoreApplication::processEvents(); + + QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1); + TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos)); + COMPARE_TOUCH_DATA(item->lastEvent, d); + item->reset(); + + QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice); + QCoreApplication::processEvents(); + d = makeTouchData(QEvent::TouchCancel, canvas); + COMPARE_TOUCH_DATA(item->lastEvent, d); + + delete item; + delete canvas; +} + void tst_qquickcanvas::clearCanvas() { QQuickCanvas *canvas = new QQuickCanvas; |