diff options
Diffstat (limited to 'tests/auto/quick/qquickanimations/tst_qquickanimations.cpp')
-rw-r--r-- | tests/auto/quick/qquickanimations/tst_qquickanimations.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
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 |