diff options
author | J-P Nurmi <jpnurmi@gmail.com> | 2015-08-28 18:53:15 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-03 10:48:48 +0000 |
commit | 067e55185497c46412c8d5353b8c984514d53580 (patch) | |
tree | 973a5487ded2b2191bb4bf4150343435e0acf0a0 /tests/auto/controls/data/tst_slider.qml | |
parent | bbfcde37af5936c2929446e085c5f122ed8d8341 (diff) |
Fix Slider position calculation to take paddings into account
When Slider had paddings set, the handle didn't follow the touch
point / mouse cursor. The larger paddings were set, the more the
handle was "off".
Change-Id: I82d97092a2c3fc99cba108fe011a463a571e5507
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls/data/tst_slider.qml')
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 04d328c8..e497636c 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -358,4 +358,77 @@ TestCase { control.destroy() } + + function test_padding() { + // test with "unbalanced" paddings (left padding != right padding) to ensure + // that the slider position calculation is done taking padding into account + // ==> the position is _not_ 0.5 in the middle of the control + var control = slider.createObject(testCase, {leftPadding: 10, rightPadding: 20}) + verify(control) + + pressedSpy.target = control + verify(pressedSpy.valid) + + mousePress(control, 0, 0, Qt.LeftButton) + compare(pressedSpy.count, 1) + compare(control.pressed, true) + compare(control.value, 0.0) + compare(control.position, 0.0) + compare(control.visualPosition, 0.0) + + mouseMove(control, control.leftPadding + control.availableWidth * 0.5, control.height * 0.5, 0, Qt.LeftButton) + compare(pressedSpy.count, 1) + compare(control.pressed, true) + compare(control.value, 0.0) + compare(control.position, 0.5) + compare(control.visualPosition, 0.5) + + mouseMove(control, control.width * 0.5, control.height * 0.5, 0, Qt.LeftButton) + compare(pressedSpy.count, 1) + compare(control.pressed, true) + compare(control.value, 0.0) + verify(control.position > 0.5) + verify(control.visualPosition > 0.5) + + mouseRelease(control, control.leftPadding + control.availableWidth * 0.5, control.height * 0.5, Qt.LeftButton) + compare(pressedSpy.count, 2) + compare(control.pressed, false) + compare(control.value, 0.5) + compare(control.position, 0.5) + compare(control.visualPosition, 0.5) + + // RTL + control.value = 0 + control.layoutDirection = Qt.RightToLeft + + mousePress(control, 0, 0, Qt.LeftButton) + compare(pressedSpy.count, 3) + compare(control.pressed, true) + compare(control.value, 0.0) + compare(control.position, 0.0) + compare(control.visualPosition, 1.0) + + mouseMove(control, control.leftPadding + control.availableWidth * 0.5, control.height * 0.5, 0, Qt.LeftButton) + compare(pressedSpy.count, 3) + compare(control.pressed, true) + compare(control.value, 0.0) + compare(control.position, 0.5) + compare(control.visualPosition, 0.5) + + mouseMove(control, control.width * 0.5, control.height * 0.5, 0, Qt.LeftButton) + compare(pressedSpy.count, 3) + compare(control.pressed, true) + compare(control.value, 0.0) + verify(control.position < 0.5) + verify(control.visualPosition > 0.5) + + mouseRelease(control, control.leftPadding + control.availableWidth * 0.5, control.height * 0.5, Qt.LeftButton) + compare(pressedSpy.count, 4) + compare(control.pressed, false) + compare(control.value, 0.5) + compare(control.position, 0.5) + compare(control.visualPosition, 0.5) + + control.destroy() + } } |