aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimations
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-07-06 11:43:41 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-11 17:37:55 +0200
commitf9d7a3ec09be59ba7d2a6337463363a7609c523b (patch)
tree77e568aca282567b019c2ba23ef786ac1e782b83 /tests/auto/quick/qquickanimations
parent73cdca24419f48fe54fb298a17af92e6e6dcc4df (diff)
Fix, test and document animation started/stopped signals.
Rename completed to stopped (as it is not only emitted on completion). Ensure that the started and stopped signals are emitted at the right times. Document the signals. Task-number: QTBUG-14968 Change-Id: Icd3babcef2c9e544476592a26e6b9e58a21ebe95 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickanimations')
-rw-r--r--tests/auto/quick/qquickanimations/data/signals.qml30
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp54
2 files changed, 84 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimations/data/signals.qml b/tests/auto/quick/qquickanimations/data/signals.qml
new file mode 100644
index 0000000000..c91ad93626
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/signals.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+
+
+Item {
+ id: wrapper
+ width: 400; height: 400
+
+ function start() { animation.start() }
+ function stop() { animation.stop() }
+ property alias alwaysRunToEnd: animation.alwaysRunToEnd
+
+ property int startedCount: 0
+ property int stoppedCount: 0
+
+ Rectangle {
+ id: greenRect
+ width: 50; height: 50
+ color: "green"
+
+ NumberAnimation on x {
+ id: animation
+ from: 0
+ to: 100
+ duration: 200
+
+ onStarted: ++startedCount
+ onStopped: ++stoppedCount
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 8cfdf74917..b5ab04cccd 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -97,6 +97,7 @@ private slots:
void dontStart();
void easingProperties();
void rotation();
+ void startStopSignals();
void runningTrueBug();
void nonTransitionBug();
void registrationBug();
@@ -1196,6 +1197,59 @@ void tst_qquickanimations::rotation()
QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
}
+void tst_qquickanimations::startStopSignals()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("signals.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(root);
+
+ QCOMPARE(root->property("startedCount").toInt(), 1); //autostart
+ QCOMPARE(root->property("stoppedCount").toInt(), 0);
+
+ QMetaObject::invokeMethod(root, "stop");
+
+ QCOMPARE(root->property("startedCount").toInt(), 1);
+ QCOMPARE(root->property("stoppedCount").toInt(), 1);
+
+ QMetaObject::invokeMethod(root, "start");
+
+ QCOMPARE(root->property("startedCount").toInt(), 2);
+ QCOMPARE(root->property("stoppedCount").toInt(), 1);
+
+ QTest::qWait(100);
+
+ QCOMPARE(root->property("startedCount").toInt(), 2);
+ QCOMPARE(root->property("stoppedCount").toInt(), 1);
+
+ QTest::qWait(100);
+
+ QTRY_COMPARE(root->property("stoppedCount").toInt(), 2);
+ QCOMPARE(root->property("startedCount").toInt(), 2);
+
+ root->setProperty("alwaysRunToEnd", true);
+
+ QMetaObject::invokeMethod(root, "start");
+
+ QCOMPARE(root->property("startedCount").toInt(), 3);
+ QCOMPARE(root->property("stoppedCount").toInt(), 2);
+
+ QTest::qWait(100);
+
+ QCOMPARE(root->property("startedCount").toInt(), 3);
+ QCOMPARE(root->property("stoppedCount").toInt(), 2);
+
+ QMetaObject::invokeMethod(root, "stop");
+
+ QCOMPARE(root->property("startedCount").toInt(), 3);
+ QCOMPARE(root->property("stoppedCount").toInt(), 2);
+
+ QTest::qWait(100);
+
+ QTRY_COMPARE(root->property("stoppedCount").toInt(), 3);
+ QCOMPARE(root->property("startedCount").toInt(), 3);
+}
+
void tst_qquickanimations::runningTrueBug()
{
//ensure we start correctly when "running: true" is explicitly set