Makes QSmoothedAnimation respect zero duration.
In automated GUI test scenarios it often desired not to wait for animations before verifying a result, so setting the duration to zero should accomplish this, before this patch; if duration was set to zero QSmoothedAnimation would treat it as if duration was not set, and used velocity to calculate animation speed. Change-Id: Ia57f1c9ffdd2056ac7c85d1cb94dbd3835fcbb7a Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
This commit is contained in:
parent
c284672e5d
commit
18f7c18769
|
@ -153,10 +153,10 @@ bool QSmoothedAnimation::recalc()
|
||||||
|
|
||||||
s = (invert? -1.0: 1.0) * s;
|
s = (invert? -1.0: 1.0) * s;
|
||||||
|
|
||||||
if (userDuration > 0 && velocity > 0) {
|
if (userDuration >= 0 && velocity > 0) {
|
||||||
tf = s / velocity;
|
tf = s / velocity;
|
||||||
if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.);
|
if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.);
|
||||||
} else if (userDuration > 0) {
|
} else if (userDuration >= 0) {
|
||||||
tf = userDuration / 1000.;
|
tf = userDuration / 1000.;
|
||||||
} else if (velocity > 0) {
|
} else if (velocity > 0) {
|
||||||
tf = s / velocity;
|
tf = s / velocity;
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 300; height: 300;
|
||||||
|
Rectangle {
|
||||||
|
objectName: "theRect"
|
||||||
|
color: "red"
|
||||||
|
width: 60; height: 60;
|
||||||
|
x: 100; y: 100;
|
||||||
|
SmoothedAnimation on x { objectName: "easeX"; to: 200; duration: 0 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ private slots:
|
||||||
void valueSource();
|
void valueSource();
|
||||||
void behavior();
|
void behavior();
|
||||||
void deleteOnUpdate();
|
void deleteOnUpdate();
|
||||||
|
void zeroDuration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQmlEngine engine;
|
QQmlEngine engine;
|
||||||
|
@ -237,6 +238,28 @@ void tst_qquicksmoothedanimation::deleteOnUpdate()
|
||||||
delete rect;
|
delete rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_qquicksmoothedanimation::zeroDuration()
|
||||||
|
{
|
||||||
|
QQmlEngine engine;
|
||||||
|
|
||||||
|
QQmlComponent c(&engine, testFileUrl("smoothedanimationZeroDuration.qml"));
|
||||||
|
|
||||||
|
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
|
||||||
|
QVERIFY(rect);
|
||||||
|
|
||||||
|
QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
|
||||||
|
QVERIFY(theRect);
|
||||||
|
|
||||||
|
QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
|
||||||
|
QVERIFY(easeX);
|
||||||
|
QVERIFY(easeX->isRunning());
|
||||||
|
|
||||||
|
QTRY_VERIFY(!easeX->isRunning());
|
||||||
|
QTRY_COMPARE(theRect->x(), qreal(200));
|
||||||
|
|
||||||
|
delete rect;
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_qquicksmoothedanimation)
|
QTEST_MAIN(tst_qquicksmoothedanimation)
|
||||||
|
|
||||||
#include "tst_qquicksmoothedanimation.moc"
|
#include "tst_qquicksmoothedanimation.moc"
|
||||||
|
|
Loading…
Reference in New Issue