summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2012-08-08 11:44:39 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-22 07:01:17 +0200
commit6c1670d8c273819435867c42725c0db0eee597dc (patch)
tree9de8f59b14624cb8c9678fa47820771f95e5b9d4 /tests
parent09dd19df5c4b708960e5aade568eb15d996ef200 (diff)
Add hint for touch -> mouse event synthesizing
Commit 7808ec79 changes QApplication to synthesize mouse events from (unhandled) touch events. On Mac OS X this creates a conflict for two-finger scroll swipes, which generates both touch events and mouse wheel events: scrolling in QTextEdit will also select the text. Add a SynthesizeMouseFromTouchEvents platform style hint that enables the event synthesising. Set to true by default and false in Cocoa. Change-Id: I1ffa5a141476aa38b81ce92a87eff676c7ec2276 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp27
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp4
2 files changed, 19 insertions, 12 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index fc91ba23b3..929b587dfb 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1926,6 +1926,9 @@ void tst_QApplication::touchEventPropagation()
int argc = 1;
QApplication app(argc, &argv0, QApplication::GuiServer);
+ const bool mouseEventSynthesizing = QGuiApplicationPrivate::platformIntegration()
+ ->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool();
+
QList<QTouchEvent::TouchPoint> pressedTouchPoints;
QTouchEvent::TouchPoint press(0);
press.setState(Qt::TouchPointPressed);
@@ -1963,7 +1966,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!window.seenTouchEvent);
- QVERIFY(window.seenMouseEvent); // Since QApplication transforms ignored touch events in mouse events
+ QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); // QApplication may transform ignored touch events in mouse events
window.reset();
window.setAttribute(Qt::WA_AcceptTouchEvents);
@@ -1977,7 +1980,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(window.seenTouchEvent);
- QVERIFY(window.seenMouseEvent);
+ QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
window.reset();
window.acceptTouchEvent = true;
@@ -2015,9 +2018,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
QVERIFY(!window.seenTouchEvent);
- QVERIFY(window.seenMouseEvent);
+ QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
window.reset();
widget.reset();
@@ -2032,9 +2035,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
QVERIFY(!window.seenTouchEvent);
- QVERIFY(window.seenMouseEvent);
+ QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
window.reset();
widget.reset();
@@ -2049,7 +2052,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
QVERIFY(!window.seenTouchEvent);
QVERIFY(!window.seenMouseEvent);
@@ -2084,9 +2087,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
QVERIFY(window.seenTouchEvent);
- QVERIFY(window.seenMouseEvent);
+ QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
window.reset();
widget.reset();
@@ -2101,7 +2104,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
QVERIFY(window.seenTouchEvent);
QVERIFY(!window.seenMouseEvent);
@@ -2119,8 +2122,8 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QVERIFY(widget.seenMouseEvent);
- QVERIFY(!window.seenTouchEvent);
+ QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QCOMPARE(!window.seenTouchEvent, mouseEventSynthesizing);
QVERIFY(!window.seenMouseEvent);
}
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 0c35107157..3b45acfa1a 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -9409,6 +9409,10 @@ public:
void tst_QWidget::touchEventSynthesizedMouseEvent()
{
+ // Pass if the platform does not want mouse event synhesizing
+ if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
+ return;
+
{
// Simple case, we ignore the touch events, we get mouse events instead
QTouchDevice *device = new QTouchDevice;