aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/touchmouse
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@theqtcompany.com>2016-10-12 10:50:22 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2016-10-20 17:41:35 +0000
commit2369fab86c545af8fb7a86dbb05fd32f1388a510 (patch)
treee66f1c579c23bffa60eb3e42905d3586dc57f9a8 /tests/auto/quick/touchmouse
parent82a5bb18d201bc8d2f4c0df6573bcfcefd64e73a (diff)
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 <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/quick/touchmouse')
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp17
1 files changed, 12 insertions, 5 deletions
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<QTouchEvent::TouchPoint> 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<QTouchEvent*>(event);
eventList.append(Event(event->type(), touch->touchPoints()));
+ QList<QTouchEvent::TouchPoint> 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<int> ids;
- ids.append(0);
+ ids.append(leftItem->point0);
rightItem->grabTouchPoints(ids);
}