diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-04-05 11:25:43 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-04-05 09:38:43 +0000 |
commit | 98a65a9c74e148758be1619b1fd3844f3f31c789 (patch) | |
tree | 4ab9011782aa3b6168c88ffcb1f2ec52e707e25d /tests | |
parent | 583b7b0324a03337b8f21b5c2eacb6657c16ade7 (diff) |
RangeSlider: add valueAt() function
This is necessary to e.g. show up-to-date values in tooltips for each
handle when live is set to false. It's copied from Slider.
[ChangeLog][Controls][RangeSlider] Added a valueAt() function to allow
accessing each handle's value when the live property is set to false.
Task-number: QTBUG-67317
Change-Id: I8d0ca1a914f983b6b950ece759a102c05c5dd2f0
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_rangeslider.qml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 31ab8332..03b34a2a 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -1061,4 +1061,25 @@ TestCase { compare(visualPositionSpy2.count, ++visualPositionCount2) touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() } + + function test_valueAt_data() { + return [ + { tag: "0.0..1.0", from: 0.0, to: 1.0, values: [0.0, 0.2, 0.5, 1.0] }, + { tag: "0..100", from: 0, to: 100, values: [0, 20, 50, 100] }, + { tag: "100..-100", from: 100, to: -100, values: [100, 60, 0, -100] }, + { tag: "-7..7", from: -7, to: 7, stepSize: 1.0, values: [-7.0, -4.0, 0.0, 7.0] }, + { tag: "-3..7", from: -3, to: 7, stepSize: 5.0, values: [-3.0, -3.0, 2.0, 7.0] }, + ] + } + + function test_valueAt(data) { + var control = createTemporaryObject(sliderComponent, testCase, + { from: data.from, to: data.to, stepSize: data.stepSize }) + verify(control) + + compare(control.valueAt(0.0), data.values[0]) + compare(control.valueAt(0.2), data.values[1]) + compare(control.valueAt(0.5), data.values[2]) + compare(control.valueAt(1.0), data.values[3]) + } } |