diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-10-08 10:58:03 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-10-11 07:23:35 +0100 |
commit | d794202f3b15c31f68592bc6b8e21846e70438ad (patch) | |
tree | 94e22dbd453cf9dd154c8e2e2f4bca2300fa0887 /tests | |
parent | fb624a684e816fb8100de6e1a7ab85d15cc36c3a (diff) |
Clean QJoint message handling
Change-Id: Ib09024017a2d213e50b3acc89d7c411728eb1869
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/joint/tst_joint.cpp | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/tests/auto/render/joint/tst_joint.cpp b/tests/auto/render/joint/tst_joint.cpp index c08d36725..0388f4a80 100644 --- a/tests/auto/render/joint/tst_joint.cpp +++ b/tests/auto/render/joint/tst_joint.cpp @@ -32,10 +32,6 @@ #include <Qt3DCore/qjoint.h> #include <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/private/qscene_p.h> -#include <Qt3DCore/qpropertyupdatedchange.h> -#include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> -#include <Qt3DCore/qpropertynodeaddedchange.h> -#include <Qt3DCore/qpropertynoderemovedchange.h> #include <QtGui/qmatrix4x4.h> #include <QtGui/qvector3d.h> #include <qbackendnodetester.h> @@ -153,43 +149,36 @@ private Q_SLOTS: backendJoint.setRenderer(&renderer); backendJoint.setJointManager(nodeManagers.jointManager()); backendJoint.setSkeletonManager(nodeManagers.skeletonManager()); - Qt3DCore::QPropertyUpdatedChangePtr updateChange; + QJoint joint; + simulateInitializationSync(&joint, &backendJoint); // WHEN - updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setPropertyName("enabled"); - updateChange->setValue(true); - backendJoint.sceneChangeEvent(updateChange); + joint.setEnabled(false); + backendJoint.syncFromFrontEnd(&joint, false); // THEN - QCOMPARE(backendJoint.isEnabled(), true); + QCOMPARE(backendJoint.isEnabled(), false); // WHEN const QVector3D newTranslation = QVector3D(1.0f, 2.0f, 3.0f); - updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setPropertyName("translation"); - updateChange->setValue(newTranslation); - backendJoint.sceneChangeEvent(updateChange); + joint.setTranslation(newTranslation); + backendJoint.syncFromFrontEnd(&joint, false); // THEN QCOMPARE(backendJoint.translation(), newTranslation); // WHEN const QQuaternion newRotation = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, 45.0f); - updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setPropertyName("rotation"); - updateChange->setValue(newRotation); - backendJoint.sceneChangeEvent(updateChange); + joint.setRotation(newRotation); + backendJoint.syncFromFrontEnd(&joint, false); // THEN QCOMPARE(backendJoint.rotation(), newRotation); // WHEN const QVector3D newScale = QVector3D(1.5f, 2.5f, 3.5f); - updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setPropertyName("scale"); - updateChange->setValue(newScale); - backendJoint.sceneChangeEvent(updateChange); + joint.setScale(newScale); + backendJoint.syncFromFrontEnd(&joint, false); // THEN QCOMPARE(backendJoint.scale(), newScale); @@ -197,44 +186,34 @@ private Q_SLOTS: // WHEN QMatrix4x4 newInverseBind; newInverseBind.scale(5.4f); - updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setPropertyName("inverseBindMatrix"); - updateChange->setValue(newInverseBind); - backendJoint.sceneChangeEvent(updateChange); + joint.setInverseBindMatrix(newInverseBind); + backendJoint.syncFromFrontEnd(&joint, false); // THEN QCOMPARE(backendJoint.inverseBindMatrix(), newInverseBind); // WHEN QVector<QJoint *> childJoints; - QPropertyNodeAddedChangePtr nodeAddedChange; for (int i = 0; i < 10; ++i) { const auto childJoint = new QJoint(); childJoints.push_back(childJoint); - - nodeAddedChange.reset(new QPropertyNodeAddedChange(QNodeId(), childJoint)); - nodeAddedChange->setPropertyName("childJoint"); - backendJoint.sceneChangeEvent(nodeAddedChange); + joint.addChildJoint(childJoint); } + backendJoint.syncFromFrontEnd(&joint, false); // THEN - for (int i = 0; i < childJoints.size(); ++i) { + for (int i = 0; i < childJoints.size(); ++i) QCOMPARE(backendJoint.childJointIds()[i], childJoints[i]->id()); - } - QPropertyNodeRemovedChangePtr nodeRemovedChange; for (int i = 0; i < 10; ++i) { // WHEN const auto childJoint = childJoints.takeLast(); - - nodeRemovedChange.reset(new QPropertyNodeRemovedChange(QNodeId(), childJoint)); - nodeRemovedChange->setPropertyName("childJoint"); - backendJoint.sceneChangeEvent(nodeAddedChange); + joint.removeChildJoint(childJoint); + backendJoint.syncFromFrontEnd(&joint, false); // THEN - for (int i = 0; i < childJoints.size(); ++i) { + for (int i = 0; i < childJoints.size(); ++i) QCOMPARE(backendJoint.childJointIds()[i], childJoints[i]->id()); - } } } @@ -314,9 +293,8 @@ private Q_SLOTS: backendJoint.syncFromFrontEnd(&joint, false); // THEN - for (int i = 0; i < childJoints.size(); ++i) { - QCOMPARE(backendJoint.childJointIds()[i], childJoints[i]->id()); - } + for (int j = 0; j < childJoints.size(); ++j) + QCOMPARE(backendJoint.childJointIds()[j], childJoints[j]->id()); } } }; |