diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-15 10:28:00 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-19 12:45:23 +0000 |
commit | b19e1cf6b03b7236c1c6bac8614eb41da8a915d8 (patch) | |
tree | f32faaf78389353f5f99ba50d45edd02a91d742f /tests | |
parent | 12a87c7792d0795feb5c5faa54d4b25477f32461 (diff) |
Add function to evaluate clip at a given phase
This is another piece of the puzzle for evaluating blend trees.
Change-Id: If0604125b11bacf0c205a69a59d39f601dd2ebd1
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index c19be320c..7c95b2117 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -873,6 +873,113 @@ private Q_SLOTS: delete handler; } + void checkEvaluateClipAtPhase_data() + { + QTest::addColumn<Handler *>("handler"); + QTest::addColumn<AnimationClipLoader *>("clip"); + QTest::addColumn<float>("phase"); + QTest::addColumn<ClipResults>("expectedResults"); + + Handler *handler; + AnimationClipLoader *clip; + float phase; + ClipResults expectedResults; + + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json")); + phase = 0.0f; + expectedResults = QVector<float>() << 0.0f << 0.0f << 0.0f; + + QTest::newRow("clip1.json, phi = 0.0") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json")); + phase = 1.0f; + expectedResults = QVector<float>() << 5.0f << 0.0f << 0.0f; + + QTest::newRow("clip1.json, phi = 1.0") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json")); + phase = 0.5f; + expectedResults = QVector<float>() << 2.5f << 0.0f << 0.0f; + + QTest::newRow("clip1.json, phi = 0.5") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip2.json")); + phase = 0.0f; + expectedResults = QVector<float>() + << 0.0f << 0.0f << 0.0f // Translation + << 1.0f << 0.0f << 0.0f << 0.0f; // Rotation + + QTest::newRow("clip2.json, phi = 0.0") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip2.json")); + phase = 1.0f; + expectedResults = QVector<float>() + << 5.0f << 0.0f << 0.0f // Translation + << 0.0f << 0.0f << -1.0f << 0.0f; // Rotation + + QTest::newRow("clip2.json, t = 1.0") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + { + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip2.json")); + phase = 0.5f; + expectedResults = QVector<float>() + << 2.5f << 0.0f << 0.0f // Translation + << 0.5f << 0.0f << -0.5f << 0.0f; // Rotation + + QTest::newRow("clip2.json, phi = 0.5") + << handler << clip << phase << expectedResults; + expectedResults.clear(); + } + } + + void checkEvaluateClipAtPhase() + { + // GIVEN + QFETCH(Handler *, handler); + QFETCH(AnimationClipLoader *, clip); + QFETCH(float, phase); + QFETCH(ClipResults, expectedResults); + + // WHEN + ClipResults actualResults = evaluateClipAtPhase(clip, phase); + + // THEN + QCOMPARE(actualResults.size(), expectedResults.size()); + for (int i = 0; i < actualResults.size(); ++i) { + auto actual = actualResults[i]; + auto expected = expectedResults[i]; + + QVERIFY(fuzzyCompare(actual, expected) == true); + } + + // Cleanup + delete handler; + } + void checkChannelComponentsToIndicesHelper_data() { QTest::addColumn<Channel>("channel"); |