summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-09-26 15:21:50 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-09-27 12:51:00 +0000
commit78175fa89bc95b88466ecf1ac8b42244762e62e2 (patch)
treeb5fe152b2e3288878a185cb95501da0fa1f4ecf8 /tests
parenta286529cbe2ae51e6bf19aaea4203afd6b4884de (diff)
Add convenience function to ChannelMapper to return list of Mappings
Caches the resolution of node ids to ChannelMappings. Updated test to check this new feature. Change-Id: I0c2f539c2bd91e7918b98c5b60c9ca486b63ec08 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/channelmapper/tst_channelmapper.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/auto/animation/channelmapper/tst_channelmapper.cpp b/tests/auto/animation/channelmapper/tst_channelmapper.cpp
index 4dcb52aef..446e1a0c5 100644
--- a/tests/auto/animation/channelmapper/tst_channelmapper.cpp
+++ b/tests/auto/animation/channelmapper/tst_channelmapper.cpp
@@ -30,6 +30,8 @@
#include <qbackendnodetester.h>
#include <Qt3DAnimation/private/handler_p.h>
#include <Qt3DAnimation/private/channelmapper_p.h>
+#include <Qt3DAnimation/private/channelmapping_p.h>
+#include <Qt3DAnimation/private/managers_p.h>
#include <Qt3DAnimation/qchannelmapper.h>
#include <Qt3DAnimation/qchannelmapping.h>
#include <Qt3DAnimation/private/qchannelmapper_p.h>
@@ -116,13 +118,40 @@ private Q_SLOTS:
// WHEN
Qt3DAnimation::QChannelMapping mapping;
const Qt3DCore::QNodeId mappingId = mapping.id();
- const auto nodeAddedChange = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &mapping);
+ Qt3DAnimation::Animation::ChannelMapping *backendMapping
+ = handler.channelMappingManager()->getOrCreateResource(mappingId);
+ backendMapping->setHandler(&handler);
+ simulateInitialization(&mapping, backendMapping);
+
+ auto nodeAddedChange = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &mapping);
nodeAddedChange->setPropertyName("mappings");
backendMapper.sceneChangeEvent(nodeAddedChange);
// THEN
QCOMPARE(backendMapper.mappingIds().size(), 1);
QCOMPARE(backendMapper.mappingIds().first(), mappingId);
+ QCOMPARE(backendMapper.mappings().size(), 1);
+ QCOMPARE(backendMapper.mappings().first(), backendMapping);
+
+ // WHEN
+ Qt3DAnimation::QChannelMapping mapping2;
+ const Qt3DCore::QNodeId mappingId2 = mapping2.id();
+ Qt3DAnimation::Animation::ChannelMapping *backendMapping2
+ = handler.channelMappingManager()->getOrCreateResource(mappingId2);
+ backendMapping2->setHandler(&handler);
+ simulateInitialization(&mapping2, backendMapping2);
+
+ nodeAddedChange = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &mapping2);
+ nodeAddedChange->setPropertyName("mappings");
+ backendMapper.sceneChangeEvent(nodeAddedChange);
+
+ // THEN
+ QCOMPARE(backendMapper.mappingIds().size(), 2);
+ QCOMPARE(backendMapper.mappingIds().first(), mappingId);
+ QCOMPARE(backendMapper.mappingIds().last(), mappingId2);
+ QCOMPARE(backendMapper.mappings().size(), 2);
+ QCOMPARE(backendMapper.mappings().first(), backendMapping);
+ QCOMPARE(backendMapper.mappings().last(), backendMapping2);
// WHEN
const auto nodeRemovedChange = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &mapping);
@@ -130,7 +159,10 @@ private Q_SLOTS:
backendMapper.sceneChangeEvent(nodeRemovedChange);
// THEN
- QCOMPARE(backendMapper.mappingIds().size(), 0);
+ QCOMPARE(backendMapper.mappingIds().size(), 1);
+ QCOMPARE(backendMapper.mappingIds().first(), mappingId2);
+ QCOMPARE(backendMapper.mappings().size(), 1);
+ QCOMPARE(backendMapper.mappings().first(), backendMapping2);
}
};