aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/touchmouse
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
commit1fb1c6c4f8769250dffa375e3941738eb1fcc885 (patch)
tree4f4c4afae97b54a793a0589f8ca53b7c919de728 /tests/auto/quick/touchmouse
parentd0ce320646b7f852a24f6e0a9e9621ddcedef554 (diff)
parent9c1c471e54bb12e8740b76d1c048f2f916a6ab59 (diff)
Merge remote-tracking branch 'origin/dev' into wip/pointerhandler
Diffstat (limited to 'tests/auto/quick/touchmouse')
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp76
1 files changed, 72 insertions, 4 deletions
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index b02d60d0c5..6e7fce6189 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), point0(-1)
+ : QQuickItem(parent), touchUngrabCount(0), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1)
{
setAcceptedMouseButtons(Qt::LeftButton);
}
@@ -111,11 +111,17 @@ public:
eventList.append(Event(QEvent::UngrabMouse, QPoint(0,0), QPoint(0,0)));
}
+ void touchUngrabEvent()
+ {
+ ++touchUngrabCount;
+ }
+
bool event(QEvent *event) {
return QQuickItem::event(event);
}
QList<Event> eventList;
+ int touchUngrabCount;
bool acceptMouse;
bool acceptTouch;
bool filterTouch; // when used as event filter
@@ -158,6 +164,7 @@ private slots:
void mouseOverTouch();
void buttonOnFlickable();
+ void touchButtonOnFlickable();
void buttonOnDelayedPressFlickable_data();
void buttonOnDelayedPressFlickable();
void buttonOnTouch();
@@ -568,9 +575,10 @@ void tst_TouchMouse::buttonOnFlickable()
QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1);
QCOMPARE(window->mouseGrabberItem(), eventItem1);
- p1 += QPoint(0, -10);
- QPoint p2 = p1 + QPoint(0, -10);
- QPoint p3 = p2 + QPoint(0, -10);
+ int dragDelta = -qApp->styleHints()->startDragDistance();
+ p1 += QPoint(0, dragDelta);
+ QPoint p2 = p1 + QPoint(0, dragDelta);
+ QPoint p3 = p2 + QPoint(0, dragDelta);
QQuickTouchUtils::flush(window.data());
QTest::touchEvent(window.data(), device).move(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
@@ -593,6 +601,66 @@ void tst_TouchMouse::buttonOnFlickable()
QQuickTouchUtils::flush(window.data());
}
+void tst_TouchMouse::touchButtonOnFlickable()
+{
+ // flickable - height 500 / 1000
+ // - eventItem1 y: 100, height 100
+ // - eventItem2 y: 300, height 100
+
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("buttononflickable.qml"));
+ window->show();
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flickable);
+
+ EventItem *eventItem2 = window->rootObject()->findChild<EventItem*>("eventItem2");
+ QVERIFY(eventItem2);
+ QCOMPARE(eventItem2->eventList.size(), 0);
+ eventItem2->acceptTouch = true;
+
+ // 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.data(), device).press(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QCOMPARE(eventItem2->eventList.size(), 1);
+ QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin);
+
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
+ QVERIFY(windowPriv->touchMouseId == -1);
+ auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
+ QCOMPARE(pointerEvent->point(0)->grabberItem(), eventItem2);
+ QCOMPARE(window->mouseGrabberItem(), nullptr);
+
+ int dragDelta = qApp->styleHints()->startDragDistance() * -0.7;
+ p1 += QPoint(0, dragDelta);
+ QPoint p2 = p1 + QPoint(0, dragDelta);
+ QPoint p3 = p2 + QPoint(0, dragDelta);
+
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p2, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p3, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ QVERIFY(eventItem2->eventList.size() > 2);
+ QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate);
+ QCOMPARE(eventItem2->touchUngrabCount, 1);
+ QCOMPARE(window->mouseGrabberItem(), flickable);
+ QVERIFY(windowPriv->touchMouseId != -1);
+ QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable);
+ QVERIFY(flickable->isMovingVertically());
+
+ QTest::touchEvent(window.data(), device).release(0, p3, window.data());
+ QQuickTouchUtils::flush(window.data());
+}
+
void tst_TouchMouse::buttonOnDelayedPressFlickable_data()
{
QTest::addColumn<bool>("scrollBeforeDelayIsOver");