summaryrefslogtreecommitdiffstats
path: root/tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp')
-rw-r--r--tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp b/tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp
index 2cc707fa5..7ec327cdc 100644
--- a/tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp
+++ b/tests/auto/animation/additiveclipblend/tst_additiveclipblend.cpp
@@ -37,9 +37,45 @@
using namespace Qt3DAnimation::Animation;
+namespace {
+
+class TestClipBlendNode : public ClipBlendNode
+{
+public:
+ TestClipBlendNode(double duration)
+ : ClipBlendNode(ClipBlendNode::LerpBlendType)
+ , m_duration(duration)
+ {}
+
+ float blend(float, float) const Q_DECL_FINAL { return 0.0f; }
+
+ QVector<Qt3DCore::QNodeId> dependencyIds() const Q_DECL_FINAL
+ {
+ return QVector<Qt3DCore::QNodeId>();
+ }
+
+ using ClipBlendNode::setClipResults;
+
+ double duration() const Q_DECL_FINAL { return m_duration; }
+
+ double m_duration;
+};
+
+} // anonymous
+
class tst_AdditiveClipBlend : public Qt3DCore::QBackendNodeTester
{
Q_OBJECT
+public:
+ TestClipBlendNode *createTestBlendNode(Handler *handler,
+ double duration)
+ {
+ auto id = Qt3DCore::QNodeId::createId();
+ TestClipBlendNode *node = new TestClipBlendNode(duration);
+ setPeerId(node, id);
+ handler->clipBlendNodeManager()->appendNode(id, node);
+ return node;
+ }
private Q_SLOTS:
@@ -201,6 +237,30 @@ private Q_SLOTS:
QCOMPARE(actualIds[0], baseClipId);
QCOMPARE(actualIds[1], anotherAdditiveClipId);
}
+
+ void checkDuration()
+ {
+ // GIVEN
+ auto handler = new Handler();
+ const double expectedDuration = 123.5;
+ const double baseNodeDuration = expectedDuration;
+ const double additiveNodeDuration = 5.0;
+
+ auto baseNode = createTestBlendNode(handler, baseNodeDuration);
+ auto additiveNode = createTestBlendNode(handler, additiveNodeDuration);
+
+ AdditiveClipBlend blendNode;
+ blendNode.setHandler(handler);
+ blendNode.setClipBlendNodeManager(handler->clipBlendNodeManager());
+ blendNode.setBaseClipId(baseNode->peerId());
+ blendNode.setAdditiveClipId(additiveNode->peerId());
+
+ // WHEN
+ double actualDuration = blendNode.duration();
+
+ // THEN
+ QCOMPARE(actualDuration, expectedDuration);
+ }
};
QTEST_MAIN(tst_AdditiveClipBlend)