summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-05-14 15:52:09 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-05-15 11:58:56 (GMT)
commit9227f6249de0e60a2a428549848c875c01dbf4d2 (patch)
tree4554e33278d1bd2f2476115b27d70376deed5121 /tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
parent92ff29b161709f4503d628e468c0eec1daf5835a (diff)
downloadQt-9227f6249de0e60a2a428549848c875c01dbf4d2.zip
Qt-9227f6249de0e60a2a428549848c875c01dbf4d2.tar.gz
Qt-9227f6249de0e60a2a428549848c875c01dbf4d2.tar.bz2
Avoid interpolating if we have less than 2 key values in QVariantAnimation
If we have less than 2 key values, we should neither try to interpolate nor set the current value. Reviewed-by: janarve
Diffstat (limited to 'tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp')
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 172950f..c753477 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -95,6 +95,7 @@ private slots:
void zeroDurationStart();
void operationsInStates_data();
void operationsInStates();
+ void oneKeyValue();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -850,5 +851,35 @@ void tst_QPropertyAnimation::operationsInStates()
#undef Resume
#undef Stop
+void tst_QPropertyAnimation::oneKeyValue()
+{
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation animation(&o, "ole");
+ animation.setStartValue(43);
+ animation.setEndValue(44);
+ animation.setDuration(100);
+
+ animation.setCurrentTime(0);
+
+ QVERIFY(animation.currentValue().isValid());
+ QCOMPARE(animation.currentValue().toInt(), 43);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ // remove the last key value
+ animation.setKeyValueAt(1.0, QVariant());
+
+ // we will neither interpolate, nor update the current value
+ // since there is only one 1 key value defined
+ animation.setCurrentTime(100);
+
+ // the animation should not have been modified
+ QVERIFY(animation.currentValue().isValid());
+ QCOMPARE(animation.currentValue().toInt(), 43);
+ QCOMPARE(o.property("ole").toInt(), 42);
+}
+
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"