summaryrefslogtreecommitdiffstats
path: root/tests/auto/animation/channelmapping/tst_channelmapping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/animation/channelmapping/tst_channelmapping.cpp')
-rw-r--r--tests/auto/animation/channelmapping/tst_channelmapping.cpp53
1 files changed, 51 insertions, 2 deletions
diff --git a/tests/auto/animation/channelmapping/tst_channelmapping.cpp b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
index a947d4a2d..5c04c7f89 100644
--- a/tests/auto/animation/channelmapping/tst_channelmapping.cpp
+++ b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
@@ -41,6 +41,18 @@
#include <Qt3DCore/private/qbackendnode_p.h>
#include "testpostmanarbiter.h"
+class tst_TargetEntity : public Qt3DCore::QEntity
+{
+ Q_OBJECT
+ Q_PROPERTY(QVector2D foo MEMBER m_foo NOTIFY fooChanged)
+
+signals:
+ void fooChanged();
+
+private:
+ QVector2D m_foo;
+};
+
class tst_ChannelMapping : public Qt3DCore::QBackendNodeTester
{
Q_OBJECT
@@ -53,7 +65,7 @@ private Q_SLOTS:
Qt3DAnimation::Animation::ChannelMapping backendMapping;
backendMapping.setHandler(&handler);
Qt3DAnimation::QChannelMapping mapping;
- auto target = new Qt3DCore::QEntity;
+ auto target = new tst_TargetEntity;
mapping.setChannelName(QLatin1String("Location"));
mapping.setTarget(target);
@@ -68,6 +80,9 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), mapping.channelName());
QCOMPARE(backendMapping.targetId(), mapping.target()->id());
QCOMPARE(backendMapping.property(), mapping.property());
+ QVERIFY(qstrcmp(backendMapping.propertyName(), "foo") == 0);
+ QCOMPARE(backendMapping.componentCount(), 2);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Vector2D));
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
// GIVEN
@@ -100,12 +115,15 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.propertyName(), nullptr);
+ QCOMPARE(backendMapping.componentCount(), 0);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Invalid));
QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
// GIVEN
Qt3DAnimation::QChannelMapping mapping;
- auto target = new Qt3DCore::QEntity;
+ auto target = new tst_TargetEntity;
mapping.setChannelName(QLatin1String("Location"));
mapping.setTarget(target);
mapping.setProperty(QLatin1String("foo"));
@@ -120,6 +138,9 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.propertyName(), nullptr);
+ QCOMPARE(backendMapping.componentCount(), 0);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Invalid));
QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
}
@@ -172,6 +193,34 @@ private Q_SLOTS:
QCOMPARE(backendMapping.property(), property);
// WHEN
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("type");
+ updateChange->setValue(QVariant(static_cast<int>(QVariant::Vector3D)));
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Vector3D));
+
+ // WHEN
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("componentCount");
+ updateChange->setValue(4);
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.componentCount(), 4);
+
+ // WHEN
+ const char *testName = "883";
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("propertyName");
+ updateChange->setValue(QVariant::fromValue(reinterpret_cast<void *>(const_cast<char *>(testName))));
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.propertyName(), testName);
+
+ // WHEN
const auto skeletonId = Qt3DCore::QNodeId::createId();
updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
updateChange->setPropertyName("skeleton");