summaryrefslogtreecommitdiffstats
path: root/tests/auto/animation/animationutils/tst_animationutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/animation/animationutils/tst_animationutils.cpp')
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp
index 7c95b2117..534eb1678 100644
--- a/tests/auto/animation/animationutils/tst_animationutils.cpp
+++ b/tests/auto/animation/animationutils/tst_animationutils.cpp
@@ -31,7 +31,9 @@
#include <Qt3DAnimation/private/animationutils_p.h>
#include <Qt3DAnimation/private/channelmapper_p.h>
#include <Qt3DAnimation/private/channelmapping_p.h>
+#include <Qt3DAnimation/private/clipblendvalue_p.h>
#include <Qt3DAnimation/private/handler_p.h>
+#include <Qt3DAnimation/private/lerpclipblend_p.h>
#include <Qt3DAnimation/private/managers_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <QtGui/qvector2d.h>
@@ -123,6 +125,28 @@ public:
return animator;
}
+ LerpClipBlend *createLerpClipBlend(Handler *handler)
+ {
+ auto lerpId = Qt3DCore::QNodeId::createId();
+ LerpClipBlend *lerp = new LerpClipBlend();
+ setPeerId(lerp, lerpId);
+ lerp->setClipBlendNodeManager(handler->clipBlendNodeManager());
+ lerp->setHandler(handler);
+ handler->clipBlendNodeManager()->appendNode(lerpId, lerp);
+ return lerp;
+ }
+
+ ClipBlendValue *createClipBlendValue(Handler *handler)
+ {
+ auto valueId = Qt3DCore::QNodeId::createId();
+ ClipBlendValue *value = new ClipBlendValue();
+ setPeerId(value, valueId);
+ value->setClipBlendNodeManager(handler->clipBlendNodeManager());
+ value->setHandler(handler);
+ handler->clipBlendNodeManager()->appendNode(valueId, value);
+ return value;
+ }
+
private Q_SLOTS:
void checkBuildPropertyMappings_data()
{
@@ -1481,6 +1505,51 @@ private Q_SLOTS:
// Cleanup
delete handler;
}
+
+ void checkGatherValueNodesToEvaluate_data()
+ {
+ QTest::addColumn<Handler *>("handler");
+ QTest::addColumn<Qt3DCore::QNodeId>("blendTreeRootId");
+ QTest::addColumn<QVector<Qt3DCore::QNodeId>>("expectedIds");
+
+ {
+ Handler *handler = new Handler;
+
+ const auto lerp = createLerpClipBlend(handler);
+ const auto value1 = createClipBlendValue(handler);
+ const auto clip1Id = Qt3DCore::QNodeId::createId();
+ value1->setClipId(clip1Id);
+ lerp->setStartClipId(value1->peerId());
+
+ const auto value2 = createClipBlendValue(handler);
+ const auto clip2Id = Qt3DCore::QNodeId::createId();
+ value2->setClipId(clip2Id);
+ lerp->setEndClipId(value2->peerId());
+
+ QVector<Qt3DCore::QNodeId> expectedIds = { value1->peerId(), value2->peerId() };
+
+ QTest::newRow("simple lerp") << handler << lerp->peerId() << expectedIds;
+ }
+ }
+
+ void checkGatherValueNodesToEvaluate()
+ {
+ // GIVEN
+ QFETCH(Handler *, handler);
+ QFETCH(Qt3DCore::QNodeId, blendTreeRootId);
+ QFETCH(QVector<Qt3DCore::QNodeId>, expectedIds);
+
+ // WHEN
+ QVector<Qt3DCore::QNodeId> actualIds = gatherValueNodesToEvaluate(handler, blendTreeRootId);
+
+ // THEN
+ QCOMPARE(actualIds.size(), expectedIds.size());
+ for (int i = 0; i < actualIds.size(); ++i)
+ QCOMPARE(actualIds[i], expectedIds[i]);
+
+ // Cleanup
+ delete handler;
+ }
};
QTEST_MAIN(tst_AnimationUtils)