diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-20 13:42:53 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:28 +0000 |
commit | 1929b3e48c0a327e7a741275d6d4847b72ddf704 (patch) | |
tree | 703782cb36b3979929b0d440550bfe337bb925a7 /tests | |
parent | b18d39153453e6e2cab9e6c75bd2991aa25d0397 (diff) |
Add a function to build list of unique channel names and types
This will be needed to construct the data layout for blend trees.
Change-Id: I0b11076f5ecd55cfad094d864f3f8270841fc62a
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index 6f0c998e6..a96f7d2d2 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -59,6 +59,7 @@ Q_DECLARE_METATYPE(AnimatorEvaluationData) Q_DECLARE_METATYPE(ClipEvaluationData) Q_DECLARE_METATYPE(ClipAnimator *) Q_DECLARE_METATYPE(BlendedClipAnimator *) +Q_DECLARE_METATYPE(QVector<ChannelNameAndType>) namespace { @@ -1953,6 +1954,131 @@ private Q_SLOTS: for (int i = 0; i < actualResults.size(); ++i) QCOMPARE(actualResults[i], expectedResults[i]); } + + void checkBuildRequiredChannelsAndTypes_data() + { + QTest::addColumn<Handler *>("handler"); + QTest::addColumn<ChannelMapper *>("mapper"); + QTest::addColumn<QVector<ChannelNameAndType>>("expectedResults"); + + { + auto handler = new Handler(); + auto channelMapping = createChannelMapping(handler, + QLatin1String("Location"), + Qt3DCore::QNodeId::createId(), + QLatin1String("translation"), + "translation", + static_cast<int>(QVariant::Vector3D)); + QVector<ChannelMapping *> channelMappings; + channelMappings.push_back(channelMapping); + + auto channelMapper = createChannelMapper(handler, + QVector<Qt3DCore::QNodeId>() << channelMapping->peerId()); + + QVector<ChannelNameAndType> expectedResults; + expectedResults.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + + QTest::addRow("Location, vec3") << handler << channelMapper << expectedResults; + } + + { + auto handler = new Handler(); + auto channelMapping1 = createChannelMapping(handler, + QLatin1String("Location"), + Qt3DCore::QNodeId::createId(), + QLatin1String("translation"), + "translation", + static_cast<int>(QVariant::Vector3D)); + auto channelMapping2 = createChannelMapping(handler, + QLatin1String("Rotation"), + Qt3DCore::QNodeId::createId(), + QLatin1String("rotatrion"), + "rotation", + static_cast<int>(QVariant::Quaternion)); + QVector<ChannelMapping *> channelMappings; + channelMappings.push_back(channelMapping1); + channelMappings.push_back(channelMapping2); + + QVector<Qt3DCore::QNodeId> channelMappingIds + = (QVector<Qt3DCore::QNodeId>() + << channelMapping1->peerId() + << channelMapping2->peerId()); + auto channelMapper = createChannelMapper(handler, channelMappingIds); + + QVector<ChannelNameAndType> expectedResults; + expectedResults.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + expectedResults.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + + QTest::addRow("Multiple unique channels") << handler << channelMapper << expectedResults; + } + + { + auto handler = new Handler(); + auto channelMapping1 = createChannelMapping(handler, + QLatin1String("Location"), + Qt3DCore::QNodeId::createId(), + QLatin1String("translation"), + "translation", + static_cast<int>(QVariant::Vector3D)); + auto channelMapping2 = createChannelMapping(handler, + QLatin1String("Rotation"), + Qt3DCore::QNodeId::createId(), + QLatin1String("rotation"), + "rotation", + static_cast<int>(QVariant::Quaternion)); + auto channelMapping3 = createChannelMapping(handler, + QLatin1String("Location"), + Qt3DCore::QNodeId::createId(), + QLatin1String("translation"), + "translation", + static_cast<int>(QVariant::Vector3D)); + auto channelMapping4 = createChannelMapping(handler, + QLatin1String("Location"), + Qt3DCore::QNodeId::createId(), + QLatin1String("translation"), + "translation", + static_cast<int>(QVariant::Vector3D)); + + QVector<ChannelMapping *> channelMappings; + channelMappings.push_back(channelMapping1); + channelMappings.push_back(channelMapping2); + channelMappings.push_back(channelMapping3); + channelMappings.push_back(channelMapping4); + + QVector<Qt3DCore::QNodeId> channelMappingIds + = (QVector<Qt3DCore::QNodeId>() + << channelMapping1->peerId() + << channelMapping2->peerId() + << channelMapping3->peerId() + << channelMapping4->peerId()); + auto channelMapper = createChannelMapper(handler, channelMappingIds); + + QVector<ChannelNameAndType> expectedResults; + expectedResults.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + expectedResults.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + + QTest::addRow("Multiple channels with repeats") << handler << channelMapper << expectedResults; + } + } + + void checkBuildRequiredChannelsAndTypes() + { + // GIVEN + QFETCH(Handler *, handler); + QFETCH(ChannelMapper *, mapper); + QFETCH(QVector<ChannelNameAndType>, expectedResults); + + // WHEN + const QVector<ChannelNameAndType> actualResults = buildRequiredChannelsAndTypes(handler, mapper); + + // THEN + QCOMPARE(actualResults.size(), expectedResults.size()); + for (int i = 0; i < actualResults.size(); ++i) + QCOMPARE(actualResults[i], expectedResults[i]); + + // Cleanup + delete handler; + } }; QTEST_MAIN(tst_AnimationUtils) |