summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qtestsupport_widgets.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-06-30 08:49:48 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-07-08 06:12:03 +0200
commite1f25b1c8df04fbbc13af1e2e8ecc1def1cfb3dc (patch)
treeae8c7f397cac30d28f0d059c38feeddaa017f568 /src/widgets/kernel/qtestsupport_widgets.cpp
parent0d5d914dbfdd28f8c4d41200c3a5219e85b9c0cf (diff)
Make it possible to check the accepted state of touch events in tests
QTouchEventSequence simulates a QPA touch event, potentially containing multiple points. (Despite the name, it only calls qt_handleTouchEvent() once, so it cannot really send a sequence of events; however, one event can contain multiple touchpoints.) Delivery is synchronous, and we keep return values through the QWindowSystemInterface::handleTouchEvent() template functions; so the remaining step is to return a bool from qt_handleTouchEvent(), so that we can return a bool from commit(). This allows tests to see the same perspective as a platform plugin can: check whether the event was accepted or not, after delivery is complete. Some tests in Qt Quick need to start doing that, to enforce correct behavior in QQuickDeliveryAgent. [ChangeLog][QtTestLib] QTouchEventSequence::commit() now returns a bool so that tests can check whether the event was accepted during delivery. Pick-to: 6.4 Task-number: QTBUG-104656 Change-Id: I9cf87909a3f847dedbdeca257013e309ac19cf0d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/kernel/qtestsupport_widgets.cpp')
-rw-r--r--src/widgets/kernel/qtestsupport_widgets.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp
index 490a40d431..ea8317db03 100644
--- a/src/widgets/kernel/qtestsupport_widgets.cpp
+++ b/src/widgets/kernel/qtestsupport_widgets.cpp
@@ -115,20 +115,22 @@ QTouchEventWidgetSequence& QTouchEventWidgetSequence::stationary(int touchId)
return *this;
}
-void QTouchEventWidgetSequence::commit(bool processEvents)
+bool QTouchEventWidgetSequence::commit(bool processEvents)
{
+ bool ret = false;
if (points.isEmpty())
- return;
+ return ret;
QThread::msleep(1);
if (targetWindow) {
- qt_handleTouchEvent(targetWindow, device, points.values());
+ ret = qt_handleTouchEvent(targetWindow, device, points.values());
} else if (targetWidget) {
- qt_handleTouchEvent(targetWidget->windowHandle(), device, points.values());
+ ret = qt_handleTouchEvent(targetWidget->windowHandle(), device, points.values());
}
if (processEvents)
QCoreApplication::processEvents();
previousPoints = points;
points.clear();
+ return ret;
}
QTest::QTouchEventWidgetSequence::QTouchEventWidgetSequence(QWidget *widget, QPointingDevice *aDevice, bool autoCommit)