summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-01-25 19:25:15 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-01-27 18:32:25 +0000
commit744c51c33e4da37bb70528f5398e56e5faf5c504 (patch)
treefb38379202c9a520fdcebd44a749bfdd467c0bb2 /tests
parent78a032e2328dddf0f60c0fe3063047888b92cc2a (diff)
Calculate animation clip duration and send to frontend
Change-Id: Iaafb8b385658be446098d982702955810f76d7c6 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animationclip/tst_animationclip.cpp34
-rw-r--r--tests/auto/animation/qanimationclip/tst_qanimationclip.cpp1
-rw-r--r--tests/manual/animation-keyframe-simple/main.qml2
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/animation/animationclip/tst_animationclip.cpp b/tests/auto/animation/animationclip/tst_animationclip.cpp
index cd1d2ccf0..f0b45bfeb 100644
--- a/tests/auto/animation/animationclip/tst_animationclip.cpp
+++ b/tests/auto/animation/animationclip/tst_animationclip.cpp
@@ -33,6 +33,7 @@
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/private/qbackendnode_p.h>
+#include <Qt3DCore/private/qpropertyupdatedchangebase_p.h>
#include <qbackendnodetester.h>
#include <testpostmanarbiter.h>
@@ -71,6 +72,7 @@ private Q_SLOTS:
QVERIFY(backendClip.peerId().isNull());
QCOMPARE(backendClip.isEnabled(), false);
QCOMPARE(backendClip.source(), QUrl());
+ QCOMPARE(backendClip.duration(), 0.0f);
// GIVEN
Qt3DAnimation::QAnimationClip clip;
@@ -84,6 +86,7 @@ private Q_SLOTS:
// THEN
QCOMPARE(backendClip.source(), QUrl());
QCOMPARE(backendClip.isEnabled(), false);
+ QCOMPARE(backendClip.duration(), 0.0f);
}
void checkPropertyChanges()
@@ -113,6 +116,37 @@ private Q_SLOTS:
// THEN
QCOMPARE(backendClip.source(), newSource);
}
+
+ void checkDurationPropertyBackendNotification()
+ {
+ // GIVEN
+ TestArbiter arbiter;
+ Qt3DAnimation::Animation::AnimationClip backendClip;
+ backendClip.setEnabled(true);
+ Qt3DCore::QBackendNodePrivate::get(&backendClip)->setArbiter(&arbiter);
+
+ // WHEN
+ backendClip.setDuration(64.0f);
+
+ // THEN
+ QCOMPARE(backendClip.duration(), 64.0f);
+ QCOMPARE(arbiter.events.count(), 1);
+ Qt3DCore::QPropertyUpdatedChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "duration");
+ QCOMPARE(change->value().toFloat(), backendClip.duration());
+ QCOMPARE(Qt3DCore::QPropertyUpdatedChangeBasePrivate::get(change.data())->m_isFinal, true);
+
+ arbiter.events.clear();
+
+ // WHEN
+ backendClip.setDuration(64.0f);
+
+ // THEN
+ QCOMPARE(backendClip.duration(), 64.0f);
+ QCOMPARE(arbiter.events.count(), 0);
+
+ arbiter.events.clear();
+ }
};
QTEST_APPLESS_MAIN(tst_AnimationClip)
diff --git a/tests/auto/animation/qanimationclip/tst_qanimationclip.cpp b/tests/auto/animation/qanimationclip/tst_qanimationclip.cpp
index 09f41ae99..8c83f6530 100644
--- a/tests/auto/animation/qanimationclip/tst_qanimationclip.cpp
+++ b/tests/auto/animation/qanimationclip/tst_qanimationclip.cpp
@@ -49,6 +49,7 @@ private Q_SLOTS:
// THEN
QCOMPARE(clip.source(), QUrl());
+ QCOMPARE(clip.duration(), 0.0f);
}
void checkPropertyChanges()
diff --git a/tests/manual/animation-keyframe-simple/main.qml b/tests/manual/animation-keyframe-simple/main.qml
index 587f851c5..e53772434 100644
--- a/tests/manual/animation-keyframe-simple/main.qml
+++ b/tests/manual/animation-keyframe-simple/main.qml
@@ -35,6 +35,8 @@ DefaultSceneEntity {
running: true
clip: AnimationClip {
source: "cubeanimation.json"
+
+ onDurationChanged: console.log("duration = " + duration)
}
// By default introspect parent Entity and try