aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 10:24:20 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 10:24:20 +0100
commit5030a9d8c6a3422d5803d21937cbe9753975e019 (patch)
tree8044b34c0d8161671f404a09c50e8fb2490146d4 /tests/auto/quick
parent8fd3cfe7d0f39a731c585334299f5160ad952df9 (diff)
parent4ed072432172398d753d1664244d74548704c107 (diff)
Merge remote-tracking branch 'origin/5.12.1' into 5.12
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/data/multiPointTracker.qml86
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp79
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml2
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp54
4 files changed, 221 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/data/multiPointTracker.qml b/tests/auto/quick/pointerhandlers/qquickpointhandler/data/multiPointTracker.qml
new file mode 100644
index 0000000000..3f50d7c761
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/data/multiPointTracker.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Item {
+ id: root
+ width: 400; height: 400
+
+ PointHandler {
+ id: ph1
+ objectName: "ph1"
+
+ target: Rectangle {
+ parent: root
+ visible: ph1.active
+ x: ph1.point.position.x - width / 2
+ y: ph1.point.position.y - height / 2
+ width: 140
+ height: width
+ radius: width / 2
+ color: "orange"
+ opacity: 0.3
+ }
+ }
+
+ PointHandler {
+ id: ph2
+ objectName: "ph2"
+
+ target: Rectangle {
+ parent: root
+ visible: ph2.active
+ x: ph2.point.position.x - width / 2
+ y: ph2.point.position.y - height / 2
+ width: 140
+ height: width
+ radius: width / 2
+ color: "orange"
+ opacity: 0.3
+ }
+ }
+
+ PointHandler {
+ id: ph3
+ objectName: "ph3"
+
+ target: Rectangle {
+ parent: root
+ visible: ph3.active
+ x: ph3.point.position.x - width / 2
+ y: ph3.point.position.y - height / 2
+ width: 140
+ height: width
+ radius: width / 2
+ color: "orange"
+ opacity: 0.3
+ }
+ }
+}
+
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
index d91c89d833..d0b3bc3d36 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
@@ -55,6 +55,7 @@ private slots:
void initTestCase();
void singleTouch();
+ void simultaneousMultiTouch();
void pressedMultipleButtons_data();
void pressedMultipleButtons();
@@ -135,6 +136,84 @@ void tst_PointHandler::singleTouch()
QCOMPARE(translationSpy.count(), 3);
}
+void tst_PointHandler::simultaneousMultiTouch()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "multiPointTracker.qml");
+ QQuickView * window = windowPtr.data();
+ QList<QQuickPointHandler *> handlers = window->rootObject()->findChildren<QQuickPointHandler *>();
+ QCOMPARE(handlers.count(), 3);
+
+ QVector<QSignalSpy*> activeSpies;
+ QVector<QSignalSpy*> pointSpies;
+ QVector<QSignalSpy*> translationSpies;
+ QVector<QPoint> points{{100,100}, {200, 200}, {100, 300}};
+ QVector<QPoint> pressPoints = points;
+ for (auto h : handlers) {
+ activeSpies << new QSignalSpy(h, SIGNAL(activeChanged()));
+ pointSpies << new QSignalSpy(h, SIGNAL(pointChanged()));
+ translationSpies << new QSignalSpy(h, SIGNAL(translationChanged()));
+ }
+
+ QTest::touchEvent(window, touchDevice).press(1, points[0], window).press(2, points[1], window).press(3, points[2], window);
+ QQuickTouchUtils::flush(window);
+ QVector<int> pointIndexPerHandler;
+ int i = 0;
+ for (auto h : handlers) {
+ QTRY_COMPARE(h->active(), true);
+ QCOMPARE(activeSpies[i]->count(), 1);
+ QCOMPARE(pointSpies[i]->count(), 1);
+ int chosenPointIndex = points.indexOf(h->point().position().toPoint());
+ QVERIFY(chosenPointIndex != -1);
+ // Verify that each handler chose a unique point
+ QVERIFY(!pointIndexPerHandler.contains(chosenPointIndex));
+ pointIndexPerHandler.append(chosenPointIndex);
+ QPoint point = points[chosenPointIndex];
+ QCOMPARE(h->point().scenePosition().toPoint(), point);
+ QCOMPARE(h->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(h->translation(), QVector2D());
+ QCOMPARE(translationSpies[i]->count(), 1);
+ ++i;
+ }
+
+ for (int i = 0; i < 3; ++i)
+ points[i] += QPoint(10 + 10 * i, 10 + 10 * i % 2);
+ QTest::touchEvent(window, touchDevice).move(1, points[0], window).move(2, points[1], window).move(3, points[2], window);
+ QQuickTouchUtils::flush(window);
+ i = 0;
+ for (auto h : handlers) {
+ QCOMPARE(h->active(), true);
+ QCOMPARE(activeSpies[i]->count(), 1);
+ QCOMPARE(pointSpies[i]->count(), 2);
+ QCOMPARE(h->point().position().toPoint(), points[pointIndexPerHandler[i]]);
+ QCOMPARE(h->point().scenePosition().toPoint(), points[pointIndexPerHandler[i]]);
+ QCOMPARE(h->point().pressPosition().toPoint(), pressPoints[pointIndexPerHandler[i]]);
+ QCOMPARE(h->point().scenePressPosition().toPoint(), pressPoints[pointIndexPerHandler[i]]);
+ QCOMPARE(h->point().pressedButtons(), Qt::NoButton);
+ QVERIFY(h->point().velocity().x() > 0);
+ QVERIFY(h->point().velocity().y() > 0);
+ QCOMPARE(h->translation(), QVector2D(10 + 10 * pointIndexPerHandler[i], 10 + 10 * pointIndexPerHandler[i] % 2));
+ QCOMPARE(translationSpies[i]->count(), 2);
+ ++i;
+ }
+
+ QTest::touchEvent(window, touchDevice).release(1, points[0], window).release(2, points[1], window).release(3, points[2], window);
+ QQuickTouchUtils::flush(window);
+ i = 0;
+ for (auto h : handlers) {
+ QTRY_COMPARE(h->active(), false);
+ QCOMPARE(activeSpies[i]->count(), 2);
+ QCOMPARE(pointSpies[i]->count(), 3);
+ QCOMPARE(h->translation(), QVector2D());
+ QCOMPARE(translationSpies[i]->count(), 3);
+ ++i;
+ }
+
+ qDeleteAll(activeSpies);
+ qDeleteAll(pointSpies);
+ qDeleteAll(translationSpies);
+}
+
void tst_PointHandler::pressedMultipleButtons_data()
{
QTest::addColumn<Qt::MouseButtons>("accepted");
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
index ba22e434ce..221e7df139 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
@@ -35,6 +35,7 @@ Rectangle {
property bool checked: false
property alias gesturePolicy: tap.gesturePolicy
signal tapped
+ signal canceled
width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0
border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true
@@ -52,6 +53,7 @@ Rectangle {
tapFlash.start()
root.tapped()
}
+ onCanceled: root.canceled()
}
Text {
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index ab6fa0dbe4..33cea69147 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -59,6 +59,7 @@ private slots:
void touchGesturePolicyDragThreshold();
void mouseGesturePolicyDragThreshold();
+ void touchMouseGesturePolicyDragThreshold();
void touchGesturePolicyWithinBounds();
void mouseGesturePolicyWithinBounds();
void touchGesturePolicyReleaseWithinBounds();
@@ -180,6 +181,59 @@ void tst_TapHandler::mouseGesturePolicyDragThreshold()
QCOMPARE(dragThresholdTappedSpy.count(), 0);
}
+void tst_TapHandler::touchMouseGesturePolicyDragThreshold()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "buttons.qml");
+ QQuickView * window = windowPtr.data();
+
+ QQuickItem *buttonDragThreshold = window->rootObject()->findChild<QQuickItem*>("DragThreshold");
+ QVERIFY(buttonDragThreshold);
+ QSignalSpy tappedSpy(buttonDragThreshold, SIGNAL(tapped()));
+ QSignalSpy canceledSpy(buttonDragThreshold, SIGNAL(canceled()));
+
+ // Press mouse, drag it outside the button, release
+ QPoint p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
+ QPoint p2 = p1 + QPoint(int(buttonDragThreshold->height()), 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::mouseMove(window, p2);
+ QTRY_COMPARE(canceledSpy.count(), 1);
+ QCOMPARE(tappedSpy.count(), 0);
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p2);
+
+ // Press and release touch, verify that it still works (QTBUG-71466)
+ QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::touchEvent(window, touchDevice).release(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
+ QCOMPARE(tappedSpy.count(), 1);
+
+ // Press touch, drag it outside the button, release
+ QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::touchEvent(window, touchDevice).move(1, p2, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+ QTest::touchEvent(window, touchDevice).release(1, p2, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(canceledSpy.count(), 2);
+ QCOMPARE(tappedSpy.count(), 1); // didn't increase
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+
+ // Press and release mouse, verify that it still works
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_COMPARE(tappedSpy.count(), 2);
+ QCOMPARE(canceledSpy.count(), 2); // didn't increase
+ QCOMPARE(buttonDragThreshold->property("pressed").toBool(), false);
+}
+
void tst_TapHandler::touchGesturePolicyWithinBounds()
{
QScopedPointer<QQuickView> windowPtr;