aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-19 15:19:40 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-19 16:36:55 +0000
commit935974e174d87f9bf10a56d14bb73ade726d827a (patch)
tree03bfc3f55da39c4c2202c9295a09623400bfdd77 /tests
parentfbe806c544a45c83f091109e04fab5d86620183f (diff)
Fix Switch to stay pressed as appropriate
Switch is a special type of button that should stay pressed (similarly to Slider) even if the finger slips outside the bounds of the control. It was doing that only when dragged from the handle, not when dragged from the background. Change-Id: I462c66cfe2e67fc3c95215ffeafe3e5771174418 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_switch.qml23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index ba41015f..1b77ff42 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -95,6 +95,29 @@ TestCase {
control.destroy()
}
+ function test_pressed_data() {
+ return [
+ { tag: "indicator", x: 15 },
+ { tag: "background", x: 5 }
+ ]
+ }
+
+ function test_pressed(data) {
+ var control = swtch.createObject(testCase, {padding: 10})
+ verify(control)
+
+ // stays pressed when dragged outside
+ compare(control.pressed, false)
+ mousePress(control, data.x, control.height / 2, Qt.LeftButton)
+ compare(control.pressed, true)
+ mouseMove(control, -1, control.height / 2)
+ compare(control.pressed, true)
+ mouseRelease(control, -1, control.height / 2, Qt.LeftButton)
+ compare(control.pressed, false)
+
+ control.destroy()
+ }
+
function test_mouse() {
var control = swtch.createObject(testCase)
verify(control)