Remove remaining messaging code in QSkeletonLoader

And matching unit tests

Change-Id: Iff0b13b2ad9ff07d08c767f4b20de2a1685a5570
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
Mike Krus 2019-10-22 08:03:42 +01:00
parent 7f3bba6e8a
commit 4d0f8bcdea
3 changed files with 0 additions and 141 deletions

View File

@ -238,18 +238,6 @@ void QSkeletonLoader::setRootJoint(QJoint *rootJoint)
/*! \internal */ /*! \internal */
void QSkeletonLoader::sceneChangeEvent(const QSceneChangePtr &change) void QSkeletonLoader::sceneChangeEvent(const QSceneChangePtr &change)
{ {
Q_D(QSkeletonLoader);
if (change->type() == Qt3DCore::PropertyUpdated) {
auto propertyChange = qSharedPointerCast<QStaticPropertyUpdatedChangeBase>(change);
if (propertyChange->propertyName() == QByteArrayLiteral("status")) {
const auto e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
d->setStatus(static_cast<QSkeletonLoader::Status>(e->value().toInt()));
} else if (propertyChange->propertyName() == QByteArrayLiteral("rootJoint")) {
auto typedChange = qSharedPointerCast<QJointChange>(propertyChange);
auto rootJoint = std::move(typedChange->data);
setRootJoint(rootJoint.release());
}
}
QAbstractSkeleton::sceneChangeEvent(change); QAbstractSkeleton::sceneChangeEvent(change);
} }

View File

@ -209,71 +209,6 @@ private Q_SLOTS:
QCOMPARE(arbiter.events.size(), 0); QCOMPARE(arbiter.events.size(), 0);
} }
} }
void checkStatusPropertyUpdate()
{
// GIVEN
qRegisterMetaType<Qt3DCore::QSkeletonLoader::Status>("Status");
TestArbiter arbiter;
arbiter.setArbiterOnNode(this);
QSignalSpy spy(this, SIGNAL(statusChanged(Status)));
const QSkeletonLoader::Status newStatus = QSkeletonLoader::Error;
// THEN
QVERIFY(spy.isValid());
// WHEN
QPropertyUpdatedChangePtr valueChange(new QPropertyUpdatedChange(QNodeId()));
valueChange->setPropertyName("status");
valueChange->setValue(QVariant::fromValue(newStatus));
sceneChangeEvent(valueChange);
// THEN
QCOMPARE(spy.count(), 1);
QCOMPARE(arbiter.events.size(), 0);
QCOMPARE(status(), newStatus);
// WHEN
spy.clear();
sceneChangeEvent(valueChange);
// THEN
QCOMPARE(spy.count(), 0);
QCOMPARE(arbiter.events.size(), 0);
QCOMPARE(status(), newStatus);
// Cleanup
QNodePrivate::get(this)->setArbiter(nullptr);
}
void checkRootJointPropertyUpdate()
{
// GIVEN
qRegisterMetaType<Qt3DCore::QJoint*>();
TestArbiter arbiter;
arbiter.setArbiterOnNode(this);
QSignalSpy spy(this, SIGNAL(rootJointChanged(Qt3DCore::QJoint*)));
std::unique_ptr<QJoint> root(new QJoint());
// THEN
QVERIFY(spy.isValid());
QVERIFY(rootJoint() == nullptr);
// WHEN
auto valueChange = QJointChangePtr::create(id());
valueChange->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
valueChange->setPropertyName("rootJoint");
valueChange->data = std::move(root);
sceneChangeEvent(valueChange);
// THEN
QCOMPARE(spy.count(), 1);
QCOMPARE(arbiter.dirtyNodes.size(), 1);
QVERIFY(rootJoint() != nullptr);
// Cleanup
QNodePrivate::get(this)->setArbiter(nullptr);
}
}; };
QTEST_MAIN(tst_QSkeletonLoader) QTEST_MAIN(tst_QSkeletonLoader)

View File

@ -198,70 +198,6 @@ private Q_SLOTS:
joint->setName(name); joint->setName(name);
QTest::newRow("inverseBind") << m << localPose << name << joint; QTest::newRow("inverseBind") << m << localPose << name << joint;
} }
void checkCreateFrontendJoints_data()
{
QTest::addColumn<SkeletonData>("skeletonData");
QTest::addColumn<QJoint *>("expectedRootJoint");
QTest::newRow("empty") << SkeletonData() << static_cast<QJoint*>(nullptr);
SkeletonData skeletonData;
JointInfo rootJointInfo;
skeletonData.joints.push_back(rootJointInfo);
skeletonData.jointNames.push_back(QLatin1String("rootJoint"));
skeletonData.localPoses.push_back(Qt3DCore::Sqt());
const int childCount = 10;
for (int i = 0; i < childCount; ++i) {
JointInfo childJointInfo;
childJointInfo.parentIndex = 0;
skeletonData.joints.push_back(childJointInfo);
const float x = static_cast<float>(i);
Qt3DCore::Sqt localPose;
localPose.translation = QVector3D(x, x, x);
skeletonData.localPoses.push_back(localPose);
skeletonData.jointNames.push_back(QString("Child-%1").arg(i));
}
QJoint *rootJoint = new QJoint();
for (int i = 0; i < childCount; ++i) {
QJoint *childJoint = new QJoint();
const float x = static_cast<float>(i);
childJoint->setTranslation(QVector3D(x, x, x));
rootJoint->addChildJoint(childJoint);
}
QTest::newRow("wide") << skeletonData << rootJoint;
skeletonData.joints.clear();
skeletonData.joints.push_back(rootJointInfo);
for (int i = 0; i < childCount; ++i) {
JointInfo childJointInfo;
childJointInfo.parentIndex = i;
skeletonData.joints.push_back(childJointInfo);
const float x = static_cast<float>(i);
Qt3DCore::Sqt localPose;
localPose.translation = QVector3D(x, x, x);
skeletonData.localPoses.push_back(localPose);
skeletonData.jointNames.push_back(QString("Child-%1").arg(i));
}
rootJoint = new QJoint();
QJoint *previousJoint = rootJoint;
for (int i = 0; i < childCount; ++i) {
QJoint *childJoint = new QJoint();
const float x = static_cast<float>(i);
childJoint->setTranslation(QVector3D(x, x, x));
previousJoint->addChildJoint(childJoint);
previousJoint = childJoint;
}
QTest::newRow("deep") << skeletonData << rootJoint;
}
}; };
QTEST_APPLESS_MAIN(tst_Skeleton) QTEST_APPLESS_MAIN(tst_Skeleton)