diff options
Diffstat (limited to 'tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp')
-rw-r--r-- | tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp b/tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp index a38bc9d..3bd1299 100644 --- a/tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp +++ b/tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp @@ -252,6 +252,7 @@ private Q_SLOTS: void testPropertyWrite(); void testPropertyWriteDerived_data(); void testPropertyWriteDerived(); + void testAnimations(); void testFunctionCalls_data(); void testFunctionCalls(); @@ -560,6 +561,43 @@ void tst_QIviSimulationEngine::testPropertyWriteDerived() QCOMPARE(obj->property("bindingProperty"), value); } +//Animations use a different way to access the properties, so we need to test this explicitly +void tst_QIviSimulationEngine::testAnimations() +{ + QIviSimulationEngine engine; + + DerivedClass testObject; + engine.registerSimulationInstance<DerivedClass>(&testObject, "TestAPI", 1, 0, "DerivedClass"); + QSignalSpy spy(&testObject, SIGNAL(propertyInBaseChanged(int))); + + QByteArray qml ("import QtQuick 2.0; \n\ + import TestAPI 1.0; \n\ + DerivedClass { \n\ + id: backend \n\ + property var animation: SequentialAnimation { \n\ + NumberAnimation { target: backend; property: \"propertyInBase\"; from: 0; to: 130; duration: 500 } \n\ + ScriptAction { script: backend.animationDone() } \n\ + running: true \n\ + } \n\ + signal animationDone(); \n\ + }"); + + QQmlComponent component(&engine); + component.setData(qml, QUrl()); + QScopedPointer<QObject> obj(component.create()); + QVERIFY2(obj, qPrintable(component.errorString())); + + //wait until the animation ended + QSignalSpy animationSpy(obj.data(), SIGNAL(animationDone())); + animationSpy.wait(); + + //Check that the animation has reached it's final value + QCOMPARE(obj->property("propertyInBase"), 130); + + //we expect at least 10 animation steps + QVERIFY2(spy.count() > 10, qPrintable(QStringLiteral("Emitted signals: ") + QString::number(spy.count()))); +} + void tst_QIviSimulationEngine::testFunctionCalls_data() { QTest::addColumn<QByteArray>("function"); |