diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2015-10-13 17:53:33 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2015-10-21 14:07:36 +0000 |
commit | 32d11f2d679b811c9af349fe9f0b0b29d4f598c0 (patch) | |
tree | b06172d8797d3b401e824861d51ab4cb6b57ca30 /tests/auto/controls/data/tst_slider.qml | |
parent | 61889f06fa828b483513b8315b4f0870532ece66 (diff) | |
download | qtquickcontrols-32d11f2d679b811c9af349fe9f0b0b29d4f598c0.tar.gz |
Avoid real-rounding glitches near ends of a slider's range.
Floating point doesn't quite reliably satisfy certain standard
identities of arithmetic ...
Task-number: QTBUG-42358
Change-Id: I7417feedbfc1fd6f59510e0ee6d07d98ff7ddc46
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls/data/tst_slider.qml')
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 305605f6..1589f2ab 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -330,5 +330,32 @@ Item { control.destroy() } + + function test_dragRounding() { + // Regression test: ends of range should be exact, not 99.99999999 &c. + var component = Qt.createComponent("slider/rounder.qml") + compare(component.status, Component.Ready) + var control = component.createObject(container) + + // Does moving to maximum (100) actually reach it ? + mousePress(control, 0, control.waist) + mouseMove(control, control.width, control.waist) + mouseRelease(control, control.width, control.waist) + // Equality checks are dodgy with floats, but this should still be exact: + verify(control.value == 100) + // Neither of the following caught the bug, with value 100 -1.421e-14 + // compare(control.value, 100) + // fuzzyCompare(control.value, 100, 1e-16) + + // Now check it all works going the other way, too: + mousePress(control, control.width, control.waist) + mouseMove(control, 0, control.waist) + mouseRelease(control, 0, control.waist) + verify(control.value == 0) + + // Tidy up. + control.destroy() + component.destroy() + } } } |