summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/tst_slider.qml
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@theqtcompany.com>2015-10-13 17:53:33 +0200
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2015-10-21 14:07:36 +0000
commit32d11f2d679b811c9af349fe9f0b0b29d4f598c0 (patch)
treeb06172d8797d3b401e824861d51ab4cb6b57ca30 /tests/auto/controls/data/tst_slider.qml
parent61889f06fa828b483513b8315b4f0870532ece66 (diff)
downloadqtquickcontrols-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.qml27
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()
+ }
}
}