summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-09-12 17:06:04 +0200
committerMitch Curtis <mitch.curtis@qt.io>2016-09-14 07:54:56 +0000
commit5d4e7366718d3784063bdf64725a5371355f179a (patch)
tree74bc2bc3e1b99009d9ea978e1bf9a7148156f46a /tests
parent3aee127f969cabec0819d93d305d47afc4cf25d6 (diff)
downloadqtquickcontrols-5d4e7366718d3784063bdf64725a5371355f179a.tar.gz
Slider: fix the handle's position when minimumValue is not 0
__handlePos (badly named; it should be, e.g. __handleValueForPos) represents the value of the handle based on "fakeHandle"'s position. It is the result of range.valueForPosition() being called. However, the arguments to this function (fakeHandle.x and fakeHandle.y) don't always change when the values of the slider change, which leads to the x calculation for the handle delegate in SliderStyle having outdated information, causing the related bug. The fix for another bug already works around this issue by passing the relevant properties as arguments (which are ignored) to the function call. This is presumably done this way because it should be cheaper than forcing the JavaScript engine to evaluate a more clearly written expression where each related property is on its own line, for example. property real __handlePos: { range.positionAtMinimum, range.positionAtMaximum; return range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y); } In the case of the related bug, minimumValue has been updated, but __handlePos is still using the old value, causing the handle to be positioned incorrectly. So, we continue this tradition and add another property to the list of arguments. Task-number: QTBUG-51765 Change-Id: I40882872e668a867a8f5e5768244e199618bd769 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_slider.qml40
1 files changed, 38 insertions, 2 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 83ba299e..9b79bc29 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -38,11 +38,12 @@
**
****************************************************************************/
-import QtQuick 2.2
+import QtQuick 2.6
import QtTest 1.0
import QtQuickControlsTests 1.0
-import QtQuick.Controls 1.2
+import QtQuick.Controls 1.4
import QtQuick.Controls.Private 1.0
+import QtQuick.Controls.Styles 1.4
Item {
id: container
@@ -64,6 +65,12 @@ Item {
id: util
}
+ Component {
+ id: sliderComponent
+
+ Slider {}
+ }
+
function test_vertical() {
var slider = Qt.createQmlObject('import QtQuick.Controls 1.2; Slider {}', testCase, '');
verify(slider.height < slider.width)
@@ -361,5 +368,34 @@ Item {
control.destroy()
component.destroy()
}
+
+ Component {
+ id: namedHandleStyle
+
+ SliderStyle {
+ handle: Rectangle {
+ objectName: "sliderHandle"
+ implicitWidth: 20
+ implicitHeight: 20
+ color: "salmon"
+ }
+ }
+ }
+
+ function test_minimumValueLargerThanValue() {
+ var control = sliderComponent.createObject(container, { "style": namedHandleStyle, "minimumValue": 0, "maximumValue": 2, value: "minimumValue" });
+ verify(control);
+
+ var handle = findChild(control, "sliderHandle");
+ verify(handle);
+
+ // The handle should stay within the bounds of the slider when
+ // minimumValue is set to a value larger than "value".
+ control.minimumValue = 1;
+ compare(control.value, control.minimumValue);
+ compare(handle.mapToItem(null, 0, 0).x, 0)
+
+ control.destroy();
+ }
}
}