diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-07-06 11:43:41 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-11 17:37:55 +0200 |
commit | f9d7a3ec09be59ba7d2a6337463363a7609c523b (patch) | |
tree | 77e568aca282567b019c2ba23ef786ac1e782b83 /tests/auto/quick/qquickanimations/tst_qquickanimations.cpp | |
parent | 73cdca24419f48fe54fb298a17af92e6e6dcc4df (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/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 |