diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-06-19 08:20:50 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-06-19 08:20:51 +0200 |
commit | e35b41fa9f713dcbfb7299b9effeadf52cfb6353 (patch) | |
tree | 548a7b2243ed5bd70e4599dfcf0198f0fedddf05 /tests/auto/animation/animationutils/tst_animationutils.cpp | |
parent | 9c28631440e37444ade0a1e1634d8f4d46bcd4d7 (diff) | |
parent | 01a6bcd086cecef3169e5d79bd72dbb0d1393a0f (diff) |
Merge 5.9 into 5.9.1
Change-Id: Iaf884c049a4d109a0bb92e01c1e9f081ad5ce2b8
Diffstat (limited to 'tests/auto/animation/animationutils/tst_animationutils.cpp')
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index a70fd271c..4c97cf7e5 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -42,6 +42,7 @@ #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> #include <QtGui/qquaternion.h> +#include <QtGui/qcolor.h> #include <qbackendnodetester.h> #include <testpostmanarbiter.h> @@ -1000,7 +1001,7 @@ private Q_SLOTS: MappingData mapping; mapping.targetId = Qt3DCore::QNodeId::createId(); mapping.propertyName = "foo"; - mapping.type = static_cast<int>(QVariant::Vector2D); + mapping.type = static_cast<int>(QVariant::Vector4D); mapping.channelIndices = QVector<int>() << 0 << 1 << 2 << 3; mappingData.push_back(mapping); channelResults = QVector<float>() << 4.0f << 3.0f << 2.0f << 1.0f; @@ -1036,7 +1037,7 @@ private Q_SLOTS: auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(mapping.targetId); change->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); change->setPropertyName(mapping.propertyName); - change->setValue(QVariant::fromValue(QQuaternion(1.0f, 0.0f, 0.0f, 1.0f))); + change->setValue(QVariant::fromValue(QQuaternion(1.0f, 0.0f, 0.0f, 1.0f).normalized())); expectedChanges.push_back(change); QTest::newRow("quaternion rotation") @@ -1047,6 +1048,34 @@ private Q_SLOTS: channelResults.clear(); expectedChanges.clear(); } + + // Single property, QColor + { + animatorId = Qt3DCore::QNodeId::createId(); + MappingData mapping; + mapping.targetId = Qt3DCore::QNodeId::createId(); + mapping.propertyName = "color"; + mapping.type = static_cast<int>(QVariant::Color); + mapping.channelIndices = QVector<int>() << 0 << 1 << 2; + mappingData.push_back(mapping); + channelResults = QVector<float>() << 0.5f << 0.4f << 0.3f; + finalFrame = false; + + auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(mapping.targetId); + change->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); + change->setPropertyName(mapping.propertyName); + change->setValue(QVariant::fromValue(QColor::fromRgbF(0.5f, 0.4f, 0.3f))); + expectedChanges.push_back(change); + + QTest::newRow("QColor color") + << animatorId << mappingData << channelResults << finalFrame + << expectedChanges; + + mappingData.clear(); + channelResults.clear(); + expectedChanges.clear(); + } + } void checkPreparePropertyChanges() @@ -1067,7 +1096,7 @@ private Q_SLOTS: for (int i = 0; i < actualChanges.size(); ++i) { auto expectedChange = expectedChanges[i]; auto actualChange - = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(expectedChanges[i]); + = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(actualChanges[i]); QCOMPARE(actualChange->subjectId(), expectedChange->subjectId()); QCOMPARE(actualChange->deliveryFlags(), expectedChange->deliveryFlags()); @@ -1157,6 +1186,28 @@ private Q_SLOTS: << handler << clip << localTime << expectedResults; expectedResults.clear(); } + { + // a clip with linear interpolation + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip4.json")); + localTime = clip->duration(); + expectedResults = QVector<float>() << 5.0 << -2.0f << 6.0f; + + QTest::newRow("clip4.json, linear, t = duration") + << handler << clip << localTime << expectedResults; + expectedResults.clear(); + } + { + // a clip with linear interpolation + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip4.json")); + localTime = clip->duration() / 2.0f; + expectedResults = QVector<float>() << 2.5f << -1.0f << 3.0f; + + QTest::newRow("clip4.json, linear, t = duration/2") + << handler << clip << localTime << expectedResults; + expectedResults.clear(); + } } void checkEvaluateClipAtLocalTime() |