diff options
Diffstat (limited to 'tests/auto/gui/kernel/qwindow/tst_qwindow.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 34 |
1 files changed, 30 insertions, 4 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)); |