summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2014-12-09 18:52:24 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2015-02-25 13:31:41 +0000
commit76922a706f0584ce2aa1a0ca758cf0c6196ea729 (patch)
treeb705f586c876189ca7495d7bd909be032b80f02d /tests/auto
parentef22739f47857c185f63f87966df79d377c89577 (diff)
Decide whether to synthesize mouse events on a per device basis
Currently Qt uses the QPlatformIntegration::StyleHint SynthesizeMouseFromTouchEvents to check whether to synthesize mouse events from touch events. But not only platform plugins can produce touch events, they can be created by e.g. QTest::touchEvent() and in this case we almost definitely need synthesizing regardless of the platform. This commit introduces a QTouchDevice::MouseEmulation capability which replaces use of the QPlatformIntegration::SynthesizeMouseFromTouchEvents. So it's possible to pass QTouchDevice without this capability to QTest::touchEvent() and be sure that mouse events will be synthesized. Notice that touch pads always emulate mouse events. As a result we can activate some tests which were disabled for specific platform configurations by commits 6c1670d8c273819435867c42725c0db0eee597dc and e9760f1559361c39f269fb89f1ebd01f6ee8378d. Change-Id: Idc82fa4007a095fc1cb5934979361b0023d2b793 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp34
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp29
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp8
3 files changed, 45 insertions, 26 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 89490525c9..8ce0e3942e 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -68,6 +68,7 @@ private slots:
void isActive();
void testInputEvents();
void touchToMouseTranslation();
+ void touchToMouseTranslationForDevices();
void mouseToTouchTranslation();
void mouseToTouchLoop();
void touchCancel();
@@ -705,8 +706,6 @@ void tst_QWindow::testInputEvents()
void tst_QWindow::touchToMouseTranslation()
{
- if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
- QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
@@ -779,6 +778,35 @@ void tst_QWindow::touchToMouseTranslation()
QTRY_COMPARE(window.mouseReleaseButton, 0);
}
+void tst_QWindow::touchToMouseTranslationForDevices()
+{
+ InputTestWindow window;
+ window.ignoreTouch = true;
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QPoint touchPoint(10, 10);
+
+ QTest::touchEvent(&window, touchDevice).press(0, touchPoint, &window);
+ QTest::touchEvent(&window, touchDevice).release(0, touchPoint, &window);
+ QCoreApplication::processEvents();
+
+ QCOMPARE(window.mousePressedCount, 1);
+ QCOMPARE(window.mouseReleasedCount, 1);
+
+ window.resetCounters();
+
+ touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
+ QTest::touchEvent(&window, touchDevice).press(0, touchPoint, &window);
+ QTest::touchEvent(&window, touchDevice).release(0, touchPoint, &window);
+ QCoreApplication::processEvents();
+ touchDevice->setCapabilities(touchDevice->capabilities() & ~QTouchDevice::MouseEmulation);
+
+ QCOMPARE(window.mousePressedCount, 0);
+ QCOMPARE(window.mouseReleasedCount, 0);
+}
+
void tst_QWindow::mouseToTouchTranslation()
{
qApp->setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true);
@@ -907,8 +935,6 @@ void tst_QWindow::touchCancel()
void tst_QWindow::touchCancelWithTouchToMouse()
{
- if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
- QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 2a4e06fe29..7e950b33c1 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -2006,9 +2006,6 @@ void tst_QApplication::touchEventPropagation()
int argc = 1;
QApplication app(argc, &argv0);
- const bool mouseEventSynthesizing = QGuiApplicationPrivate::platformIntegration()
- ->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool();
-
QList<QTouchEvent::TouchPoint> pressedTouchPoints;
QTouchEvent::TouchPoint press(0);
press.setState(Qt::TouchPointPressed);
@@ -2047,7 +2044,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!window.seenTouchEvent);
- QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); // QApplication may transform ignored touch events in mouse events
+ QVERIFY(window.seenMouseEvent); // QApplication may transform ignored touch events in mouse events
window.reset();
window.setAttribute(Qt::WA_AcceptTouchEvents);
@@ -2061,7 +2058,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(window.seenTouchEvent);
- QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(window.seenMouseEvent);
window.reset();
window.acceptTouchEvent = true;
@@ -2100,9 +2097,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(widget.seenMouseEvent);
QVERIFY(!window.seenTouchEvent);
- QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(window.seenMouseEvent);
window.reset();
widget.reset();
@@ -2117,9 +2114,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(widget.seenMouseEvent);
QVERIFY(!window.seenTouchEvent);
- QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(window.seenMouseEvent);
window.reset();
widget.reset();
@@ -2134,7 +2131,7 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(widget.seenMouseEvent);
QVERIFY(!window.seenTouchEvent);
QVERIFY(!window.seenMouseEvent);
@@ -2169,9 +2166,9 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(widget.seenMouseEvent);
QVERIFY(window.seenTouchEvent);
- QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(window.seenMouseEvent);
window.reset();
widget.reset();
@@ -2186,13 +2183,13 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
+ QVERIFY(!widget.seenMouseEvent);
QVERIFY(window.seenTouchEvent);
QVERIFY(!window.seenMouseEvent);
window.reset();
widget.reset();
- widget.acceptMouseEvent = true; // it matters, touch events are propagated in parallel to synthesized mouse events
+ widget.acceptMouseEvent = true; // doesn't matter, touch events are propagated first
window.acceptTouchEvent = true;
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
@@ -2204,8 +2201,8 @@ void tst_QApplication::touchEventPropagation()
touchPointList(releasedTouchPoints));
QCoreApplication::processEvents();
QVERIFY(!widget.seenTouchEvent);
- QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing);
- QCOMPARE(!window.seenTouchEvent, mouseEventSynthesizing);
+ QVERIFY(!widget.seenMouseEvent);
+ QVERIFY(window.seenTouchEvent);
QVERIFY(!window.seenMouseEvent);
}
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index d717f26c52..e5e96d5b3d 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -9824,9 +9824,6 @@ public:
void tst_QWidget::touchEventSynthesizedMouseEvent()
{
- // Pass if the platform does not want mouse event synhesizing
- if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
- return;
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
@@ -9852,7 +9849,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
QCOMPARE(widget.m_lastMouseEventPos, QPointF(15, 15));
QTest::touchEvent(&widget, device).release(0, QPoint(20, 20), &widget);
QCOMPARE(widget.m_touchEventCount, 0);
- QCOMPARE(widget.m_mouseEventCount, 3);
+ QCOMPARE(widget.m_mouseEventCount, 4); // we receive extra mouse move event
QCOMPARE(widget.m_lastMouseEventPos, QPointF(20, 20));
}
@@ -9903,8 +9900,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
QCOMPARE(parent.m_touchEventCount, 1);
QCOMPARE(parent.m_mouseEventCount, 0);
QCOMPARE(child.m_touchEventCount, 0);
- QCOMPARE(child.m_mouseEventCount, 1); // Attempt at mouse event before propagation
- QCOMPARE(child.m_lastMouseEventPos, QPointF(10, 10));
+ QCOMPARE(child.m_mouseEventCount, 0);
}
{