summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-08 08:15:54 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-08 08:15:54 (GMT)
commitd44a1bf3af16f2d2d251d03936ba3af5e585628c (patch)
tree07de40fb11e14614b765a86aa25238e8de3e650d /tests
parente982ba18f8cffaa55f7c73a3ef877932abb91db1 (diff)
downloadQt-d44a1bf3af16f2d2d251d03936ba3af5e585628c.zip
Qt-d44a1bf3af16f2d2d251d03936ba3af5e585628c.tar.gz
Qt-d44a1bf3af16f2d2d251d03936ba3af5e585628c.tar.bz2
add tst_QTouchEventWidget to handle touch events
test that sending the TouchBegin to this widget both succeeds and accepts the event
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtouchevent/tst_qtouchevent.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp
index 8ed7035..a830970 100644
--- a/tests/auto/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp
@@ -42,6 +42,25 @@
#include <QtGui>
#include <QtTest>
+class tst_QTouchEventWidget : public QWidget
+{
+public:
+ bool event(QEvent *event)
+ {
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ break;
+ case QEvent::TouchUpdate:
+ break;
+ case QEvent::TouchEnd:
+ break;
+ default:
+ return QWidget::event(event);
+ }
+ return true;
+ }
+};
+
class tst_QTouchEvent : public QObject
{
Q_OBJECT
@@ -78,6 +97,8 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
QWidget widget;
widget.setAttribute(Qt::WA_AcceptTouchEvents);
+ // QWidget doesn't handle touch event by default, so sending it fails
+ // (but the event is accepted)
QList<QTouchEvent::TouchPoint> touchPoints;
touchPoints.append(QTouchEvent::TouchPoint(0));
QTouchEvent touchEvent(QEvent::TouchBegin,
@@ -85,10 +106,20 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
Qt::TouchPointPressed,
touchPoints);
bool res = QApplication::sendEvent(&widget, &touchEvent);
- QVERIFY(!res); // not handled...
- QVERIFY(touchEvent.isAccepted()); // but accepted
+ QVERIFY(!res);
+ QVERIFY(touchEvent.isAccepted());
+
+ // tst_QTouchEventWidget does handle, sending succeeds
+ tst_QTouchEventWidget touchWidget;
+ touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ touchEvent.ignore();
+ res = QApplication::sendEvent(&touchWidget, &touchEvent);
+ QVERIFY(res);
+ QVERIFY(touchEvent.isAccepted());
}
+
+
QTEST_MAIN(tst_QTouchEvent)
#include "tst_qtouchevent.moc"