summaryrefslogtreecommitdiffstats
path: root/tests/auto/core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/core')
-rw-r--r--tests/auto/core/core.pro4
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp106
-rw-r--r--tests/auto/core/qaspectengine/tst_qaspectengine.cpp14
-rw-r--r--tests/auto/core/qcircularbuffer/tst_qcircularbuffer.cpp12
-rw-r--r--tests/auto/core/qservicelocator/tst_qservicelocator.cpp16
-rw-r--r--tests/auto/core/qskeleton/tst_qskeleton.cpp36
-rw-r--r--tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp65
-rw-r--r--tests/auto/core/threadpooler/tst_threadpooler.cpp16
8 files changed, 108 insertions, 161 deletions
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro
index 001b947d5..13f4a0dc7 100644
--- a/tests/auto/core/core.pro
+++ b/tests/auto/core/core.pro
@@ -25,10 +25,10 @@ qtConfig(private_tests) {
threadpooler \
qpostman \
vector4d_base \
- vector3d_base
+ vector3d_base \
+ aspectcommanddebugger
QT_FOR_CONFIG += 3dcore-private
- qtConfig(qt3d-profile-jobs): SUBDIRS += aspectcommanddebugger
qtConfig(qt3d-simd-sse2) {
SUBDIRS += \
vector4d_sse \
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 3b93e7715..87f66bab2 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -40,6 +40,7 @@
#include <Qt3DCore/qpropertynoderemovedchange.h>
#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DCore/private/qaspectengine_p.h>
+#include <Qt3DCore/private/qaspectengine_p.h>
#include <private/qabstractaspect_p.h>
#include <private/qpostman_p.h>
@@ -92,6 +93,7 @@ private slots:
void checkConstructionWithNonRootParent(); // QTBUG-73986
void checkConstructionAsListElement();
void checkSceneIsSetOnConstructionWithParent(); // QTBUG-69352
+ void checkSubNodePostConstructIsCalledWhenReferincingNodeProperty(); // QTBUG-79350
void appendingComponentToEntity();
void appendingParentlessComponentToEntityWithoutScene();
@@ -290,22 +292,15 @@ public slots:
if (!attribute->parent())
attribute->setParent(this);
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), attribute);
- change->setPropertyName("attribute");
- d->notifyObservers(change);
- }
+ d->updateNode(attribute, "attribute", Qt3DCore::PropertyValueAdded);
}
}
void removeAttribute(MyQNode *attribute)
{
Qt3DCore::QNodePrivate *d = Qt3DCore::QNodePrivate::get(this);
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), attribute);
- change->setPropertyName("attribute");
- d->notifyObservers(change);
- }
+ d->updateNode(attribute, "attribute", Qt3DCore::PropertyValueRemoved);
+
m_attributes.removeOne(attribute);
// Remove bookkeeping connection
d->unregisterDestructionHelper(attribute);
@@ -384,11 +379,7 @@ public:
if (!attribute->parent())
attribute->setParent(this);
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), attribute);
- change->setPropertyName("attribute");
- d->notifyObservers(change);
- }
+ d->updateNode(attribute, "attribute", Qt3DCore::PropertyValueRemoved);
}
}
@@ -435,6 +426,29 @@ public:
}
};
+class MyFakeMaterial : public Qt3DCore::QComponent
+{
+ Q_OBJECT
+public:
+ explicit MyFakeMaterial(Qt3DCore::QNode *parent = nullptr)
+ : QComponent(parent)
+ , m_effect(new MyQNode(this))
+ , m_technique(new MyQNode(m_effect))
+ , m_renderPass(new MyQNode(m_technique))
+ {
+ }
+
+ void setArbiter(Qt3DCore::QAbstractArbiter *arbiter)
+ {
+ Q_ASSERT(arbiter);
+ Qt3DCore::QComponentPrivate::get(this)->setArbiter(arbiter);
+ }
+
+ MyQNode *m_effect;
+ MyQNode *m_technique;
+ MyQNode *m_renderPass;
+};
+
class TestAspectPrivate;
class TestAspect : public Qt3DCore::QAbstractAspect
{
@@ -1543,20 +1557,8 @@ void tst_Nodes::checkConstructionAsListElement()
QCoreApplication::processEvents();
QCOMPARE(root->children().count(), 1);
- QCOMPARE(spy.events.size(), 2); // 1 child added change, 1 property change
-
- const auto newChildEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QPropertyNodeAddedChange>();
- QVERIFY(!newChildEvent.isNull());
- QCOMPARE(newChildEvent->subjectId(), root->id());
- 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::QPropertyNodeAddedChange>();
- QVERIFY(!propertyEvent.isNull());
- QCOMPARE(propertyEvent->subjectId(), root->id());
- QCOMPARE(propertyEvent->propertyName(), "attribute");
- QCOMPARE(newChildEvent->addedNodeId(), node->id());
+ QCOMPARE(spy.dirtyNodes.size(), 1); // 1 property change
+ QCOMPARE(spy.dirtySubNodes.size(), 1); // 1 child added change
}
void tst_Nodes::checkSceneIsSetOnConstructionWithParent()
@@ -1605,6 +1607,52 @@ void tst_Nodes::checkSceneIsSetOnConstructionWithParent()
QCOMPARE(spy.dirtySubNodes.size(), 5); // 5 entities changed
}
+void tst_Nodes::checkSubNodePostConstructIsCalledWhenReferincingNodeProperty()
+{
+ // GIVEN
+ ObserverSpy spy;
+ Qt3DCore::QAspectEngine engine;
+ Qt3DCore::QScene scene(&engine);
+ QScopedPointer<MyQNode> root(new MyQNode());
+
+ // WHEN
+ root->setArbiterAndScene(&spy, &scene);
+ root->setSimulateBackendCreated(true);
+
+ // THEN
+ QVERIFY(Qt3DCore::QNodePrivate::get(root.data())->scene() != nullptr);
+
+ // WHEN
+ Qt3DCore::QEntity *subTreeRoot = new Qt3DCore::QEntity(root.data());
+ QCoreApplication::processEvents();
+
+ // THEN
+ QVERIFY(Qt3DCore::QNodePrivate::get(subTreeRoot)->m_hasBackendNode);
+
+ // WHEN
+ MyFakeMaterial *material = new MyFakeMaterial(subTreeRoot);
+ subTreeRoot->addComponent(material);
+
+ // THEN
+ QVERIFY(Qt3DCore::QNodePrivate::get(material)->m_hasBackendNode);
+ QVERIFY(Qt3DCore::QNodePrivate::get(material->m_effect)->m_hasBackendNode);
+ QVERIFY(Qt3DCore::QNodePrivate::get(material->m_technique)->m_hasBackendNode);
+ QVERIFY(Qt3DCore::QNodePrivate::get(material->m_renderPass)->m_hasBackendNode);
+
+ // WHEN
+ MyQNode *fakeRenderState = new MyQNode(material);
+ Qt3DCore::QNodePrivate *dPtr = Qt3DCore::QNodePrivate::get(fakeRenderState);
+
+ // THEN
+ QVERIFY(!dPtr->m_hasBackendNode);
+
+ // WHEN
+ material->m_renderPass->addAttribute(fakeRenderState);
+
+ // THEN
+ QVERIFY(dPtr->m_hasBackendNode);
+}
+
void tst_Nodes::appendingParentlessComponentToEntityWithoutScene()
{
// GIVEN
diff --git a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
index eb20536e6..48443a66f 100644
--- a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
+++ b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
@@ -146,6 +146,10 @@ private Q_SLOTS:
void shouldNotCrashInNormalStartupShutdownSequence()
{
+#ifdef Q_OS_MACOS
+ QSKIP("Test frequently times out. See QTBUG-80660.");
+#endif
+
// GIVEN
// An initialized aspect engine...
QAspectEngine engine;
@@ -168,7 +172,7 @@ private Q_SLOTS:
engine.setRootEntity(entity);
QEventLoop eventLoop;
- QTimer::singleShot(100, &eventLoop, SLOT(quit()));
+ QTimer::singleShot(1000, &eventLoop, SLOT(quit()));
eventLoop.exec();
// THEN
@@ -179,7 +183,7 @@ private Q_SLOTS:
// WHEN
// we set an empty/null scene root...
engine.setRootEntity(QEntityPtr());
- QTimer::singleShot(1000, &eventLoop, SLOT(quit()));
+ QTimer::singleShot(600, &eventLoop, SLOT(quit()));
// ...and allow events to process...
eventLoop.exec();
@@ -243,21 +247,21 @@ private Q_SLOTS:
// THEN
QCOMPARE(engine.executeCommand("list aspects").toString(),
- QString("Loaded aspects:\n * fake"));
+ QString("fake"));
// WHEN
engine.registerAspect("otherfake");
// THEN
QCOMPARE(engine.executeCommand("list aspects").toString(),
- QString("Loaded aspects:\n * fake\n * otherfake"));
+ QString("fake\notherfake"));
// WHEN
engine.registerAspect(new FakeAspect3);
// THEN
QCOMPARE(engine.executeCommand("list aspects").toString(),
- QString("Loaded aspects:\n * fake\n * otherfake\n * <unnamed>"));
+ QString("fake\notherfake\n<unnamed>"));
}
void shouldDelegateCommandsToAspects()
diff --git a/tests/auto/core/qcircularbuffer/tst_qcircularbuffer.cpp b/tests/auto/core/qcircularbuffer/tst_qcircularbuffer.cpp
index 4bc04fafa..7d8f6eed6 100644
--- a/tests/auto/core/qcircularbuffer/tst_qcircularbuffer.cpp
+++ b/tests/auto/core/qcircularbuffer/tst_qcircularbuffer.cpp
@@ -166,13 +166,13 @@ void tst_QCircularBuffer::construction()
QVERIFY(circ4.size() == 2);
QVERIFY(circ4.at(0) == 10);
QVERIFY(circ4.at(1) == 10);
- QVERIFY(circ4.refCount().load() == 1);
+ QVERIFY(circ4.refCount().loadRelaxed() == 1);
// Copy construct from circ4. Both circ4 and circ5 should now have a
// refCount() of 2 since we are using implicit sharing.
QCircularBuffer<int> circ5(circ4);
- QVERIFY(circ4.refCount().load() == 2);
- QVERIFY(circ5.refCount().load() == 2);
+ QVERIFY(circ4.refCount().loadRelaxed() == 2);
+ QVERIFY(circ5.refCount().loadRelaxed() == 2);
QVERIFY(circ5.capacity() == 5);
QVERIFY(circ5.size() == 2);
QVERIFY(circ5.at(0) == 10);
@@ -199,7 +199,7 @@ void tst_QCircularBuffer::destruction()
cir->append(MyComplexType(2));
cir->append(MyComplexType(3));
cir->remove(0);
- Q_UNUSED(cir);
+ Q_UNUSED(cir)
// Check that the dtor was called 2 times fewer than the constructor.
// At this stage will still have 2 items in the circular buffer.
@@ -208,7 +208,7 @@ void tst_QCircularBuffer::destruction()
// Destroy the circular buffer and check that the active count
// is 0. (Same number of calls to dtor as have been made to the constructors)
delete cir;
- cir = 0;
+ cir = nullptr;
QVERIFY(MyComplexType::ms_activeCount == 0);
}
@@ -273,7 +273,7 @@ void tst_QCircularBuffer::clear()
circ.clear();
QVERIFY(circ.size() == 0);
QVERIFY(circ.capacity() == 3);
- QVERIFY(circ.refCount().load() == 1);
+ QVERIFY(circ.refCount().loadRelaxed() == 1);
}
void tst_QCircularBuffer::contains()
diff --git a/tests/auto/core/qservicelocator/tst_qservicelocator.cpp b/tests/auto/core/qservicelocator/tst_qservicelocator.cpp
index cde9834b4..40f0610df 100644
--- a/tests/auto/core/qservicelocator/tst_qservicelocator.cpp
+++ b/tests/auto/core/qservicelocator/tst_qservicelocator.cpp
@@ -52,11 +52,8 @@ class DummySystemInfoService : public QSystemInformationService
{
public:
DummySystemInfoService()
- : QSystemInformationService(QStringLiteral("Dummy System Information Service"))
+ : QSystemInformationService(nullptr, QStringLiteral("Dummy System Information Service"))
{}
-
- QStringList aspectNames() const final { return QStringList(); }
- int threadPoolThreadCount() const final { return 4; }
};
@@ -90,8 +87,8 @@ void tst_QServiceLocator::defaultServices()
QSystemInformationService *sysInfo = locator.systemInformation();
QVERIFY(sysInfo != nullptr);
- QVERIFY(sysInfo->description() == QStringLiteral("Null System Information Service"));
- QVERIFY(sysInfo->threadPoolThreadCount() == 0);
+ QVERIFY(sysInfo->description() == QStringLiteral("Default System Information Service"));
+ QVERIFY(sysInfo->threadPoolThreadCount() != 0);
}
void tst_QServiceLocator::addRemoveDefaultService()
@@ -105,7 +102,6 @@ void tst_QServiceLocator::addRemoveDefaultService()
// Get the service from the locator and check it works as expected
QSystemInformationService *service = locator.systemInformation();
QVERIFY(service == dummy.data());
- QVERIFY(service->threadPoolThreadCount() == 4);
// Ensure the other default services work
QOpenGLInformationService *glInfo = locator.openGLInformation();
@@ -118,7 +114,7 @@ void tst_QServiceLocator::addRemoveDefaultService()
QVERIFY(locator.serviceCount() == QServiceLocator::DefaultServiceCount);
// Check the dummy service still exists
- QVERIFY(dummy->threadPoolThreadCount() == 4);
+ QVERIFY(!dummy.isNull());
}
void tst_QServiceLocator::addRemoveUserService()
@@ -138,8 +134,8 @@ void tst_QServiceLocator::addRemoveUserService()
// Ensure the default services work
QSystemInformationService *sysInfo = locator.systemInformation();
QVERIFY(sysInfo != nullptr);
- QVERIFY(sysInfo->description() == QStringLiteral("Null System Information Service"));
- QVERIFY(sysInfo->threadPoolThreadCount() == 0);
+ QVERIFY(sysInfo->description() == QStringLiteral("Default System Information Service"));
+ QVERIFY(sysInfo->threadPoolThreadCount() != 0);
// Remove custom service
locator.unregisterServiceProvider(dummy->type());
diff --git a/tests/auto/core/qskeleton/tst_qskeleton.cpp b/tests/auto/core/qskeleton/tst_qskeleton.cpp
index 299567806..5c88bd754 100644
--- a/tests/auto/core/qskeleton/tst_qskeleton.cpp
+++ b/tests/auto/core/qskeleton/tst_qskeleton.cpp
@@ -30,7 +30,6 @@
#include <Qt3DCore/qskeleton.h>
#include <Qt3DCore/private/qskeleton_p.h>
#include <Qt3DCore/qjoint.h>
-#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
@@ -160,41 +159,6 @@ private Q_SLOTS:
// THEN Should not crash when the joint is destroyed (tests for failed removal of destruction helper)
}
}
-
- void checkJointCountPropertyUpdate()
- {
- // GIVEN
- TestArbiter arbiter;
- arbiter.setArbiterOnNode(this);
- QSignalSpy spy(this, SIGNAL(jointCountChanged(int)));
- const int newJointCount = 99;
-
- // THEN
- QVERIFY(spy.isValid());
-
- // WHEN
- auto valueChange = QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- valueChange->setPropertyName("jointCount");
- valueChange->setValue(QVariant(newJointCount));
- sceneChangeEvent(valueChange);
-
- // THEN
- QCOMPARE(spy.count(), 1);
- QCOMPARE(arbiter.events.size(), 0);
- QCOMPARE(jointCount(), newJointCount);
-
- // WHEN
- spy.clear();
- sceneChangeEvent(valueChange);
-
- // THEN
- QCOMPARE(spy.count(), 0);
- QCOMPARE(arbiter.events.size(), 0);
- QCOMPARE(jointCount(), newJointCount);
-
- // Cleanup
- QNodePrivate::get(this)->setArbiter(nullptr);
- }
};
QTEST_MAIN(tst_QSkeleton)
diff --git a/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp b/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
index 7fcdc4bbe..f0f4c3872 100644
--- a/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
+++ b/tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
@@ -209,71 +209,6 @@ private Q_SLOTS:
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)
diff --git a/tests/auto/core/threadpooler/tst_threadpooler.cpp b/tests/auto/core/threadpooler/tst_threadpooler.cpp
index a656c25c1..289f0b103 100644
--- a/tests/auto/core/threadpooler/tst_threadpooler.cpp
+++ b/tests/auto/core/threadpooler/tst_threadpooler.cpp
@@ -182,7 +182,7 @@ void massTestFunction(QVector3D *data)
void tst_ThreadPooler::initTestCase()
{
- m_jobManager = new JobManager(this);
+ m_jobManager = new JobManager(nullptr);
}
void tst_ThreadPooler::cleanupTestCase()
@@ -195,13 +195,13 @@ void tst_ThreadPooler::defaultPerThread()
// GIVEN
QAtomicInt callCounter;
int maxThreadCount = QThread::idealThreadCount();
- callCounter.store(0);
+ callCounter.storeRelaxed(0);
// WHEN
m_jobManager->waitForPerThreadFunction(perThreadFunction, &callCounter);
// THEN
- QVERIFY(maxThreadCount == callCounter.load());
+ QVERIFY(maxThreadCount == callCounter.loadRelaxed());
}
void tst_ThreadPooler::defaultAspectQueue()
@@ -210,7 +210,7 @@ void tst_ThreadPooler::defaultAspectQueue()
QAtomicInt callCounter;
int value = 0; // Not used in this test
QVector<QSharedPointer<Qt3DCore::QAspectJob> > jobList;
- callCounter.store(0);
+ callCounter.storeRelaxed(0);
const int jobCount = 5;
// WHEN
@@ -223,7 +223,7 @@ void tst_ThreadPooler::defaultAspectQueue()
m_jobManager->waitForAllJobs();
// THEN
- QVERIFY(jobCount == callCounter.load());
+ QVERIFY(jobCount == callCounter.loadRelaxed());
}
/*
@@ -236,7 +236,7 @@ void tst_ThreadPooler::doubleAspectQueue()
QAtomicInt callCounter;
int value = 0; // Not used in this test
QVector<QSharedPointer<Qt3DCore::QAspectJob> > jobList;
- callCounter.store(0);
+ callCounter.storeRelaxed(0);
const int jobCount = 3;
// WHEN
@@ -258,7 +258,7 @@ void tst_ThreadPooler::doubleAspectQueue()
m_jobManager->waitForAllJobs();
// THEN
- QVERIFY(jobCount * 2 == callCounter.load());
+ QVERIFY(jobCount * 2 == callCounter.loadRelaxed());
}
/*
@@ -335,7 +335,7 @@ public:
quint64 globalAtomicValue() const
{
- return m_globalAtomic.load();
+ return m_globalAtomic.loadRelaxed();
}
private: