summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-09-30 10:47:48 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-09-30 17:04:45 +0100
commit9c951154256734b36328142e1078382dc2d7ae01 (patch)
tree60bf432a557511b0a08b2f2dfff8276065e59150 /tests
parent205ba7689c3c6c547543cf4d5d7ec968cce9a7a5 (diff)
parentaee10edf33ccb1faf3179b23b44a2ad48bf4d0f0 (diff)
Merge branch '5.9' into 5.10
Conflicts: src/animation/backend/animationutils.cpp src/animation/backend/animationutils_p.h src/render/geometry/qmesh.cpp tests/auto/animation/animation.pro Change-Id: Ifb57bfb0b12b3ebf9ee177d4ea684134455b4143
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animation.pro3
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp117
-rw-r--r--tests/auto/animation/channelmapper/tst_channelmapper.cpp36
-rw-r--r--tests/auto/animation/clipblendvalue/tst_clipblendvalue.cpp6
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/clip1.json114
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.pro15
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.qrc5
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp204
-rw-r--r--tests/auto/render/meshfunctors/tst_meshfunctors.cpp44
9 files changed, 448 insertions, 96 deletions
diff --git a/tests/auto/animation/animation.pro b/tests/auto/animation/animation.pro
index eff1a4779..c97b07923 100644
--- a/tests/auto/animation/animation.pro
+++ b/tests/auto/animation/animation.pro
@@ -38,5 +38,6 @@ qtConfig(private_tests) {
animationutils \
qabstractanimation \
clock \
- skeleton
+ skeleton \
+ findrunningclipanimatorsjob
}
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp
index 9bc7a8c47..177dbd19a 100644
--- a/tests/auto/animation/animationutils/tst_animationutils.cpp
+++ b/tests/auto/animation/animationutils/tst_animationutils.cpp
@@ -271,77 +271,6 @@ public:
private Q_SLOTS:
void checkBuildPropertyMappings_data()
{
- QTest::addColumn<Handler *>("handler");
- QTest::addColumn<QVector<ChannelMapping *>>("channelMappings");
- QTest::addColumn<ChannelMapper *>("channelMapper");
- QTest::addColumn<AnimationClip *>("clip");
- QTest::addColumn<QVector<MappingData>>("expectedMappingData");
-
- 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);
-
- // ... a channel mapper...
- auto channelMapper = createChannelMapper(handler, QVector<Qt3DCore::QNodeId>() << channelMapping->peerId());
-
- // ...and an animation clip
- auto clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json"));
-
- QVector<MappingData> mappingData;
- MappingData mapping;
- mapping.targetId = channelMapping->targetId();
- mapping.propertyName = channelMapping->propertyName(); // Location
- mapping.type = channelMapping->type();
- mapping.channelIndices = QVector<int>() << 0 << 1 << 2; // Location X, Y, Z
- mappingData.push_back(mapping);
-
- QTest::newRow("clip1.json") << handler
- << channelMappings
- << channelMapper
- << clip
- << mappingData;
- }
-
- void checkBuildPropertyMappings()
- {
- // GIVEN
- QFETCH(Handler *, handler);
- QFETCH(QVector<ChannelMapping *>, channelMappings);
- QFETCH(ChannelMapper *, channelMapper);
- QFETCH(AnimationClip *, clip);
- QFETCH(QVector<MappingData>, expectedMappingData);
-
- // WHEN
- // Build the mapping data for the above configuration
- QVector<MappingData> mappingData = buildPropertyMappings(handler, clip, channelMapper);
-
- // THEN
- QCOMPARE(mappingData.size(), expectedMappingData.size());
- for (int i = 0; i < mappingData.size(); ++i) {
- const auto mapping = mappingData[i];
- const auto expectedMapping = expectedMappingData[i];
-
- QCOMPARE(mapping.targetId, expectedMapping.targetId);
- QCOMPARE(mapping.propertyName, expectedMapping.propertyName);
- QCOMPARE(mapping.type, expectedMapping.type);
- QCOMPARE(mapping.channelIndices.size(), expectedMapping.channelIndices.size());
- for (int j = 0; j < mapping.channelIndices.size(); ++j) {
- QCOMPARE(mapping.channelIndices[j], expectedMapping.channelIndices[j]);
- }
- }
-
- // Cleanup
- delete handler;
- }
-
- void checkBuildPropertyMappings2_data()
- {
QTest::addColumn<QVector<ChannelMapping *>>("channelMappings");
QTest::addColumn<QVector<ChannelNameAndType>>("channelNamesAndTypes");
QTest::addColumn<QVector<ComponentIndices>>("channelComponentIndices");
@@ -507,7 +436,7 @@ private Q_SLOTS:
}
}
- void checkBuildPropertyMappings2()
+ void checkBuildPropertyMappings()
{
// GIVEN
QFETCH(QVector<ChannelMapping *>, channelMappings);
@@ -2088,6 +2017,18 @@ private Q_SLOTS:
QTest::newRow("simple lerp") << handler << lerp->peerId() << expectedIds;
}
+
+ {
+ Handler *handler = new Handler;
+
+ const auto value1 = createClipBlendValue(handler);
+ const auto clip1Id = Qt3DCore::QNodeId::createId();
+ value1->setClipId(clip1Id);
+
+ QVector<Qt3DCore::QNodeId> expectedIds = { value1->peerId() };
+
+ QTest::newRow("value only") << handler << value1->peerId() << expectedIds;
+ }
}
void checkGatherValueNodesToEvaluate()
@@ -2694,8 +2635,8 @@ private Q_SLOTS:
clip->setSource(QUrl("qrc:/clip3.json"));
clip->loadAnimation();
- ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation
- 4, 5, 6, // Location
+ ComponentIndices expectedResults = { 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json)
+ 4, 6, 5, // Location (y/z swapped in clip3.json)
7, 8, 9, // Base Color
10, // Metalness
11 }; // Roughness
@@ -2724,8 +2665,8 @@ private Q_SLOTS:
clip->setSource(QUrl("qrc:/clip3.json"));
clip->loadAnimation();
- ComponentIndices expectedResults = { 4, 5, 6, // Location
- 0, 1, 2, 3, // Rotation
+ ComponentIndices expectedResults = { 4, 6, 5, // Location (y/z swapped in clip3.json)
+ 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json)
7, 8, 9, // Base Color
10, // Metalness
11 }; // Roughness
@@ -2754,8 +2695,8 @@ private Q_SLOTS:
clip->setSource(QUrl("qrc:/clip3.json"));
clip->loadAnimation();
- ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation
- 4, 5, 6, // Location
+ ComponentIndices expectedResults = { 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json)
+ 4, 6, 5, // Location (y/z swapped in clip3.json)
-1, -1, -1, // Albedo (missing from clip)
10, // Metalness
11 }; // Roughness
@@ -2784,8 +2725,8 @@ private Q_SLOTS:
clip->setSource(QUrl("qrc:/clip3.json"));
clip->loadAnimation();
- ComponentIndices expectedResults = { 4, 5, 6, // Location
- 0, 1, 2, 3, // Rotation
+ ComponentIndices expectedResults = { 4, 6, 5, // Location (y/z swapped in clip3.json)
+ 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json)
-1, -1, -1, // Albedo (missing from clip)
10, // Metalness
11 }; // Roughness
@@ -2825,17 +2766,17 @@ private Q_SLOTS:
clip->setSource(QUrl("qrc:/clip5.json"));
clip->loadAnimation();
- ComponentIndices expectedResults = { 4, 5, 6, // Location, joint 0
- 0, 1, 2, 3, // Rotation, joint 0
+ ComponentIndices expectedResults = { 4, 6, 5, // Location, joint 0 (y/z swapped in clip5.json)
+ 0, 1, 3, 2, // Rotation, joint 0 (y/z swapped in clip5.json)
7, 8, 9, // Scale, joint 0
- 14, 15, 16, // Location, joint 1
- 10, 11, 12, 13, // Rotation, joint 1
+ 14, 16, 15, // Location, joint 1 (y/z swapped in clip5.json)
+ 10, 11, 13, 12, // Rotation, joint 1 (y/z swapped in clip5.json)
17, 18, 19, // Scale, joint 1
- 24, 25, 26, // Location, joint 2
- 20, 21, 22, 23, // Rotation, joint 2
+ 24, 26, 25, // Location, joint 2 (y/z swapped in clip5.json)
+ 20, 21, 23, 22, // Rotation, joint 2 (y/z swapped in clip5.json)
27, 28, 29, // Scale, joint 2
- 34, 35, 36, // Location, joint 3
- 30, 31, 32, 33, // Rotation, joint 3
+ 34, 36, 35, // Location, joint 3 (y/z swapped in clip5.json)
+ 30, 31, 33, 32, // Rotation, joint 3 (y/z swapped in clip5.json)
37, 38, 39 }; // Scale, joint 3
QTest::newRow("skeleton (SQT), 4 joints")
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);
}
};
diff --git a/tests/auto/animation/clipblendvalue/tst_clipblendvalue.cpp b/tests/auto/animation/clipblendvalue/tst_clipblendvalue.cpp
index 6fe2846b8..fcbc167ca 100644
--- a/tests/auto/animation/clipblendvalue/tst_clipblendvalue.cpp
+++ b/tests/auto/animation/clipblendvalue/tst_clipblendvalue.cpp
@@ -137,8 +137,7 @@ private Q_SLOTS:
QVector<Qt3DCore::QNodeId> actualIds = clipNode.currentDependencyIds();
// THEN
- QCOMPARE(actualIds.size(), 1);
- QCOMPARE(actualIds[0], clipId);
+ QCOMPARE(actualIds.size(), 0);
// WHEN
auto anotherClipId = Qt3DCore::QNodeId::createId();
@@ -146,8 +145,7 @@ private Q_SLOTS:
actualIds = clipNode.currentDependencyIds();
// THEN
- QCOMPARE(actualIds.size(), 1);
- QCOMPARE(actualIds[0], anotherClipId);
+ QCOMPARE(actualIds.size(), 0);
}
void checkDuration()
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/clip1.json b/tests/auto/animation/findrunningclipanimatorsjob/clip1.json
new file mode 100644
index 000000000..a2ad365a8
--- /dev/null
+++ b/tests/auto/animation/findrunningclipanimatorsjob/clip1.json
@@ -0,0 +1,114 @@
+{
+ "animations": [
+ {
+ "animationName": "CubeAction",
+ "channels": [
+ {
+ "channelComponents": [
+ {
+ "channelComponentName": "Location X",
+ "keyFrames": [
+ {
+ "coords": [
+ 0.0,
+ 0.0
+ ],
+ "leftHandle": [
+ -0.9597616195678711,
+ 0.0
+ ],
+ "rightHandle": [
+ 0.9597616195678711,
+ 0.0
+ ]
+ },
+ {
+ "coords": [
+ 2.4583333333333335,
+ 5.0
+ ],
+ "leftHandle": [
+ 1.4985717137654622,
+ 5.0
+ ],
+ "rightHandle": [
+ 3.4180949529012046,
+ 5.0
+ ]
+ }
+ ]
+ },
+ {
+ "channelComponentName": "Location Y",
+ "keyFrames": [
+ {
+ "coords": [
+ 0.0,
+ 0.0
+ ],
+ "leftHandle": [
+ -0.9597616195678711,
+ 0.0
+ ],
+ "rightHandle": [
+ 0.9597616195678711,
+ 0.0
+ ]
+ },
+ {
+ "coords": [
+ 2.4583333333333335,
+ 0.0
+ ],
+ "leftHandle": [
+ 1.4985717137654622,
+ 0.0
+ ],
+ "rightHandle": [
+ 3.4180949529012046,
+ 0.0
+ ]
+ }
+ ]
+ },
+ {
+ "channelComponentName": "Location Z",
+ "keyFrames": [
+ {
+ "coords": [
+ 0.0,
+ 0.0
+ ],
+ "leftHandle": [
+ -0.9597616195678711,
+ 0.0
+ ],
+ "rightHandle": [
+ 0.9597616195678711,
+ 0.0
+ ]
+ },
+ {
+ "coords": [
+ 2.4583333333333335,
+ 0.0
+ ],
+ "leftHandle": [
+ 1.4985717137654622,
+ 0.0
+ ],
+ "rightHandle": [
+ 3.4180949529012046,
+ 0.0
+ ]
+ }
+ ]
+ }
+ ],
+ "channelName": "Location"
+ }
+ ]
+ }
+ ]
+}
+
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.pro b/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.pro
new file mode 100644
index 000000000..f81b95dcd
--- /dev/null
+++ b/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+
+TARGET = tst_findrunningclipanimatorsjob
+
+QT += core-private 3dcore 3dcore-private 3danimation 3danimation-private testlib
+
+CONFIG += testcase
+
+SOURCES += \
+ tst_findrunningclipanimatorsjob.cpp
+
+include(../../core/common/common.pri)
+
+RESOURCES += \
+ findrunningclipanimatorsjob.qrc
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.qrc b/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.qrc
new file mode 100644
index 000000000..72234ec64
--- /dev/null
+++ b/tests/auto/animation/findrunningclipanimatorsjob/findrunningclipanimatorsjob.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>clip1.json</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
new file mode 100644
index 000000000..79d18b7cf
--- /dev/null
+++ b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QTest>
+#include <Qt3DAnimation/qanimationcliploader.h>
+#include <Qt3DAnimation/qclipanimator.h>
+#include <Qt3DAnimation/qchannelmapper.h>
+#include <Qt3DAnimation/qchannelmapping.h>
+#include <Qt3DAnimation/private/clipanimator_p.h>
+#include <Qt3DAnimation/private/channelmapper_p.h>
+#include <Qt3DAnimation/private/channelmapping_p.h>
+#include <Qt3DAnimation/private/findrunningclipanimatorsjob_p.h>
+#include <Qt3DAnimation/private/handler_p.h>
+#include <Qt3DAnimation/private/managers_p.h>
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/private/qbackendnode_p.h>
+#include <qbackendnodetester.h>
+#include <testpostmanarbiter.h>
+
+using namespace Qt3DAnimation::Animation;
+
+Q_DECLARE_METATYPE(Qt3DAnimation::Animation::Handler*)
+Q_DECLARE_METATYPE(QVector<Qt3DAnimation::Animation::HClipAnimator>)
+
+typedef QHash<ClipAnimator*, QVector<Qt3DAnimation::Animation::MappingData>> MappingDataResults;
+Q_DECLARE_METATYPE(MappingDataResults)
+
+class tst_FindRunningClipAnimatorsJob: public Qt3DCore::QBackendNodeTester
+{
+ Q_OBJECT
+public:
+ ChannelMapping *createChannelMapping(Handler *handler,
+ const QString &channelName,
+ const Qt3DCore::QNodeId targetId,
+ const QString &property,
+ const char *propertyName,
+ int type)
+ {
+ auto channelMappingId = Qt3DCore::QNodeId::createId();
+ ChannelMapping *channelMapping = handler->channelMappingManager()->getOrCreateResource(channelMappingId);
+ setPeerId(channelMapping, channelMappingId);
+ channelMapping->setHandler(handler);
+ channelMapping->setTargetId(targetId);
+ channelMapping->setProperty(property);
+ channelMapping->setPropertyName(propertyName);
+ channelMapping->setChannelName(channelName);
+ channelMapping->setType(type);
+ return channelMapping;
+ }
+
+ ChannelMapper *createChannelMapper(Handler *handler,
+ const QVector<Qt3DCore::QNodeId> &mappingIds)
+ {
+ auto channelMapperId = Qt3DCore::QNodeId::createId();
+ ChannelMapper *channelMapper = handler->channelMapperManager()->getOrCreateResource(channelMapperId);
+ setPeerId(channelMapper, channelMapperId);
+ channelMapper->setHandler(handler);
+ channelMapper->setMappingIds(mappingIds);
+ return channelMapper;
+ }
+
+ AnimationClip *createAnimationClipLoader(Handler *handler,
+ const QUrl &source)
+ {
+ auto clipId = Qt3DCore::QNodeId::createId();
+ AnimationClip *clip = handler->animationClipLoaderManager()->getOrCreateResource(clipId);
+ setPeerId(clip, clipId);
+ clip->setHandler(handler);
+ clip->setDataType(AnimationClip::File);
+ clip->setSource(source);
+ clip->loadAnimation();
+ return clip;
+ }
+
+ ClipAnimator *createClipAnimator(Handler *handler,
+ qint64 globalStartTimeNS,
+ int loops)
+ {
+ auto animatorId = Qt3DCore::QNodeId::createId();
+ ClipAnimator *animator = handler->clipAnimatorManager()->getOrCreateResource(animatorId);
+ setPeerId(animator, animatorId);
+ animator->setHandler(handler);
+ animator->setStartTime(globalStartTimeNS);
+ animator->setLoops(loops);
+ return animator;
+ }
+
+private Q_SLOTS:
+ void checkJob_data()
+ {
+ QTest::addColumn<Handler *>("handler");
+ QTest::addColumn<QVector<HClipAnimator>>("dirtyClipAnimators");
+ QTest::addColumn<MappingDataResults>("expectedResults");
+
+ Handler *handler;
+ AnimationClip *clip;
+ ClipAnimator *animator;
+ QVector<HClipAnimator> dirtyClipAnimators;
+ ChannelMapper *channelMapper;
+ MappingDataResults expectedResults;
+
+ {
+ handler = new Handler();
+ clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json"));
+
+ const qint64 globalStartTimeNS = 0;
+ const int loops = 1;
+ animator = createClipAnimator(handler, globalStartTimeNS, loops);
+ animator->setClipId(clip->peerId());
+ dirtyClipAnimators = (QVector<HClipAnimator>()
+ << handler->clipAnimatorManager()->getOrAcquireHandle(animator->peerId()));
+
+ auto channelMapping = createChannelMapping(handler,
+ QLatin1String("Location"),
+ Qt3DCore::QNodeId::createId(),
+ QLatin1String("translation"),
+ "translation",
+ static_cast<int>(QVariant::Vector3D));
+ QVector<ChannelMapping *> channelMappings;
+ channelMappings.push_back(channelMapping);
+
+ channelMapper = createChannelMapper(handler, QVector<Qt3DCore::QNodeId>() << channelMapping->peerId());
+ animator->setMapperId(channelMapper->peerId());
+ animator->setRunning(true); // Has to be marked as running for the job to process it
+
+ const ComponentIndices locationIndices = { 0, 1, 2 };
+ MappingData expectedMapping;
+ expectedMapping.targetId = channelMapping->targetId();
+ expectedMapping.propertyName = channelMapping->propertyName();
+ expectedMapping.type = channelMapping->type();
+ expectedMapping.channelIndices = locationIndices;
+ expectedResults.insert(animator, QVector<MappingData>() << expectedMapping);
+
+ QTest::newRow("single mapping")
+ << handler
+ << dirtyClipAnimators
+ << expectedResults;
+ }
+ }
+
+ void checkJob()
+ {
+ // GIVEN
+ QFETCH(Handler *, handler);
+ QFETCH(QVector<HClipAnimator>, dirtyClipAnimators);
+ QFETCH(MappingDataResults, expectedResults);
+ FindRunningClipAnimatorsJob job;
+
+ // WHEN
+ job.setHandler(handler);
+ job.setDirtyClipAnimators(dirtyClipAnimators);
+ job.run();
+
+ // THEN - check the resulting MappingData on the animator matches the expected results
+ for (const auto &dirtyClipAnimator : dirtyClipAnimators) {
+ const auto animator = handler->clipAnimatorManager()->data(dirtyClipAnimator);
+ const QVector<MappingData> actualMappingData = animator->mappingData();
+ const QVector<MappingData> expectedMappingData = expectedResults[animator];
+
+ QCOMPARE(expectedMappingData.size(), actualMappingData.size());
+ for (int i = 0; i < actualMappingData.size(); ++i) {
+ QCOMPARE(expectedMappingData[i].targetId, actualMappingData[i].targetId);
+ QCOMPARE(expectedMappingData[i].type, actualMappingData[i].type);
+ QVERIFY(qstrcmp(expectedMappingData[i].propertyName, actualMappingData[i].propertyName) == 0);
+ QCOMPARE(expectedMappingData[i].channelIndices.size(), actualMappingData[i].channelIndices.size());
+
+ for (int j = 0; j < actualMappingData[i].channelIndices.size(); ++j) {
+ QCOMPARE(expectedMappingData[i].channelIndices[j], actualMappingData[i].channelIndices[j]);
+ }
+ }
+ }
+ }
+};
+
+QTEST_APPLESS_MAIN(tst_FindRunningClipAnimatorsJob)
+
+#include "tst_findrunningclipanimatorsjob.moc"
diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
index bf5f0d55f..fd430c5d8 100644
--- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
+++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
@@ -27,8 +27,12 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <Qt3DCore/qcomponent.h>
#include <Qt3DRender/qgeometryfactory.h>
#include <Qt3DRender/qgeometry.h>
+#include <Qt3DRender/qmesh.h>
+#include <Qt3DRender/private/qmesh_p.h>
+#include <Qt3DCore/qaspectengine.h>
class MeshFunctorA : public Qt3DRender::QGeometryFactory
{
@@ -117,8 +121,46 @@ private Q_SLOTS:
QVERIFY(*functorB == *functorB);
QVERIFY(*functorASub == *functorASub);
}
+
+ void checkMeshFunctorEquality()
+ {
+ // GIVEN
+ Qt3DCore::QAspectEngine engine;
+ auto meshA = new Qt3DRender::QMesh();
+ meshA->setSource(QUrl::fromLocalFile(QLatin1String("/foo")));
+ meshA->setMeshName(QLatin1String("bar"));
+
+ auto meshB = new Qt3DRender::QMesh();
+ meshB->setSource(QUrl::fromLocalFile(QLatin1String("/foo")));
+ meshB->setMeshName(QLatin1String("baz"));
+
+ auto meshC = new Qt3DRender::QMesh();
+ meshC->setSource(QUrl::fromLocalFile(QLatin1String("/baz")));
+ meshC->setMeshName(QLatin1String("bar"));
+
+ auto meshD = new Qt3DRender::QMesh();
+ meshD->setSource(QUrl::fromLocalFile(QLatin1String("/foo")));
+ meshD->setMeshName(QLatin1String("bar"));
+
+ const Qt3DRender::MeshLoaderFunctor functorA(meshA, &engine);
+ const Qt3DRender::MeshLoaderFunctor functorB(meshB, &engine);
+ const Qt3DRender::MeshLoaderFunctor functorC(meshC, &engine);
+ const Qt3DRender::MeshLoaderFunctor functorD(meshD, &engine);
+
+ // WHEN
+ const bool selfEquality = (functorA == functorA);
+ const bool sameSource = (functorA == functorB);
+ const bool sameMeshName = (functorA == functorC);
+ const bool perfectMatch = (functorA == functorD);
+
+ // THEN
+ QCOMPARE(selfEquality, true);
+ QCOMPARE(sameSource, false);
+ QCOMPARE(sameMeshName, false);
+ QCOMPARE(perfectMatch, true);
+ }
};
-QTEST_APPLESS_MAIN(tst_MeshFunctors)
+QTEST_MAIN(tst_MeshFunctors)
#include "tst_meshfunctors.moc"