summaryrefslogtreecommitdiffstats
path: root/tests/auto/gestures/tst_gestures.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-03 19:05:46 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-15 12:48:58 (GMT)
commitf04eafcc816de608aad64b9cf1132cfd421642ca (patch)
tree8c1be83418beeb47667f368bacfd3057ce40b2ea /tests/auto/gestures/tst_gestures.cpp
parent37bb264e777e6b46749963e99db2ce6e3835fa9b (diff)
downloadQt-f04eafcc816de608aad64b9cf1132cfd421642ca.zip
Qt-f04eafcc816de608aad64b9cf1132cfd421642ca.tar.gz
Qt-f04eafcc816de608aad64b9cf1132cfd421642ca.tar.bz2
Gesture autotest improvements
Diffstat (limited to 'tests/auto/gestures/tst_gestures.cpp')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp77
1 files changed, 68 insertions, 9 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 0061506..8df856d 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -110,6 +110,14 @@ struct GestureState
TouchPoint point;
QPoint offset;
} secondfinger;
+ struct PanGesture
+ {
+ bool delivered;
+ TouchPoint startPoints[2];
+ TouchPoint lastPoints[2];
+ TouchPoint points[2];
+ QPoint offset;
+ } pan;
QSet<QString> cancelled;
} last;
@@ -292,6 +300,18 @@ protected:
if (shouldAcceptSecondFingerGesture)
g->accept();
}
+ if (PanGesture *g = (PanGesture*)e->gesture(PanGestureRecognizer::Name)) {
+ gesture.last.pan.delivered = true;
+ gesture.last.pan.startPoints[0] = g->startPoints[0];
+ gesture.last.pan.startPoints[1] = g->startPoints[1];
+ gesture.last.pan.lastPoints[0] = g->lastPoints[0];
+ gesture.last.pan.lastPoints[1] = g->lastPoints[1];
+ gesture.last.pan.points[0] = g->points[0];
+ gesture.last.pan.points[1] = g->points[1];
+ gesture.last.pan.offset = g->offset;
+ if (shouldAcceptPanGesture)
+ g->accept();
+ }
gesture.last.cancelled = e->cancelledGestures();
return true;
}
@@ -498,7 +518,8 @@ private slots:
void simpleGraphicsItem();
void overlappingGraphicsItems();
- void touch();
+ void touch_widget();
+ void touch_graphicsView();
void panOnWidgets();
@@ -506,6 +527,7 @@ private:
SingleshotGestureRecognizer *singleshotRecognizer;
PinchGestureRecognizer *pinchRecognizer;
SecondFingerGestureRecognizer *secondFingerRecognizer;
+ PanGestureRecognizer *panGestureRecognizer;
GestureWidget *mainWidget;
void sendPinchEvents(QWidget *receiver, const QPoint &fromFinger1, const QPoint &fromFinger2);
@@ -516,9 +538,11 @@ tst_Gestures::tst_Gestures()
singleshotRecognizer = new SingleshotGestureRecognizer;
pinchRecognizer = new PinchGestureRecognizer;
secondFingerRecognizer = new SecondFingerGestureRecognizer;
+ panGestureRecognizer = new PanGestureRecognizer;
qApp->addGestureRecognizer(singleshotRecognizer);
qApp->addGestureRecognizer(pinchRecognizer);
qApp->addGestureRecognizer(secondFingerRecognizer);
+ qApp->addGestureRecognizer(panGestureRecognizer);
}
tst_Gestures::~tst_Gestures()
@@ -805,7 +829,46 @@ void tst_Gestures::overlappingGraphicsItems()
QVERIFY(item->gesture.last.singleshot.delivered);
}
-void tst_Gestures::touch()
+void tst_Gestures::touch_widget()
+{
+ GestureWidget leftWidget(GestureWidget::DoNotGrabGestures);
+ leftWidget.setObjectName("leftWidget");
+ leftWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ GestureWidget rightWidget(GestureWidget::DoNotGrabGestures);
+ rightWidget.setObjectName("rightWidget");
+ rightWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ delete mainWidget->layout();
+ (void)new QHBoxLayout(mainWidget);
+ mainWidget->layout()->addWidget(&leftWidget);
+ mainWidget->layout()->addWidget(&rightWidget);
+ QApplication::processEvents();
+
+ QTest::touchEvent()
+ .press(0, QPoint(10, 10), &leftWidget);
+ QTest::touchEvent()
+ .move(0, QPoint(12, 30), &leftWidget);
+ QTest::touchEvent()
+ .stationary(0)
+ .press(1, QPoint(15, 15), &rightWidget);
+ QTest::touchEvent()
+ .move(0, QPoint(10, 35), &leftWidget)
+ .press(1, QPoint(15, 15), &rightWidget);
+ QTest::touchEvent()
+ .move(0, QPoint(10, 40), &leftWidget)
+ .move(1, QPoint(20, 50), &rightWidget);
+ QTest::touchEvent()
+ .release(0, QPoint(10, 40), &leftWidget)
+ .release(1, QPoint(20, 50), &rightWidget);
+ QVERIFY(!mainWidget->touch.seenTouchBeginEvent);
+ QVERIFY(leftWidget.touch.seenTouchBeginEvent);
+ QVERIFY(leftWidget.touch.seenTouchUpdateEvent);
+ QVERIFY(leftWidget.touch.seenTouchEndEvent);
+ QVERIFY(rightWidget.touch.seenTouchBeginEvent);
+ QVERIFY(rightWidget.touch.seenTouchUpdateEvent);
+ QVERIFY(rightWidget.touch.seenTouchEndEvent);
+}
+
+void tst_Gestures::touch_graphicsView()
{
mainWidget->setAttribute(Qt::WA_AcceptTouchEvents);
GraphicsScene scene;
@@ -877,13 +940,9 @@ void tst_Gestures::panOnWidgets()
QTest::touchEvent()
.release(0, QPoint(10, 40), &leftWidget)
.release(1, QPoint(20, 50), &rightWidget);
- QVERIFY(!mainWidget->touch.seenTouchBeginEvent);
- QVERIFY(leftWidget.touch.seenTouchBeginEvent);
- QVERIFY(leftWidget.touch.seenTouchUpdateEvent);
- QVERIFY(leftWidget.touch.seenTouchEndEvent);
- QVERIFY(rightWidget.touch.seenTouchBeginEvent);
- QVERIFY(rightWidget.touch.seenTouchUpdateEvent);
- QVERIFY(rightWidget.touch.seenTouchEndEvent);
+
+ QVERIFY(leftWidget.gesture.last.pan.delivered);
+ QVERIFY(rightWidget.gesture.last.pan.delivered);
}
QTEST_MAIN(tst_Gestures)