aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimations
diff options
context:
space:
mode:
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