diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-03-26 16:50:40 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-23 17:44:03 +0200 |
commit | d0ae3a312a03c118a1aa25a4c6c0352375d569fc (patch) | |
tree | 01df3e8ea22c8a1ecd969a6e9e6d7014c635da9f /tests/auto/quick/pointerhandlers | |
parent | d5d6a56809032796444fe63c220a2e940ce237c0 (diff) |
Remove QQuickPointerDevice in favor of QPointingDevice
...and generally deal with changes immediately required after adding
QInputDevice and QPointingDevice.
Also fixed a few usages of deprecated accessors that weren't taken
care of in 212c2bffbb041aee0e3c9a7f0551ef151ed2d3ad.
Task-number: QTBUG-46412
Task-number: QTBUG-69433
Task-number: QTBUG-72167
Change-Id: I93a2643162878afa216556f10808fd92e0b20071
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
8 files changed, 28 insertions, 48 deletions
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp index f4ed051e1f..2cdbaf3bf6 100644 --- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp +++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp @@ -82,7 +82,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_FlickableInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName) 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 794562fea0..26b6e0540b 100644 --- a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp @@ -45,8 +45,6 @@ class tst_MouseAreaInterop : public QQmlDataTest Q_OBJECT public: tst_MouseAreaInterop() - : touchDevice(QTest::createTouchDevice()) - , touchPointerDevice(QQuickPointerDevice::touchDevice(touchDevice)) {} private slots: @@ -56,8 +54,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; - QQuickPointerDevice *touchPointerDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_MouseAreaInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName) @@ -79,7 +76,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse QScopedPointer<QQuickView> windowPtr; createView(windowPtr, "dragTakeOverFromSibling.qml"); QQuickView * window = windowPtr.data(); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::genericMouseDevice()); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QPointingDevice::primaryPointingDevice()); QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); QVERIFY(handler); @@ -127,7 +124,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch QScopedPointer<QQuickView> windowPtr; createView(windowPtr, "dragTakeOverFromSibling.qml"); QQuickView * window = windowPtr.data(); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice); QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); QVERIFY(handler); 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 4a7a132be2..82e9b4e71f 100644 --- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp @@ -46,8 +46,6 @@ class tst_MptaInterop : public QQmlDataTest Q_OBJECT public: tst_MptaInterop() - : touchDevice(QTest::createTouchDevice()) - , touchPointerDevice(QQuickPointerDevice::touchDevice(touchDevice)) {} private slots: @@ -60,8 +58,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; - QQuickPointerDevice *touchPointerDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_MptaInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName) @@ -111,7 +108,7 @@ void tst_MptaInterop::touchDrag() QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint(); touch.press(1, p1).commit(); QQuickTouchUtils::flush(window); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice); QCOMPARE(tp.at(0)->property("pressed").toBool(), true); QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag)); @@ -153,7 +150,7 @@ void tst_MptaInterop::touchesThenPinch() QSignalSpy mptaReleasedSpy(mpta, SIGNAL(released(QList<QObject*>))); QSignalSpy mptaCanceledSpy(mpta, SIGNAL(canceled(QList<QObject*>))); QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice); // Press one touchpoint: // DragHandler gets a passive grab @@ -307,7 +304,7 @@ void tst_MptaInterop::dragHandlerInParentStealingGrabFromItem() // QTBUG-75025 QScopedPointer<QQuickView> windowPtr; createView(windowPtr, "dragParentOfMPTA.qml"); QQuickView * window = windowPtr.data(); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::genericMouseDevice()); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QPointingDevice::primaryPointingDevice()); QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); QVERIFY(handler); diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 47cfd27817..f6faa97b37 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -72,7 +72,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); QSet<QQuickPointerHandler *> passiveGrabbers(QQuickWindow *window, int pointId = 0); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_DragHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName) @@ -92,15 +92,13 @@ QSet<QQuickPointerHandler*> tst_DragHandler::passiveGrabbers(QQuickWindow *windo { QSet<QQuickPointerHandler*> result; QQuickWindowPrivate *winp = QQuickWindowPrivate::get(window); - if (QQuickPointerDevice* device = QQuickPointerDevice::touchDevice(touchDevice)) { - QQuickPointerEvent *pointerEvent = winp->pointerEventInstance(device); - for (int i = 0; i < pointerEvent->pointCount(); ++i) { - QQuickEventPoint *eventPoint = pointerEvent->point(i); - QVector<QPointer <QQuickPointerHandler> > passives = eventPoint->passiveGrabbers(); - if (!pointId || eventPoint->pointId() == pointId) { - for (auto it = passives.constBegin(); it != passives.constEnd(); ++it) - result << it->data(); - } + QQuickPointerEvent *pointerEvent = winp->pointerEventInstance(touchDevice); + for (int i = 0; i < pointerEvent->pointCount(); ++i) { + QQuickEventPoint *eventPoint = pointerEvent->point(i); + QVector<QPointer <QQuickPointerHandler> > passives = eventPoint->passiveGrabbers(); + if (!pointId || eventPoint->pointId() == pointId) { + for (auto it = passives.constBegin(); it != passives.constEnd(); ++it) + result << it->data(); } } return result; diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp index 19fdae3b44..0c300cfd4e 100644 --- a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp @@ -43,9 +43,8 @@ class tst_QQuickPinchHandler: public QQmlDataTest { Q_OBJECT public: - tst_QQuickPinchHandler() : device(0) { } + tst_QQuickPinchHandler() { } private slots: - void initTestCase(); void cleanupTestCase(); void pinchProperties(); void scale(); @@ -60,17 +59,8 @@ private slots: private: QQuickView *createView(); - QTouchDevice *device; + QPointingDevice *device = QTest::createTouchDevice(); }; -void tst_QQuickPinchHandler::initTestCase() -{ - QQmlDataTest::initTestCase(); - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } -} void tst_QQuickPinchHandler::cleanupTestCase() { @@ -677,8 +667,7 @@ void tst_QQuickPinchHandler::cancel() QSKIP("cancel is not supported atm"); - QTouchEvent cancelEvent(QEvent::TouchCancel); - cancelEvent.setDevice(device); + QTouchEvent cancelEvent(QEvent::TouchCancel, device); QCoreApplication::sendEvent(window, &cancelEvent); QQuickTouchUtils::flush(window); diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index 7bfaac318f..cb20168c1d 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -230,7 +230,7 @@ class tst_PointerHandlers : public QQmlDataTest Q_OBJECT public: tst_PointerHandlers() - :touchDevice(QTest::createTouchDevice()) + : touchDevice(QTest::createTouchDevice()) {} private slots: @@ -271,7 +271,7 @@ protected: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; QList<Event> filteredEventList; }; @@ -343,7 +343,7 @@ void tst_PointerHandlers::touchEventDelivery() QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab); QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice); QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1); p1 += QPoint(10, 0); QTest::touchEvent(window, touchDevice).move(0, p1, window); diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp index ca6463f365..900202f132 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp @@ -62,7 +62,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_PointHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName) @@ -145,7 +145,7 @@ void tst_PointHandler::tabletStylus() QQuickView * window = windowPtr.data(); QQuickPointHandler *handler = window->rootObject()->findChild<QQuickPointHandler *>("pointHandler"); QVERIFY(handler); - handler->setAcceptedDevices(QQuickPointerDevice::Stylus); + handler->setAcceptedDevices(QInputDevice::DeviceType::Stylus); QSignalSpy activeSpy(handler, SIGNAL(activeChanged())); QSignalSpy pointSpy(handler, SIGNAL(pointChanged())); @@ -155,7 +155,7 @@ void tst_PointHandler::tabletStylus() const qint64 stylusId = 1234567890; QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0.5, 25, 35, 0.6, 12.3, 3, stylusId, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0.5, 25, 35, 0.6, 12.3, 3, stylusId, Qt::NoModifier); QTRY_COMPARE(handler->active(), true); QCOMPARE(activeSpy.count(), 1); QCOMPARE(pointSpy.count(), 1); @@ -170,7 +170,7 @@ void tst_PointHandler::tabletStylus() point += QPoint(10, 10); QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0.45, 23, 33, 0.57, 15.6, 3.4, stylusId, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0.45, 23, 33, 0.57, 15.6, 3, stylusId, Qt::NoModifier); QTRY_COMPARE(pointSpy.count(), 2); QCOMPARE(handler->active(), true); QCOMPARE(activeSpy.count(), 1); @@ -188,7 +188,7 @@ void tst_PointHandler::tabletStylus() QCOMPARE(translationSpy.count(), 2); QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier); QTRY_COMPARE(handler->active(), false); QCOMPARE(activeSpy.count(), 2); QCOMPARE(pointSpy.count(), 3); diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index 419afed3ac..32a68293c2 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -51,7 +51,6 @@ class tst_TapHandler : public QQmlDataTest Q_OBJECT public: tst_TapHandler() - :touchDevice(QTest::createTouchDevice()) {} private slots: @@ -74,7 +73,7 @@ private slots: private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_TapHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName) |