diff options
Diffstat (limited to 'tests/auto/controls/data/tst_slider.qml')
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index a831e402..368bc9fd 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -804,4 +804,66 @@ 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) + + touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() + } } |