diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-10-09 10:29:00 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-10-11 12:29:27 +0200 |
commit | c54083ff933830a28f43551b9c3b132bfb11492d (patch) | |
tree | 2fbc7a23a5d45dc7bf619eb3e6a18af8fc700d71 /tests/auto/corelib/tools | |
parent | eaf4911db29a82b3d94826a8ff09afe075a2b636 (diff) |
Fix QEasingCurve possible imprecision at endpoints
Both the spline curves and (most of) the predefines curves are defined
as having start value 0.0 and end value 1.0. The spline and In/OutBack
functions would sometimes not produce that result precisely, so code
could not reliably depend on expressions like (easedValue < 1.0)
becoming false. Fix by explicitly handling endpoints.
Fixes: QTBUG-76781
Fixes: QTBUG-72630
Change-Id: I21be43af469a76c090154bffef8406a9baf2d0b1
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 3af6132695..2a9c1e1e41 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -404,6 +404,11 @@ void tst_QEasingCurve::valueForProgress() const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100))); QVERIFY(error <= errorBound); } + + if (type != QEasingCurve::SineCurve && type != QEasingCurve::CosineCurve) { + QVERIFY( !(curve.valueForProgress(0) > 0) ); + QVERIFY( !(curve.valueForProgress(1) < 1) ); + } #endif } @@ -632,6 +637,9 @@ void tst_QEasingCurve::bezierSpline() QCOMPARE(value, ex); QVERIFY(error <= errorBound); } + + QVERIFY( !(bezierEasingCurve.valueForProgress(0) > 0) ); + QVERIFY( !(bezierEasingCurve.valueForProgress(1) < 1) ); } void tst_QEasingCurve::tcbSpline_data() @@ -691,6 +699,9 @@ void tst_QEasingCurve::tcbSpline() QCOMPARE(value, ex); QVERIFY(error <= errorBound); } + + QVERIFY( !(tcbEasingCurve.valueForProgress(0) > 0) ); + QVERIFY( !(tcbEasingCurve.valueForProgress(1) < 1) ); } /*This is single precision code for a cubic root used inside the spline easing curve. |