summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-10 15:32:26 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-18 18:53:40 +0200
commit28ef8d283db336d0d1641b8fbab31eac5b46a498 (patch)
treee349521d8d16c35adb248d3ca3e88dd869f33fc2 /tests/auto
parent68de38ded1c0e5387ae29aacaee50ba5dacfc59a (diff)
Add QPointingDevice argument to every QWSI input event handler function
We want every QInputEvent to carry a valid device pointer. It may be some time until all QPA plugins are sending it, but it's necessary to provide the functions for them to start doing that. We now try to maintain the same order of arguments to all the functions. handleTouchEvent(window, timestamp, device, the rest) was already there (except "device" has changed type now), and is used in a lot of platform plugins; so it seems easiest to let that set the precedent, and modify the rest to match. We do that by adding new functions; we can deprecate the older functions after it becomes clear that the new ones work well. However the handleGestureEvent functions have only ever been used in the cocoa plugin, so it's easy to change their argument order right now. Modify tst_qwindow::tabletEvents() to test new tablet event API. Task-number: QTBUG-46412 Change-Id: I1828b61183cf51f3a08774936156c6a91cfc9a12 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index afa764d580..05f58f769f 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -1725,6 +1725,11 @@ public:
void tst_QWindow::tabletEvents()
{
#if QT_CONFIG(tabletevent)
+ // the fake USB tablet device is "plugged in"
+ QPointingDevice tabletDevice("macow", 0xbeef, QInputDevice::DeviceType::Unknown, QPointingDevice::PointerType::Generic,
+ QInputDevice::Capability::Position, 1, 0);
+ QWindowSystemInterface::registerInputDevice(&tabletDevice);
+
TabletTestWindow window;
window.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize));
qGuiApp->installEventFilter(&window);
@@ -1733,24 +1738,36 @@ void tst_QWindow::tabletEvents()
const QPoint global = window.mapToGlobal(local);
const QPoint deviceLocal = QHighDpi::toNativeLocalPosition(local, &window);
const QPoint deviceGlobal = QHighDpi::toNativePixels(global, window.screen());
- QWindowSystemInterface::handleTabletEvent(&window, deviceLocal, deviceGlobal,
- 1, 2, Qt::LeftButton, 0.5, 1, 2, 0.1, 0, 0, 0);
+ ulong timestamp = 1234;
+
+ // the stylus is just now seen for the first time, as it comes into proximity
+ // its QObject-parent will be the tablet device
+ QPointingDevice tabletStylus("macow stylus eraser", 0xe6a5e6, QInputDevice::DeviceType::Stylus, QPointingDevice::PointerType::Eraser,
+ QInputDevice::Capability::Position | QInputDevice::Capability::Pressure, 1, 3, QString(),
+ QPointingDeviceUniqueId::fromNumericId(42), &tabletDevice);
+ QWindowSystemInterface::registerInputDevice(&tabletStylus);
+ QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(&window, timestamp++, &tabletStylus, true);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.eventType, QEvent::TabletEnterProximity);
+ QCOMPARE(window.eventDevice, QInputDevice::DeviceType::Stylus);
+ QCOMPARE(window.eventPointerType, QPointingDevice::PointerType::Eraser);
+
+ // the eraser is pressed into contact with the tablet surface
+ QWindowSystemInterface::handleTabletEvent(&window, timestamp++, &tabletStylus, deviceLocal, deviceGlobal,
+ Qt::LeftButton, 0.5, 1, 2, 0.1, 0, 0, {});
QCoreApplication::processEvents();
QTRY_VERIFY(window.eventType == QEvent::TabletPress);
QTRY_COMPARE(window.eventGlobal.toPoint(), global);
QTRY_COMPARE(window.eventLocal.toPoint(), local);
- QWindowSystemInterface::handleTabletEvent(&window, deviceLocal, deviceGlobal, 1, 2,
- {}, 0.5, 1, 2, 0.1, 0, 0, 0);
- QCoreApplication::processEvents();
- QTRY_COMPARE(window.eventType, QEvent::TabletRelease);
- QWindowSystemInterface::handleTabletEnterProximityEvent(int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Eraser), 3);
+ // now it's lifted
+ QWindowSystemInterface::handleTabletEvent(&window, timestamp++, &tabletStylus, deviceLocal, deviceGlobal,
+ Qt::NoButton, 0, 3, 4, 0.11, 2, 1, {});
QCoreApplication::processEvents();
- QTRY_COMPARE(window.eventType, QEvent::TabletEnterProximity);
- QCOMPARE(window.eventDevice, QInputDevice::DeviceType::Stylus);
- QCOMPARE(window.eventPointerType, QPointingDevice::PointerType::Eraser);
+ QTRY_COMPARE(window.eventType, QEvent::TabletRelease);
- QWindowSystemInterface::handleTabletLeaveProximityEvent(int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Eraser), 3);
+ // and is taken away (goes out of proxmity)
+ QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(&window, timestamp, &tabletStylus, false);
QCoreApplication::processEvents();
QTRY_COMPARE(window.eventType, QEvent::TabletLeaveProximity);
QCOMPARE(window.eventDevice, QInputDevice::DeviceType::Stylus);