diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-01-20 16:01:51 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-01-20 15:26:30 +0000 |
commit | 7f2a5162511f5ce47ce8ff2b7e90071cedab37f9 (patch) | |
tree | 916b59627d936427564f765512c19ca1119a16ea /tests | |
parent | 6c0ee76c646778d6a45018acc8d561c5a5d931f8 (diff) |
QQuickScrollBar: fix overshoot
ScrollBar should not always force a range of 0.0-1.0, but only when
interacted with. This way, the scrollbar stops at bounds when dragged,
but flicking the attached Flickable respects its boundsBehavior and
overshoots if appropriate.
The logic and test is adapted from QQuickScrollIndicator commit 8d093a.
Change-Id: Ida720d4cc2bb1de06ba0c02dfb25be51dd3108fc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_scrollbar.qml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 0a7fab9e..cf1a8559 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -492,4 +492,38 @@ TestCase { compare(control.visible, true) verify(control.state === "active" || control.contentItem.state === "active") } + + function test_overshoot() { + var container = flickable.createObject(testCase) + verify(container) + waitForRendering(container) + + var vertical = scrollBar.createObject(container, {size: 0.5}) + container.ScrollBar.vertical = vertical + + var horizontal = scrollBar.createObject(container, {size: 0.5}) + container.ScrollBar.horizontal = horizontal + + // negative vertical overshoot (pos < 0) + vertical.position = -0.1 + compare(vertical.contentItem.y, vertical.topPadding) + compare(vertical.contentItem.height, 0.4 * vertical.availableHeight) + + // positive vertical overshoot (pos + size > 1) + vertical.position = 0.8 + compare(vertical.contentItem.y, vertical.topPadding + 0.8 * vertical.availableHeight) + compare(vertical.contentItem.height, 0.2 * vertical.availableHeight) + + // negative horizontal overshoot (pos < 0) + horizontal.position = -0.1 + compare(horizontal.contentItem.x, horizontal.leftPadding) + compare(horizontal.contentItem.width, 0.4 * horizontal.availableWidth) + + // positive horizontal overshoot (pos + size > 1) + horizontal.position = 0.8 + compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth) + compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth) + + container.destroy() + } } |