diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-18 15:41:24 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:22 +0000 |
commit | b18d39153453e6e2cab9e6c75bd2991aa25d0397 (patch) | |
tree | 32495680fcb26976b3046ad54fe0da69f073d51a /tests/auto/animation | |
parent | 982ea29558d6374067eb6cc0505b709eb9ecdae3 (diff) |
Add function to format clip results using a gather operation
If an index in the format is -1 put a default value of 0 into the
formatted results. This will allow clips to not have to provide every
channel used anywhere by the blend tree.
Change-Id: I9e18d0840e75a959ef680cbd54259a74c9331fa8
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/auto/animation')
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index dcdbafdae..6f0c998e6 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -1885,6 +1885,74 @@ private Q_SLOTS: // Cleanup delete handler; } + + void checkFormatClipResults_data() + { + QTest::addColumn<ClipResults>("rawClipResults"); + QTest::addColumn<ComponentIndices>("format"); + QTest::addColumn<ClipResults>("expectedResults"); + + { + ClipResults rawClipResults = { 1.0f, 2.0f, 3.0f }; + ComponentIndices format = { 0, 1, 2 }; + ClipResults expectedResults = { 1.0f, 2.0f, 3.0f }; + + QTest::newRow("identity") + << rawClipResults << format << expectedResults; + } + + { + ClipResults rawClipResults = { 1.0f, 2.0f }; + ComponentIndices format = { 1, 0 }; + ClipResults expectedResults = { 2.0f, 1.0f }; + + QTest::newRow("swap") + << rawClipResults << format << expectedResults; + } + + { + ClipResults rawClipResults = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + ComponentIndices format = { 0, 2, 1, 3, 4 }; + ClipResults expectedResults = { 1.0f, 3.0f, 2.0f, 4.0f, 5.0f }; + + QTest::newRow("swap subset") + << rawClipResults << format << expectedResults; + } + + { + ClipResults rawClipResults = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + ComponentIndices format = { 4, 3, 2, 1, 0 }; + ClipResults expectedResults = { 5.0f, 4.0f, 3.0f, 2.0f, 1.0f }; + + QTest::newRow("reverse") + << rawClipResults << format << expectedResults; + } + + { + ClipResults rawClipResults = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + ComponentIndices format = { 0, 1, -1, 3, 4 }; + ClipResults expectedResults = { 1.0f, 2.0f, 0.0f, 4.0f, 5.0f }; + + QTest::newRow("include missing") + << rawClipResults << format << expectedResults; + } + } + + void checkFormatClipResults() + { + // GIVEN + QFETCH(ClipResults, rawClipResults); + QFETCH(ComponentIndices, format); + QFETCH(ClipResults, expectedResults); + + // WHEN + const ClipResults actualResults = formatClipResults(rawClipResults, format); + + // THEN + QCOMPARE(actualResults.size(), expectedResults.size()); + for (int i = 0; i < actualResults.size(); ++i) + QCOMPARE(actualResults[i], expectedResults[i]); + } }; QTEST_MAIN(tst_AnimationUtils) |