summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2017-11-21 12:23:55 +0100
committerSean Harmer <sean.harmer@kdab.com>2018-01-23 18:23:31 +0000
commitf6a9174e5efeda68151f2d992fcd916fb2dd2c99 (patch)
treecee5aa42d7164d5e3f8b18c6c1a0217965d0784e /tests
parentf6699afc911da958347c6916c1eff3558ee8d431 (diff)
Add normalizedTime function to blendedlclip animators
Change-Id: I19c1907371d9d131295558eb19c297d544ebef7d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp75
-rw-r--r--tests/manual/animation-keyframe-blendtree/main.qml16
2 files changed, 84 insertions, 7 deletions
diff --git a/tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp b/tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp
index d25041886..56be94472 100644
--- a/tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp
+++ b/tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp
@@ -145,6 +145,47 @@ private Q_SLOTS:
QCOMPARE(blendedClipAnimator.loopCount(), newValue);
QCOMPARE(spy.count(), 0);
}
+
+ {
+ // WHEN
+ QSignalSpy spy(&blendedClipAnimator, SIGNAL(normalizedTimeChanged(float)));
+ const float newValue = 0.5;
+ blendedClipAnimator.setNormalizedTime(newValue);
+
+ // THEN
+ QVERIFY(spy.isValid());
+ QCOMPARE(blendedClipAnimator.normalizedTime(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ blendedClipAnimator.setNormalizedTime(newValue);
+
+ // THEN
+ QCOMPARE(blendedClipAnimator.normalizedTime(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+
+ {
+ // WHEN
+ QSignalSpy spy(&blendedClipAnimator, SIGNAL(normalizedTimeChanged(float)));
+ const float newValue = -0.01f; // Invalid
+ blendedClipAnimator.setNormalizedTime(newValue);
+ const float oldValue = blendedClipAnimator.normalizedTime();
+
+ // THEN
+ QVERIFY(spy.isValid());
+ QCOMPARE(blendedClipAnimator.normalizedTime(), oldValue);
+ QCOMPARE(spy.count(), 0);
+
+ // WHEN
+ spy.clear();
+ blendedClipAnimator.setNormalizedTime(1.01f); // Invalid
+
+ // THEN
+ QCOMPARE(blendedClipAnimator.normalizedTime(), oldValue);
+ QCOMPARE(spy.count(), 0);
+ }
}
void checkCreationData()
@@ -181,6 +222,7 @@ private Q_SLOTS:
QCOMPARE(blendedClipAnimator.isEnabled(), creationChangeData->isNodeEnabled());
QCOMPARE(blendedClipAnimator.metaObject(), creationChangeData->metaObject());
QCOMPARE(blendedClipAnimator.loopCount(), cloneData.loops);
+ QCOMPARE(blendedClipAnimator.normalizedTime(), cloneData.normalizedTime);
}
// WHEN
@@ -375,6 +417,39 @@ private Q_SLOTS:
}
}
+
+ void checkNormalizedTimeUpdate()
+ {
+ // GIVEN
+ TestArbiter arbiter;
+ Qt3DAnimation::QBlendedClipAnimator blendedClipAnimator;
+ arbiter.setArbiterOnNode(&blendedClipAnimator);
+
+ {
+ // WHEN
+ blendedClipAnimator.setNormalizedTime(0.5f);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 1);
+ auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "normalizedTime");
+ QCOMPARE(change->value().value<float>(), blendedClipAnimator.normalizedTime());
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+
+ arbiter.events.clear();
+ }
+
+ {
+ // WHEN
+ blendedClipAnimator.setNormalizedTime(0.5f);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ }
+
+ }
};
QTEST_MAIN(tst_QBlendedClipAnimator)
diff --git a/tests/manual/animation-keyframe-blendtree/main.qml b/tests/manual/animation-keyframe-blendtree/main.qml
index 3d7fa47e5..74413b4e2 100644
--- a/tests/manual/animation-keyframe-blendtree/main.qml
+++ b/tests/manual/animation-keyframe-blendtree/main.qml
@@ -57,6 +57,15 @@ import Qt3D.Extras 2.0
DefaultSceneEntity {
id: scene
+ KeyboardDevice { id: kyb }
+ KeyboardHandler {
+ id: keyboardHandler
+ sourceDevice: kyb
+ focus: true
+ onLeftPressed:blendedAnimator.normalizedTime -= 0.02
+ onRightPressed: blendedAnimator.normalizedTime += 0.02
+ }
+
Entity {
id: cube
@@ -95,7 +104,6 @@ DefaultSceneEntity {
BlendedClipAnimator {
id: blendedAnimator
loops: 3
-
clock: Clock {
id: animatorClock
playbackRate: 0.5
@@ -127,10 +135,4 @@ DefaultSceneEntity {
position: Qt.vector3d(10, 3, 15)
viewCenter: Qt.vector3d(2.5, 1, 0)
}
-
- OrbitCameraController {
- camera: scene.camera
- linearSpeed: 8
- lookSpeed: 180
- }
}