From 437330b3c0c4d848e3dca6c1e41a9c31eb99fd10 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 17:18:28 +0200 Subject: Simplified emulating touch events by using RawTouch event. --- tests/auto/gestures/tst_gestures.cpp | 41 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 70c3ec4..9ab252a 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -785,20 +785,24 @@ namespace QTest class QTouchEventSequence { public: - QTouchEventSequence(QWidget *widget, QEvent::Type type) - : relativeWindow(widget), eventType(type) + QTouchEventSequence(QWidget *widget) + : relativeWindow(widget) { ++refcount; } QTouchEventSequence(const QTouchEventSequence &v) - : relativeWindow(v.relativeWindow), eventType(v.eventType) + : relativeWindow(v.relativeWindow) { ++refcount; } ~QTouchEventSequence() { - if (!--refcount) + if (!--refcount) { commit(); + foreach(QTouchEvent::TouchPoint *pt, points) + delete pt; + points.clear(); + } } QTouchEventSequence& press(int touchId, const QPoint &pt) { @@ -857,7 +861,7 @@ namespace QTest void commit() { if (relativeWindow) { - QTouchEvent event(eventType, Qt::NoModifier, + QTouchEvent event(QEvent::RawTouch, Qt::NoModifier, touchPointStates, points.values()); ::sendSpontaneousEvent(relativeWindow, &event); relativeWindow = 0; @@ -865,29 +869,16 @@ namespace QTest } static int refcount; - static QMap points; + QMap points; QWidget *relativeWindow; - QEvent::Type eventType; Qt::TouchPointStates touchPointStates; friend QTouchEventSequence touchBeginEvent(QWidget*); }; - QMap QTouchEventSequence::points; int QTouchEventSequence::refcount = 0; - QTouchEventSequence touchBeginEvent(QWidget *widget) - { - foreach(QTouchEvent::TouchPoint *point, QTouchEventSequence::points.values()) - delete point; - QTouchEventSequence::points.clear(); - return QTouchEventSequence(widget, QEvent::TouchBegin); - } - QTouchEventSequence touchUpdateEvent(QWidget *widget) - { - return QTouchEventSequence(widget, QEvent::TouchUpdate); - } - QTouchEventSequence touchEndEvent(QWidget *widget) + QTouchEventSequence touchEvent(QWidget *widget) { - return QTouchEventSequence(widget, QEvent::TouchEnd); + return QTouchEventSequence(widget); } } @@ -916,16 +907,16 @@ void tst_Gestures::touch() QRect itemRect = view.mapFromScene(item->mapRectToScene(item->boundingRect())).boundingRect(); QPoint pt = itemRect.center(); - QTest::touchBeginEvent(view.viewport()) + QTest::touchEvent(view.viewport()) .press(0, pt) .press(1, pt); - QTest::touchUpdateEvent(view.viewport()) + QTest::touchEvent(view.viewport()) .move(0, pt + QPoint(20, 30)) .move(1, QPoint(300, 300)); - QTest::touchUpdateEvent(view.viewport()) + QTest::touchEvent(view.viewport()) .stationary(0) .move(1, QPoint(330, 330)); - QTest::touchEndEvent(view.viewport()) + QTest::touchEvent(view.viewport()) .release(0, QPoint(120, 120)) .release(1, QPoint(300, 300)); -- cgit v0.12