From d0ae3a312a03c118a1aa25a4c6c0352375d569fc Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 26 Mar 2020 16:50:40 +0100 Subject: Remove QQuickPointerDevice in favor of QPointingDevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...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 --- .../flickableinterop/tst_flickableinterop.cpp | 2 +- .../mousearea_interop/tst_mousearea_interop.cpp | 9 +++----- .../tst_multipointtoucharea_interop.cpp | 11 ++++----- .../qquickdraghandler/tst_qquickdraghandler.cpp | 18 +++++++-------- .../qquickpinchhandler/tst_qquickpinchhandler.cpp | 17 +++----------- .../tst_qquickpointerhandler.cpp | 6 ++--- .../qquickpointhandler/tst_qquickpointhandler.cpp | 10 ++++----- .../qquicktaphandler/tst_qquicktaphandler.cpp | 3 +-- .../quick/qquickflickable/tst_qquickflickable.cpp | 3 +-- tests/auto/quick/qquickitem/tst_qquickitem.cpp | 7 +----- .../quick/qquicklistview/tst_qquicklistview.cpp | 5 ++--- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 14 +----------- .../tst_qquickmultipointtoucharea.cpp | 12 ++-------- .../quick/qquickpincharea/tst_qquickpincharea.cpp | 15 ++----------- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 26 +++++++++++----------- tests/auto/quick/touchmouse/tst_touchmouse.cpp | 13 ++++------- .../quickwidgets/qquickwidget/tst_qquickwidget.cpp | 2 +- 17 files changed, 55 insertions(+), 118 deletions(-) (limited to 'tests/auto') 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 &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_FlickableInterop::createView(QScopedPointer &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 &window, const char *fileName); - QTouchDevice *touchDevice; - QQuickPointerDevice *touchPointerDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_MouseAreaInterop::createView(QScopedPointer &window, const char *fileName) @@ -79,7 +76,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse QScopedPointer 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 handler = window->rootObject()->findChild(); QVERIFY(handler); @@ -127,7 +124,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch QScopedPointer windowPtr; createView(windowPtr, "dragTakeOverFromSibling.qml"); QQuickView * window = windowPtr.data(); - auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice); QPointer handler = window->rootObject()->findChild(); 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 &window, const char *fileName); - QTouchDevice *touchDevice; - QQuickPointerDevice *touchPointerDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_MptaInterop::createView(QScopedPointer &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))); QSignalSpy mptaCanceledSpy(mpta, SIGNAL(canceled(QList))); 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 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 handler = window->rootObject()->findChild(); 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 &window, const char *fileName); QSet passiveGrabbers(QQuickWindow *window, int pointId = 0); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_DragHandler::createView(QScopedPointer &window, const char *fileName) @@ -92,15 +92,13 @@ QSet tst_DragHandler::passiveGrabbers(QQuickWindow *windo { QSet 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 > 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 > 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 &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; QList 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 &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice; }; void tst_PointHandler::createView(QScopedPointer &window, const char *fileName) @@ -145,7 +145,7 @@ void tst_PointHandler::tabletStylus() QQuickView * window = windowPtr.data(); QQuickPointHandler *handler = window->rootObject()->findChild("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 &window, const char *fileName); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_TapHandler::createView(QScopedPointer &window, const char *fileName) diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 9f7cfa842e..dcf5a0b09e 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -149,7 +149,6 @@ class tst_qquickflickable : public QQmlDataTest Q_OBJECT public: tst_qquickflickable() - : touchDevice(QTest::createTouchDevice()) {} private slots: @@ -209,7 +208,7 @@ private slots: private: void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to); - QTouchDevice *touchDevice; + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; void tst_qquickflickable::initTestCase() diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 77f183ad2a..924a1d2c4e 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -1337,12 +1337,7 @@ void tst_qquickitem::touchEventAcceptIgnore() item->setParentItem(window.contentItem()); item->acceptIncomingTouchEvents = itemSupportsTouch; - static QTouchDevice* device = nullptr; - if (!device) { - device =new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } + static QPointingDevice* device = QTest::createTouchDevice(); // Send Begin, Update & End touch sequence { diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 56c3f370d2..4f504103d4 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -352,7 +352,7 @@ private: QQuickView *m_view; QString testForView; - QTouchDevice *touchDevice = QTest::createTouchDevice(); + QPointingDevice *touchDevice = QTest::createTouchDevice(); }; class TestObject : public QObject @@ -9673,8 +9673,7 @@ void tst_QQuickListView::touchCancel() // QTBUG-74679 // and because Flickable filtered it, QQuickFlickablePrivate::pressed // should be true, but it's not easily tested here - QTouchEvent cancelEvent(QEvent::TouchCancel); - cancelEvent.setDevice(touchDevice); + QTouchEvent cancelEvent(QEvent::TouchCancel, touchDevice); 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 diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 5879fc6897..1d22680261 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -94,14 +94,12 @@ class tst_QQuickMouseArea: public QQmlDataTest Q_OBJECT public: tst_QQuickMouseArea() - : device(nullptr) { qmlRegisterType("Test", 1, 0, "CircleMask"); qmlRegisterType("Test", 1, 0, "EventSender"); } private slots: - void initTestCase() override; void dragProperties(); void resetDrag(); void dragging_data() { acceptedButton_data(); } @@ -166,22 +164,12 @@ private: } void acceptedButton_data(); void rejectedButton_data(); - QTouchDevice *device; + QPointingDevice *device = QTest::createTouchDevice(); }; Q_DECLARE_METATYPE(Qt::MouseButton) Q_DECLARE_METATYPE(Qt::MouseButtons) -void tst_QQuickMouseArea::initTestCase() -{ - QQmlDataTest::initTestCase(); - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } -} - void tst_QQuickMouseArea::acceptedButton_data() { QTest::addColumn("acceptedButtons"); diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index c18a220996..04a44a2c10 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -47,14 +47,6 @@ public: tst_QQuickMultiPointTouchArea() { } private slots: - void initTestCase() { - QQmlDataTest::initTestCase(); - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } - } void cleanupTestCase() {} void properties(); @@ -80,7 +72,7 @@ private slots: private: QQuickView *createAndShowView(const QString &file); - QTouchDevice *device = nullptr; + QPointingDevice *device = QTest::createTouchDevice(); }; void tst_QQuickMultiPointTouchArea::properties() @@ -838,7 +830,7 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818 QTest::touchEvent(window.data(), device).press(0, p1); QQuickTouchUtils::flush(window.data()); QTRY_COMPARE(point11->pressed(), true); - auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + auto pointerEvent = windowPriv->pointerEventInstance(device); QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); // release: MPTA receives TouchEnd (which is asymmetric with mouse press); does NOT emit canceled. diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp index 5b7108d96b..3213d49dd5 100644 --- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp +++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp @@ -43,7 +43,6 @@ class tst_QQuickPinchArea: public QQmlDataTest public: tst_QQuickPinchArea() { } private slots: - void initTestCase(); void cleanupTestCase(); void pinchProperties(); void scale(); @@ -55,17 +54,8 @@ private slots: private: QQuickView *createView(); - QTouchDevice *device = nullptr; + QPointingDevice *device = QTest::createTouchDevice(); }; -void tst_QQuickPinchArea::initTestCase() -{ - QQmlDataTest::initTestCase(); - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } -} void tst_QQuickPinchArea::cleanupTestCase() { @@ -510,8 +500,7 @@ void tst_QQuickPinchArea::cancel() QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 QCOMPARE(blackRect->scale(), 1.5); - 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/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index c957d2d702..39cb911647 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -171,7 +171,7 @@ public: lastVelocity = lastVelocityFromMouseMove = QVector2D(); lastMousePos = QPointF(); - lastMouseCapabilityFlags = 0; + lastMouseCapabilityFlags = {}; touchEventCount = 0; mouseMoveCount = 0; mouseUngrabEventCount = 0; @@ -199,7 +199,7 @@ public: QVector2D lastVelocity; QVector2D lastVelocityFromMouseMove; QPointF lastMousePos; - int lastMouseCapabilityFlags; + QInputDevice::Capabilities lastMouseCapabilityFlags; void touchEvent(QTouchEvent *event) { if (!acceptTouchEvents) { @@ -208,7 +208,7 @@ public: } ++touchEventCount; lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints()); - if (event->device()->capabilities().testFlag(QTouchDevice::Velocity) && !event->touchPoints().isEmpty()) { + if (event->device()->capabilities().testFlag(QPointingDevice::Capability::Velocity) && !event->touchPoints().isEmpty()) { lastVelocity = event->touchPoints().first().velocity(); } else { lastVelocity = QVector2D(); @@ -225,7 +225,7 @@ public: } mousePressCount = ++mousePressNum; lastMousePos = e->position().toPoint(); - lastMouseCapabilityFlags = QGuiApplicationPrivate::mouseEventCaps(e); + lastMouseCapabilityFlags = e->device()->capabilities(); } void mouseMoveEvent(QMouseEvent *e) { @@ -235,7 +235,7 @@ public: } mouseMoveCount = ++mouseMoveNum; lastVelocityFromMouseMove = QGuiApplicationPrivate::mouseEventVelocity(e); - lastMouseCapabilityFlags = QGuiApplicationPrivate::mouseEventCaps(e); + lastMouseCapabilityFlags = e->device()->capabilities(); lastMousePos = e->position().toPoint(); } @@ -246,7 +246,7 @@ public: } ++mouseReleaseNum; lastMousePos = e->position().toPoint(); - lastMouseCapabilityFlags = QGuiApplicationPrivate::mouseEventCaps(e); + lastMouseCapabilityFlags = e->device()->capabilities(); } void mouseUngrabEvent() { @@ -382,10 +382,10 @@ class tst_qquickwindow : public QQmlDataTest public: tst_qquickwindow() : touchDevice(QTest::createTouchDevice()) - , touchDeviceWithVelocity(QTest::createTouchDevice()) + , touchDeviceWithVelocity(QTest::createTouchDevice(QInputDevice::DeviceType::TouchScreen, + QInputDevice::Capability::Position | QPointingDevice::Capability::Velocity)) { QQuickWindow::setDefaultAlphaBuffer(true); - touchDeviceWithVelocity->setCapabilities(QTouchDevice::Position | QTouchDevice::Velocity); } private slots: @@ -501,8 +501,8 @@ private slots: void rendererInterfaceWithRenderControl(); private: - QTouchDevice *touchDevice; - QTouchDevice *touchDeviceWithVelocity; + QPointingDevice *touchDevice; + QPointingDevice *touchDeviceWithVelocity; }; #if QT_CONFIG(opengl) @@ -1185,7 +1185,7 @@ void tst_qquickwindow::mouseFromTouch_basic() QCOMPARE(item->mouseReleaseNum, 1); QCOMPARE(item->lastMousePos.toPoint(), item->mapFromScene(points[0].position()).toPoint()); QCOMPARE(item->lastVelocityFromMouseMove, velocity); - QVERIFY((item->lastMouseCapabilityFlags & QTouchDevice::Velocity) != 0); +// QVERIFY(item->lastMouseCapabilityFlags.testFlag(QInputDevice::Capability::Velocity)); // TODO // Now the same with a transformation. item->setRotation(90); // clockwise @@ -2850,7 +2850,7 @@ void tst_qquickwindow::pointerEventTypeAndPointCount() QList() << QTouchEvent::TouchPoint(1)); - QQuickPointerMouseEvent pme(nullptr, QQuickPointerDevice::genericMouseDevice()); + QQuickPointerMouseEvent pme(nullptr, QPointingDevice::primaryPointingDevice()); pme.reset(&me); QCOMPARE(pme.asMouseEvent(localPosition), &me); QVERIFY(pme.asPointerMouseEvent()); @@ -2862,7 +2862,7 @@ void tst_qquickwindow::pointerEventTypeAndPointCount() QCOMPARE(pme.asMouseEvent(localPosition)->position(), localPosition); QCOMPARE(pme.asMouseEvent(localPosition)->globalPosition(), screenPosition); - QQuickPointerTouchEvent pte(nullptr, QQuickPointerDevice::touchDevice(touchDevice)); + QQuickPointerTouchEvent pte(nullptr, touchDevice); pte.reset(&te); QCOMPARE(pte.asTouchEvent(), &te); QVERIFY(!pte.asPointerMouseEvent()); diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index b0d31e9121..9117df812a 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -173,7 +173,6 @@ class tst_TouchMouse : public QQmlDataTest Q_OBJECT public: tst_TouchMouse() - :device(QTest::createTouchDevice()) {} private slots: @@ -218,7 +217,7 @@ protected: private: QQuickView *createView(); - QTouchDevice *device; + QPointingDevice *device = QTest::createTouchDevice(); QList filteredEventList; }; @@ -613,7 +612,7 @@ void tst_TouchMouse::buttonOnFlickable() QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QVERIFY(windowPriv->touchMouseId != -1); - auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + auto pointerEvent = windowPriv->pointerEventInstance(device); QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1); QCOMPARE(window->mouseGrabberItem(), eventItem1); @@ -674,7 +673,7 @@ void tst_TouchMouse::touchButtonOnFlickable() QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QVERIFY(windowPriv->touchMouseId == -1); - auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + auto pointerEvent = windowPriv->pointerEventInstance(device); QCOMPARE(pointerEvent->point(0)->grabberItem(), eventItem2); QCOMPARE(window->mouseGrabberItem(), nullptr); @@ -808,7 +807,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // for the touchMouseId to the new grabber. QCOMPARE(window->mouseGrabberItem(), flickable); QVERIFY(windowPriv->touchMouseId != -1); - auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + auto pointerEvent = windowPriv->pointerEventInstance(device); QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable); } @@ -1464,10 +1463,6 @@ void tst_TouchMouse::touchPointDeliveryOrder() void tst_TouchMouse::hoverEnabled() { - // QTouchDevice *device = new QTouchDevice; - // device->setType(QTouchDevice::TouchScreen); - // QWindowSystemInterface::registerTouchDevice(device); - QScopedPointer window(createView()); window->setSource(testFileUrl("hoverMouseAreas.qml")); QQuickViewTestUtil::centerOnScreen(window.data()); diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 3f67006554..e205d2e8f2 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -146,7 +146,7 @@ private slots: void resizeOverlay(); private: - QTouchDevice *device = QTest::createTouchDevice(); + QPointingDevice *device = QTest::createTouchDevice(); const QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); }; -- cgit v1.2.3