aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_rangeslider.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/controls/data/tst_rangeslider.qml')
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml54
1 files changed, 20 insertions, 34 deletions
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml
index cc12b851..3167be0b 100644
--- a/tests/auto/controls/data/tst_rangeslider.qml
+++ b/tests/auto/controls/data/tst_rangeslider.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import Qt.labs.controls 1.0
+import QtQuick.Controls 2.0
TestCase {
id: testCase
@@ -50,14 +50,9 @@ TestCase {
when: windowShown
name: "RangeSlider"
- SignalSpy {
- id: firstPressedSpy
- signalName: "pressedChanged"
- }
-
- SignalSpy {
- id: secondPressedSpy
- signalName: "pressedChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -84,21 +79,6 @@ TestCase {
}
}
- function init() {
- verify(!firstPressedSpy.target)
- compare(firstPressedSpy.count, 0)
-
- verify(!secondPressedSpy.target)
- compare(secondPressedSpy.count, 0)
- }
-
- function cleanup() {
- firstPressedSpy.target = null
- firstPressedSpy.clear()
- secondPressedSpy.target = null
- secondPressedSpy.clear()
- }
-
function test_defaults() {
var control = sliderComponent.createObject(testCase)
verify(control)
@@ -303,10 +283,10 @@ TestCase {
var control = sliderComponent.createObject(testCase, { orientation: data.orientation })
verify(control)
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
- secondPressedSpy.target = control.second
+ var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"})
verify(secondPressedSpy.valid)
mousePress(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton)
@@ -473,7 +453,7 @@ TestCase {
var pressedCount = 0
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
control.first.handle.forceActiveFocus()
@@ -511,7 +491,7 @@ TestCase {
control.stepSize = 0.25
pressedCount = 0;
- secondPressedSpy.target = control.second
+ var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"})
verify(secondPressedSpy.valid)
control.second.handle.forceActiveFocus()
@@ -553,7 +533,7 @@ TestCase {
var control = sliderComponent.createObject(testCase, { leftPadding: 10, rightPadding: 20 })
verify(control)
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
mousePress(control, control.first.handle.x, control.first.handle.y, Qt.LeftButton)
@@ -621,18 +601,24 @@ TestCase {
function test_snapMode_data() {
return [
- { tag: "NoSnap", snapMode: Slider.NoSnap, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] },
- { tag: "SnapAlways", snapMode: Slider.SnapAlways, values: [0, 0, 0.2], positions: [0, 0.1, 0.1] },
- { tag: "SnapOnRelease", snapMode: Slider.SnapOnRelease, values: [0, 0, 0.2], positions: [0, 0.1, 0.1] }
+ { tag: "NoSnap", snapMode: RangeSlider.NoSnap, from: 0, to: 2, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] },
+ { tag: "SnapAlways (0..2)", snapMode: RangeSlider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapAlways (1..3)", snapMode: RangeSlider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapAlways (-1..1)", snapMode: RangeSlider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapAlways (1..-1)", snapMode: RangeSlider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapOnRelease (0..2)", snapMode: RangeSlider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapOnRelease (1..3)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapOnRelease (-1..1)", snapMode: RangeSlider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapOnRelease (1..-1)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] }
]
}
function test_snapMode(data) {
- var control = sliderComponent.createObject(testCase, {snapMode: data.snapMode, from: 0, to: 2, stepSize: 0.2})
+ var control = sliderComponent.createObject(testCase, {snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
verify(control)
control.first.value = 0
- control.second.value = 2
+ control.second.value = data.to
function sliderCompare(left, right) {
return Math.abs(left - right) < 0.05