QEasingCurve: The setting order of properties should not matter.
Previously, this failed because QEasingCurveFunction only had a linear behavior. The fix is to change that and let QEasingCurveFunction handle any of the simple "non-parametric easing" functions. Task-number: QTBUG-38686 Change-Id: I666d59e10ceb589dcc52956b16a6f0c259aebdad Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
e12f6a47a5
commit
ec5f402cfd
|
|
@ -373,9 +373,12 @@ public:
|
|||
|
||||
};
|
||||
|
||||
static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve);
|
||||
|
||||
qreal QEasingCurveFunction::value(qreal t)
|
||||
{
|
||||
return t;
|
||||
QEasingCurve::EasingFunction func = curveToFunc(_t);
|
||||
return func(t);
|
||||
}
|
||||
|
||||
QEasingCurveFunction *QEasingCurveFunction::copy() const
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ private slots:
|
|||
void operators();
|
||||
void properties();
|
||||
void metaTypes();
|
||||
void propertyOrderIsNotImportant();
|
||||
void bezierSpline_data();
|
||||
void bezierSpline();
|
||||
void tcbSpline_data();
|
||||
|
|
@ -560,6 +561,25 @@ void tst_QEasingCurve::metaTypes()
|
|||
QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
|
||||
}
|
||||
|
||||
/*
|
||||
Test to ensure that regardless of what order properties are set, they should produce the same
|
||||
behavior.
|
||||
*/
|
||||
void tst_QEasingCurve::propertyOrderIsNotImportant()
|
||||
{
|
||||
|
||||
QEasingCurve c1;
|
||||
c1.setPeriod(1);
|
||||
c1.setType(QEasingCurve::OutSine);
|
||||
QVERIFY(c1.valueForProgress(0.75) > 0.9);
|
||||
|
||||
QEasingCurve c2;
|
||||
c2.setType(QEasingCurve::OutSine);
|
||||
c2.setPeriod(1);
|
||||
|
||||
QCOMPARE(c1.valueForProgress(0.75), c2.valueForProgress(0.75));
|
||||
}
|
||||
|
||||
void tst_QEasingCurve::bezierSpline_data()
|
||||
{
|
||||
QTest::addColumn<QString>("definition");
|
||||
|
|
|
|||
Loading…
Reference in New Issue