summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-11-30 10:48:18 +0100
committerAndy Shaw <andy.shaw@qt.io>2018-04-17 09:06:20 +0000
commit0689a8256c0a21087c01fff3998fd3b606a5ac4c (patch)
tree06fc65bac9ec9570513b7f52b0028e4cc3e81691 /tests
parent71beceb772dedfcaa30eda8ce2ed146e835b59f9 (diff)
downloadqtquickcontrols-0689a8256c0a21087c01fff3998fd3b606a5ac4c.tar.gz
Slider: don't break the binding on value when using the mouse wheel
When the wheel was used it could cause any binding on value to be broken since it was updated directly. Going via range.position ensures this is not the case. Change-Id: Ic041ea911cee68de34f5c4e184cf8460f5e002da Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_slider.qml33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index e95d26d9..f6435314 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -439,5 +439,38 @@ Item {
control.destroy();
}
+
+ Component {
+ id: mouseWheelSlider
+ Slider {
+ property real boundValue: 10
+ width: 300
+ height: 50
+ minimumValue: 0
+ maximumValue: 200
+ stepSize: 2
+ value: boundValue
+ }
+ }
+
+ function test_mouseWheelWithValueBinding() {
+ var slider = createTemporaryObject(mouseWheelSlider, container)
+ slider.forceActiveFocus()
+
+ var defaultScrollSpeed = 20.0
+ var mouseStep = 15.0
+ var deltatUnit = 8.0
+ var mouseRatio = deltatUnit * mouseStep / defaultScrollSpeed;
+ var sliderDeltaRatio = 1; //(slider.maximumValue - slider.minimumValue)/slider.width
+ var ratio = mouseRatio / sliderDeltaRatio
+
+ compare(slider.value, 10)
+
+ mouseWheel(slider, 5, 5, -20 * ratio, 0)
+ compare(slider.value, 24)
+
+ slider.boundValue = 50
+ compare(slider.value, 50)
+ }
}
}