summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp')
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp69
1 files changed, 67 insertions, 2 deletions
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 2e5fd00..7e910d4 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QtCore/qpropertyanimation.h>
+#include <QtCore/qvariantanimation.h>
#include <QtGui/qwidget.h>
//TESTED_CLASS=QPropertyAnimation
@@ -95,6 +96,8 @@ private slots:
void zeroDurationStart();
void operationsInStates_data();
void operationsInStates();
+ void oneKeyValue();
+ void updateOnSetKeyValues();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -794,9 +797,9 @@ void tst_QPropertyAnimation::operationsInStates()
* | pause() |start() |resume() |stop()
* ----------+------------+-----------+-----------+-------------------+
* Stopped | Stopped |Running |Stopped |Stopped |
- * _| qWarning | |qWarning |- |
+ * _| qWarning |restart |qWarning | |
* Paused | Paused |Running |Running |Stopped |
- * _| - | | | |
+ * _| | | | |
* Running | Paused |Running |Running |Stopped |
* | |restart |qWarning | |
* ----------+------------+-----------+-----------+-------------------+
@@ -850,5 +853,67 @@ 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);
+}
+
+void tst_QPropertyAnimation::updateOnSetKeyValues()
+{
+ QObject o;
+ o.setProperty("ole", 100);
+ QCOMPARE(o.property("ole").toInt(), 100);
+
+ QPropertyAnimation animation(&o, "ole");
+ animation.setStartValue(100);
+ animation.setEndValue(200);
+ animation.setDuration(100);
+
+ animation.setCurrentTime(50);
+ QCOMPARE(animation.currentValue().toInt(), 150);
+ animation.setKeyValueAt(0.0, 300);
+ QCOMPARE(animation.currentValue().toInt(), 250);
+
+ o.setProperty("ole", 100);
+ QPropertyAnimation animation2(&o, "ole");
+ QVariantAnimation::KeyValues kValues;
+ kValues << QVariantAnimation::KeyValue(0.0, 100) << QVariantAnimation::KeyValue(1.0, 200);
+ animation2.setKeyValues(kValues);
+ animation2.setDuration(100);
+ animation2.setCurrentTime(50);
+ QCOMPARE(animation2.currentValue().toInt(), 150);
+
+ kValues.clear();
+ kValues << QVariantAnimation::KeyValue(0.0, 300) << QVariantAnimation::KeyValue(1.0, 200);
+ animation2.setKeyValues(kValues);
+
+ QCOMPARE(animation2.currentValue().toInt(), animation.currentValue().toInt());
+}
+
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"