diff options
author | Yulong Bai <yulong.bai@qt.io> | 2018-03-02 14:31:36 +0100 |
---|---|---|
committer | Yulong Bai <yulong.bai@qt.io> | 2018-03-12 12:08:24 +0000 |
commit | b6dbfe623ab6df58ccb7bf8a922eb853fc10155a (patch) | |
tree | 0b50cbc8f30246fa96b0ee7b49273172cfd0d826 /tests | |
parent | 41dd1405d5c5bfac05f9c42a4c4017de5075f5cc (diff) |
QQuickSlider: add touchDragThreshold property
Add touchDragThreshold property for configuring the threshold to initiate a 'drag',
i.e. touch move, of the handle of the slider. The mouse 'drag' won't be affected
by the property.
This property may be also used to configure the drag events stealing priorities
of nested draggable items in the future.
[ChangeLog][Slider] Added touchDragThreshold property for configuring the threshold
to initiate the touch 'drag' of the handle of the slider. The mouse 'drag' won't be
affected by the property.
Task-number: QTBUG-62784
Change-Id: Ifaeea4653b48c44efbe7e1cb09d399a91359c16a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index a831e402..39e0ea17 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -804,4 +804,64 @@ TestCase { mouseRelease(control) compare(control.pressed, false) } + + function test_touchDragThreshold_data() { + var d1 = 3; var d2 = 7; + return [ + { tag: "horizontal", orientation: Qt.Horizontal, dx1: d1, dy1: 0, dx2: d2, dy2: 0 }, + { tag: "vertical", orientation: Qt.Vertical, dx1: 0, dy1: -d1, dx2: 0, dy2: -d2 }, + { tag: "horizontal2", orientation: Qt.Horizontal, dx1: -d1, dy1: 0, dx2: -d2, dy2: 0 }, + { tag: "vertical2", orientation: Qt.Vertical, dx1: 0, dy1: d1, dx2: 0, dy2: d2 } + ] + } + + function test_touchDragThreshold(data) { + var control = createTemporaryObject(slider, testCase, {touchDragThreshold: 10, live: true, orientation: data.orientation, value: 0.5}) + verify(control) + compare(control.touchDragThreshold, 10) + + var valueChangedCount = 0 + var valueChangedSpy = signalSpy.createObject(control, {target: control, signalName: "touchDragThresholdChanged"}) + verify(valueChangedSpy.valid) + + control.touchDragThreshold = undefined + compare(control.touchDragThreshold, -1) // reset to -1 + compare(valueChangedSpy.count, ++valueChangedCount) + + var t = 5 + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, ++valueChangedCount) + + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, valueChangedCount) + + var pressedCount = 0 + var movedCount = 0 + + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) + verify(pressedSpy.valid) + + var movedSpy = signalSpy.createObject(control, {target: control, signalName: "moved"}) + verify(movedSpy.valid) + + var touch = touchEvent(control) + var x0 = control.handle.x + control.handle.width * 0.5 + var y0 = control.handle.y + control.handle.height * 0.5 + touch.press(0, control, x0, y0).commit() + compare(pressedSpy.count, ++pressedCount) + compare(movedSpy.count, movedCount) + compare(control.pressed, true) + + touch.move(0, control, x0 + data.dx1, y0 + data.dy1).commit() + compare(pressedSpy.count, pressedCount) + compare(movedSpy.count, movedCount) // shouldn't move + compare(control.pressed, true) + + touch.move(0, control, x0 + data.dx2, y0 + data.dy2).commit() + compare(pressedSpy.count, pressedCount) + compare(movedSpy.count, ++movedCount) + compare(control.pressed, true) + } } |