diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-13 22:05:02 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-17 14:32:16 +0100 |
commit | 3073a81e90c8d835dfccccf8b3a080a93ed0d2af (patch) | |
tree | 2338c61c994ac73a2fb05e20f866d8aed6d89bd1 /tests/auto/quick/qquickflickable | |
parent | ae79378d9000bafdfcbe3dcfcbb99e6ccd1f918f (diff) |
Add tst_qquickflickable::parallelTouch
Prove that we can drag multiple Flickables with multiple touchpoints now.
[ChangeLog][QtQuick][Flickable] Flickable now handles touch events directly:
you can now drag multiple Flickables with multiple touchpoints.
Fixes: QTBUG-30840
Change-Id: I0a3e58595a67f5afb4b93ad64d5280cb3fc52f7a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r-- | tests/auto/quick/qquickflickable/data/parallel.qml | 67 | ||||
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 43 |
2 files changed, 110 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/parallel.qml b/tests/auto/quick/qquickflickable/data/parallel.qml new file mode 100644 index 0000000000..4259173e9f --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/parallel.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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.0 + +Row { + id: root + width: 320 + height: 480 + Flickable { + id: fl1 + objectName: "fl1" + width: parent.width / 2 + height: parent.height + contentHeight: 640 + Rectangle { + width: fl1.width + height: 640 + color: fl1.dragging ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + text: "flick this" + } + } + } + Flickable { + id: fl2 + objectName: "fl2" + width: parent.width / 2 + height: parent.height + contentHeight: 640 + Rectangle { + width: fl2.width + height: 640 + color: fl2.dragging ? "bisque" : "beige" + Text { + anchors.centerIn: parent + text: "and flick\nthis too" + } + } + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index eb6ad494b4..310ab17db4 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -44,6 +44,8 @@ #include <qpa/qwindowsysteminterface.h> +Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests") + using namespace QQuickViewTestUtil; using namespace QQuickVisualTestUtil; @@ -201,6 +203,7 @@ private slots: void synchronousDrag_data(); void synchronousDrag(); void visibleAreaBinding(); + void parallelTouch(); private: void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to); @@ -2545,6 +2548,46 @@ void tst_qquickflickable::visibleAreaBinding() // Shouldn't crash. } +void tst_qquickflickable::parallelTouch() // QTBUG-30840 +{ + const int threshold = qApp->styleHints()->startDragDistance(); + QQuickView view; + view.setSource(testFileUrl("parallel.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(view.rootObject()); + QQuickFlickable *flickable1 = view.rootObject()->findChild<QQuickFlickable*>("fl1"); + QVERIFY(flickable1); + QQuickFlickable *flickable2 = view.rootObject()->findChild<QQuickFlickable*>("fl2"); + QVERIFY(flickable2); + + // Drag both in parallel via touch, opposite directions + QPoint p0(80, 240); + QPoint p1(240, 240); + QTest::touchEvent(&view, touchDevice).press(0, p0, &view).press(1, p1, &view); + int began1After = -1; + int began2After = -1; + for (int i = 0; i < 8; ++i) { + p0 += QPoint(0, threshold); + p1 -= QPoint(0, threshold); + QTest::touchEvent(&view, touchDevice).move(0, p0, &view).move(1, p1, &view); + QQuickTouchUtils::flush(&view); + if (began1After < 0 && flickable1->isDragging()) + began1After = i; + if (began2After < 0 && flickable2->isDragging()) + began2After = i; + } + qCDebug(lcTests, "flickables began dragging after %d and %d events respectively", began1After, began2After); + QVERIFY(flickable1->isDraggingVertically()); + QVERIFY(flickable2->isDraggingVertically()); + QCOMPARE(began1After, 2); + QCOMPARE(began2After, 2); + QTest::touchEvent(&view, touchDevice).release(0, p0, &view).release(1, p1, &view); + QTRY_VERIFY(!flickable1->isMoving()); + QTRY_VERIFY(!flickable2->isMoving()); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |