aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-06-14 19:08:52 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-06-16 08:45:49 +0000
commit0d851ddab069bd4373e90beacba0efa38ec021bb (patch)
tree7d80d3504c1f1e05a5b3caf5919989f4e37bd967 /tests/auto/controls
parente96fd5f39158f775d45ae9a60564f00454b789ed (diff)
QQuickSpinBox: emit valueModified() on long press
Move the emit inside QQuickSpinBoxPrivate::setValue() to avoid having to store and compare the old value in so many places where the value changes are interactive (mouse, keys, wheel). Task-number: QTBUG-61426 Change-Id: I7f42fc09cafc403eb55a9748e3a93c2e9bf6df62 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml103
1 files changed, 28 insertions, 75 deletions
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 4b2e38b3..eced19df 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -189,91 +189,44 @@ TestCase {
compare(control.down.indicator.enabled, true)
}
- function test_mouse() {
- var control = createTemporaryObject(spinBox, testCase, {stepSize: 50})
+ function test_mouse_data() {
+ return [
+ { tag: "up", button: "up", value: 50, enabled: true, hold: false, modified: 1, expected: 51 },
+ { tag: "down", button: "down", value: 50, enabled: true, hold: false, modified: 1, expected: 49 },
+ { tag: "up:disabled", button: "up", value: 99, enabled: false, hold: false, modified: 0, expected: 99 },
+ { tag: "down:disabled", button: "down", value: 0, enabled: false, hold: false, modified: 0, expected: 0 },
+ { tag: "up:hold", button: "up", value: 95, enabled: true, hold: true, modified: 4, expected: 99 },
+ { tag: "down:hold", button: "down", value: 5, enabled: true, hold: true, modified: 5, expected: 0 }
+ ]
+ }
+
+ function test_mouse(data) {
+ var control = createTemporaryObject(spinBox, testCase, {value: data.value})
verify(control)
- var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"})
- verify(upPressedSpy.valid)
+ var button = control[data.button]
+ verify(button)
- var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"})
- verify(downPressedSpy.valid)
+ var pressedSpy = signalSpy.createObject(control, {target: button, signalName: "pressedChanged"})
+ verify(pressedSpy.valid)
var valueModifiedSpy = signalSpy.createObject(control, {target: control, signalName: "valueModified"})
verify(valueModifiedSpy.valid)
- mousePress(control.up.indicator)
- compare(upPressedSpy.count, 1)
- compare(control.up.pressed, true)
- compare(downPressedSpy.count, 0)
- compare(control.down.pressed, false)
- compare(control.value, 0)
+ mousePress(button.indicator)
+ compare(pressedSpy.count, data.enabled ? 1 : 0)
+ compare(button.pressed, data.enabled)
+ compare(control.value, data.value)
compare(valueModifiedSpy.count, 0)
- mouseRelease(control.up.indicator)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(downPressedSpy.count, 0)
- compare(control.down.pressed, false)
- compare(control.value, 50)
- compare(valueModifiedSpy.count, 1)
-
- // Disable the up button and try again.
- control.value = control.to
- compare(control.up.indicator.enabled, false)
+ if (data.hold)
+ tryCompare(control, "value", data.expected)
- mousePress(control.up.indicator)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(downPressedSpy.count, 0)
- compare(control.down.pressed, false)
- compare(control.value, control.to)
- compare(valueModifiedSpy.count, 1)
-
- mouseRelease(control.up.indicator)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(downPressedSpy.count, 0)
- compare(control.down.pressed, false)
- compare(control.value, control.to)
- compare(valueModifiedSpy.count, 1)
-
- control.value = 50;
- mousePress(control.down.indicator)
- compare(downPressedSpy.count, 1)
- compare(control.down.pressed, true)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(control.value, 50)
- compare(valueModifiedSpy.count, 1)
-
- mouseRelease(control.down.indicator)
- compare(downPressedSpy.count, 2)
- compare(control.down.pressed, false)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(control.value, 0)
- compare(valueModifiedSpy.count, 2)
-
- // Disable the down button and try again.
- control.value = control.from
- compare(control.down.indicator.enabled, false)
-
- mousePress(control.down.indicator)
- compare(downPressedSpy.count, 2)
- compare(control.down.pressed, false)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(control.value, control.from)
- compare(valueModifiedSpy.count, 2)
-
- mouseRelease(control.down.indicator)
- compare(downPressedSpy.count, 2)
- compare(control.down.pressed, false)
- compare(upPressedSpy.count, 2)
- compare(control.up.pressed, false)
- compare(control.value, control.from)
- compare(valueModifiedSpy.count, 2)
+ mouseRelease(button.indicator)
+ compare(pressedSpy.count, data.enabled ? 2 : 0)
+ compare(button.pressed, false)
+ compare(control.value, data.expected)
+ compare(valueModifiedSpy.count, data.modified)
}
function test_keys() {