From 2369fab86c545af8fb7a86dbb05fd32f1388a510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 12 Oct 2016 10:50:22 +0200 Subject: Relax assumptions of the value of the touchMouseId This is needed in order to be able to integrate a change that mangles the device identifier into the touch point id in qtbase Change-Id: I7675ade377da51f8da31830c7d43875487680845 Reviewed-by: Frederik Gladhorn --- tests/auto/quick/touchmouse/tst_touchmouse.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tests/auto/quick/touchmouse') diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 309c01dcdc..b5af61d723 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -71,7 +71,7 @@ Q_SIGNALS: public: EventItem(QQuickItem *parent = 0) - : QQuickItem(parent), acceptMouse(false), acceptTouch(false), filterTouch(false) + : QQuickItem(parent), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1) { setAcceptedMouseButtons(Qt::LeftButton); } @@ -79,6 +79,9 @@ public: void touchEvent(QTouchEvent *event) { eventList.append(Event(event->type(), event->touchPoints())); + QList tps = event->touchPoints(); + Q_ASSERT(!tps.isEmpty()); + point0 = tps.first().id(); event->setAccepted(acceptTouch); emit onTouchEvent(this); } @@ -125,12 +128,16 @@ public: event->type() == QEvent::TouchEnd) { QTouchEvent *touch = static_cast(event); eventList.append(Event(event->type(), touch->touchPoints())); + QList tps = touch->touchPoints(); + Q_ASSERT(!tps.isEmpty()); + point0 = tps.first().id(); if (filterTouch) event->accept(); return true; } return false; } + int point0; }; class tst_TouchMouse : public QQmlDataTest @@ -581,7 +588,7 @@ void tst_TouchMouse::buttonOnFlickable() QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window); - QCOMPARE(windowPriv->touchMouseId, 0); + QVERIFY(windowPriv->touchMouseId != -1); auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); QCOMPARE(pointerEvent->point(0)->grabber(), eventItem1); QCOMPARE(window->mouseGrabberItem(), eventItem1); @@ -603,7 +610,7 @@ void tst_TouchMouse::buttonOnFlickable() QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove); QCOMPARE(window->mouseGrabberItem(), flickable); - QCOMPARE(windowPriv->touchMouseId, 0); + QVERIFY(windowPriv->touchMouseId != -1); QCOMPARE(pointerEvent->point(0)->grabber(), flickable); QVERIFY(flickable->isMovingVertically()); @@ -710,7 +717,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // flickable should have the mouse grab, and have moved the itemForTouchPointId // for the touchMouseId to the new grabber. QCOMPARE(window->mouseGrabberItem(), flickable); - QCOMPARE(windowPriv->touchMouseId, 0); + QVERIFY(windowPriv->touchMouseId != -1); auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); QCOMPARE(pointerEvent->point(0)->grabber(), flickable); @@ -1246,7 +1253,7 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab() rightItem->acceptTouch = true; { QVector ids; - ids.append(0); + ids.append(leftItem->point0); rightItem->grabTouchPoints(ids); } -- cgit v1.2.3