summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/manual/qtouchevent/main.cpp54
-rw-r--r--tests/manual/qtouchevent/touchwidget.cpp26
-rw-r--r--tests/manual/qtouchevent/touchwidget.h20
3 files changed, 82 insertions, 18 deletions
diff --git a/tests/manual/qtouchevent/main.cpp b/tests/manual/qtouchevent/main.cpp
index c406543..2aab4ca 100644
--- a/tests/manual/qtouchevent/main.cpp
+++ b/tests/manual/qtouchevent/main.cpp
@@ -38,13 +38,63 @@ void tst_ManualMultitouch::touchBeginPropagation()
{
MultitouchTestWidget testWidget;
testWidget.testNameLabel->setText("Touch event propagation");
- testWidget.testDescriptionLabel->setText("Touch, move, and release your finger over the green widget, the close this window.");
+ testWidget.testDescriptionLabel->setText("Touch, move, and release your finger over the green widget.");
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
testWidget.greenWidget->acceptTouchBegin = true;
- testWidget.show();
+ testWidget.greenWidget->acceptTouchUpdate = true;
+ testWidget.greenWidget->acceptTouchEnd = true;
+ testWidget.greenWidget->closeWindowOnTouchEnd = 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);
+
+ // again, ignoring the TouchEnd
+ testWidget.greenWidget->reset();
+ 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);
+ QVERIFY(testWidget.greenWidget->seenTouchUpdate);
+ QVERIFY(testWidget.greenWidget->seenTouchEnd);
+ QVERIFY(!testWidget.greenWidget->seenMousePress);
+ QVERIFY(!testWidget.greenWidget->seenMouseMove);
+ QVERIFY(!testWidget.greenWidget->seenMouseRelease);
+
+ // again, ignoring TouchUpdates
+ testWidget.greenWidget->reset();
+ 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);
+ QVERIFY(testWidget.greenWidget->seenTouchUpdate);
+ QVERIFY(testWidget.greenWidget->seenTouchEnd);
+ QVERIFY(!testWidget.greenWidget->seenMousePress);
+ QVERIFY(!testWidget.greenWidget->seenMouseMove);
+ QVERIFY(!testWidget.greenWidget->seenMouseRelease);
+
+ // last time, ignoring TouchUpdates and TouchEnd
+ testWidget.greenWidget->reset();
+ 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);
QVERIFY(testWidget.greenWidget->seenTouchUpdate);
QVERIFY(testWidget.greenWidget->seenTouchEnd);
diff --git a/tests/manual/qtouchevent/touchwidget.cpp b/tests/manual/qtouchevent/touchwidget.cpp
index 5205504..54ca685 100644
--- a/tests/manual/qtouchevent/touchwidget.cpp
+++ b/tests/manual/qtouchevent/touchwidget.cpp
@@ -3,6 +3,28 @@
#include <QMouseEvent>
#include <QTouchEvent>
+
+void TouchWidget::reset()
+{
+ acceptTouchBegin
+ = acceptTouchUpdate
+ = acceptTouchEnd
+ = seenTouchBegin
+ = seenTouchUpdate
+ = seenTouchEnd
+ = closeWindowOnTouchEnd
+
+ = acceptMousePress
+ = acceptMouseMove
+ = acceptMouseRelease
+ = seenMousePress
+ = seenMouseMove
+ = seenMouseRelease
+ = closeWindowOnMouseRelease
+
+ = false;
+}
+
bool TouchWidget::event(QEvent *event)
{
switch (event->type()) {
@@ -22,6 +44,8 @@ bool TouchWidget::event(QEvent *event)
break;
case QEvent::TouchEnd:
seenTouchEnd = true;
+ if (closeWindowOnTouchEnd)
+ window()->close();
if (acceptTouchEnd) {
event->accept();
return true;
@@ -44,6 +68,8 @@ bool TouchWidget::event(QEvent *event)
break;
case QEvent::MouseButtonRelease:
seenMouseRelease = true;
+ if (closeWindowOnMouseRelease)
+ window()->close();
if (acceptMouseRelease) {
event->accept();
return true;
diff --git a/tests/manual/qtouchevent/touchwidget.h b/tests/manual/qtouchevent/touchwidget.h
index f438a87..3e95610 100644
--- a/tests/manual/qtouchevent/touchwidget.h
+++ b/tests/manual/qtouchevent/touchwidget.h
@@ -10,8 +10,11 @@ class TouchWidget : public QWidget
public:
bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd;
bool seenTouchBegin, seenTouchUpdate, seenTouchEnd;
+ bool closeWindowOnTouchEnd;
+
bool acceptMousePress, acceptMouseMove, acceptMouseRelease;
bool seenMousePress, seenMouseMove, seenMouseRelease;
+ bool closeWindowOnMouseRelease;
inline TouchWidget(QWidget *parent = 0)
: QWidget(parent)
@@ -19,22 +22,7 @@ public:
reset();
}
- void reset()
- {
- acceptTouchBegin
- = acceptTouchUpdate
- = acceptTouchEnd
- = seenTouchBegin
- = seenTouchUpdate
- = seenTouchEnd
- = acceptMousePress
- = acceptMouseMove
- = acceptMouseRelease
- = seenMousePress
- = seenMouseMove
- = seenMouseRelease
- = false;
- }
+ void reset();
bool event(QEvent *event);
};