aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <[email protected]>2025-03-27 17:19:03 +0100
committerShawn Rutledge <[email protected]>2025-05-10 20:03:44 +0200
commitf09eb295c3b14ac24815eec524732bb619b2205f (patch)
treed54f55832207ceed1a9213c5c11eec530726fc38
parent9d3a157cf5c0ebb26249ef53e76234463d103d0d (diff)
tests: do not leak QPointingDevice instances
QTest::createTouchDevice() passes ownership of the device to the caller, so make sure it gets deleted. Pick-to: 6.8 6.9 Change-Id: I1289def6b40bf688a7334b9997f7e4319516d018 Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp6
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp10
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp51
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp47
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp31
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp95
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp151
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp10
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp13
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp140
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp26
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp104
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp202
13 files changed, 444 insertions, 442 deletions
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
index d60f4b2cba..2a8cc84419 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
@@ -38,7 +38,7 @@ private slots:
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
- QPointingDevice *touchDevice = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_MouseAreaInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName)
@@ -109,7 +109,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "dragTakeOverFromSibling.qml");
QQuickView * window = windowPtr.data();
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>();
QVERIFY(handler);
@@ -118,7 +118,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
ma->setPreventStealing(preventStealing);
QPoint p1(150, 150);
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index 90d3178111..d4f27f5868 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -38,7 +38,7 @@ private slots:
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
- QPointingDevice *touchDevice = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_MptaInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName)
@@ -79,7 +79,7 @@ void tst_MptaInterop::touchDrag()
QVERIFY(tp.at(3)); // the QML declares four touchpoints
QSignalSpy mptaPressedSpy(mpta, SIGNAL(pressed(QList<QObject*>)));
QSignalSpy mptaReleasedSpy(mpta, SIGNAL(released(QList<QObject*>)));
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
// Press one touchpoint:
// DragHandler gets a passive grab
@@ -88,7 +88,7 @@ void tst_MptaInterop::touchDrag()
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
QTRY_VERIFY(devPriv->pointById(1)->passiveGrabbers.contains(drag));
@@ -129,8 +129,8 @@ void tst_MptaInterop::touchesThenPinch()
QSignalSpy mptaPressedSpy(mpta, SIGNAL(pressed(QList<QObject*>)));
QSignalSpy mptaReleasedSpy(mpta, SIGNAL(released(QList<QObject*>)));
QSignalSpy mptaCanceledSpy(mpta, SIGNAL(canceled(QList<QObject*>)));
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
// Press one touchpoint:
// DragHandler gets a passive grab
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index f90be8640b..17782ff132 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -28,7 +28,6 @@ class tst_DragHandler : public QQmlDataTest
public:
tst_DragHandler()
: QQmlDataTest(QT_QMLTEST_DATADIR)
- , touchDevice(QTest::createTouchDevice())
{}
private slots:
@@ -59,7 +58,7 @@ private:
void sendWheelEvent(QQuickView &window, QPoint pos, QPoint angleDelta, QPoint pixelDelta, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, bool inverted);
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
QSet<QQuickPointerHandler *> passiveGrabbers(QQuickWindow *window, int pointId = 0);
- QPointingDevice *touchDevice;
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_DragHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName)
@@ -79,7 +78,7 @@ QSet<QQuickPointerHandler*> tst_DragHandler::passiveGrabbers(QQuickWindow *windo
{
Q_UNUSED(window);
QSet<QQuickPointerHandler*> result;
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
for (auto &epd : devPriv->activePoints.values()) {
auto passives = epd.passiveGrabbers;
if (!pointId || epd.eventPoint.id() == pointId) {
@@ -153,7 +152,7 @@ void tst_DragHandler::touchDrag()
QPointF ballCenter = ball->clipRect().center();
QPointF scenePressPos = ball->mapToScene(ballCenter);
QPoint p1 = scenePressPos.toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler->active());
QCOMPARE(dragHandler->centroid().position(), ballCenter);
@@ -163,7 +162,7 @@ void tst_DragHandler::touchDrag()
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
QCOMPARE(centroidChangedSpy.size(), 1);
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "velocity after drag" << dragHandler->centroid().velocity();
if (dragThreshold > 0)
@@ -171,7 +170,7 @@ void tst_DragHandler::touchDrag()
QCOMPARE(centroidChangedSpy.size(), 2);
QVERIFY(!dragHandler->active());
p1 += QPoint(1, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
QCOMPARE(translationChangedSpy.size(), 0);
@@ -182,7 +181,7 @@ void tst_DragHandler::touchDrag()
QPointF sceneGrabPos = p1;
QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
p1 += QPoint(19, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
QCOMPARE(dragHandler->centroid().position(), ballCenter);
@@ -198,7 +197,7 @@ void tst_DragHandler::touchDrag()
QCOMPARE(translationChangedSpy.first().first().value<QVector2D>(), QVector2D(dragThreshold + 20, 0));
QVERIFY(dragHandler->centroid().velocity().x() > 0);
QCOMPARE(centroidChangedSpy.size(), 4);
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler->active());
QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
@@ -212,56 +211,56 @@ void tst_DragHandler::touchDrag()
// Drag again: activeTranslation starts over, while persistentTranslation accumulates
p1 = ball->mapToScene(ballCenter).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(dragHandler->persistentTranslation().x(), dragThreshold + 20);
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
p1 += QPoint(1, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
p1 += QPoint(9, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(xDeltaSpy.size(), 2);
QCOMPARE(xDeltaSpy.last().first().toReal(), dragThreshold + 10);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(dragHandler->activeTranslation().x(), dragThreshold + 20);
QCOMPARE(dragHandler->persistentTranslation().x(), dragThreshold * 2 + 40);
QCOMPARE(xDeltaSpy.size(), 3);
QCOMPARE(xDeltaSpy.last().first().toReal(), 10);
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
// Call setPersistentTranslation and drag yet again:
// activeTranslation starts over, while persistentTranslation adds the drags onto the new basis
dragHandler->setPersistentTranslation({10, 10});
p1 = ball->mapToScene(ballCenter).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(dragHandler->persistentTranslation().x(), 10);
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
p1 += QPoint(1, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
p1 += QPoint(9, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(dragHandler->activeTranslation().x(), dragThreshold + 20);
QCOMPARE(dragHandler->persistentTranslation().x(), dragThreshold + 30);
QCOMPARE(xDeltaSpy.size(), 6);
QCOMPARE(xDeltaSpy.last().first().toReal(), 10);
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
}
@@ -618,7 +617,7 @@ void tst_DragHandler::touchDragMulti()
QPointF ball2Center = ball2->clipRect().center();
QPointF scenePressPos2 = ball2->mapToScene(ball2Center);
QPoint p2 = scenePressPos2.toPoint();
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchscreen.get(), false);
touchSeq.press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
@@ -772,7 +771,7 @@ void tst_DragHandler::touchDragMultiSliders()
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "multipleSliders.qml");
QQuickView * window = windowPtr.data();
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
QQuickRepeater *rowRepeater = window->rootObject()->findChildren<QQuickRepeater *>()[sliderRow];
QVector<QQuickItem *> knobs;
@@ -855,7 +854,7 @@ void tst_DragHandler::touchPassiveGrabbers()
expectedPassiveGrabbers << row2->findChild<QQuickPointerHandler*>(objectName);
QPointF p1 = row2->mapToScene(row2->clipRect().center());
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
touch.press(1, p1.toPoint()).commit();
QQuickTouchUtils::flush(window);
@@ -908,7 +907,7 @@ void tst_DragHandler::touchPinchAndMouseMove()
QPoint p2(250,200);
// Trigger a scale pinch, PinchHandler should activate
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
touch.press(1, p1).press(2, p2).commit();
QQuickTouchUtils::flush(window);
QPoint delta(10,0);
@@ -957,7 +956,7 @@ void tst_DragHandler::unsuitableEventDuringDrag()
QPoint p1(100, 100);
QPoint p2(150, 150);
- QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
+ QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchscreen.get());
// When we start dragging...
touch.press(3,p1).commit();
touch.move(3, p2).commit();
@@ -1168,7 +1167,7 @@ void tst_DragHandler::touchDragExclusiveGrabber()
QPoint p1 = scenePressPos.toPoint();
auto dragThreshold = dragHandler->dragThreshold();
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, touchDevice, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, touchscreen.get(), false);
touchSeq.press(1, p1, &window).commit();
QVERIFY(!dragHandler->active());
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
index 4afe95f279..e301e5a377 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
@@ -251,7 +251,6 @@ class tst_PointerHandlers : public QQmlDataTest
public:
tst_PointerHandlers()
: QQmlDataTest(QT_QMLTEST_DATADIR)
- , touchDevice(QTest::createTouchDevice())
{}
private slots:
@@ -298,7 +297,7 @@ protected:
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
- QPointingDevice *touchDevice;
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
QList<Event> filteredEventList;
};
@@ -341,7 +340,7 @@ void tst_PointerHandlers::touchEventDelivery()
EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>();
QVERIFY(eventItem1);
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
// In Qt 5, QQItem::acceptTouchEvents(true) was the default, but not in Qt 6.
// This test is written to expect touch events on eventItem1.
// ignoreTouch = true just tells it to reject the events as they come.
@@ -349,18 +348,18 @@ void tst_PointerHandlers::touchEventDelivery()
// Reject incoming mouse and touch events
QPoint p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events from touch press" << eventItem1->eventList;
QTRY_COMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
QCOMPARE_EVENT(1, Event::ItemTouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, NoGrab);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch move" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 3); // no grabs -> only the handler gets the update
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch release" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 4);
@@ -370,19 +369,19 @@ void tst_PointerHandlers::touchEventDelivery()
// Accept touch events only
eventItem1->ignoreTouch = false;
p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
QCOMPARE_EVENT(1, Event::ItemTouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem1);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 4);
QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, NoGrab);
QCOMPARE_EVENT(3, Event::ItemTouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 6);
QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, NoGrab);
@@ -397,7 +396,7 @@ void tst_PointerHandlers::touchEventDelivery()
eventItem1->ignoreMouse = false;
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch press" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 2);
@@ -411,11 +410,11 @@ void tst_PointerHandlers::touchEventDelivery()
QCOMPARE(eventItem1->eventList.at(1).posWrtScene, scenePos);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch move" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 3);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch release" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 4);
@@ -430,7 +429,7 @@ void tst_PointerHandlers::touchEventDelivery()
eventItem1->ignoreMouse = true;
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch press" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 2);
@@ -438,11 +437,11 @@ void tst_PointerHandlers::touchEventDelivery()
QCOMPARE_EVENT(1, Event::ItemTouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, NoGrab);
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, nullptr);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch move" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 3);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch release" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 4);
@@ -455,18 +454,18 @@ void tst_PointerHandlers::touchEventDelivery()
eventItem1->ignoreTouch = false;
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
QCOMPARE_EVENT(1, Event::ItemTouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 4);
QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, NoGrab);
QCOMPARE_EVENT(3, Event::ItemTouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 6);
QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, NoGrab);
@@ -480,17 +479,17 @@ void tst_PointerHandlers::touchEventDelivery()
eventItem1->acceptPoint = true;
eventItem1->grabPoint = true;
p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::None, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
QCOMPARE_EVENT(1, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
p1 += QPoint(10, 0);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 3);
QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 5);
qCDebug(lcPointerTests) << eventItem1->eventList;
@@ -623,12 +622,12 @@ void tst_PointerHandlers::touchReleaseOutside()
handler->grabPoint = grabPoint;
QPoint p1 = QPoint(20, 20);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch press" << eventItem1->eventList;
p1.setX(eventItem1->mapToScene(eventItem1->clipRect().bottomRight()).x() + 10);
- QTest::touchEvent(window, touchDevice).move(0, p1, window);
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "events after touch release" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), eventCount);
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
index d6e8fa27bb..9c67069455 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
@@ -29,7 +29,6 @@ class tst_PointHandler : public QQmlDataTest
public:
tst_PointHandler()
: QQmlDataTest(QT_QMLTEST_DATADIR)
- , touchDevice(QTest::createTouchDevice())
{}
private slots:
@@ -45,7 +44,7 @@ private slots:
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
- QPointingDevice *touchDevice;
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_PointHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName)
@@ -84,7 +83,7 @@ void tst_PointHandler::singleTouch()
QSignalSpy translationSpy(handler, SIGNAL(translationChanged()));
QPoint point(100,100);
- QTest::touchEvent(window, touchDevice).press(1, point, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, point, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(handler->active(), true);
QCOMPARE(activeSpy.size(), 1);
@@ -96,7 +95,7 @@ void tst_PointHandler::singleTouch()
QCOMPARE(translationSpy.size(), 1);
point += QPoint(10, 10);
- QTest::touchEvent(window, touchDevice).move(1, point, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, point, window);
QQuickTouchUtils::flush(window);
QCOMPARE(handler->active(), true);
QCOMPARE(activeSpy.size(), 1);
@@ -111,7 +110,7 @@ void tst_PointHandler::singleTouch()
QCOMPARE(handler->translation(), QVector2D(10, 10));
QCOMPARE(translationSpy.size(), 2);
- QTest::touchEvent(window, touchDevice).release(1, point, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, point, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(handler->active(), false);
QCOMPARE(activeSpy.size(), 2);
@@ -217,7 +216,7 @@ void tst_PointHandler::simultaneousMultiTouch()
translationSpies << new QSignalSpy(h, SIGNAL(translationChanged()));
}
- QTest::touchEvent(window, touchDevice).press(1, points[0], window).press(2, points[1], window).press(3, points[2], window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, points[0], window).press(2, points[1], window).press(3, points[2], window);
QQuickTouchUtils::flush(window);
QVector<int> pointIndexPerHandler;
int i = 0;
@@ -240,7 +239,7 @@ void tst_PointHandler::simultaneousMultiTouch()
for (int i = 0; i < 3; ++i)
points[i] += QPoint(10 + 10 * i, 10 + 10 * i % 2);
- QTest::touchEvent(window, touchDevice).move(1, points[0], window).move(2, points[1], window).move(3, points[2], window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, points[0], window).move(2, points[1], window).move(3, points[2], window);
QQuickTouchUtils::flush(window);
i = 0;
for (auto h : handlers) {
@@ -259,7 +258,7 @@ void tst_PointHandler::simultaneousMultiTouch()
++i;
}
- QTest::touchEvent(window, touchDevice).release(1, points[0], window).release(2, points[1], window).release(3, points[2], window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, points[0], window).release(2, points[1], window).release(3, points[2], window);
QQuickTouchUtils::flush(window);
i = 0;
for (auto h : handlers) {
@@ -411,18 +410,18 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
QVERIFY(QQuickTest::showView(window, testFileUrl("pointTracker.qml")));
QQuickPointHandler *handler = window.rootObject()->findChild<QQuickPointHandler *>();
QVERIFY(handler);
- auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QSignalSpy activeSpy(handler, SIGNAL(activeChanged()));
QSignalSpy pointSpy(handler, SIGNAL(pointChanged()));
// touch press
QPoint point(100,100);
- QTest::touchEvent(&window, touchDevice).press(0, point, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, point, &window);
QQuickTouchUtils::flush(&window);
// touch move
point += QPoint(10, 10);
- QTest::touchEvent(&window, touchDevice).move(0, point, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, point, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(handler->active(), true);
QCOMPARE(activeSpy.size(), 1);
@@ -432,7 +431,7 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
// Windows begins to synthesize mouse events in parallel with the touch event stream: move to touchpoint position, then press
{
QMouseEvent move(QEvent::MouseMove, point, point, window.mapToGlobal(point),
- Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchscreen.get());
move.setTimestamp(235); // slightly after the last touch event
QGuiApplication::sendEvent(&window, &move);
}
@@ -442,7 +441,7 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
{
QMouseEvent press(QEvent::MouseButtonPress, point, point, window.mapToGlobal(point),
- Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchscreen.get());
press.setTimestamp(235);
QGuiApplication::sendEvent(&window, &press);
}
@@ -453,7 +452,7 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
// another touch move
point += QPoint(10, 10);
- QTest::touchEvent(&window, touchDevice).move(0, point, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, point, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(handler->active(), true);
QCOMPARE(activeSpy.size(), 1);
@@ -467,7 +466,7 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
// another fake mouse move
{
QMouseEvent move(QEvent::MouseMove, point, point, window.mapToGlobal(point),
- Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchscreen.get());
move.setTimestamp(240);
QGuiApplication::sendEvent(&window, &move);
}
@@ -481,7 +480,7 @@ void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
// end with released state
- QTest::touchEvent(&window, touchDevice).release(0, point, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, point, &window);
QMouseEvent release(QEvent::MouseButtonRelease, point, point, window.mapToGlobal(point),
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
release.setTimestamp(280);
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index 799ed60641..5e732cbe14 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -65,7 +65,8 @@ private slots:
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName,
QWindow *parent = nullptr);
- QPointingDevice *touchDevice = QTest::createTouchDevice(); // TODO const after fixing QTBUG-107864
+ // TODO const after fixing QTBUG-107864
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
void mouseEvent(QEvent::Type type, Qt::MouseButton button, const QPoint &point,
QWindow *targetWindow, QWindow *mapToWindow);
};
@@ -126,14 +127,14 @@ void tst_TapHandler::touchGesturePolicyDragThreshold()
// DragThreshold button stays pressed while touchpoint stays within dragThreshold, emits tapped on release
QPoint p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonDragThreshold->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
QCOMPARE(dragThresholdTappedSpy.size(), 1);
@@ -143,18 +144,18 @@ void tst_TapHandler::touchGesturePolicyDragThreshold()
// DragThreshold button is no longer pressed if touchpoint goes beyond dragThreshold
dragThresholdTappedSpy.clear();
p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonDragThreshold->property("pressed").toBool());
p1 += QPoint(1, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!buttonDragThreshold->property("pressed").toBool());
QCOMPARE(dragThresholdTappedSpy.size(), 0);
@@ -225,22 +226,22 @@ void tst_TapHandler::touchMouseGesturePolicyDragThreshold()
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p2);
// Press and release touch, verify that it still works (QTBUG-71466)
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
QCOMPARE(tappedSpy.size(), 1);
// Press touch, drag it outside the button, release
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).move(1, p2, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p2, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(buttonDragThreshold->property("pressed").toBool(), false);
- QTest::touchEvent(window, touchDevice).release(1, p2, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p2, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(canceledSpy.size(), 2);
QCOMPARE(tappedSpy.size(), 1); // didn't increase
@@ -267,14 +268,14 @@ void tst_TapHandler::touchGesturePolicyWithinBounds()
// WithinBounds button stays pressed while touchpoint stays within bounds, emits tapped on release
QPoint p1 = buttonWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonWithinBounds->property("pressed").toBool());
p1 += QPoint(50, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonWithinBounds->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonWithinBounds->property("pressed").toBool());
QCOMPARE(withinBoundsTappedSpy.size(), 1);
@@ -282,14 +283,14 @@ void tst_TapHandler::touchGesturePolicyWithinBounds()
// WithinBounds button is no longer pressed if touchpoint leaves bounds
withinBoundsTappedSpy.clear();
p1 = buttonWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonWithinBounds->property("pressed").toBool());
p1 += QPoint(0, 100);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonWithinBounds->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!buttonWithinBounds->property("pressed").toBool());
QCOMPARE(withinBoundsTappedSpy.size(), 0);
@@ -342,22 +343,22 @@ void tst_TapHandler::touchGesturePolicyReleaseWithinBounds()
// ReleaseWithinBounds button stays pressed while touchpoint wanders anywhere,
// then if it comes back within bounds, emits tapped on release
QPoint p1 = buttonReleaseWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
p1 += QPoint(50, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
p1 += QPoint(250, 100);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
p1 = buttonReleaseWithinBounds->mapToScene(QPointF(25, 15)).toPoint();
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonReleaseWithinBounds->property("pressed").toBool());
QCOMPARE(releaseWithinBoundsTappedSpy.size(), 1);
@@ -365,14 +366,14 @@ void tst_TapHandler::touchGesturePolicyReleaseWithinBounds()
// ReleaseWithinBounds button does not emit tapped if released out of bounds
releaseWithinBoundsTappedSpy.clear();
p1 = buttonReleaseWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
p1 += QPoint(0, 100);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonReleaseWithinBounds->property("pressed").toBool());
QCOMPARE(releaseWithinBoundsTappedSpy.size(), 0);
@@ -426,7 +427,7 @@ void tst_TapHandler::gesturePolicyDragWithinBounds_data()
QTest::addColumn<QPoint>("dragDistance");
QTest::addColumn<QString>("expectedFeedback");
- const QPointingDevice *constTouchDevice = touchDevice;
+ const QPointingDevice *constTouchDevice = touchscreen.get();
QTest::newRow("mouse: click") << QPointingDevice::primaryPointingDevice() << QPoint(200, 200) << QPoint(0, 0) << "middle";
QTest::newRow("touch: tap") << constTouchDevice << QPoint(200, 200) << QPoint(0, 0) << "middle";
@@ -477,39 +478,39 @@ void tst_TapHandler::touchMultiTap()
// Tap once
QPoint p1 = button->mapToScene(QPointF(2, 2)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(button->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
QCOMPARE(tappedSpy.size(), 1);
// Tap again in exactly the same place (not likely with touch in the real world)
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(button->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
QCOMPARE(tappedSpy.size(), 2);
// Tap a third time, nearby
p1 += QPoint(dragThreshold, dragThreshold);
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(button->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
QCOMPARE(tappedSpy.size(), 3);
// Tap a fourth time, drifting farther away
p1 += QPoint(dragThreshold, dragThreshold);
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(button->property("pressed").toBool());
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
QCOMPARE(tappedSpy.size(), 4);
@@ -518,15 +519,15 @@ void tst_TapHandler::touchMultiTap()
tappedSpy.clear();
constexpr int count = 2;
for (int i = 0; i < count; ++i) {
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
p1 -= QPoint(dragThreshold, dragThreshold);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(1, p1, window);
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(1, p1, window);
QQuickTouchUtils::flush(window);
p1 += QPoint(dragThreshold, dragThreshold);
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(1, p1, window);
QQuickTouchUtils::flush(window);
}
QCOMPARE(tappedSpy.count(), count);
@@ -743,9 +744,9 @@ void tst_TapHandler::singleTapDoubleTap()
break;
case QPointingDevice::DeviceType::TouchScreen:
QTest::qWait(delay);
- QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, window);
QTRY_VERIFY(tapHandler->isPressed());
- QTest::touchEvent(window, touchDevice).release(0, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, window);
break;
default:
break;
@@ -791,7 +792,7 @@ void tst_TapHandler::longPress_data()
QTest::addColumn<bool>("expectLongPress");
QTest::addColumn<bool>("expectTapped");
- const QPointingDevice *constTouchDevice = touchDevice;
+ const QPointingDevice *constTouchDevice = touchscreen.get();
// Reduce the threshold so that we can get a long press quickly (faster in CI)
const qreal longPressThreshold = 0.3;
@@ -992,7 +993,7 @@ void tst_TapHandler::buttonsMultiTouch()
QQuickItem *buttonReleaseWithinBounds = window->rootObject()->findChild<QQuickItem*>("ReleaseWithinBounds");
QVERIFY(buttonReleaseWithinBounds);
QSignalSpy releaseWithinBoundsTappedSpy(buttonReleaseWithinBounds, SIGNAL(tapped()));
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchscreen.get(), false);
// can press multiple buttons at the same time
QPoint p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
@@ -1199,8 +1200,8 @@ void tst_TapHandler::nonTopLevelParentWindow() // QTBUG-91716
QCOMPARE(root->property("tapCount").toInt(), 1);
- QTest::touchEvent(window, touchDevice).press(0, p1, parentWindow).commit();
- QTest::touchEvent(window, touchDevice).release(0, p1, parentWindow).commit();
+ QTest::touchEvent(window, touchscreen.get()).press(0, p1, parentWindow).commit();
+ QTest::touchEvent(window, touchscreen.get()).release(0, p1, parentWindow).commit();
QCOMPARE(root->property("tapCount").toInt(), 2);
}
@@ -1273,7 +1274,7 @@ void tst_TapHandler::nestedAndSiblingPropagation_data()
QTest::addColumn<QQuickTapHandler::GesturePolicy>("gesturePolicy");
QTest::addColumn<bool>("expectPropagation");
- const QPointingDevice *constTouchDevice = touchDevice;
+ const QPointingDevice *constTouchDevice = touchscreen.get();
QTest::newRow("primary, DragThreshold") << QPointingDevice::primaryPointingDevice()
<< QQuickTapHandler::GesturePolicy::DragThreshold << true;
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 099928149a..2aefa2d2e1 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -240,14 +240,14 @@ private slots:
void nestedWheelEventPropagation();
private:
- QPointingDevice *touchDevice = QTest::createTouchDevice();
- const QPointingDevice *mouseDevice = new QPointingDevice(
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
+ std::unique_ptr<QPointingDevice> mouseDevice{new QPointingDevice(
"test mouse", 1000, QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
QInputDevice::Capability::Position | QInputDevice::Capability::Hover | QInputDevice::Capability::Scroll,
- 1, 5, QString(), QPointingDeviceUniqueId(), this);
- QScopedPointer<QPointingDevice> touchpad = QScopedPointer<QPointingDevice>(
+ 1, 5, QString(), QPointingDeviceUniqueId(), this)};
+ std::unique_ptr<QPointingDevice> touchpad{
QTest::createTouchDevice(QInputDevice::DeviceType::TouchPad,
- QInputDevice::Capability::Position | QInputDevice::Capability::PixelScroll));
+ QInputDevice::Capability::Position | QInputDevice::Capability::PixelScroll)};
};
void tst_qquickflickable::initTestCase()
@@ -257,8 +257,7 @@ void tst_qquickflickable::initTestCase()
#endif
QQmlDataTest::initTestCase();
qmlRegisterType<TouchDragArea>("Test",1,0,"TouchDragArea");
- touchDevice->setParent(this); // avoid leak
- QWindowSystemInterface::registerInputDevice(mouseDevice);
+ QWindowSystemInterface::registerInputDevice(mouseDevice.get());
}
void tst_qquickflickable::cleanup()
@@ -406,7 +405,7 @@ void tst_qquickflickable::boundsBehavior()
void tst_qquickflickable::rebound()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("rebound.qml")));
QVERIFY(window.rootObject() != nullptr);
@@ -542,10 +541,11 @@ void tst_qquickflickable::flickDeceleration()
void tst_qquickflickable::pressDelay_data()
{
QTest::addColumn<const QPointingDevice *>("device");
- const QPointingDevice *constTouchDevice = touchDevice;
+ const QPointingDevice *constMouse = mouseDevice.get();
+ const QPointingDevice *constTouchscreen = touchscreen.get();
- QTest::newRow("mouse") << mouseDevice;
- QTest::newRow("touch") << constTouchDevice;
+ QTest::newRow("mouse") << constMouse;
+ QTest::newRow("touch") << constTouchscreen;
}
void tst_qquickflickable::pressDelay()
@@ -637,7 +637,7 @@ void tst_qquickflickable::pressDelay()
// QTBUG-17361
void tst_qquickflickable::nestedPressDelay()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("nestedPressDelay.qml")));
@@ -712,7 +712,7 @@ void tst_qquickflickable::nestedPressDelay()
void tst_qquickflickable::filterReplayedPress()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("nestedPressDelay.qml")));
@@ -750,7 +750,7 @@ void tst_qquickflickable::filterReplayedPress()
// QTBUG-37316
void tst_qquickflickable::nestedClickThenFlick()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("nestedClickThenFlick.qml")));
@@ -1145,7 +1145,8 @@ void tst_qquickflickable::nestedSameDirectionTrackpad() // QTBUG-124478
void tst_qquickflickable::movingAndFlicking_data()
{
- const QPointingDevice *constTouchDevice = touchDevice;
+ const QPointingDevice *constMouse = mouseDevice.get();
+ const QPointingDevice *constTouchscreen = touchscreen.get();
QTest::addColumn<bool>("verticalEnabled");
QTest::addColumn<bool>("horizontalEnabled");
@@ -1156,37 +1157,37 @@ void tst_qquickflickable::movingAndFlicking_data()
QTest::addColumn<QPoint>("flickToWithSnapBack");
QTest::newRow("vertical")
- << true << false << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << mouseDevice
+ << true << false << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << constMouse
<< QPoint(50, 100)
<< QPoint(50, 300);
QTest::newRow("horizontal")
- << false << true << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << mouseDevice
+ << false << true << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << constMouse
<< QPoint(-50, 200)
<< QPoint(150, 200);
QTest::newRow("both")
- << true << true << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << mouseDevice
+ << true << true << Qt::MouseButtons(Qt::LeftButton) << Qt::LeftButton << constMouse
<< QPoint(-50, 100)
<< QPoint(150, 300);
QTest::newRow("mouse disabled")
- << true << true << Qt::MouseButtons(Qt::NoButton) << Qt::LeftButton << mouseDevice
+ << true << true << Qt::MouseButtons(Qt::NoButton) << Qt::LeftButton << constMouse
<< QPoint(-50, 100)
<< QPoint(150, 300);
QTest::newRow("wrong button")
- << true << true << Qt::MouseButtons(Qt::RightButton) << Qt::LeftButton << mouseDevice
+ << true << true << Qt::MouseButtons(Qt::RightButton) << Qt::LeftButton << constMouse
<< QPoint(-50, 100)
<< QPoint(150, 300);
QTest::newRow("right button")
- << true << true << Qt::MouseButtons(Qt::RightButton) << Qt::RightButton << mouseDevice
+ << true << true << Qt::MouseButtons(Qt::RightButton) << Qt::RightButton << constMouse
<< QPoint(-50, 100)
<< QPoint(150, 300);
QTest::newRow("touch")
- << true << true << Qt::MouseButtons(Qt::NoButton) << Qt::LeftButton << constTouchDevice
+ << true << true << Qt::MouseButtons(Qt::NoButton) << Qt::LeftButton << constTouchscreen
<< QPoint(-50, 100)
<< QPoint(150, 300);
}
@@ -1363,7 +1364,7 @@ void tst_qquickflickable::movingAndDragging()
QFETCH(bool, horizontalEnabled);
QFETCH(QPoint, moveByWithoutSnapBack);
QFETCH(QPoint, moveByWithSnapBack);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
const QPoint moveFrom(50, 200); // centre
@@ -1536,11 +1537,12 @@ void tst_qquickflickable::dragAndSwitchDirection_data()
QTest::addColumn<const QPointingDevice *>("device");
QTest::addColumn<bool>("dragH");
- const QPointingDevice *constTouchDevice = touchDevice;
- QTest::newRow("mouse, drag horizontally") << mouseDevice << true;
- QTest::newRow("device, drag horizontally") << constTouchDevice << true;
- QTest::newRow("mouse, drag vertically") << mouseDevice << false;
- QTest::newRow("device, drag vertically") << constTouchDevice << false;
+ const QPointingDevice *constMouse = mouseDevice.get();
+ const QPointingDevice *constTouchscreen = touchscreen.get();
+ QTest::newRow("mouse, drag horizontally") << constMouse << true;
+ QTest::newRow("device, drag horizontally") << constTouchscreen << true;
+ QTest::newRow("mouse, drag vertically") << constMouse << false;
+ QTest::newRow("device, drag vertically") << constTouchscreen << false;
}
void tst_qquickflickable::dragAndSwitchDirection()
@@ -1607,7 +1609,7 @@ void tst_qquickflickable::dragAndSwitchDirection()
void tst_qquickflickable::flickOnRelease()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("flickable03.qml")));
@@ -1636,7 +1638,7 @@ void tst_qquickflickable::flickOnRelease()
void tst_qquickflickable::pressWhileFlicking()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("flickable03.qml")));
@@ -1690,7 +1692,7 @@ void tst_qquickflickable::pressWhileFlicking()
void tst_qquickflickable::dragWhileFlicking()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("flickable03.qml")));
@@ -1759,7 +1761,7 @@ void tst_qquickflickable::dragWhileFlicking()
void tst_qquickflickable::disabled()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("disabled.qml")));
@@ -1785,7 +1787,7 @@ void tst_qquickflickable::disabled()
void tst_qquickflickable::flickVelocity()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("flickable03.qml")));
@@ -1891,7 +1893,7 @@ void tst_qquickflickable::cancelOnHide()
void tst_qquickflickable::cancelOnMouseGrab()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("cancel.qml")));
@@ -1927,7 +1929,7 @@ void tst_qquickflickable::cancelOnMouseGrab()
void tst_qquickflickable::clickAndDragWhenTransformed()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("transformedFlickable.qml")));
@@ -1984,7 +1986,7 @@ void tst_qquickflickable::flickTwiceUsingTouches()
QCOMPARE(flickable->contentY(), 0.0f);
- QQuickTest::pointerFlick(touchDevice, &window, 1, QPoint(100, 400), QPoint(100, 240), 100);
+ QQuickTest::pointerFlick(touchscreen.get(), &window, 1, QPoint(100, 400), QPoint(100, 240), 100);
qreal contentYAfterFirstFlick = flickable->contentY();
qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick;
@@ -1992,7 +1994,7 @@ void tst_qquickflickable::flickTwiceUsingTouches()
// Wait until view stops moving
QTRY_VERIFY(!flickable->isMoving());
- QQuickTest::pointerFlick(touchDevice, &window, 1, QPoint(100, 400), QPoint(100, 240), 100);
+ QQuickTest::pointerFlick(touchscreen.get(), &window, 1, QPoint(100, 400), QPoint(100, 240), 100);
// In the original bug, that second flick would cause Flickable to halt immediately
qreal contentYAfterSecondFlick = flickable->contentY();
@@ -2037,7 +2039,7 @@ void tst_qquickflickable::nestedStopAtBounds()
QFETCH(bool, innerFiltering);
QFETCH(int, pressDelay);
QFETCH(bool, waitForPressDelay);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("nestedStopAtBounds.qml")));
@@ -2167,10 +2169,11 @@ void tst_qquickflickable::nestedStopAtBounds()
void tst_qquickflickable::nestedDraggingFlickingMoving_data()
{
QTest::addColumn<const QPointingDevice *>("device");
+ const QPointingDevice *constMouse = mouseDevice.get();
+ const QPointingDevice *constTouchscreen = touchscreen.get();
- const QPointingDevice *constTouchDevice = touchDevice;
- QTest::newRow("mouse") << mouseDevice;
- QTest::newRow("touch") << constTouchDevice;
+ QTest::newRow("mouse") << constMouse;
+ QTest::newRow("touch") << constTouchscreen;
}
void tst_qquickflickable::nestedDraggingFlickingMoving()
@@ -2256,7 +2259,7 @@ void tst_qquickflickable::stopAtBounds()
QFETCH(bool, transpose);
QFETCH(bool, invert);
QFETCH(bool, pixelAligned);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("stopAtBounds.qml")));
@@ -2363,7 +2366,7 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
QVERIFY(flickable != nullptr);
QCOMPARE(flickable->contentY(), 50.0f);
- QQuickTest::pointerFlick(touchDevice, &window, 1, QPoint(100, 300), QPoint(100, 200), 100);
+ QQuickTest::pointerFlick(touchscreen.get(), &window, 1, QPoint(100, 300), QPoint(100, 200), 100);
// flickable should not have moved
QCOMPARE(flickable->contentY(), 50.0);
@@ -2382,7 +2385,7 @@ void tst_qquickflickable::nestedMouseAreaPropagateComposedEvents()
QVERIFY(flickable != nullptr);
QCOMPARE(flickable->contentY(), 50.0f);
- QQuickTest::pointerFlick(touchDevice, &window, 1, QPoint(100, 300), QPoint(100, 200), 100);
+ QQuickTest::pointerFlick(touchscreen.get(), &window, 1, QPoint(100, 300), QPoint(100, 200), 100);
// flickable should have moved
QVERIFY(!qFuzzyCompare(flickable->contentY(), 50.0));
@@ -2424,15 +2427,15 @@ void tst_qquickflickable::nestedSliderUsingTouch()
tda->setKeepMouseGrab(keepMouseGrab);
tda->setKeepTouchGrab(keepTouchGrab);
QPoint p0 = tda->mapToScene(QPoint(20, 20)).toPoint();
- QTest::touchEvent(&window, touchDevice).press(0, p0, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p0, &window);
QQuickTouchUtils::flush(&window);
for (int i = 0; i < 8; ++i) {
p0 += QPoint(dragThreshold / 6, dragThreshold / 4);
- QTest::touchEvent(&window, touchDevice).move(0, p0, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p0, &window);
QQuickTouchUtils::flush(&window);
}
QCOMPARE(tda->active(), keepMouseGrab || keepTouchGrab);
- QTest::touchEvent(&window, touchDevice).release(0, p0, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p0, &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(tda->touchPointStates.first(), QEventPoint::State::Pressed);
QTRY_VERIFY(tda->touchUpdates >= minUpdates);
@@ -2443,7 +2446,7 @@ void tst_qquickflickable::nestedSliderUsingTouch()
// QTBUG-31328
void tst_qquickflickable::pressDelayWithLoader()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("pressDelayWithLoader.qml")));
@@ -2521,7 +2524,7 @@ void tst_qquickflickable::ratios_smallContent()
// QTBUG-48018
void tst_qquickflickable::contentXYNotTruncatedToInt()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("contentXY.qml")));
@@ -2537,7 +2540,7 @@ void tst_qquickflickable::contentXYNotTruncatedToInt()
void tst_qquickflickable::keepGrab()
{
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("keepGrab.qml")));
@@ -2584,7 +2587,7 @@ void tst_qquickflickable::overshoot()
QFETCH(QQuickFlickable::BoundsBehavior, boundsBehavior);
QFETCH(int, boundsMovement);
QFETCH(bool, pixelAligned);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("overshoot.qml")));
@@ -2847,7 +2850,7 @@ void tst_qquickflickable::synchronousDrag_data()
void tst_qquickflickable::synchronousDrag()
{
QFETCH(bool, synchronousDrag);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("longList.qml")));
@@ -2879,20 +2882,20 @@ void tst_qquickflickable::synchronousDrag()
flickable->setContentY(0);
// Drag via touch
- QTest::touchEvent(&window, touchDevice).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, touchDevice).move(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p2, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, touchDevice).move(0, p3, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p3, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, touchDevice).move(0, p4, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p4, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(flickable->contentY(), synchronousDrag ? 50.0f : 0.0f);
- QTest::touchEvent(&window, touchDevice).move(0, p5, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p5, &window);
QQuickTouchUtils::flush(&window);
if (!synchronousDrag)
QVERIFY(flickable->contentY() < 50.0f);
- QTest::touchEvent(&window, touchDevice).release(0, p5, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p5, &window);
}
// QTBUG-81098: tests that a binding to visibleArea doesn't result
@@ -2918,13 +2921,13 @@ void tst_qquickflickable::parallelTouch() // QTBUG-30840
// Drag both in parallel via touch, opposite directions
QPoint p0(80, 240);
QPoint p1(240, 240);
- QTest::touchEvent(&window, touchDevice).press(0, p0, &window).press(1, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p0, &window).press(1, p1, &window);
int began1After = -1;
int began2After = -1;
for (int i = 0; i < 8; ++i) {
p0 += QPoint(0, threshold);
p1 -= QPoint(0, threshold);
- QTest::touchEvent(&window, touchDevice).move(0, p0, &window).move(1, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p0, &window).move(1, p1, &window);
QQuickTouchUtils::flush(&window);
if (began1After < 0 && flickable1->isDragging())
began1After = i;
@@ -2936,7 +2939,7 @@ void tst_qquickflickable::parallelTouch() // QTBUG-30840
QVERIFY(flickable2->isDraggingVertically());
QCOMPARE(began1After, 2);
QCOMPARE(began2After, 2);
- QTest::touchEvent(&window, touchDevice).release(0, p0, &window).release(1, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p0, &window).release(1, p1, &window);
QTRY_VERIFY(!flickable1->isMoving());
QTRY_VERIFY(!flickable2->isMoving());
}
@@ -2944,7 +2947,7 @@ void tst_qquickflickable::parallelTouch() // QTBUG-30840
void tst_qquickflickable::ignoreNonLeftMouseButtons() // QTBUG-96909
{
QFETCH(Qt::MouseButton, otherButton);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
const int threshold = qApp->styleHints()->startDragDistance();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("dragon.qml")));
@@ -3045,7 +3048,7 @@ void tst_qquickflickable::flickWhenRotated() // QTBUG-99639
QFETCH(qreal, rootRotation);
QFETCH(qreal, flickableRotation);
QFETCH(qreal, scale);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("rotatedFlickable.qml")));
@@ -3201,7 +3204,7 @@ void tst_qquickflickable::setContentPositionWhileDragging() // QTBUG-104966
QFETCH(bool, isHorizontal);
QFETCH(int, newPos);
QFETCH(int, newExtent);
- auto device = mouseDevice;
+ const auto device = mouseDevice.get();
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("contentPosWhileDragging.qml")));
@@ -3299,13 +3302,13 @@ void tst_qquickflickable::coalescedMove()
QSignalSpy flickStartedSpy(flickable, SIGNAL(flickStarted()));
QSignalSpy flickEndedSpy(flickable, SIGNAL(flickEnded()));
- QTest::touchEvent(&window, touchDevice).press(0, {10, 10}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).press(0, {10, 10}).commit();
- QTest::touchEvent(&window, touchDevice).move(0, {10, 40}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).move(0, {10, 40}).commit();
- QTest::touchEvent(&window, touchDevice).move(0, {10, 100}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).move(0, {10, 100}).commit();
- QTest::touchEvent(&window, touchDevice).release(0, {10, 150}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).release(0, {10, 150}).commit();
QQuickTouchUtils::flush(&window);
QTRY_VERIFY(!flickable->isMoving());
@@ -3329,13 +3332,13 @@ void tst_qquickflickable::onlyOneMove()
QSignalSpy flickStartedSpy(flickable, SIGNAL(flickStarted()));
QSignalSpy flickEndedSpy(flickable, SIGNAL(flickEnded()));
- QTest::touchEvent(&window, touchDevice).press(0, {10, 10}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).press(0, {10, 10}).commit();
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, touchDevice).move(0, {10, 100}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).move(0, {10, 100}).commit();
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, touchDevice).release(0, {10, 200}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).release(0, {10, 200}).commit();
QQuickTouchUtils::flush(&window);
QTRY_VERIFY(!flickable->isMoving());
@@ -3423,17 +3426,17 @@ void tst_qquickflickable::touchCancel()
QSignalSpy movementEndedSpy(flickable, SIGNAL(movementEnded()));
int touchPosY = 10;
- QTest::touchEvent(&window, touchDevice).press(0, {10, touchPosY}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).press(0, {10, touchPosY}).commit();
QQuickTouchUtils::flush(&window);
for (int i = 0; i < 3; ++i) {
touchPosY += qApp->styleHints()->startDragDistance();
- QTest::touchEvent(&window, touchDevice).move(0, {10, touchPosY}).commit();
+ QTest::touchEvent(&window, touchscreen.get()).move(0, {10, touchPosY}).commit();
QQuickTouchUtils::flush(&window);
}
QTRY_COMPARE(movementStartedSpy.size(), 1);
- QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchDevice);
+ QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchscreen.get());
QTRY_COMPARE(movementEndedSpy.size(), 1);
}
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index f224c2608a..d0368f499f 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -246,6 +246,8 @@ private:
w->requestActivate();
return QTest::qWaitForWindowActive(w);
}
+
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
tst_qquickitem::tst_qquickitem()
@@ -1460,21 +1462,19 @@ void tst_qquickitem::touchEventAcceptIgnore()
item->setAcceptTouchEvents(itemAcceptsTouch); // it's false by default in Qt 6
item->acceptIncomingTouchEvents = itemAcceptsTouchEvents;
- static QPointingDevice* device = QTest::createTouchDevice();
-
// Send Begin, Update & End touch sequence
item->touchEventReached = false;
- QTest::touchEvent(&window, device).press(1, QPoint(50, 50), &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, QPoint(50, 50), &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(item->touchEventReached, itemAcceptsTouch);
item->touchEventReached = false;
- QTest::touchEvent(&window, device).move(1, QPoint(60, 60), &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(1, QPoint(60, 60), &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(item->touchEventReached, itemAcceptsTouchEvents);
item->touchEventReached = false;
- QTest::touchEvent(&window, device).release(1, QPoint(60, 60), &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, QPoint(60, 60), &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(item->touchEventReached, itemAcceptsTouchEvents);
}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 2602f7ec04..e6df9ece8f 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -52,7 +52,6 @@ class tst_QQuickListView : public QQmlDataTest
Q_OBJECT
public:
tst_QQuickListView();
- ~tst_QQuickListView() { delete touchDevice; }
private slots:
// WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with.
@@ -344,12 +343,12 @@ private:
QQuickView *m_view;
QString testForView;
- QPointingDevice *touchDevice = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
#if QT_CONFIG(tabletevent)
- QScopedPointer<const QPointingDevice> tabletStylusDevice = QScopedPointer<const QPointingDevice>(
+ std::unique_ptr<const QPointingDevice> tabletStylusDevice{
QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType::Stylus,
QPointingDevice::PointerType::Pen,
- QPointingDeviceUniqueId::fromNumericId(1234567890)));
+ QPointingDeviceUniqueId::fromNumericId(1234567890))};
#endif
};
@@ -9777,13 +9776,13 @@ void tst_QQuickListView::touchCancel() // QTBUG-74679
QVERIFY(mouseArea);
QPoint p1(300, 300);
- QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).press(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
QTRY_VERIFY(mouseArea->isPressed());
// and because Flickable filtered it, QQuickFlickablePrivate::pressed
// should be true, but it's not easily tested here
- QTouchEvent cancelEvent(QEvent::TouchCancel, touchDevice);
+ QTouchEvent cancelEvent(QEvent::TouchCancel, touchscreen.get());
QCoreApplication::sendEvent(window.data(), &cancelEvent);
// now QQuickWindowPrivate::sendUngrabEvent() will be called, Flickable will filter it,
// QQuickFlickablePrivate::pressed will be set to false, and that will allow setCurrentIndex() to make it move
@@ -9799,7 +9798,7 @@ void tst_QQuickListView::cancelDelegatePastDragThreshold_data()
QTest::addColumn<const QPointingDevice *>("device");
QTest::newRow("primary") << QPointingDevice::primaryPointingDevice();
- QTest::newRow("touch") << static_cast<const QPointingDevice*>(touchDevice); // TODO QTBUG-107864
+ QTest::newRow("touch") << static_cast<const QPointingDevice*>(touchscreen.get()); // TODO QTBUG-107864
#if QT_CONFIG(tabletevent) && !defined(Q_OS_QNX)
QTest::newRow("stylus") << tabletStylusDevice.get();
#endif
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 28fb44ad05..4dbafeb067 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -56,7 +56,7 @@ private slots:
void disabledIgnoresHover();
private:
- QPointingDevice *device = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_QQuickMultiPointTouchArea::properties()
@@ -94,7 +94,7 @@ void tst_QQuickMultiPointTouchArea::signalTest()
QPoint p4(80,100);
QPoint p5(100,100);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).press(1, p2).commit();
QQuickTouchUtils::flush(&window);
@@ -158,7 +158,7 @@ void tst_QQuickMultiPointTouchArea::release()
QPoint p1(20,100);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).commit();
QQuickTouchUtils::flush(&window);
@@ -200,7 +200,7 @@ void tst_QQuickMultiPointTouchArea::reuse()
QPoint p3(60,100);
QPoint p4(80,100);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).press(1, p2).commit();
QQuickTouchUtils::flush(&window);
@@ -273,7 +273,7 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping()
QPoint p4(80,180);
QPoint p5(100,180);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).commit();
QQuickTouchUtils::flush(&window);
@@ -385,7 +385,7 @@ void tst_QQuickMultiPointTouchArea::nested()
QPoint p2(40,100);
QPoint p3(60,180);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).commit();
QQuickTouchUtils::flush(&window);
@@ -569,7 +569,7 @@ void tst_QQuickMultiPointTouchArea::nestedTouchPosCheck()
auto *bottomMPTA = window.rootObject()->findChild<QQuickMultiPointTouchArea *>("bottomMPTA");
QVERIFY(bottomMPTA != nullptr);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, QPoint(10, 110)).commit();
QQuickTouchUtils::flush(&window);
@@ -605,7 +605,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QPoint p2(40,100);
// moving one point vertically: flickable gets the grab
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
QPoint delta(0, 15);
@@ -613,7 +613,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
if (lcTests().isDebugEnabled())
QTest::qWait(250);
p1 += delta;
- QTest::touchEvent(&window, device).move(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests, "after drag %d to %d,%d contentY is %lf",
i, p1.x(), p1.y(), flickable->contentY());
@@ -623,7 +623,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QCOMPARE(point11->pressed(), false);
QCOMPARE(point12->pressed(), false);
- QTest::touchEvent(&window, device).release(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1);
QQuickTouchUtils::flush(&window);
QTRY_VERIFY(!flickable->isMoving());
@@ -631,8 +631,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
// moving two points vertically: MPTAs handle them, Flickable ignores multi-touch.
// The stray mouse events simulate OS-level synth-from-touch, and should not interfere.
p1 = QPoint(20,100);
- QTest::touchEvent(&window, device).press(0, p1).press(1, p2);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1).press(1, p2);
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -647,8 +647,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
if (lcTests().isDebugEnabled())
QTest::qWait(250);
p1 += delta; p2 += delta;
- QTest::touchEvent(&window, device).move(0, p1).move(1, p2);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1).move(1, p2);
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::LeftButton, Qt::NoButton, QEvent::MouseMove,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -663,8 +663,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QCOMPARE(window.rootObject()->property("cancelCount").toInt(), 0);
QCOMPARE(window.rootObject()->property("touchCount").toInt(), 2);
- QTest::touchEvent(&window, device).release(0, p1).release(1, p2);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1).release(1, p2);
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::NoButton, Qt::LeftButton, QEvent::MouseButtonRelease,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -675,14 +675,14 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
// moving two points horizontally, then two points vertically
p1 = QPoint(20,100);
p2 = QPoint(40,100);
- QTest::touchEvent(&window, device).press(0, p1).press(1, p2);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1).press(1, p2);
QQuickTouchUtils::flush(&window);
QCOMPARE(point11->pressed(), true);
QCOMPARE(point12->pressed(), true);
// ensure that mouse events do not fall through to the Flickable
mpta->setMaximumTouchPoints(3);
mpta->setAcceptedMouseButtons(Qt::LeftButton);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -697,8 +697,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
if (i == 4)
delta = QPoint(0, 15);
p1 += delta; p2 += delta;
- QTest::touchEvent(&window, device).move(0, p1).move(1, p2);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1).move(1, p2);
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::LeftButton, Qt::NoButton, QEvent::MouseMove,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -711,8 +711,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QCOMPARE(point11->pressed(), true);
QCOMPARE(point12->pressed(), true);
- QTest::touchEvent(&window, device).release(0, p1).release(1, p2);
- QWindowSystemInterface::handleMouseEvent(&window, device, p1, window.mapToGlobal(p1),
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1).release(1, p2);
+ QWindowSystemInterface::handleMouseEvent(&window, touchscreen.get(), p1, window.mapToGlobal(p1),
Qt::NoButton, Qt::LeftButton, QEvent::MouseButtonRelease,
Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
qApp->processEvents();
@@ -740,13 +740,13 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
QPoint p1(50,100);
// move point horizontally, out of Flickable area
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1);
for (int i = 0; i < 4; ++i) {
p1 += QPoint(dragThreshold, 0);
- QTest::touchEvent(&window, device).move(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1);
QQuickTouchUtils::flush(&window);
QTest::mouseMove(&window, p1);
}
@@ -754,7 +754,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
QVERIFY(!flickable->isMoving());
QVERIFY(point11->pressed());
- QTest::touchEvent(&window, device).release(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1);
QQuickTouchUtils::flush(&window);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTest::qWait(50);
@@ -764,14 +764,14 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
// Check that we can still move the Flickable
QSignalSpy gestureStartedSpy(mpta, &QQuickMultiPointTouchArea::gestureStarted);
p1 = QPoint(50,100);
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
QCOMPARE(point11->pressed(), true);
for (int i = 0; i < 4; ++i) {
p1 += QPoint(0, dragThreshold);
- QTest::touchEvent(&window, device).move(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1);
QQuickTouchUtils::flush(&window);
// QTBUG-113653: gestureStarted is emitted when touch delta exceeds drag threshold,
// regardless of the filtering Flickable parent
@@ -782,7 +782,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
QVERIFY(flickable->isMoving());
QCOMPARE(point11->pressed(), false);
- QTest::touchEvent(&window, device).release(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1);
QQuickTouchUtils::flush(&window);
QTest::qWait(50);
@@ -808,19 +808,19 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
// press: Flickable prevents delivery of TouchBegin, but sends mouse press instead, after the delay.
// MPTA handles the mouse press, and its first declared touchpoint is pressed.
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(point11->pressed(), true);
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
// release: MPTA receives TouchEnd (which is asymmetric with mouse press); does NOT emit canceled.
- QTest::touchEvent(&window, device).release(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1);
QQuickTouchUtils::flush(&window);
QCOMPARE(flickable->property("cancelCount").toInt(), 0);
// press again
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(point11->pressed(), true); // wait until pressDelay exceeded
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
@@ -834,7 +834,7 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
int contentYChangedAfter = -1;
for (; i < 10 && contentYChangedAfter < 0; ++i) {
p1 += QPoint(0,dragThreshold);
- QTest::touchEvent(&window, device).move(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1);
QQuickTouchUtils::flush(&window);
if (devPriv->firstPointExclusiveGrabber() == flickable)
grabbedAfter = i;
@@ -853,7 +853,7 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
QVERIFY(flickable->contentY() < 0);
QVERIFY(flickable->isMoving());
- QTest::touchEvent(&window, device).release(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1);
QQuickTouchUtils::flush(&window);
QTRY_VERIFY(!flickable->isMoving());
@@ -874,9 +874,9 @@ void tst_QQuickMultiPointTouchArea::inMouseArea()
QPoint innerPoint(40,100);
QPoint outerPoint(10,100);
- QTest::touchEvent(&window, device).press(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, innerPoint);
QVERIFY(mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, innerPoint);
QVERIFY(!mpta->property("pressed").toBool());
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, outerPoint);
@@ -891,15 +891,15 @@ void tst_QQuickMultiPointTouchArea::inMouseArea()
QVERIFY(!mpta->property("pressed").toBool());
QVERIFY(!mouseArea->property("pressed").toBool());
- QTest::touchEvent(&window, device).press(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, innerPoint);
QVERIFY(mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, innerPoint);
QVERIFY(!mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).press(0, outerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, outerPoint);
QVERIFY(mouseArea->property("pressed").toBool());
QVERIFY(!mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, outerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, outerPoint);
QVERIFY(!mouseArea->property("pressed").toBool());
QVERIFY(!mpta->property("pressed").toBool());
@@ -911,10 +911,10 @@ void tst_QQuickMultiPointTouchArea::inMouseArea()
mpta->setProperty("mouseEnabled", false);
- QTest::touchEvent(&window, device).press(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, innerPoint);
QVERIFY(mpta->property("pressed").toBool());
QVERIFY(!mouseArea->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, innerPoint);
QVERIFY(!mpta->property("pressed").toBool());
QVERIFY(!mouseArea->property("pressed").toBool());
@@ -930,15 +930,15 @@ void tst_QQuickMultiPointTouchArea::inMouseArea()
QVERIFY(!mpta->property("pressed").toBool());
QVERIFY(!mouseArea->property("pressed").toBool());
- QTest::touchEvent(&window, device).press(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, innerPoint);
QVERIFY(mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, innerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, innerPoint);
QVERIFY(!mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).press(0, outerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, outerPoint);
QVERIFY(mouseArea->property("pressed").toBool());
QVERIFY(!mpta->property("pressed").toBool());
- QTest::touchEvent(&window, device).release(0, outerPoint);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, outerPoint);
QVERIFY(!mouseArea->property("pressed").toBool());
QVERIFY(!mpta->property("pressed").toBool());
}
@@ -963,15 +963,15 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QPoint touch3(10,10);
// Touch both, release one, manipulate other touchpoint with mouse
- QTest::touchEvent(&window, device).press(1, touch1);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, touch1);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).move(1, touch1).press(2, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).move(1, touch1).press(2, touch2);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
QCOMPARE(touch2rect->property("x").toInt(), touch2.x());
QCOMPARE(touch2rect->property("y").toInt(), touch2.y());
- QTest::touchEvent(&window, device).release(1, touch1).move(2, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, touch1).move(2, touch2);
touch1.setY(20);
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, touch1);
QQuickTouchUtils::flush(&window);
@@ -979,7 +979,7 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
QCOMPARE(touch2rect->property("x").toInt(), touch2.x());
QCOMPARE(touch2rect->property("y").toInt(), touch2.y());
- QTest::touchEvent(&window, device).release(2, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).release(2, touch2);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, touch1);
QQuickTouchUtils::flush(&window);
@@ -990,14 +990,14 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
touch2.setX(60);
- QTest::touchEvent(&window, device).press(3, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).press(3, touch2);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
QCOMPARE(touch2rect->property("x").toInt(), touch2.x());
QCOMPARE(touch2rect->property("y").toInt(), touch2.y());
touch2.setY(150);
- QTest::touchEvent(&window, device).move(3, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).move(3, touch2);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
@@ -1005,7 +1005,7 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QCOMPARE(touch2rect->property("y").toInt(), touch2.y());
// Touch third point - nothing happens
- QTest::touchEvent(&window, device).press(4, touch3);
+ QTest::touchEvent(&window, touchscreen.get()).press(4, touch3);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
@@ -1014,9 +1014,9 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
// Release all
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, touch1);
- QTest::touchEvent(&window, device).release(3, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).release(3, touch2);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(4, touch3);
+ QTest::touchEvent(&window, touchscreen.get()).release(4, touch3);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
@@ -1035,14 +1035,14 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, mouse1);
QCOMPARE(touch1rect->property("x").toInt(), mouse1.x());
QCOMPARE(touch1rect->property("y").toInt(), mouse1.y());
- QTest::touchEvent(&window, device).press(1, touch1);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, touch1);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), mouse1.x());
QCOMPARE(touch1rect->property("y").toInt(), mouse1.y());
QCOMPARE(touch2rect->property("x").toInt(), touch1.x());
QCOMPARE(touch2rect->property("y").toInt(), touch1.y());
- QTest::touchEvent(&window, device).press(2, touch2).press(3, touch3).press(4, touch4);
+ QTest::touchEvent(&window, touchscreen.get()).press(2, touch2).press(3, touch3).press(4, touch4);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), mouse1.x());
QCOMPARE(touch1rect->property("y").toInt(), mouse1.y());
@@ -1057,7 +1057,7 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
// Release all
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, mouse1);
- QTest::touchEvent(&window, device).release(1, touch1).release(2, touch2).release(3, touch3).release(4, touch4);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, touch1).release(2, touch2).release(3, touch3).release(4, touch4);
QQuickTouchUtils::flush(&window);
}
@@ -1083,16 +1083,16 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
QCOMPARE(touch1rect->property("x").toInt(), 10);
QCOMPARE(touch1rect->property("y").toInt(), 10);
- QTest::touchEvent(&window, device).press(1, touch1);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, touch1);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
touch1.setY(150);
- QTest::touchEvent(&window, device).move(1, touch1);
+ QTest::touchEvent(&window, touchscreen.get()).move(1, touch1);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
- QTest::touchEvent(&window, device).press(2, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).press(2, touch2);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
@@ -1101,9 +1101,9 @@ void tst_QQuickMultiPointTouchArea::mouseAsTouchpoint()
// Release all
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, mouse1);
- QTest::touchEvent(&window, device).release(1, touch1);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, touch1);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(2, touch2);
+ QTest::touchEvent(&window, touchscreen.get()).release(2, touch2);
QQuickTouchUtils::flush(&window);
QCOMPARE(touch1rect->property("x").toInt(), touch1.x());
QCOMPARE(touch1rect->property("y").toInt(), touch1.y());
@@ -1126,7 +1126,7 @@ void tst_QQuickMultiPointTouchArea::invisible()
QPoint p1(20,100);
QPoint p2(40,100);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).press(1, p2).commit();
@@ -1181,7 +1181,7 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea()
QQuickMultiPointTouchArea *area = window.rootObject()->findChild<QQuickMultiPointTouchArea *>("touchArea");
QVERIFY(area != nullptr);
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
sequence.press(0, p1).commit();
QCOMPARE(area->property("pointCount").toInt(), total1);
@@ -1291,7 +1291,7 @@ void tst_QQuickMultiPointTouchArea::cancel()
QVERIFY(QQuickTest::showView(window, testFileUrl("cancel.qml")));
QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(window.rootObject());
- QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(&window, touchscreen.get());
QQuickTouchPoint *point1 = area->findChild<QQuickTouchPoint*>("point1");
QPoint p1(20,100);
@@ -1353,7 +1353,7 @@ void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTB
QMutableEventPoint::setGlobalPosition(tp1, window.mapToGlobal(p1));
QMutableEventPoint::setState(tp1, QEventPoint::State::Pressed);
QMutableEventPoint::setPressure(tp1, 0.5);
- qt_handleTouchEvent(&window, device, {tp1});
+ qt_handleTouchEvent(&window, touchscreen.get(), {tp1});
QQuickTouchUtils::flush(&window);
QCOMPARE(point1->pressed(), true);
@@ -1361,14 +1361,14 @@ void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTB
QMutableEventPoint::setState(tp1, QEventPoint::State::Stationary);
QMutableEventPoint::setPressure(tp1, 0.6);
- qt_handleTouchEvent(&window, device, {tp1});
+ qt_handleTouchEvent(&window, touchscreen.get(), {tp1});
QQuickTouchUtils::flush(&window);
QCOMPARE(point1->pressure(), 0.6);
QMutableEventPoint::setState(tp1, QEventPoint::State::Released);
QMutableEventPoint::setPressure(tp1, 0);
- qt_handleTouchEvent(&window, device, {tp1});
+ qt_handleTouchEvent(&window, touchscreen.get(), {tp1});
QQuickTouchUtils::flush(&window);
QCOMPARE(point1->pressed(), false);
@@ -1386,7 +1386,7 @@ void tst_QQuickMultiPointTouchArea::touchFiltering() // QTBUG-74028
QSignalSpy mptaSpy(mpta, &QQuickMultiPointTouchArea::pressed);
const QPoint pt = window.rootObject()->boundingRect().center().toPoint();
- QTest::touchEvent(&window, device).press(1, pt);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, pt);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(mpta->parentItem()->property("mptaPoint").toPoint(), pt);
QCOMPARE(mpta->parentItem()->property("maPoint").toPoint(), ma->boundingRect().center().toPoint());
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index cd1c3daf68..2d85ed6fec 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -268,7 +268,7 @@ private:
QQmlEngine engine;
- QPointingDevice *touchDevice = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
};
void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
@@ -3444,9 +3444,9 @@ void tst_qquicktextedit::inFlickableTouch()
// flick with touch
QPoint p(10, 100);
- QTest::touchEvent(&view, touchDevice).press(1, p, &view);
+ QTest::touchEvent(&view, touchscreen.get()).press(1, p, &view);
QQuickTouchUtils::flush(&view);
- QObject *pressGrabber = QPointingDevicePrivate::get(touchDevice)->firstPointExclusiveGrabber();
+ QObject *pressGrabber = QPointingDevicePrivate::get(touchscreen.get())->firstPointExclusiveGrabber();
// even if TextEdit is readonly, it still grabs on press. But not if it's disabled.
if (enabled)
QCOMPARE(pressGrabber, edit);
@@ -3456,7 +3456,7 @@ void tst_qquicktextedit::inFlickableTouch()
// after a couple of events, Flickable steals the grab and starts moving
for (; i < 4 && !flick->isMoving(); ++i) {
p -= QPoint(0, dragThreshold);
- QTest::touchEvent(&view, touchDevice).move(1, p, &view);
+ QTest::touchEvent(&view, touchscreen.get()).move(1, p, &view);
QQuickTouchUtils::flush(&view);
}
QCOMPARE(flick->isMoving(), bool(expectFlickingAfter));
@@ -3464,7 +3464,7 @@ void tst_qquicktextedit::inFlickableTouch()
qCDebug(lcTests) << "flickable started moving after" << i << "moves, when we got to" << p;
QCOMPARE(i, expectFlickingAfter);
}
- QTest::touchEvent(&view, touchDevice).release(1, p, &view);
+ QTest::touchEvent(&view, touchscreen.get()).release(1, p, &view);
}
void tst_qquicktextedit::simulateKey(QWindow *view, int key, Qt::KeyboardModifiers modifiers)
@@ -6749,9 +6749,9 @@ void tst_qquicktextedit::touchscreenDoesNotSelect()
int x1 = 10;
int x2 = 70;
int y = QFontMetrics(textEditObject->font()).height() / 2;
- QTest::touchEvent(&window, touchDevice).press(0, QPoint(x1,y), &window);
- QTest::touchEvent(&window, touchDevice).move(0, QPoint(x2,y), &window);
- QTest::touchEvent(&window, touchDevice).release(0, QPoint(x2,y), &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, QPoint(x1,y), &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, QPoint(x2,y), &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, QPoint(x2,y), &window);
QQuickTouchUtils::flush(&window);
// if the import version is old enough, fall back to old behavior: touch swipe _does_ select text
QCOMPARE(textEditObject->selectedText().isEmpty(), mouseOnly);
@@ -6774,7 +6774,7 @@ void tst_qquicktextedit::touchscreenSetsFocusAndMovesCursor()
// tap the bottom field
QPoint p1 = bottom->mapToScene({6, 6}).toPoint();
- QTest::touchEvent(&window, touchDevice).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(qApp->focusObject(), bottom);
// text cursor is at 0 by default, on press
@@ -6784,7 +6784,7 @@ void tst_qquicktextedit::touchscreenSetsFocusAndMovesCursor()
QTest::keyClick(&window, Qt::Key_Q);
QVERIFY(bottom->text().startsWith('q'));
QCOMPARE(bottom->text().size(), len + 1);
- QTest::touchEvent(&window, touchDevice).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
// the cursor gets moved on release, as long as TextInput's grab wasn't stolen (e.g. by Flickable)
QVERIFY(bottom->cursorPosition() < 5);
@@ -6792,9 +6792,9 @@ void tst_qquicktextedit::touchscreenSetsFocusAndMovesCursor()
// press-drag-and-release from p1 to p2 on the top field
p1 = top->mapToScene({6, 6}).toPoint();
QPoint p2 = top->mapToScene({76, 6}).toPoint();
- QTest::touchEvent(&window, touchDevice).press(0, p1, &window);
- QTest::touchEvent(&window, touchDevice).move(0, p2, &window);
- QTest::touchEvent(&window, touchDevice).release(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p2, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(qApp->focusObject(), top);
QVERIFY(top->selectedText().isEmpty());
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 84b1d58670..1f63f7cc34 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -417,12 +417,6 @@ class tst_qquickwindow : public QQmlDataTest
public:
tst_qquickwindow()
: QQmlDataTest(QT_QMLTEST_DATADIR)
- , touchDevice(QTest::createTouchDevice())
- , touchDeviceWithVelocity(QTest::createTouchDevice(QInputDevice::DeviceType::TouchScreen,
- QInputDevice::Capability::Position | QPointingDevice::Capability::Velocity))
- , tabletStylusDevice(QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType::Stylus,
- QPointingDevice::PointerType::Pen,
- QPointingDeviceUniqueId::fromNumericId(1234567890)))
{
QQuickWindow::setDefaultAlphaBuffer(true);
}
@@ -560,9 +554,17 @@ private slots:
void dataIsNotAList();
private:
- QPointingDevice *touchDevice; // TODO make const after fixing QTBUG-107864
- const QPointingDevice *touchDeviceWithVelocity;
- const QPointingDevice *tabletStylusDevice;
+ // TODO make const after fixing QTBUG-107864
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
+ std::unique_ptr<QPointingDevice> touchscreenWithVelocity{
+ QTest::createTouchDevice(QInputDevice::DeviceType::TouchScreen,
+ QInputDevice::Capability::Position | QPointingDevice::Capability::Velocity)};
+#if QT_CONFIG(tabletevent)
+ std::unique_ptr<const QPointingDevice> tabletStylusDevice{
+ QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType::Stylus,
+ QPointingDevice::PointerType::Pen,
+ QPointingDeviceUniqueId::fromNumericId(1234567890))};
+#endif
};
#if QT_CONFIG(opengl)
@@ -713,7 +715,7 @@ void tst_qquickwindow::touchEvent_basic()
topItem->setSize(QSizeF(150, 150));
QPointF pos(10, 10);
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchscreen.get(), false);
// press single point
touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window).commit();
@@ -863,16 +865,16 @@ void tst_qquickwindow::touchEvent_propagation()
topItem->setVisible(showItem);
// single touch to top item, should be received by middle item
- QTest::touchEvent(window, touchDevice).press(0, pointInTopItem, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, pointInTopItem, window);
QTRY_COMPARE(middleItem->lastEvent.touchPoints.size(), 1);
QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed,
makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
- QTest::touchEvent(window, touchDevice).release(0, pointInTopItem, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, pointInTopItem, window);
// touch top and middle items, middle item should get both events
- QTest::touchEvent(window, touchDevice).press(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).press(0, pointInTopItem, window)
.press(1, pointInMiddleItem, window);
QTRY_COMPARE(middleItem->lastEvent.touchPoints.size(), 2);
QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
@@ -880,7 +882,7 @@ void tst_qquickwindow::touchEvent_propagation()
COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed,
(QList<QEventPoint>() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))
<< makeTouchPoint(middleItem, pos) )));
- QTest::touchEvent(window, touchDevice).release(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).release(0, pointInTopItem, window)
.release(1, pointInMiddleItem, window);
middleItem->reset();
@@ -891,7 +893,7 @@ void tst_qquickwindow::touchEvent_propagation()
middleItem->setVisible(showItem);
// touch top and middle items, bottom item should get all events
- QTest::touchEvent(window, touchDevice).press(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).press(0, pointInTopItem, window)
.press(1, pointInMiddleItem, window);
QTRY_COMPARE(bottomItem->lastEvent.touchPoints.size(), 2);
QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
@@ -905,18 +907,18 @@ void tst_qquickwindow::touchEvent_propagation()
bottomItem->acceptTouchEvents = acceptTouchEvents;
bottomItem->setEnabled(enableItem);
bottomItem->setVisible(showItem);
- QTest::touchEvent(window, touchDevice).release(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).release(0, pointInTopItem, window)
.release(1, pointInMiddleItem, window);
// no events should be received
- QTest::touchEvent(window, touchDevice).press(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).press(0, pointInTopItem, window)
.press(1, pointInMiddleItem, window)
.press(2, pointInBottomItem, window);
QTest::qWait(50);
QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- QTest::touchEvent(window, touchDevice).release(0, pointInTopItem, window)
+ QTest::touchEvent(window, touchscreen.get()).release(0, pointInTopItem, window)
.release(1, pointInMiddleItem, window)
.release(2, pointInBottomItem, window);
topItem->reset();
@@ -927,7 +929,7 @@ void tst_qquickwindow::touchEvent_propagation()
middleItem->acceptTouchEvents = acceptTouchEvents;
middleItem->setEnabled(enableItem);
middleItem->setVisible(showItem);
- QTest::touchEvent(window, touchDevice).press(0, pointInTopItem, window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, pointInTopItem, window);
QTest::qWait(50);
if (!enableItem || !showItem) {
// middle item is disabled or has 0 opacity, bottom item receives the event
@@ -944,7 +946,7 @@ void tst_qquickwindow::touchEvent_propagation()
COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed,
makeTouchPoint(topItem, pos)));
}
- QTest::touchEvent(window, touchDevice).release(0, pointInTopItem, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, pointInTopItem, window);
delete topItem;
delete middleItem;
@@ -981,7 +983,7 @@ void tst_qquickwindow::touchEvent_cancel()
item->setSize(QSizeF(150, 150));
QPointF pos(50, 50);
- QTest::touchEvent(window, touchDevice).press(0, item->mapToScene(pos).toPoint(), window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, item->mapToScene(pos).toPoint(), window);
QCoreApplication::processEvents();
QTRY_COMPARE(item->lastEvent.touchPoints.size(), 1);
@@ -989,7 +991,7 @@ void tst_qquickwindow::touchEvent_cancel()
COMPARE_TOUCH_DATA(item->lastEvent, d);
item->reset();
- QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchDevice);
+ QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchscreen.get());
QCoreApplication::processEvents();
d = makeTouchData(QEvent::TouchCancel, window, QEventPoint::State::Pressed, makeTouchPoint(item, pos));
COMPARE_TOUCH_DATA(item->lastEvent, d);
@@ -1017,13 +1019,13 @@ void tst_qquickwindow::touchEvent_cancelClearsMouseGrab()
item->setAcceptTouchEvents(false);
QPointF pos(50, 50);
- QTest::touchEvent(window, touchDevice).press(0, item->mapToScene(pos).toPoint(), window);
+ QTest::touchEvent(window, touchscreen.get()).press(0, item->mapToScene(pos).toPoint(), window);
QCoreApplication::processEvents();
QTRY_COMPARE(item->mousePressCount, 1);
QTRY_COMPARE(item->mouseUngrabEventCount, 0);
- QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchDevice);
+ QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchscreen.get());
QCoreApplication::processEvents();
QTRY_COMPARE(item->mouseUngrabEventCount, 1);
@@ -1051,10 +1053,10 @@ void tst_qquickwindow::touchEvent_reentrant()
QPointF pos(60, 60);
// None of these should commit from the dtor.
- QTest::QTouchEventSequence press = QTest::touchEvent(window, touchDevice, false).press(0, pos.toPoint(), window);
+ QTest::QTouchEventSequence press = QTest::touchEvent(window, touchscreen.get(), false).press(0, pos.toPoint(), window);
pos += QPointF(2, 2);
- QTest::QTouchEventSequence move = QTest::touchEvent(window, touchDevice, false).move(0, pos.toPoint(), window);
- QTest::QTouchEventSequence release = QTest::touchEvent(window, touchDevice, false).release(0, pos.toPoint(), window);
+ QTest::QTouchEventSequence move = QTest::touchEvent(window, touchscreen.get(), false).move(0, pos.toPoint(), window);
+ QTest::QTouchEventSequence release = QTest::touchEvent(window, touchscreen.get(), false).release(0, pos.toPoint(), window);
// Now commit (i.e. call QWindowSystemInterface::handleTouchEvent), but do not process the events yet.
press.commit(false);
@@ -1093,7 +1095,7 @@ void tst_qquickwindow::touchEvent_velocity()
QMutableEventPoint::setGlobalPosition(tp, screenPos);
QMutableEventPoint::setEllipseDiameters(tp, QSizeF(4, 4));
points << tp;
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1104,7 +1106,7 @@ void tst_qquickwindow::touchEvent_velocity()
QMutableEventPoint::setGlobalPosition(points[0], screenPos + QPointF(5, 5));
QVector2D velocity(1.5, 2.5);
QMutableEventPoint::setVelocity(points[0], velocity);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1119,7 +1121,7 @@ void tst_qquickwindow::touchEvent_velocity()
item->setRotation(90); // clockwise
QMutableEventPoint::setPosition(points[0], points[0].position() + QPointF(5, 5));
QMutableEventPoint::setGlobalPosition(points[0], points[0].globalPosition() + QPointF(5, 5));
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1129,7 +1131,7 @@ void tst_qquickwindow::touchEvent_velocity()
QCOMPARE(itemLocalPos, itemLocalPosFromEvent);
QMutableEventPoint::setState(points[0], QEventPoint::State::Released);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1233,7 +1235,7 @@ void tst_qquickwindow::mouseFromTouch_basic()
QMutableEventPoint::setGlobalPosition(tp, screenPos);
QMutableEventPoint::setEllipseDiameters(tp, QSizeF(4, 4));
points << tp;
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1242,12 +1244,12 @@ void tst_qquickwindow::mouseFromTouch_basic()
QMutableEventPoint::setGlobalPosition(points[0], screenPos + QPointF(5, 5));
QVector2D velocity(1.5, 2.5);
QMutableEventPoint::setVelocity(points[0], velocity);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
QMutableEventPoint::setState(points[0], QEventPoint::State::Released);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1267,14 +1269,14 @@ void tst_qquickwindow::mouseFromTouch_basic()
QMutableEventPoint::setVelocity(points[0], velocity);
QMutableEventPoint::setPosition(tp, localPos);
QMutableEventPoint::setGlobalPosition(tp, screenPos);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
QMutableEventPoint::setState(points[0], QEventPoint::State::Updated);
QMutableEventPoint::setPosition(points[0], localPos + QPointF(5, 5));
QMutableEventPoint::setGlobalPosition(points[0], screenPos + QPointF(5, 5));
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1282,7 +1284,7 @@ void tst_qquickwindow::mouseFromTouch_basic()
QCOMPARE(item->lastVelocityFromMouseMove, velocity); // Velocity is always in scene coords
QMutableEventPoint::setState(points[0], QEventPoint::State::Released);
- QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
+ QWindowSystemInterface::handleTouchEvent(window, touchscreenWithVelocity.get(),
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QCoreApplication::processEvents();
QQuickTouchUtils::flush(window);
@@ -1317,11 +1319,11 @@ void tst_qquickwindow::synthMouseFromTouch()
QPoint p1 = QPoint(20, 20);
QPoint p2 = QPoint(30, 30);
- QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).press(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QTest::touchEvent(window.data(), touchDevice).move(0, p2, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).move(0, p2, window.data());
QQuickTouchUtils::flush(window.data());
- QTest::touchEvent(window.data(), touchDevice).release(0, p2, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).release(0, p2, window.data());
QQuickTouchUtils::flush(window.data());
QCOMPARE(item->m_touchEvents.size(), acceptTouch ? 3 : 0);
@@ -1362,14 +1364,14 @@ void tst_qquickwindow::synthMouseDoubleClickFromTouch()
QTest::qWait(100);
QPoint p1 = item->mapToScene(item->clipRect().center()).toPoint();
- QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data());
- QTest::touchEvent(window.data(), touchDevice).move(0, p1 + movement, window.data());
- QTest::touchEvent(window.data(), touchDevice).release(0, p1 + movement, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).press(0, p1, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).move(0, p1 + movement, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).release(0, p1 + movement, window.data());
QPoint p2 = p1 + distanceBetweenPresses;
- QTest::touchEvent(window.data(), touchDevice).press(1, p2, window.data());
- QTest::touchEvent(window.data(), touchDevice).move(1, p2 + movement, window.data());
- QTest::touchEvent(window.data(), touchDevice).release(1, p2 + movement, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).press(1, p2, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).move(1, p2 + movement, window.data());
+ QTest::touchEvent(window.data(), touchscreen.get()).release(1, p2 + movement, window.data());
const int eventCount = item->m_mouseEvents.size();
QVERIFY(eventCount >= 2);
@@ -2396,7 +2398,7 @@ void tst_qquickwindow::qobjectEventFilter_touch()
QPointF pos(10, 10);
// press single point
- QTest::touchEvent(&window, touchDevice).press(0, item->mapToScene(pos).toPoint(), &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, item->mapToScene(pos).toPoint(), &window);
QCOMPARE(eventFilter.events.size(), 1);
QCOMPARE(eventFilter.events.first(), (int)QEvent::TouchBegin);
@@ -3606,7 +3608,7 @@ void tst_qquickwindow::testChildMouseEventFilter()
if (useMouseEvents)
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, mousePos);
else
- QTest::touchEvent(&window, touchDevice).press(0, mousePos, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, mousePos, &window);
// Check if event got delivered to the root item. If so, append it to the list of items the event got delivered to
if (rootFilter->events.contains(QEvent::MouseButtonPress))
@@ -3626,7 +3628,7 @@ void tst_qquickwindow::testChildMouseEventFilter()
if (useMouseEvents)
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, mousePos);
else
- QTest::touchEvent(&window, touchDevice).release(0, mousePos, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, mousePos, &window);
}
void tst_qquickwindow::cleanupGrabsOnRelease()
@@ -3670,8 +3672,8 @@ void tst_qquickwindow::subclassWithPointerEventVirtualOverrides_data()
QTest::addColumn<const QPointingDevice *>("device");
QTest::newRow("mouse click") << QPointingDevice::primaryPointingDevice();
- QTest::newRow("touch tap") << static_cast<const QPointingDevice*>(touchDevice); // TODO QTBUG-107864
- QTest::newRow("stylus tap") << tabletStylusDevice;
+ QTest::newRow("touch tap") << static_cast<const QPointingDevice*>(touchscreen.get()); // TODO QTBUG-107864
+ QTest::newRow("stylus tap") << tabletStylusDevice.get();
}
void tst_qquickwindow::subclassWithPointerEventVirtualOverrides() // QTBUG-97859
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index 3290719791..b9c56cadc3 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -262,7 +262,7 @@ protected:
private:
QQuickView *createView();
- QPointingDevice *device = QTest::createTouchDevice();
+ std::unique_ptr<QPointingDevice> touchscreen{QTest::createTouchDevice()};
QList<Event> filteredEventList;
GrabMonitor grabMonitor;
};
@@ -277,7 +277,7 @@ void tst_TouchMouse::initTestCase()
{
QQmlDataTest::initTestCase();
qmlRegisterType<EventItem>("Qt.test", 1, 0, "EventItem");
- connect(device, &QPointingDevice::grabChanged, &grabMonitor, &GrabMonitor::onGrabChanged);
+ connect(touchscreen.get(), &QPointingDevice::grabChanged, &grabMonitor, &GrabMonitor::onGrabChanged);
}
void tst_TouchMouse::simpleTouchEvent_data()
@@ -297,24 +297,24 @@ void tst_TouchMouse::simpleTouchEvent()
EventItem *eventItem1 = window.rootObject()->findChild<EventItem*>("eventItem1");
QVERIFY(eventItem1);
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
// Do not accept touch or mouse
eventItem1->setAcceptTouchEvents(false);
QPoint p1;
p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
// Get a synth-mouse event if allowed
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
if (synthMouse)
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
// Not accepted, no updates
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
eventItem1->eventList.clear();
@@ -323,14 +323,14 @@ void tst_TouchMouse::simpleTouchEvent()
eventItem1->setAcceptTouchEvents(true);
eventItem1->acceptTouch = true;
p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 1);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 2);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 3);
eventItem1->eventList.clear();
@@ -344,7 +344,7 @@ void tst_TouchMouse::simpleTouchEvent()
eventItem1->setAcceptTouchEvents(false);
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
if (synthMouse)
@@ -359,14 +359,14 @@ void tst_TouchMouse::simpleTouchEvent()
}
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 0);
if (synthMouse)
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseMove);
// else, if there was no synth-mouse and we didn't accept the touch,
// TouchUpdate was not sent to eventItem1 either.
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 0);
if (synthMouse) {
@@ -385,16 +385,16 @@ void tst_TouchMouse::simpleTouchEvent()
eventItem1->acceptMouse = false;
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
if (synthMouse)
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), synthMouse ? 1 : 0);
eventItem1->eventList.clear();
@@ -407,16 +407,16 @@ void tst_TouchMouse::simpleTouchEvent()
eventItem1->setAcceptTouchEvents(true);
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::TouchUpdate);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 3);
QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchEnd);
@@ -442,11 +442,11 @@ void tst_TouchMouse::testEventFilter()
// eventItem1->installEventFilter(filter);
// QPoint p1 = QPoint(20, 20);
-// QTest::touchEvent(&window, device).press(0, p1, &window);
+// QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
// // QEXPECT_FAIL("", "We do not implement event filters correctly", Abort);
// QCOMPARE(eventItem1->eventList.size(), 0);
// QCOMPARE(filter->eventList.size(), 1);
-// QTest::touchEvent(&window, device).release(0, p1, &window);
+// QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
// QCOMPARE(eventItem1->eventList.size(), 0);
// QCOMPARE(filter->eventList.size(), 2);
@@ -474,7 +474,7 @@ void tst_TouchMouse::mouse()
// item 2 doesn't accept anything, thus it sees a touch pass by
eventItem2->setAcceptTouchEvents(false);
QPoint p1 = QPoint(30, 30);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 1);
@@ -502,7 +502,7 @@ void tst_TouchMouse::touchOverMouse()
QCOMPARE(eventItem1->eventList.size(), 0);
QPoint p1 = QPoint(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "expected delivered events: press(mouse)" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 1);
@@ -510,12 +510,12 @@ void tst_TouchMouse::touchOverMouse()
QCOMPARE(eventItem2->eventList.size(), 1);
QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "expected delivered events: press(mouse) move(mouse)" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseMove);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "expected delivered events: press(mouse) move(mouse) release(mouse) ungrab(mouse)" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 4);
@@ -544,16 +544,16 @@ void tst_TouchMouse::mouseOverTouch()
QPoint p1 = QPoint(20, 20);
QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 10);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 0);
QCOMPARE(eventItem2->eventList.size(), 1);
QCOMPARE(eventItem2->eventList.at(0).type, QEvent::MouseButtonPress);
p1 += QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QCOMPARE(eventItem2->eventList.size(), 1);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
qCDebug(lcTests) << "expected delivered events: press(mouse) move(mouse) release(mouse) ungrab(mouse)" << eventItem2->eventList;
QCOMPARE(eventItem2->eventList.size(), 4);
eventItem2->eventList.clear();
@@ -592,11 +592,11 @@ void tst_TouchMouse::buttonOnFlickable()
// mouse button
QCOMPARE(eventItem1->eventList.size(), 0);
QPoint p1 = QPoint(20, 130);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(eventItem1->eventList.size(), 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 3);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonRelease);
@@ -605,11 +605,11 @@ void tst_TouchMouse::buttonOnFlickable()
// touch button
p1 = QPoint(10, 310);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem2->eventList.size(), 1);
QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem2->eventList.size(), 2);
QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchEnd);
@@ -621,10 +621,10 @@ void tst_TouchMouse::buttonOnFlickable()
// click above button, no events please
p1 = QPoint(10, 90);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 0);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 0);
eventItem1->eventList.clear();
@@ -635,14 +635,14 @@ void tst_TouchMouse::buttonOnFlickable()
// check that flickable moves - mouse button
QCOMPARE(eventItem1->eventList.size(), 0);
p1 = QPoint(10, 110);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem1->eventList.size(), 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(&window);
QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId != -1);
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem1);
QCOMPARE(grabMonitor.exclusiveGrabber, eventItem1);
@@ -652,7 +652,7 @@ void tst_TouchMouse::buttonOnFlickable()
int i = 0;
for (; i < 10 && !flickable->isMovingVertically(); ++i) {
p1 += QPoint(0, dragDelta);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
}
QVERIFY(flickable->isMovingVertically());
@@ -665,7 +665,7 @@ void tst_TouchMouse::buttonOnFlickable()
QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId != -1);
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
}
@@ -690,14 +690,14 @@ void tst_TouchMouse::touchButtonOnFlickable()
// press via touch, then drag: check that flickable moves and that the button gets ungrabbed
QCOMPARE(eventItem2->eventList.size(), 0);
QPoint p1 = QPoint(10, 310);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(eventItem2->eventList.size(), 1);
QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin);
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(&window);
QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId == -1);
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem2);
QCOMPARE(grabMonitor.exclusiveGrabber, eventItem2);
@@ -707,11 +707,11 @@ void tst_TouchMouse::touchButtonOnFlickable()
QPoint p3 = p2 + QPoint(0, dragDelta);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).move(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p2, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).move(0, p3, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p3, &window);
QQuickTouchUtils::flush(&window);
QTRY_COMPARE(eventItem2->touchUngrabCount, 1);
@@ -724,7 +724,7 @@ void tst_TouchMouse::touchButtonOnFlickable()
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
QVERIFY(flickable->isMovingVertically());
- QTest::touchEvent(&window, device).release(0, p3, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p3, &window);
QQuickTouchUtils::flush(&window);
}
@@ -787,7 +787,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
// touch press
QPoint p1 = QPoint(10, 110);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
if (scrollBeforeDelayIsOver || releaseBeforeDelayIsOver) {
@@ -806,7 +806,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
// move the touchpoint: try to flick
for (int i = 0; i < 3; ++i) {
p1 += QPoint(0, -threshold);
- QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1, &window);
QQuickTouchUtils::flush(&window);
}
QTRY_VERIFY(flickable->isMovingVertically());
@@ -827,11 +827,11 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
// flickable should have the touchpoint grab: it no longer relies on synth-mouse
QCOMPARE(grabMonitor.exclusiveGrabber, flickable);
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
}
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
if (releaseBeforeDelayIsOver) {
@@ -889,7 +889,7 @@ void tst_TouchMouse::buttonOnTouch()
EventItem *eventItem4 = window.rootObject()->findChild<EventItem*>("eventItem4");
QVERIFY(eventItem4);
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, device, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, touchscreen.get(), false);
// Test the common case of a mouse area on top of pinch
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
@@ -1016,17 +1016,17 @@ void tst_TouchMouse::pinchOnFlickable()
// flick the flickable with one touchpoint
QCOMPARE(flickable->contentX(), 0);
QPoint p = QPoint(100, 100);
- QTest::touchEvent(&window, device).press(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(rect->position(), QPointF(200, 200));
for (int i = 0; i < 4; ++i) {
p -= QPoint(threshold, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
if (!flickable->isAtXBeginning()) // currently happens when i == 3
qCDebug(lcTests, "flicking after %d moves: %lf", i + 1, flickable->contentX());
}
- QTest::touchEvent(&window, device).release(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p, &window);
QTRY_COMPARE(flickable->isAtXBeginning(), false);
// wait until flicking is done
QTRY_COMPARE(flickable->isFlicking(), false);
@@ -1034,7 +1034,7 @@ void tst_TouchMouse::pinchOnFlickable()
// pinch with two touchpoints
QPoint p1 = QPoint(40, 20);
QPoint p2 = QPoint(60, 20);
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, touchscreen.get());
QQuickTouchUtils::flush(&window);
pinchSequence.press(0, p1, &window).commit();
QQuickTouchUtils::flush(&window);
@@ -1075,22 +1075,22 @@ void tst_TouchMouse::flickableOnPinch()
// flickable - single touch point
QCOMPARE(flickable->contentX(), 0.0);
QPoint p = QPoint(100, 100);
- QTest::touchEvent(&window, device).press(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(rect->position(), QPointF(200.0, 200.0));
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
QTest::qWait(1000);
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p, &window);
QQuickTouchUtils::flush(&window);
QTest::qWait(1000);
@@ -1103,7 +1103,7 @@ void tst_TouchMouse::flickableOnPinch()
// pinch
QPoint p1 = QPoint(40, 20);
QPoint p2 = QPoint(60, 20);
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, touchscreen.get());
pinchSequence.press(0, p1, &window).commit();
QQuickTouchUtils::flush(&window);
// In order for the stationary point to remember its previous position,
@@ -1150,19 +1150,19 @@ void tst_TouchMouse::mouseOnFlickableOnPinch()
// flickable - single touch point
QCOMPARE(flickable->contentX(), 0.0);
QPoint p = QPoint(100, 100);
- QTest::touchEvent(&window, device).press(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(rect->position(), QPointF(200.0, 200.0));
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
p -= QPoint(10, 0);
- QTest::touchEvent(&window, device).move(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(0, p, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p, &window);
QQuickTouchUtils::flush(&window);
QVERIFY(flickable->isMovingHorizontally());
@@ -1174,7 +1174,7 @@ void tst_TouchMouse::mouseOnFlickableOnPinch()
// pinch
QPoint p1 = QPoint(40, 20);
QPoint p2 = QPoint(60, 20);
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, device);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, touchscreen.get());
pinchSequence.press(0, p1, &window).commit();
QQuickTouchUtils::flush(&window);
// In order for the stationary point to remember its previous position,
@@ -1275,17 +1275,17 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne()
// tap the front mouse area (see qml file)
QPoint p1(20, 20);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(bottomClickedSpy.size(), 1);
QCOMPARE(bottomDoubleClickedSpy.size(), 0);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(bottomClickedSpy.size(), 1);
@@ -1315,7 +1315,7 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab()
leftItem->setAcceptedMouseButtons(Qt::LeftButton);
QPoint p1;
p1 = QPoint(leftItem->width() / 2, leftItem->height() / 2);
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "expected delivered events: press(mouse)" << leftItem->eventList;
QCOMPARE(leftItem->eventList.size(), 1);
@@ -1324,7 +1324,7 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab()
leftItem->eventList.clear();
rightItem->acceptTouch = true;
- auto devPriv = QPointingDevicePrivate::get(device);
+ auto devPriv = QPointingDevicePrivate::get(touchscreen.get());
auto epd = devPriv->queryPointById(0);
QVERIFY(epd);
devPriv->setExclusiveGrabber(nullptr, epd->eventPoint, rightItem);
@@ -1355,7 +1355,7 @@ void tst_TouchMouse::touchPointDeliveryOrder()
QPoint pLeftMiddle = QPoint(200, 100);
QPoint pRightMiddle = QPoint(350, 100);
- QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, device, false);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(&window, touchscreen.get(), false);
QVector<QQuickItem*> events;
EventItem *background = window.rootObject()->findChild<EventItem*>("background");
@@ -1470,7 +1470,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QVERIFY(!mouseArea2->hovered());
// ------------------------- Touch click on mouseArea1
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(enterSpy1.size(), 1);
@@ -1479,14 +1479,14 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(clickSpy1.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
// ------------------------- Touch click on mouseArea2
- QTest::touchEvent(&window, device).press(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p2, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(!mouseArea1->hovered());
@@ -1495,7 +1495,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QCOMPARE(enterSpy1.size(), 1);
QCOMPARE(enterSpy2.size(), 1);
- QTest::touchEvent(&window, device).release(0, p2, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p2, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(clickSpy2.size() == 1);
@@ -1505,7 +1505,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QCOMPARE(exitSpy2.size(), 1);
// ------------------------- Another touch click on mouseArea1
- QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(enterSpy1.size(), 2);
@@ -1514,7 +1514,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
- QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(clickSpy1.size(), 2);
QVERIFY(mouseArea1->hovered());
@@ -1534,23 +1534,23 @@ void tst_TouchMouse::implicitUngrab()
eventItem->acceptMouse = true;
eventItem->setAcceptTouchEvents(false);
QPoint p1(20, 20);
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QCOMPARE(grabMonitor.exclusiveGrabber, eventItem);
eventItem->eventList.clear();
eventItem->setEnabled(false);
QVERIFY(!eventItem->eventList.isEmpty());
QCOMPARE(eventItem->eventList.at(0).type, QEvent::UngrabMouse);
- QTest::touchEvent(&window, device).release(0, p1); // clean up potential state
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1); // clean up potential state
QCOMPARE(windowPriv->deliveryAgentPrivate()->touchMouseId, -1);
eventItem->setEnabled(true);
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
eventItem->eventList.clear();
eventItem->setVisible(false);
QVERIFY(!eventItem->eventList.isEmpty());
QCOMPARE(eventItem->eventList.at(0).type, QEvent::UngrabMouse);
- QTest::touchEvent(&window, device).release(0, p1); // clean up potential state
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1); // clean up potential state
}
void tst_TouchMouse::touchCancelWillCancelMousePress()
@@ -1566,12 +1566,12 @@ void tst_TouchMouse::touchCancelWillCancelMousePress()
QPoint p1(20, 20);
// Begin a new touch, that gets converted to a mouse press
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QCOMPARE(eventItem->eventList.size(), 1);
QCOMPARE(eventItem->eventList.at(0).type, QEvent::MouseButtonPress);
// Cancel it...
- QTouchEvent cancelEvent(QEvent::TouchCancel, device);
+ QTouchEvent cancelEvent(QEvent::TouchCancel, touchscreen.get());
QCoreApplication::sendEvent(&window, &cancelEvent);
QCOMPARE(eventItem->eventList.size(), 3);
QCOMPARE(eventItem->eventList.at(1).type, QEvent::TouchCancel);
@@ -1579,11 +1579,11 @@ void tst_TouchMouse::touchCancelWillCancelMousePress()
// Begin a second touch. Since the last one was cancelled, this
// should end up as a new mouse press on the target item.
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QVERIFY(eventItem->eventList.size() >= 5);
QCOMPARE(eventItem->eventList.at(3).type, QEvent::MouseButtonPress);
- QTest::touchEvent(&window, device).release(0, p1); // clean up potential state
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1); // clean up potential state
}
void tst_TouchMouse::oneTouchInsideAndOneOutside() // QTBUG-102996
@@ -1597,28 +1597,28 @@ void tst_TouchMouse::oneTouchInsideAndOneOutside() // QTBUG-102996
// Press the MouseArea
QPoint p1 = ma->mapToScene(ma->boundingRect().center()).toPoint();
- QTest::touchEvent(&window, device).press(1, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, p1);
QQuickTouchUtils::flush(&window);
QVERIFY(ma->isPressed());
// Tap outside the MouseArea with a second finger
QPoint p2(100, 100);
- QTest::touchEvent(&window, device).stationary(1).press(2, p2);
+ QTest::touchEvent(&window, touchscreen.get()).stationary(1).press(2, p2);
QQuickTouchUtils::flush(&window);
- QTest::touchEvent(&window, device).stationary(1).release(2, p2);
+ QTest::touchEvent(&window, touchscreen.get()).stationary(1).release(2, p2);
QQuickTouchUtils::flush(&window);
QVERIFY(ma->isPressed());
// Press again outside the MouseArea with a second finger
- QTest::touchEvent(&window, device).stationary(1).press(2, p2);
+ QTest::touchEvent(&window, touchscreen.get()).stationary(1).press(2, p2);
// Release the first finger: MouseArea should be released
- QTest::touchEvent(&window, device).release(1, p1).stationary(2);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, p1).stationary(2);
QQuickTouchUtils::flush(&window);
QCOMPARE(ma->isPressed(), false);
// Release the second finger
- QTest::touchEvent(&window, device).release(2, p2);
+ QTest::touchEvent(&window, touchscreen.get()).release(2, p2);
QQuickTouchUtils::flush(&window);
}
@@ -1637,7 +1637,7 @@ void tst_TouchMouse::strayTouchDoesntAutograb() // QTBUG-107867
grabMonitor.reset();
// Begin a new touch, that gets converted to a mouse press
- QTest::touchEvent(&window, device).press(0, p1);
+ QTest::touchEvent(&window, touchscreen.get()).press(0, p1);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "after touch press:" << eventItem->eventList;
QCOMPARE(eventItem->eventList.size(), 1);
@@ -1646,7 +1646,7 @@ void tst_TouchMouse::strayTouchDoesntAutograb() // QTBUG-107867
// Drag
for (int i = 0; i < 3; ++i) {
- QTest::touchEvent(&window, device).move(0, p1 + QPoint(i * 5, i * 5), &window);
+ QTest::touchEvent(&window, touchscreen.get()).move(0, p1 + QPoint(i * 5, i * 5), &window);
QQuickTouchUtils::flush(&window);
QCOMPARE(grabMonitor.transitionCount, 1); // no new grab
QCOMPARE(eventItem->eventList.size(), i + 2);
@@ -1654,13 +1654,13 @@ void tst_TouchMouse::strayTouchDoesntAutograb() // QTBUG-107867
}
// Press an extra point: EventItem should see nothing
- QTest::touchEvent(&window, device).stationary(0).press(1, p1);
+ QTest::touchEvent(&window, touchscreen.get()).stationary(0).press(1, p1);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "after press of second touchpoint:" << eventItem->eventList;
QCOMPARE(eventItem->eventList.size(), 4);
QCOMPARE(grabMonitor.transitionCount, 1); // no new grab
- QTest::touchEvent(&window, device).release(0, p1).release(1, p1);
+ QTest::touchEvent(&window, touchscreen.get()).release(0, p1).release(1, p1);
}
void tst_TouchMouse::noDoubleClickWithInterveningTouch() // QTBUG-116442
@@ -1686,8 +1686,8 @@ void tst_TouchMouse::noDoubleClickWithInterveningTouch() // QTBUG-116442
const QPoint pRight(240, 200);
// tap left
- QTest::touchEvent(&window, device).press(1, pLeft, &window);
- QTest::touchEvent(&window, device).release(1, pLeft, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, pLeft, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, pLeft, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "left tap" << leftItem->eventList;
QCOMPARE(leftItem->eventList.size(), 3);
@@ -1695,8 +1695,8 @@ void tst_TouchMouse::noDoubleClickWithInterveningTouch() // QTBUG-116442
leftItem->eventList.clear();
// tap right
- QTest::touchEvent(&window, device).press(1, pRight, &window);
- QTest::touchEvent(&window, device).release(1, pRight, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(1, pRight, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(1, pRight, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "right tap" << rightItem->eventList;
QCOMPARE(rightItem->eventList.size(), 2);
@@ -1704,8 +1704,8 @@ void tst_TouchMouse::noDoubleClickWithInterveningTouch() // QTBUG-116442
rightItem->eventList.clear();
// tap left again: this is NOT a double-click, even though it's within time and space limits
- QTest::touchEvent(&window, device).press(3, pLeft, &window);
- QTest::touchEvent(&window, device).release(3, pLeft, &window);
+ QTest::touchEvent(&window, touchscreen.get()).press(3, pLeft, &window);
+ QTest::touchEvent(&window, touchscreen.get()).release(3, pLeft, &window);
QQuickTouchUtils::flush(&window);
qCDebug(lcTests) << "left tap again" << leftItem->eventList;
QCOMPARE(leftItem->eventList.size(), 3);