summaryrefslogtreecommitdiffstats
path: root/tests/manual/qtouchevent/main.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-04-23 15:54:17 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-04-23 15:54:17 (GMT)
commit66ed5fc90fe44554e852a6f8dca4548154da781c (patch)
treeff2fe1a15f8a39a9a05924592b95d7e2a6b71584 /tests/manual/qtouchevent/main.cpp
parent704261859297dae22f90be32ed0e4b675fd02ed3 (diff)
downloadQt-66ed5fc90fe44554e852a6f8dca4548154da781c.zip
Qt-66ed5fc90fe44554e852a6f8dca4548154da781c.tar.gz
Qt-66ed5fc90fe44554e852a6f8dca4548154da781c.tar.bz2
update test to test basic event handling and touch begin propagation
Diffstat (limited to 'tests/manual/qtouchevent/main.cpp')
-rw-r--r--tests/manual/qtouchevent/main.cpp152
1 files changed, 148 insertions, 4 deletions
diff --git a/tests/manual/qtouchevent/main.cpp b/tests/manual/qtouchevent/main.cpp
index 2aab4ca..7ed9b15 100644
--- a/tests/manual/qtouchevent/main.cpp
+++ b/tests/manual/qtouchevent/main.cpp
@@ -12,8 +12,15 @@ public:
MultitouchTestWidget(QWidget *parent = 0)
: QWidget(parent)
{
+ setAttribute(Qt::WA_QuitOnClose, false);\
setupUi(this);
}
+
+ void closeEvent(QCloseEvent *event)
+ {
+ event->accept();
+ QTimer::singleShot(1000, qApp, SLOT(quit()));
+ }
};
class tst_ManualMultitouch : public QObject
@@ -25,7 +32,8 @@ public:
~tst_ManualMultitouch();
private slots:
- void touchBeginPropagation();
+ void basicEventHandling();
+ void touchEventPropagation();
};
tst_ManualMultitouch::tst_ManualMultitouch()
@@ -34,11 +42,99 @@ tst_ManualMultitouch::tst_ManualMultitouch()
tst_ManualMultitouch::~tst_ManualMultitouch()
{ }
-void tst_ManualMultitouch::touchBeginPropagation()
+void tst_ManualMultitouch::basicEventHandling()
+{
+ // first, make sure that we get mouse events when not enabling touch events
+ MultitouchTestWidget testWidget;
+ testWidget.testNameLabel->setText("Basic QTouchEvent handling 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);
+ QVERIFY(!testWidget.greenWidget->seenTouchEnd);
+ QVERIFY(testWidget.greenWidget->seenMousePress);
+ // QVERIFY(testWidget.greenWidget->seenMouseMove);
+ QVERIFY(testWidget.greenWidget->seenMouseRelease);
+
+ // now enable touch and make sure we get the touch events
+ testWidget.greenWidget->reset();
+ 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
+ && testWidget.greenWidget->seenTouchEnd);
+ QVERIFY(!testWidget.greenWidget->seenMousePress
+ && !testWidget.greenWidget->seenMouseMove
+ && !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);
+ QVERIFY(!testWidget.greenWidget->seenMousePress);
+ QVERIFY(!testWidget.greenWidget->seenMouseMove);
+ QVERIFY(!testWidget.greenWidget->seenMouseRelease);
+}
+
+void tst_ManualMultitouch::touchEventPropagation()
{
+ // first, make sure the greenWidget gets TouchBegin even though blueWidget is not touch aware
MultitouchTestWidget testWidget;
- testWidget.testNameLabel->setText("Touch event propagation");
- testWidget.testDescriptionLabel->setText("Touch, move, and release your finger over the green widget.");
+ testWidget.testNameLabel->setText("QTouchEvent propagation test");
+ 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.greenWidget->acceptTouchBegin = true;
testWidget.greenWidget->acceptTouchUpdate = true;
@@ -47,6 +143,36 @@ void tst_ManualMultitouch::touchBeginPropagation()
testWidget.showMaximized();
(void) qApp->exec();
+ QVERIFY(!testWidget.blueWidget->seenTouchBegin);
+ QVERIFY(!testWidget.blueWidget->seenTouchUpdate);
+ QVERIFY(!testWidget.blueWidget->seenTouchEnd);
+ QVERIFY(!testWidget.blueWidget->seenMousePress);
+ QVERIFY(!testWidget.blueWidget->seenMouseMove);
+ QVERIFY(!testWidget.blueWidget->seenMouseRelease);
+ 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, but this time blueWidget should see the TouchBegin
+ testWidget.blueWidget->reset();
+ testWidget.greenWidget->reset();
+ testWidget.blueWidget->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.blueWidget->seenTouchBegin);
+ QVERIFY(!testWidget.blueWidget->seenTouchUpdate);
+ QVERIFY(!testWidget.blueWidget->seenTouchEnd);
+ QVERIFY(!testWidget.blueWidget->seenMousePress);
+ QVERIFY(!testWidget.blueWidget->seenMouseMove);
+ QVERIFY(!testWidget.blueWidget->seenMouseRelease);
QVERIFY(testWidget.greenWidget->seenTouchBegin);
QVERIFY(testWidget.greenWidget->seenTouchUpdate);
QVERIFY(testWidget.greenWidget->seenTouchEnd);
@@ -63,6 +189,12 @@ void tst_ManualMultitouch::touchBeginPropagation()
testWidget.showMaximized();
(void) qApp->exec();
+ QVERIFY(testWidget.blueWidget->seenTouchBegin);
+ QVERIFY(!testWidget.blueWidget->seenTouchUpdate);
+ QVERIFY(!testWidget.blueWidget->seenTouchEnd);
+ QVERIFY(!testWidget.blueWidget->seenMousePress);
+ QVERIFY(!testWidget.blueWidget->seenMouseMove);
+ QVERIFY(!testWidget.blueWidget->seenMouseRelease);
QVERIFY(testWidget.greenWidget->seenTouchBegin);
QVERIFY(testWidget.greenWidget->seenTouchUpdate);
QVERIFY(testWidget.greenWidget->seenTouchEnd);
@@ -79,6 +211,12 @@ void tst_ManualMultitouch::touchBeginPropagation()
testWidget.showMaximized();
(void) qApp->exec();
+ QVERIFY(testWidget.blueWidget->seenTouchBegin);
+ QVERIFY(!testWidget.blueWidget->seenTouchUpdate);
+ QVERIFY(!testWidget.blueWidget->seenTouchEnd);
+ QVERIFY(!testWidget.blueWidget->seenMousePress);
+ QVERIFY(!testWidget.blueWidget->seenMouseMove);
+ QVERIFY(!testWidget.blueWidget->seenMouseRelease);
QVERIFY(testWidget.greenWidget->seenTouchBegin);
QVERIFY(testWidget.greenWidget->seenTouchUpdate);
QVERIFY(testWidget.greenWidget->seenTouchEnd);
@@ -95,6 +233,12 @@ void tst_ManualMultitouch::touchBeginPropagation()
testWidget.showMaximized();
(void) qApp->exec();
+ QVERIFY(testWidget.blueWidget->seenTouchBegin);
+ QVERIFY(!testWidget.blueWidget->seenTouchUpdate);
+ QVERIFY(!testWidget.blueWidget->seenTouchEnd);
+ QVERIFY(!testWidget.blueWidget->seenMousePress);
+ QVERIFY(!testWidget.blueWidget->seenMouseMove);
+ QVERIFY(!testWidget.blueWidget->seenMouseRelease);
QVERIFY(testWidget.greenWidget->seenTouchBegin);
QVERIFY(testWidget.greenWidget->seenTouchUpdate);
QVERIFY(testWidget.greenWidget->seenTouchEnd);