summaryrefslogtreecommitdiffstats
path: root/tests/auto/core
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-08-06 15:30:01 +0100
committerPaul Lemire <paul.lemire@kdab.com>2019-08-28 06:30:29 +0200
commitf3268fcb2a4e73d99dbd66aa5e262a118b5a5480 (patch)
tree374bd9ace2fccaa33534f338950185368ab5598b /tests/auto/core
parent91dc1e1a61651a82a0ee5ce6ad3b24e82f526be6 (diff)
Do direct notification of backend nodeswip/refactor
Since aspect manager is now on main thread, we can directly update backend nodes safely. Track nodes which have changed properties and notify the backend nodes as part of the frame loop. This avoid allocating and delivering many change messages. To follow: - implement on all nodes - look at backend to frontend syncing - figure out what to do with non property messages (components added/removed, commands, ...) Change-Id: Ia0c442b0528e728c4324d168200bae021bc29266 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/auto/core')
-rw-r--r--tests/auto/core/common/testpostmanarbiter.cpp13
-rw-r--r--tests/auto/core/common/testpostmanarbiter.h3
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp129
-rw-r--r--tests/auto/core/qarmature/tst_qarmature.cpp23
-rw-r--r--tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp36
-rw-r--r--tests/auto/core/qjoint/tst_qjoint.cpp52
-rw-r--r--tests/auto/core/qscene/qscene.pro2
-rw-r--r--tests/auto/core/qscene/tst_qscene.cpp17
-rw-r--r--tests/auto/core/qskeleton/tst_qskeleton.cpp23
-rw-r--r--tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp29
-rw-r--r--tests/auto/core/qtransform/tst_qtransform.cpp52
11 files changed, 191 insertions, 188 deletions
diff --git a/tests/auto/core/common/testpostmanarbiter.cpp b/tests/auto/core/common/testpostmanarbiter.cpp
index ffc5bce5f..3fd8c80d1 100644
--- a/tests/auto/core/common/testpostmanarbiter.cpp
+++ b/tests/auto/core/common/testpostmanarbiter.cpp
@@ -72,7 +72,7 @@ void TestArbiter::sceneChangeEventWithLock(const Qt3DCore::QSceneChangePtr &e)
void TestArbiter::sceneChangeEventWithLock(const Qt3DCore::QSceneChangeList &e)
{
- events += QVector<Qt3DCore::QSceneChangePtr>::fromStdVector(e);
+ events += QVector<Qt3DCore::QSceneChangePtr>(e.begin(), e.end());
}
Qt3DCore::QAbstractPostman *TestArbiter::postman() const
@@ -88,4 +88,15 @@ void TestArbiter::setArbiterOnNode(Qt3DCore::QNode *node)
setArbiterOnNode(n);
}
+void TestArbiter::addDirtyFrontEndNode(Qt3DCore::QNode *node)
+{
+ if (!dirtyNodes.contains(node))
+ dirtyNodes << node;
+}
+
+void TestArbiter::removeDirtyFrontEndNode(Qt3DCore::QNode *node)
+{
+ dirtyNodes.removeOne(node);
+}
+
QT_END_NAMESPACE
diff --git a/tests/auto/core/common/testpostmanarbiter.h b/tests/auto/core/common/testpostmanarbiter.h
index 7d7e4e49b..8dfb5874e 100644
--- a/tests/auto/core/common/testpostmanarbiter.h
+++ b/tests/auto/core/common/testpostmanarbiter.h
@@ -66,8 +66,11 @@ public:
Qt3DCore::QAbstractPostman *postman() const final;
QVector<Qt3DCore::QSceneChangePtr> events;
+ QVector<Qt3DCore::QNode *> dirtyNodes;
void setArbiterOnNode(Qt3DCore::QNode *node);
+ void addDirtyFrontEndNode(Qt3DCore::QNode *node) final;
+ void removeDirtyFrontEndNode(Qt3DCore::QNode *node) final;
private:
TestPostman *m_postman;
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index d8ffbc361..dd6cc4892 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -103,6 +103,8 @@ private slots:
void checkEnabledUpdate();
void checkPropertyTrackModeUpdate();
void checkTrackedPropertyNamesUpdate();
+
+ void checkNodeRemovedFromDirtyListOnDestruction();
};
class ObserverSpy;
@@ -113,8 +115,8 @@ public:
: m_spy(spy)
{}
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) final {};
- void setScene(Qt3DCore::QScene *) final {};
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) final {}
+ void setScene(Qt3DCore::QScene *) final {}
void notifyBackend(const Qt3DCore::QSceneChangePtr &change) final;
bool shouldNotifyFrontend(const Qt3DCore::QSceneChangePtr &changee) final { Q_UNUSED(changee); return false; }
@@ -143,9 +145,7 @@ public:
{
}
- ~ObserverSpy()
- {
- }
+ ~ObserverSpy();
void sceneChangeEventWithLock(const Qt3DCore::QSceneChangePtr &e) override
{
@@ -169,10 +169,24 @@ public:
return m_postman.data();
}
+ void addDirtyFrontEndNode(Qt3DCore::QNode *node) final {
+ if (!dirtyNodes.contains(node))
+ dirtyNodes << node;
+ }
+
+ void removeDirtyFrontEndNode(Qt3DCore::QNode *node) final {
+ dirtyNodes.removeOne(node);
+ };
+
+ QVector<Qt3DCore::QNode *> dirtyNodes;
QList<ChangeRecord> events;
QScopedPointer<SimplePostman> m_postman;
};
+ObserverSpy::~ObserverSpy()
+{
+}
+
void SimplePostman::notifyBackend(const Qt3DCore::QSceneChangePtr &change)
{
m_spy->sceneChangeEventWithLock(change);
@@ -299,7 +313,7 @@ class MyQEntity : public Qt3DCore::QEntity
{
Q_OBJECT
public:
- explicit MyQEntity(Qt3DCore::QNode *parent = 0)
+ explicit MyQEntity(Qt3DCore::QNode *parent = nullptr)
: QEntity(parent)
{}
@@ -1244,10 +1258,10 @@ void tst_Nodes::checkConstructionWithParent()
root->setNodeProperty(node);
// THEN we should get one creation change, one child added change
- // and one property change event, in that order.
+ // in that order.
QCoreApplication::processEvents();
QCOMPARE(root->children().count(), 1);
- QCOMPARE(spy.events.size(), 3); // 1 creation change, 1 child added change, 1 property change
+ QCOMPARE(spy.events.size(), 2); // 1 creation change, 1 child added change
// Ensure first event is child node's creation change
const auto creationEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
@@ -1260,12 +1274,15 @@ void tst_Nodes::checkConstructionWithParent()
QCOMPARE(newChildEvent->propertyName(), "children");
QCOMPARE(newChildEvent->addedNodeId(), node->id());
- // Ensure second and last event is property set change
- const auto propertyEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QPropertyUpdatedChange>();
- QVERIFY(!propertyEvent.isNull());
- QCOMPARE(propertyEvent->subjectId(), root->id());
- QCOMPARE(propertyEvent->propertyName(), "nodeProperty");
- QCOMPARE(propertyEvent->value().value<Qt3DCore::QNodeId>(), node->id());
+ // Ensure the parent node is dirty
+ QCOMPARE(spy.dirtyNodes.size(), 1);
+ QCOMPARE(spy.dirtyNodes.front(), root.data());
+
+// const auto propertyEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QPropertyUpdatedChange>();
+// QVERIFY(!propertyEvent.isNull());
+// QCOMPARE(propertyEvent->subjectId(), root->id());
+// QCOMPARE(propertyEvent->propertyName(), "nodeProperty");
+// QCOMPARE(propertyEvent->value().value<Qt3DCore::QNodeId>(), node->id());
}
void tst_Nodes::checkConstructionWithNonRootParent()
@@ -1298,7 +1315,7 @@ void tst_Nodes::checkConstructionWithNonRootParent()
QCOMPARE(root->children().count(), 1);
QCOMPARE(parent->children().count(), 1);
- QCOMPARE(spy.events.size(), 4); // 2 creation changes, 1 child added changes, 1 property change
+ QCOMPARE(spy.events.size(), 3); // 2 creation changes, 1 child added changes
// Ensure first event is parent node's creation change
const auto parentCreationEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
@@ -1316,11 +1333,8 @@ void tst_Nodes::checkConstructionWithNonRootParent()
QCOMPARE(parentNewChildEvent->addedNodeId(), parent->id());
// Ensure second and last event is property set change
- const auto propertyEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QPropertyUpdatedChange>();
- QVERIFY(!propertyEvent.isNull());
- QCOMPARE(propertyEvent->subjectId(), root->id());
- QCOMPARE(propertyEvent->propertyName(), "nodeProperty");
- QCOMPARE(propertyEvent->value().value<Qt3DCore::QNodeId>(), child->id());
+ QCOMPARE(spy.dirtyNodes.size(), 1);
+ QCOMPARE(spy.dirtyNodes.front(), root.data());
}
void tst_Nodes::checkConstructionAsListElement()
@@ -1730,12 +1744,8 @@ void tst_Nodes::changeCustomProperty()
// WHEN
node->setCustomProperty(QStringLiteral("foo"));
// THEN
- QCOMPARE(spy.events.size(), 1);
- QVERIFY(spy.events.first().wasLocked());
- Qt3DCore::QPropertyUpdatedChangePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(event->type(), Qt3DCore::PropertyUpdated);
- QCOMPARE(event->propertyName(), "customProperty");
- QCOMPARE(event->value().toString(), QString("foo"));
+ QCOMPARE(spy.dirtyNodes.size(), 1);
+ QCOMPARE(spy.dirtyNodes.front(), node.data());
}
void tst_Nodes::checkDestruction()
@@ -1918,25 +1928,22 @@ void tst_Nodes::checkEnabledUpdate()
{
// WHEN
node.setEnabled(false);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "enabled");
- QCOMPARE(change->value().value<bool>(), node.isEnabled());
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), &node);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
{
// WHEN
node.setEnabled(false);
- QCoreApplication::processEvents();
// THEN
QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
}
@@ -1995,6 +2002,60 @@ void tst_Nodes::checkTrackedPropertyNamesUpdate()
}
+void tst_Nodes::checkNodeRemovedFromDirtyListOnDestruction()
+{
+ // GIVEN
+ TestArbiter arbiter;
+ Qt3DCore::QScene scene;
+
+ {
+ // GIVEN
+ QScopedPointer<MyQNode> node(new MyQNode());
+ node->setArbiterAndScene(&arbiter, &scene);
+
+ // WHEN
+ node->setEnabled(false);
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), node.data());
+
+ // WHEN
+ // scene should be unset and node removed from arbiter dirtyList
+ node.reset();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
+ }
+ {
+ // GIVEN
+ QScopedPointer<MyQNode> node(new MyQNode());
+ node->setArbiterAndScene(&arbiter, &scene);
+
+
+ Qt3DCore::QNode *child = new Qt3DCore::QNode(node.data());
+ // Wait for deferred initialization of child node
+ QCoreApplication::processEvents();
+
+ // WHEN
+ child->setEnabled(false);
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 2); // nodeCreated + childAdded
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), child);
+
+ // WHEN
+ // scene should be unset and child node removed from arbiter dirtyList
+ node.reset();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 2); // childRemoved + nodeDestroyed
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
+ }
+}
QTEST_MAIN(tst_Nodes)
diff --git a/tests/auto/core/qarmature/tst_qarmature.cpp b/tests/auto/core/qarmature/tst_qarmature.cpp
index f624b998f..b64757b5c 100644
--- a/tests/auto/core/qarmature/tst_qarmature.cpp
+++ b/tests/auto/core/qarmature/tst_qarmature.cpp
@@ -98,33 +98,22 @@ private Q_SLOTS:
// WHEN
QSkeleton *skeleton = new QSkeleton(armature.data());
- QCoreApplication::processEvents();
- arbiter.events.clear();
-
armature->setSkeleton(skeleton);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- QPropertyUpdatedChangePtr change = arbiter.events.first().staticCast<QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "skeleton");
- QCOMPARE(change->value().value<QNodeId>(), skeleton->id());
- QCOMPARE(change->type(), PropertyUpdated);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), armature.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
armature->setSkeleton(nullptr);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "skeleton");
- QCOMPARE(change->value().value<QNodeId>(), QNodeId());
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), armature.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
void checkSkeletonBookkeeping()
diff --git a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
index 6574a91d9..e1b92f797 100644
--- a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
+++ b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
@@ -810,25 +810,19 @@ void tst_QChangeArbiter::distributePropertyChanges()
// WHEN
root->setProp1(root->prop1() + 1);
- arbiter->syncChanges();
// THEN
- QVERIFY(!rootObserver->lastChange().isNull());
- QCOMPARE(rootObserver->lastChange()->type(), Qt3DCore::PropertyUpdated);
- Qt3DCore::QPropertyUpdatedChangePtr propChange = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(rootObserver->lastChange());
- QCOMPARE(root->id(), propChange->subjectId());
- QCOMPARE(QString(propChange->propertyName()), QString("prop1"));
+ auto dirtyNodes = arbiter->takeDirtyFrontEndNodes();
+ QCOMPARE(dirtyNodes.size(), 1);
+ QCOMPARE(dirtyNodes.front(), root);
// WHEN
root->setProp2(root->prop2() + 1.f);
- arbiter->syncChanges();
// THEN
- QVERIFY(!rootObserver->lastChange().isNull());
- QCOMPARE(rootObserver->lastChange()->type(), Qt3DCore::PropertyUpdated);
- propChange = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(rootObserver->lastChange());
- QCOMPARE(root->id(), propChange->subjectId());
- QCOMPARE(QString(propChange->propertyName()), QString("prop2"));
+ dirtyNodes = arbiter->takeDirtyFrontEndNodes();
+ QCOMPARE(dirtyNodes.size(), 1);
+ QCOMPARE(dirtyNodes.front(), root);
// Test change notifications made to an entity that was added to the scene
// via QNode::setParent()
@@ -839,14 +833,11 @@ void tst_QChangeArbiter::distributePropertyChanges()
tst_SimpleObserver *setParentChildObserver = new tst_SimpleObserver();
arbiter->registerObserver(setParentChildObserver, setParentChild->id());
setParentChild->setProp2(setParentChild->prop2() + 1.f);
- arbiter->syncChanges();
// THEN
- QVERIFY(!setParentChildObserver->lastChange().isNull());
- QCOMPARE(setParentChildObserver->lastChange()->type(), Qt3DCore::PropertyUpdated);
- propChange = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(setParentChildObserver->lastChange());
- QCOMPARE(setParentChild->id(), propChange->subjectId());
- QCOMPARE(QString(propChange->propertyName()), QString("prop2"));
+ dirtyNodes = arbiter->takeDirtyFrontEndNodes();
+ QCOMPARE(dirtyNodes.size(), 1);
+ QCOMPARE(dirtyNodes.front(), setParentChild);
// Test change notifications made to an entity that was added to the scene
// via the QNode() constructor parent parameter
@@ -857,14 +848,11 @@ void tst_QChangeArbiter::distributePropertyChanges()
tst_SimpleObserver *directChildObserver = new tst_SimpleObserver();
arbiter->registerObserver(directChildObserver, directChild->id());
directChild->setProp1(directChild->prop1() + 1);
- arbiter->syncChanges();
// THEN
- QVERIFY(!directChildObserver->lastChange().isNull());
- QCOMPARE(directChildObserver->lastChange()->type(), Qt3DCore::PropertyUpdated);
- propChange = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(directChildObserver->lastChange());
- QCOMPARE(directChild->id(), propChange->subjectId());
- QCOMPARE(QString(propChange->propertyName()), QString("prop1"));
+ dirtyNodes = arbiter->takeDirtyFrontEndNodes();
+ QCOMPARE(dirtyNodes.size(), 1);
+ QCOMPARE(dirtyNodes.front(), directChild);
Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data());
}
diff --git a/tests/auto/core/qjoint/tst_qjoint.cpp b/tests/auto/core/qjoint/tst_qjoint.cpp
index ec1a45f90..436814f7f 100644
--- a/tests/auto/core/qjoint/tst_qjoint.cpp
+++ b/tests/auto/core/qjoint/tst_qjoint.cpp
@@ -317,69 +317,54 @@ private Q_SLOTS:
{
// WHEN
joint.setScale(QVector3D(2.0f, 1.0f, 3.0f));
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "scale");
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
- QCOMPARE(change->value().value<QVector3D>(), joint.scale());
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), &joint);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
joint.setScale(QVector3D(2.0f, 1.0f, 3.0f));
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
{
// WHEN
const auto newValue = QQuaternion::fromAxisAndAngle(1.0f, 1.0f, 1.0f, 45.0f);
joint.setRotation(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rotation");
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
- QCOMPARE(change->value().value<QQuaternion>(), newValue);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), &joint);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
joint.setRotation(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
{
// WHEN
const QVector3D newValue(1.0f, 2.0f, 3.0f);
joint.setTranslation(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "translation");
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
- QCOMPARE(change->value().value<QVector3D>(), newValue);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), &joint);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
joint.setTranslation(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
{
@@ -387,23 +372,18 @@ private Q_SLOTS:
QMatrix4x4 newValue;
newValue.rotate(90.0f, 1.0f, 0.0f, 0.0f);
joint.setInverseBindMatrix(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "inverseBindMatrix");
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
- QCOMPARE(change->value().value<QMatrix4x4>(), newValue);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), &joint);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
joint.setInverseBindMatrix(newValue);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
}
};
diff --git a/tests/auto/core/qscene/qscene.pro b/tests/auto/core/qscene/qscene.pro
index 829130997..150b86f71 100644
--- a/tests/auto/core/qscene/qscene.pro
+++ b/tests/auto/core/qscene/qscene.pro
@@ -6,3 +6,5 @@ QT += testlib core-private 3dcore 3dcore-private
SOURCES += \
tst_qscene.cpp
+
+include(../common/common.pri)
diff --git a/tests/auto/core/qscene/tst_qscene.cpp b/tests/auto/core/qscene/tst_qscene.cpp
index 0a7e6d9b8..9a50d2abc 100644
--- a/tests/auto/core/qscene/tst_qscene.cpp
+++ b/tests/auto/core/qscene/tst_qscene.cpp
@@ -34,6 +34,7 @@
#include <Qt3DCore/private/qobservableinterface_p.h>
#include <Qt3DCore/private/qlockableobserverinterface_p.h>
#include <private/qnode_p.h>
+#include "testpostmanarbiter.h"
class tst_QScene : public QObject
{
@@ -60,14 +61,6 @@ private slots:
void nodeUpdatePropertyTrackData();
};
-class tst_LockableObserver : public Qt3DCore::QLockableObserverInterface
-{
-public:
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) override {}
- void sceneChangeEventWithLock(const Qt3DCore::QSceneChangePtr &) override {}
- void sceneChangeEventWithLock(const Qt3DCore::QSceneChangeList &) override {}
-};
-
class tst_Observable : public Qt3DCore::QObservableInterface
{
public:
@@ -111,7 +104,7 @@ void tst_QScene::addObservable()
observables.append(new tst_Observable());
Qt3DCore::QScene *scene = new Qt3DCore::QScene;
- scene->setArbiter(new tst_LockableObserver);
+ scene->setArbiter(new TestArbiter);
// WHEN
for (int i = 0; i < 5; i++)
@@ -146,7 +139,7 @@ void tst_QScene::addNodeObservable()
nodes.append(new tst_Node());
Qt3DCore::QScene *scene = new Qt3DCore::QScene;
- scene->setArbiter(new tst_LockableObserver);
+ scene->setArbiter(new TestArbiter);
// WHEN
for (int i = 0; i < 10; i++)
@@ -171,7 +164,7 @@ void tst_QScene::removeObservable()
observables.append(new tst_Observable());
Qt3DCore::QScene *scene = new Qt3DCore::QScene;
- scene->setArbiter(new tst_LockableObserver);
+ scene->setArbiter(new TestArbiter);
// WHEN
for (int i = 0; i < 5; i++)
@@ -222,7 +215,7 @@ void tst_QScene::removeNodeObservable()
observables.append(new tst_Observable());
Qt3DCore::QScene *scene = new Qt3DCore::QScene;
- scene->setArbiter(new tst_LockableObserver);
+ scene->setArbiter(new TestArbiter);
// WHEN
scene->addObservable(node1);
diff --git a/tests/auto/core/qskeleton/tst_qskeleton.cpp b/tests/auto/core/qskeleton/tst_qskeleton.cpp
index f66e07cbe..6ad6e538c 100644
--- a/tests/auto/core/qskeleton/tst_qskeleton.cpp
+++ b/tests/auto/core/qskeleton/tst_qskeleton.cpp
@@ -109,33 +109,24 @@ private Q_SLOTS:
// WHEN
QJoint *joint = new QJoint(skeleton.data());
- QCoreApplication::processEvents();
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
skeleton->setRootJoint(joint);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- QPropertyUpdatedChangePtr change = arbiter.events.first().staticCast<QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rootJoint");
- QCOMPARE(change->value().value<QNodeId>(), joint->id());
- QCOMPARE(change->type(), PropertyUpdated);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), skeleton.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
skeleton->setRootJoint(nullptr);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rootJoint");
- QCOMPARE(change->value().value<QNodeId>(), QNodeId());
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), skeleton.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
void checkRootJointBookkeeping()
diff --git a/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp b/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
index 1386429d4..7fcdc4bbe 100644
--- a/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
+++ b/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
@@ -169,12 +169,11 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "source");
- QCOMPARE(change->type(), PropertyUpdated);
+ QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes[0], &skeleton);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
{
@@ -184,21 +183,20 @@ private Q_SLOTS:
// THEN
QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 0);
}
-
{
// WHEN
skeleton.setCreateJointsEnabled(true);
QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "createJointsEnabled");
- QCOMPARE(change->type(), PropertyUpdated);
+ QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes[0], &skeleton);
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
{
@@ -208,6 +206,7 @@ private Q_SLOTS:
// THEN
QCOMPARE(arbiter.events.size(), 0);
+ QCOMPARE(arbiter.events.size(), 0);
}
}
@@ -242,6 +241,9 @@ private Q_SLOTS:
QCOMPARE(spy.count(), 0);
QCOMPARE(arbiter.events.size(), 0);
QCOMPARE(status(), newStatus);
+
+ // Cleanup
+ QNodePrivate::get(this)->setArbiter(nullptr);
}
void checkRootJointPropertyUpdate()
@@ -266,8 +268,11 @@ private Q_SLOTS:
// THEN
QCOMPARE(spy.count(), 1);
- QCOMPARE(arbiter.events.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
QVERIFY(rootJoint() != nullptr);
+
+ // Cleanup
+ QNodePrivate::get(this)->setArbiter(nullptr);
}
};
diff --git a/tests/auto/core/qtransform/tst_qtransform.cpp b/tests/auto/core/qtransform/tst_qtransform.cpp
index f5527ebf5..0590a8259 100644
--- a/tests/auto/core/qtransform/tst_qtransform.cpp
+++ b/tests/auto/core/qtransform/tst_qtransform.cpp
@@ -123,74 +123,54 @@ private Q_SLOTS:
// WHEN
transform->setTranslation(QVector3D(454.0f, 427.0f, 383.0f));
- QCoreApplication::processEvents();
// THEN
- Qt3DCore::QPropertyUpdatedChangePtr change;
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "translation");
- QCOMPARE(change->value().value<QVector3D>(), QVector3D(454.0f, 427.0f, 383.0f));
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), transform.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
QQuaternion q = Qt3DCore::QTransform::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 90.0f);
transform->setRotation(q);
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rotation");
- QCOMPARE(change->value().value<QQuaternion>(), q);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), transform.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
transform->setScale3D(QVector3D(883.0f, 1200.0f, 1340.0f));
QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "scale3D");
- QCOMPARE(change->value().value<QVector3D>(), QVector3D(883.0f, 1200.0f, 1340.0f));
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), transform.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
// WHEN
// Force the transform to update its matrix
(void)transform->matrix();
transform->setMatrix(QMatrix4x4());
- QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 3);
- change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "scale3D");
- QCOMPARE(change->value().value<QVector3D>(), QVector3D(1.0f, 1.0f, 1.0f));
- change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rotation");
- QCOMPARE(change->value().value<QQuaternion>(), QQuaternion());
- change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "translation");
- QCOMPARE(change->value().value<QVector3D>(), QVector3D());
-
- arbiter.events.clear();
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), transform.data());
+
+ arbiter.dirtyNodes.clear();
// WHEN
transform->setRotationX(20.0f);
QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "rotation");
- QCOMPARE(change->value().value<QQuaternion>().toEulerAngles().x(), 20.0f);
+ QCOMPARE(arbiter.dirtyNodes.size(), 1);
+ QCOMPARE(arbiter.dirtyNodes.front(), transform.data());
- arbiter.events.clear();
+ arbiter.dirtyNodes.clear();
}
void checkSignalEmittion()