diff options
Diffstat (limited to 'tests/auto/quickcontrols/controls/data/tst_tumbler.qml')
-rw-r--r-- | tests/auto/quickcontrols/controls/data/tst_tumbler.qml | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/tests/auto/quickcontrols/controls/data/tst_tumbler.qml b/tests/auto/quickcontrols/controls/data/tst_tumbler.qml index bb098f92db..c5c567b7d2 100644 --- a/tests/auto/quickcontrols/controls/data/tst_tumbler.qml +++ b/tests/auto/quickcontrols/controls/data/tst_tumbler.qml @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtTest @@ -464,7 +464,10 @@ TestCase { ]; for (var i = 0; i < data.length; ++i) { var row = data[i]; - row.tag = "delegate" + row.index + " offset=" + row.offset + " expectedDisplacement=" + row.expectedDisplacement; + row.tag = "count=" + row.count + + " delegate" + row.index + + " offset=" + row.offset + + " expectedDisplacement=" + row.expectedDisplacement; } return data; } @@ -1244,4 +1247,46 @@ TestCase { tumbler = createTemporaryObject(initialCurrentIndexTumbler, testCase, {wrap: false}); compare(tumbler.currentIndex, 4); } + + // QTBUG-109995 + Component { + id: flickTumbler + Flickable { + width: 50 + height: 200 + interactive: true + contentHeight: 400 + property alias tumblerItem: noWrapTumbler + Tumbler { + id: noWrapTumbler + anchors.fill: parent + model: 20 + wrap: false + } + } + } + + function test_flick() { + let control = createTemporaryObject(flickTumbler, testCase) + verify(control) + + let tumbler = control.tumblerItem + compare(tumbler.count, 20) + compare(tumbler.wrap, false) + + let touch = touchEvent(tumbler) + let tumblerView = findView(tumbler) + let delegateHeight = tumblerView.children[0].children[0].height + + // Move delegates through touch operation and check the current index + touch.press(0, tumblerView, control.width / 2, control.height / 2).commit() + // Move slowly, otherwise its considered as flick which cause current index + // to be varied according to its velocity + var scrollOffset = control.height / 2 + for (; scrollOffset > delegateHeight / 2; scrollOffset-=5) { + touch.move(0, tumblerView, control.width / 2, scrollOffset).commit() + } + touch.release(0, tumblerView, control.width / 2, scrollOffset).commit() + tryCompare(tumblerView, "currentIndex", 2) + } } |