summaryrefslogtreecommitdiffstats
path: root/tests/auto/gestures
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-03 17:25:02 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-03 17:33:06 (GMT)
commitf26f5b230e614faecce33cf52af0a0d62dcaddaa (patch)
treeff42696653d6100d53c04049487814846555e5fa /tests/auto/gestures
parent0afecb87783b54dc1647be86387beca0b5725535 (diff)
downloadQt-f26f5b230e614faecce33cf52af0a0d62dcaddaa.zip
Qt-f26f5b230e614faecce33cf52af0a0d62dcaddaa.tar.gz
Qt-f26f5b230e614faecce33cf52af0a0d62dcaddaa.tar.bz2
Improved touch event emulation code in testlib.
* Added a context for the touch positions in press(), move(), release() functions. * Sending RawTouch events to QApplication object if the target widget is not specified.
Diffstat (limited to 'tests/auto/gestures')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index a649004..0061506 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -240,6 +240,7 @@ public:
bool shouldAcceptPanGesture;
GestureState gesture;
+ TouchState touch;
void reset()
{
@@ -248,11 +249,20 @@ public:
shouldAcceptSecondFingerGesture = true;
shouldAcceptPanGesture = true;
gesture.reset();
+ touch.reset();
}
protected:
bool event(QEvent *event)
{
- if (event->type() == QEvent::Gesture) {
+ if (event->type() == QEvent::TouchBegin) {
+ event->accept();
+ ++touch.seenTouchBeginEvent;
+ return true;
+ } else if (event->type() == QEvent::TouchUpdate) {
+ ++touch.seenTouchUpdateEvent;
+ } else if (event->type() == QEvent::TouchEnd) {
+ ++touch.seenTouchEndEvent;
+ } else if (event->type() == QEvent::Gesture) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
++gesture.seenGestureEvent;
if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) {
@@ -490,6 +500,8 @@ private slots:
void touch();
+ void panOnWidgets();
+
private:
SingleshotGestureRecognizer *singleshotRecognizer;
PinchGestureRecognizer *pinchRecognizer;
@@ -835,5 +847,44 @@ void tst_Gestures::touch()
QVERIFY(item->touch.seenTouchEndEvent);
}
+void tst_Gestures::panOnWidgets()
+{
+ GestureWidget leftWidget(GestureWidget::GrabPan);
+ leftWidget.setObjectName("leftWidget");
+ leftWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ GestureWidget rightWidget(GestureWidget::GrabPan);
+ 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);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"