diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-27 11:21:12 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-27 11:22:48 (GMT) |
commit | 96d2094b48db6cccd7a0fb34a778bd3e71ba43b4 (patch) | |
tree | dde4d6f09c8452eeec90bfaae6b62100269a2544 /tests/manual | |
parent | ed2e1e64d922e3e531984d099a800515037c89f6 (diff) | |
download | Qt-96d2094b48db6cccd7a0fb34a778bd3e71ba43b4.zip Qt-96d2094b48db6cccd7a0fb34a778bd3e71ba43b4.tar.gz Qt-96d2094b48db6cccd7a0fb34a778bd3e71ba43b4.tar.bz2 |
add basic multi-touch event handling test, split existing tests into more logical pieces
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/qtouchevent/main.cpp | 130 | ||||
-rw-r--r-- | tests/manual/qtouchevent/touchwidget.cpp | 4 | ||||
-rw-r--r-- | tests/manual/qtouchevent/touchwidget.h | 1 |
3 files changed, 110 insertions, 25 deletions
diff --git a/tests/manual/qtouchevent/main.cpp b/tests/manual/qtouchevent/main.cpp index 05fdc44..8b28967 100644 --- a/tests/manual/qtouchevent/main.cpp +++ b/tests/manual/qtouchevent/main.cpp @@ -32,8 +32,11 @@ public: ~tst_ManualMultitouch(); private slots: - void basicEventHandling(); - void touchEventPropagation(); + void ignoringTouchEventsEmulatesMouseEvents(); + void basicSingleTouchEventHandling(); + void basicMultiTouchEventHandling(); + void acceptingTouchBeginStopsPropagation(); + void ignoringTouchBeginPropagatesToParent(); }; tst_ManualMultitouch::tst_ManualMultitouch() @@ -42,17 +45,16 @@ tst_ManualMultitouch::tst_ManualMultitouch() tst_ManualMultitouch::~tst_ManualMultitouch() { } -void tst_ManualMultitouch::basicEventHandling() +void tst_ManualMultitouch::ignoringTouchEventsEmulatesMouseEvents() { // first, make sure that we get mouse events when not enabling touch events MultitouchTestWidget testWidget; - testWidget.testNameLabel->setText("Basic QTouchEvent handling test"); + testWidget.testNameLabel->setText("Mouse Event Emulation Test"); testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget."); testWidget.redWidget->hide(); testWidget.blueWidget->hide(); testWidget.greenWidget->closeWindowOnMouseRelease = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(!testWidget.greenWidget->seenTouchBegin); QVERIFY(!testWidget.greenWidget->seenTouchUpdate); @@ -61,15 +63,34 @@ void tst_ManualMultitouch::basicEventHandling() // QVERIFY(testWidget.greenWidget->seenMouseMove); QVERIFY(testWidget.greenWidget->seenMouseRelease); - // now enable touch and make sure we get the touch events + // enable touch, but don't accept the events testWidget.greenWidget->reset(); testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); + testWidget.greenWidget->closeWindowOnMouseRelease = true; + testWidget.showMaximized(); + (void) qApp->exec(); + QVERIFY(testWidget.greenWidget->seenTouchBegin); + QVERIFY(!testWidget.greenWidget->seenTouchUpdate); + QVERIFY(!testWidget.greenWidget->seenTouchEnd); + QVERIFY(testWidget.greenWidget->seenMousePress); + // QVERIFY(testWidget.greenWidget->seenMouseMove); + QVERIFY(testWidget.greenWidget->seenMouseRelease); +} + +void tst_ManualMultitouch::basicSingleTouchEventHandling() +{ + // now enable touch and make sure we get the touch events + MultitouchTestWidget testWidget; + testWidget.testNameLabel->setText("Basic Single-Touch Event Handling Test"); + testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget."); + testWidget.redWidget->hide(); + testWidget.blueWidget->hide(); + testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); testWidget.greenWidget->acceptTouchBegin = true; testWidget.greenWidget->acceptTouchUpdate = true; testWidget.greenWidget->acceptTouchEnd = true; testWidget.greenWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greenWidget->seenTouchBegin && testWidget.greenWidget->seenTouchUpdate @@ -85,7 +106,6 @@ void tst_ManualMultitouch::basicEventHandling() // testWidget.greenWidget->acceptTouchEnd = true; testWidget.greenWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greenWidget->seenTouchBegin); QVERIFY(testWidget.greenWidget->seenTouchUpdate); @@ -101,7 +121,6 @@ void tst_ManualMultitouch::basicEventHandling() testWidget.greenWidget->acceptTouchEnd = true; testWidget.greenWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greenWidget->seenTouchBegin); QVERIFY(testWidget.greenWidget->seenTouchUpdate); @@ -117,7 +136,6 @@ void tst_ManualMultitouch::basicEventHandling() // testWidget.greenWidget->acceptTouchEnd = true; testWidget.greenWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greenWidget->seenTouchBegin); QVERIFY(testWidget.greenWidget->seenTouchUpdate); @@ -127,15 +145,83 @@ void tst_ManualMultitouch::basicEventHandling() QVERIFY(!testWidget.greenWidget->seenMouseRelease); } -void tst_ManualMultitouch::touchEventPropagation() +void tst_ManualMultitouch::basicMultiTouchEventHandling() { + // repeat, this time looking for multiple fingers MultitouchTestWidget testWidget; - testWidget.testNameLabel->setText("QTouchEvent propagation test, Blue blocks Green"); - testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the blue widget."); - testWidget.redWidget->hide(); + testWidget.testNameLabel->setText("Basic Multi-Touch Event Handling Test"); + testWidget.testDescriptionLabel->setText("Touch, hold, and release several fingers on the red widget."); + testWidget.greenWidget->hide(); + testWidget.greyWidget->hide(); + testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); + testWidget.redWidget->acceptTouchBegin = true; + testWidget.redWidget->acceptTouchUpdate = true; + testWidget.redWidget->acceptTouchEnd = true; + testWidget.redWidget->closeWindowOnTouchEnd = true; + testWidget.showMaximized(); + (void) qApp->exec(); + QVERIFY(testWidget.redWidget->seenTouchBegin); + QVERIFY(testWidget.redWidget->seenTouchUpdate); + QVERIFY(testWidget.redWidget->seenTouchEnd); + QVERIFY(testWidget.redWidget->touchPointCount > 1); + QVERIFY(!testWidget.greenWidget->seenMousePress); + QVERIFY(!testWidget.greenWidget->seenMouseMove); + QVERIFY(!testWidget.greenWidget->seenMouseRelease); + testWidget.redWidget->reset(); + testWidget.redWidget->acceptTouchBegin = true; + // testWidget.redWidget->acceptTouchUpdate = true; + testWidget.redWidget->acceptTouchEnd = true; + testWidget.redWidget->closeWindowOnTouchEnd = true; + testWidget.showMaximized(); + (void) qApp->exec(); + QVERIFY(testWidget.redWidget->seenTouchBegin); + QVERIFY(testWidget.redWidget->seenTouchUpdate); + QVERIFY(testWidget.redWidget->seenTouchEnd); + QVERIFY(testWidget.redWidget->touchPointCount > 1); + QVERIFY(!testWidget.greenWidget->seenMousePress); + QVERIFY(!testWidget.greenWidget->seenMouseMove); + QVERIFY(!testWidget.greenWidget->seenMouseRelease); + + testWidget.redWidget->reset(); + testWidget.redWidget->acceptTouchBegin = true; + testWidget.redWidget->acceptTouchUpdate = true; + // testWidget.redWidget->acceptTouchEnd = true; + testWidget.redWidget->closeWindowOnTouchEnd = true; + testWidget.showMaximized(); + (void) qApp->exec(); + QVERIFY(testWidget.redWidget->seenTouchBegin); + QVERIFY(testWidget.redWidget->seenTouchUpdate); + QVERIFY(testWidget.redWidget->seenTouchEnd); + QVERIFY(testWidget.redWidget->touchPointCount > 1); + QVERIFY(!testWidget.greenWidget->seenMousePress); + QVERIFY(!testWidget.greenWidget->seenMouseMove); + QVERIFY(!testWidget.greenWidget->seenMouseRelease); + + testWidget.redWidget->reset(); + testWidget.redWidget->acceptTouchBegin = true; + // testWidget.redWidget->acceptTouchUpdate = true; + // testWidget.redWidget->acceptTouchEnd = true; + testWidget.redWidget->closeWindowOnTouchEnd = true; + testWidget.showMaximized(); + (void) qApp->exec(); + QVERIFY(testWidget.redWidget->seenTouchBegin); + QVERIFY(testWidget.redWidget->seenTouchUpdate); + QVERIFY(testWidget.redWidget->seenTouchEnd); + QVERIFY(testWidget.redWidget->touchPointCount > 1); + QVERIFY(!testWidget.greenWidget->seenMousePress); + QVERIFY(!testWidget.greenWidget->seenMouseMove); + QVERIFY(!testWidget.greenWidget->seenMouseRelease); +} + +void tst_ManualMultitouch::acceptingTouchBeginStopsPropagation() +{ // test that accepting the TouchBegin event on the // blueWidget stops propagation to the greenWidget + MultitouchTestWidget testWidget; + testWidget.testNameLabel->setText("Touch Event Propagation Test: Accepting in Blue Blocks Green"); + testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the blue widget."); + testWidget.redWidget->hide(); testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents); testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); testWidget.blueWidget->acceptTouchBegin = true; @@ -143,7 +229,6 @@ void tst_ManualMultitouch::touchEventPropagation() testWidget.blueWidget->acceptTouchEnd = true; testWidget.blueWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.blueWidget->seenTouchBegin); QVERIFY(testWidget.blueWidget->seenTouchUpdate); @@ -166,7 +251,6 @@ void tst_ManualMultitouch::touchEventPropagation() // testWidget.blueWidget->acceptTouchEnd = true; testWidget.blueWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.blueWidget->seenTouchBegin); QVERIFY(testWidget.blueWidget->seenTouchUpdate); @@ -189,7 +273,6 @@ void tst_ManualMultitouch::touchEventPropagation() testWidget.blueWidget->acceptTouchEnd = true; testWidget.blueWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.blueWidget->seenTouchBegin); QVERIFY(testWidget.blueWidget->seenTouchUpdate); @@ -212,7 +295,6 @@ void tst_ManualMultitouch::touchEventPropagation() // testWidget.blueWidget->acceptTouchEnd = true; testWidget.blueWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.blueWidget->seenTouchBegin); QVERIFY(testWidget.blueWidget->seenTouchUpdate); @@ -226,13 +308,16 @@ void tst_ManualMultitouch::touchEventPropagation() QVERIFY(!testWidget.greenWidget->seenMousePress); QVERIFY(!testWidget.greenWidget->seenMouseMove); QVERIFY(!testWidget.greenWidget->seenMouseRelease); +} +void tst_ManualMultitouch::ignoringTouchBeginPropagatesToParent() +{ // repeat the test above, now ignoring touch events in the // greyWidget, they should be propagated to the redWidget - testWidget.testNameLabel->setText("QTouchEvent propagation test, Red handles Grey's ignored events"); + MultitouchTestWidget testWidget; + testWidget.testNameLabel->setText("Touch Event Propagation Test: Ignoring in Grey Propagates to Red"); testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the grey widget."); testWidget.greenWidget->hide(); - testWidget.redWidget->show(); testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents, false); testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); testWidget.greyWidget->reset(); @@ -242,7 +327,6 @@ void tst_ManualMultitouch::touchEventPropagation() testWidget.redWidget->acceptTouchEnd = true; testWidget.redWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(!testWidget.greyWidget->seenTouchBegin); QVERIFY(!testWidget.greyWidget->seenTouchUpdate); @@ -266,7 +350,6 @@ void tst_ManualMultitouch::touchEventPropagation() testWidget.redWidget->acceptTouchEnd = true; testWidget.redWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greyWidget->seenTouchBegin); QVERIFY(!testWidget.greyWidget->seenTouchUpdate); @@ -289,7 +372,6 @@ void tst_ManualMultitouch::touchEventPropagation() // testWidget.redWidget->acceptTouchEnd = true; testWidget.redWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greyWidget->seenTouchBegin); QVERIFY(!testWidget.greyWidget->seenTouchUpdate); @@ -312,7 +394,6 @@ void tst_ManualMultitouch::touchEventPropagation() testWidget.redWidget->acceptTouchEnd = true; testWidget.redWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greyWidget->seenTouchBegin); QVERIFY(!testWidget.greyWidget->seenTouchUpdate); @@ -335,7 +416,6 @@ void tst_ManualMultitouch::touchEventPropagation() // testWidget.redWidget->acceptTouchEnd = true; testWidget.redWidget->closeWindowOnTouchEnd = true; testWidget.showMaximized(); - (void) qApp->exec(); QVERIFY(testWidget.greyWidget->seenTouchBegin); QVERIFY(!testWidget.greyWidget->seenTouchUpdate); diff --git a/tests/manual/qtouchevent/touchwidget.cpp b/tests/manual/qtouchevent/touchwidget.cpp index 1e57c36..0516c5b 100644 --- a/tests/manual/qtouchevent/touchwidget.cpp +++ b/tests/manual/qtouchevent/touchwidget.cpp @@ -24,6 +24,7 @@ void TouchWidget::reset() = closeWindowOnMouseRelease = false; + touchPointCount = 0; } bool TouchWidget::event(QEvent *event) @@ -31,6 +32,7 @@ bool TouchWidget::event(QEvent *event) switch (event->type()) { case QEvent::TouchBegin: seenTouchBegin = true; + touchPointCount = qMax(touchPointCount, static_cast<QTouchEvent *>(event)->touchPoints().count()); if (acceptTouchBegin) { event->accept(); return true; @@ -38,6 +40,7 @@ bool TouchWidget::event(QEvent *event) break; case QEvent::TouchUpdate: seenTouchUpdate = true; + touchPointCount = qMax(touchPointCount, static_cast<QTouchEvent *>(event)->touchPoints().count()); if (acceptTouchUpdate) { event->accept(); return true; @@ -45,6 +48,7 @@ bool TouchWidget::event(QEvent *event) break; case QEvent::TouchEnd: seenTouchEnd = true; + touchPointCount = qMax(touchPointCount, static_cast<QTouchEvent *>(event)->touchPoints().count()); if (closeWindowOnTouchEnd) window()->close(); if (acceptTouchEnd) { diff --git a/tests/manual/qtouchevent/touchwidget.h b/tests/manual/qtouchevent/touchwidget.h index 3e95610..2726deb 100644 --- a/tests/manual/qtouchevent/touchwidget.h +++ b/tests/manual/qtouchevent/touchwidget.h @@ -11,6 +11,7 @@ public: bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; bool closeWindowOnTouchEnd; + int touchPointCount; bool acceptMousePress, acceptMouseMove, acceptMouseRelease; bool seenMousePress, seenMouseMove, seenMouseRelease; |