summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2018-12-21 11:34:57 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2019-01-12 12:29:35 +0000
commit5bca991b07903942fb48450f3e867b5a3c30d1e5 (patch)
tree386f1ac699be210ccb4fdf1780fa024ae5a09ebd /tests
parent34e23de0523e0a4250584a74d56cab35ca28f3a7 (diff)
downloadqtivi-5bca991b07903942fb48450f3e867b5a3c30d1e5.tar.gz
Fix a crash in the QIviSimulationEngine when using animations
The code handles now read and write of properties using the staticMetaObject correctly. Added more internal documentation for it and a autotest. Change-Id: Iddceeebcf5317ddb3a6986d82febc81bd374b575 Fixes: AUTOSUITE-727 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/qivisimulationengine/tst_qivisimulationengine.cpp38
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");