summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-08 09:13:15 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-08 09:13:15 (GMT)
commitcc91b6fa04266c044da1754db3d15c43bd8c619c (patch)
treef02ed288c0dc9618ddbd5e8b2b02fcee5ef17525 /tests
parent82d51d442f1b655981c0993f81f794eafeb70d30 (diff)
downloadQt-cc91b6fa04266c044da1754db3d15c43bd8c619c.zip
Qt-cc91b6fa04266c044da1754db3d15c43bd8c619c.tar.gz
Qt-cc91b6fa04266c044da1754db3d15c43bd8c619c.tar.bz2
add test for TouchBegin propagation
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtouchevent/tst_qtouchevent.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp
index a830970..0b915ec 100644
--- a/tests/auto/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp
@@ -45,14 +45,42 @@
class tst_QTouchEventWidget : public QWidget
{
public:
+ bool seenTouchBegin, seenTouchUpdate, seenTouchEnd;
+ bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd;
+
+ tst_QTouchEventWidget()
+ : QWidget()
+ {
+ reset();
+ }
+
+ void reset()
+ {
+ seenTouchBegin = seenTouchUpdate = seenTouchEnd = false;
+ acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true;
+ }
+
bool event(QEvent *event)
{
switch (event->type()) {
case QEvent::TouchBegin:
+ if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin");
+ if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin");
+ if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin");
+ seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd;
+ event->setAccepted(acceptTouchBegin);
break;
case QEvent::TouchUpdate:
+ if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin");
+ if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate");
+ seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
+ event->setAccepted(acceptTouchUpdate);
break;
case QEvent::TouchEnd:
+ if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin");
+ if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd");
+ seenTouchEnd = seenTouchBegin && !seenTouchEnd;
+ event->setAccepted(acceptTouchEnd);
break;
default:
return QWidget::event(event);
@@ -71,6 +99,7 @@ public:
private slots:
void touchDisabledByDefault();
void touchEventAcceptedByDefault();
+ void touchBeginPropagatesWhenIgnored();
};
void tst_QTouchEvent::touchDisabledByDefault()
@@ -118,7 +147,31 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
QVERIFY(touchEvent.isAccepted());
}
+void tst_QTouchEvent::touchBeginPropagatesWhenIgnored()
+{
+ tst_QTouchEventWidget window, child, grandchild;
+ child.setParent(&window);
+ grandchild.setParent(&child);
+
+ // all widgets accept touch events, but
+ window.setAttribute(Qt::WA_AcceptTouchEvents);
+ child.setAttribute(Qt::WA_AcceptTouchEvents);
+ grandchild.setAttribute(Qt::WA_AcceptTouchEvents);
+ grandchild.acceptTouchBegin = false;
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ touchPoints.append(QTouchEvent::TouchPoint(0));
+ QTouchEvent touchEvent(QEvent::TouchBegin,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ touchPoints);
+ bool res = QApplication::sendEvent(&grandchild, &touchEvent);
+ QVERIFY(res);
+ QVERIFY(touchEvent.isAccepted());
+ QVERIFY(grandchild.seenTouchBegin);
+ QVERIFY(child.seenTouchBegin);
+ QVERIFY(!window.seenTouchBegin);
+}
QTEST_MAIN(tst_QTouchEvent)