diff options
Diffstat (limited to 'tests')
21 files changed, 232 insertions, 810 deletions
diff --git a/tests/auto/core/common/qbackendnodetester.cpp b/tests/auto/core/common/qbackendnodetester.cpp index 13f4683d9..0bec5e5dd 100644 --- a/tests/auto/core/common/qbackendnodetester.cpp +++ b/tests/auto/core/common/qbackendnodetester.cpp @@ -84,3 +84,5 @@ QNodeCreatedChangeBasePtr QBackendNodeTester::creationChange(QNode *frontend) co } // namespace Qt3DCore QT_END_NAMESPACE + +#include "moc_qbackendnodetester.cpp" diff --git a/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp b/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp index dccf90d10..9bd3afc83 100644 --- a/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp +++ b/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp @@ -29,7 +29,9 @@ #include <QtTest/QtTest> #include <Qt3DCore/private/matrix4x4_sse_p.h> +#ifdef QT_COMPILER_SUPPORTS_SSE2 using namespace Qt3DCore; +#endif class tst_Matrix4x4_SSE: public QObject { @@ -37,6 +39,7 @@ class tst_Matrix4x4_SSE: public QObject private Q_SLOTS: +#ifdef QT_COMPILER_SUPPORTS_SSE2 void defaultConstruction() { // GIVEN @@ -520,6 +523,7 @@ private Q_SLOTS: QCOMPARE(resultingVec.toQVector3D(), tmpMat.mapVector(tmpVec3)); } } +#endif // QT_COMPILER_SUPPORTS_SSE2 }; QTEST_MAIN(tst_Matrix4x4_SSE) diff --git a/tests/auto/core/qchangearbiter/qchangearbiter.pro b/tests/auto/core/qchangearbiter/qchangearbiter.pro index 64a7b36e7..4628bf6cd 100644 --- a/tests/auto/core/qchangearbiter/qchangearbiter.pro +++ b/tests/auto/core/qchangearbiter/qchangearbiter.pro @@ -6,3 +6,5 @@ QT += testlib core core-private 3dcore 3dcore-private SOURCES += \ tst_qchangearbiter.cpp + +include(../common/common.pri) diff --git a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp index 4837ac87b..9f79e4272 100644 --- a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp +++ b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp @@ -31,17 +31,7 @@ QT_WARNING_DISABLE_DEPRECATED #include <QtTest/QTest> -#include <Qt3DCore/private/qobserverinterface_p.h> -#include <Qt3DCore/private/qobservableinterface_p.h> #include <Qt3DCore/private/qchangearbiter_p.h> -#include <Qt3DCore/private/qpostman_p.h> -#include <Qt3DCore/qscenechange.h> -#include <Qt3DCore/qcomponentaddedchange.h> -#include <Qt3DCore/qcomponentremovedchange.h> -#include <Qt3DCore/qpropertyupdatedchange.h> -#include <Qt3DCore/qpropertynodeaddedchange.h> -#include <Qt3DCore/qpropertynoderemovedchange.h> -#include <Qt3DCore/qscenechange.h> #include <Qt3DCore/private/qscene_p.h> #include <Qt3DCore/qnode.h> #include <Qt3DCore/qentity.h> @@ -51,95 +41,14 @@ QT_WARNING_DISABLE_DEPRECATED #include <Qt3DCore/private/qbackendnode_p.h> #include <QThread> #include <QWaitCondition> +#include "testpostmanarbiter.h" class tst_QChangeArbiter : public QObject { Q_OBJECT private slots: - void registerObservers(); - void registerSceneObserver(); - void unregisterObservers(); - void unregisterSceneObservers(); - void distributeFrontendChanges(); - void distributePropertyChanges(); - void distributeBackendChanges(); -}; - -class AllChangesChange : public Qt3DCore::QSceneChange -{ -public: - AllChangesChange(Qt3DCore::QNodeId subjectId) - : Qt3DCore::QSceneChange(Qt3DCore::AllChanges, subjectId) - { - } -}; - -class tst_Node : public Qt3DCore::QEntity -{ -public: - explicit tst_Node(Qt3DCore::QNode *parent = 0) : Qt3DCore::QEntity(parent) - {} - - void sendNodeAddedNotification(QNode *node) - { - Qt3DCore::QPropertyNodeAddedChangePtr e(new Qt3DCore::QPropertyNodeAddedChange(id(), node)); - e->setPropertyName("PropertyValueAdded"); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sendNodeRemovedNotification(QNode *node) - { - Qt3DCore::QPropertyNodeRemovedChangePtr e(new Qt3DCore::QPropertyNodeRemovedChange(id(), node)); - e->setPropertyName("PropertyValueRemoved"); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sendNodeUpdatedNotification() - { - Qt3DCore::QPropertyUpdatedChangePtr e(new Qt3DCore::QPropertyUpdatedChange(id())); - e->setPropertyName("PropertyUpdated"); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sendComponentAddedNotification(Qt3DCore::QComponent *component) - { - Qt3DCore::QComponentAddedChangePtr e(new Qt3DCore::QComponentAddedChange(this, component)); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sendComponentRemovedNotification(Qt3DCore::QComponent *component) - { - Qt3DCore::QComponentRemovedChangePtr e(new Qt3DCore::QComponentRemovedChange(this, component)); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sendAllChangesNotification() - { - Qt3DCore::QSceneChangePtr e(new AllChangesChange(id())); - Qt3DCore::QNodePrivate::get(this)->notifyObservers(e); - } - - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override - { - QVERIFY(!change.isNull()); - m_lastChanges << change; - } - - Qt3DCore::QSceneChangePtr lastChange() const - { - if (m_lastChanges.isEmpty()) - return Qt3DCore::QSceneChangePtr(); - return m_lastChanges.last(); - } - - QList<Qt3DCore::QSceneChangePtr> lastChanges() const - { - return m_lastChanges; - } - -private: - QList<Qt3DCore::QSceneChangePtr> m_lastChanges; + void recordsDirtyNodes(); }; // used to test property change notifications @@ -180,722 +89,51 @@ private: float m_prop2 = 0.0f; }; -class tst_SimpleObserver : public Qt3DCore::QObserverInterface -{ -public: - - // QObserverInterface interface - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override - { - QVERIFY(!e.isNull()); - m_lastChanges.append(e); - } - - Qt3DCore::QSceneChangePtr lastChange() const - { - if (m_lastChanges.isEmpty()) - return Qt3DCore::QSceneChangePtr(); - return m_lastChanges.last(); - } - - QList<Qt3DCore::QSceneChangePtr> lastChanges() const - { - return m_lastChanges; - } - - void clear() - { - m_lastChanges.clear(); - } - -private: - QList<Qt3DCore::QSceneChangePtr> m_lastChanges; -}; - -class tst_BackendObserverObservable : public Qt3DCore::QBackendNode -{ -public: - - tst_BackendObserverObservable() - : Qt3DCore::QBackendNode(ReadWrite) - {} - - // QObserverInterface interface - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override - { - QVERIFY(!e.isNull()); - m_lastChanges << e; - m_targetId = e->subjectId(); - } - - // should be called in thread - void sendReply() - { - Qt3DCore::QPropertyUpdatedChangePtr reply; - reply = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(m_targetId); - reply->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); - reply->setPropertyName("Reply"); - notifyObservers(reply); - qDebug() << Q_FUNC_INFO; - } - - Qt3DCore::QSceneChangePtr lastChange() const - { - if (m_lastChanges.isEmpty()) - return Qt3DCore::QSceneChangePtr(); - return m_lastChanges.last(); - } - - QList<Qt3DCore::QSceneChangePtr> lastChanges() const - { - return m_lastChanges; - } - - void clear() - { - m_lastChanges.clear(); - } - -private: - QList<Qt3DCore::QSceneChangePtr> m_lastChanges; - Qt3DCore::QNodeId m_targetId; - -}; - -class ThreadedAnswer : public QThread -{ - Q_OBJECT -public: - ThreadedAnswer(Qt3DCore::QChangeArbiter *arbiter, tst_BackendObserverObservable *backend) - : QThread() - , m_arbiter(arbiter) - , m_backendObs(backend) - {} - - ~ThreadedAnswer() { qDebug() << this; } - - void run() override - { - // create backend change queue on QChangeArbiter - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(m_arbiter); - m_backendObs->sendReply(); - // gives time for other threads to start waiting - QThread::currentThread()->sleep(1); - // wake waiting condition - m_waitingForReplyToBeSent.wakeOne(); - exec(); - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(m_arbiter); - } - - QWaitCondition *waitingCondition() { return &m_waitingForReplyToBeSent; } - -private: - Qt3DCore::QChangeArbiter *m_arbiter; - tst_BackendObserverObservable *m_backendObs; - QWaitCondition m_waitingForReplyToBeSent; -}; - -class tst_PostManObserver : public Qt3DCore::QAbstractPostman -{ -public: - - tst_PostManObserver() - : m_sceneInterface(nullptr) - , m_allowFrontendNotifications(false) - {} - - void setScene(Qt3DCore::QScene *scene) final - { - m_sceneInterface = scene; - } - - void setAllowFrontendNotifications(bool allow) - { - m_allowFrontendNotifications = allow; - } - - // QObserverInterface interface - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) - { - QVERIFY(!e.isNull()); - Qt3DCore::QPropertyUpdatedChangePtr change = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(e); - QVERIFY(!change.isNull()); - Qt3DCore::QNode *targetNode = m_sceneInterface->lookupNode(change->subjectId()); - QVERIFY(targetNode != nullptr); - m_lastChanges << e; - } - - Qt3DCore::QSceneChangePtr lastChange() const - { - if (m_lastChanges.isEmpty()) - return Qt3DCore::QSceneChangePtr(); - return m_lastChanges.last(); - } - - QList<Qt3DCore::QSceneChangePtr> lastChanges() const - { - return m_lastChanges; - } - - void notifyBackend(const Qt3DCore::QSceneChangePtr &e) final - { - m_sceneInterface->arbiter()->sceneChangeEventWithLock(e); - } - - bool shouldNotifyFrontend(const Qt3DCore::QSceneChangePtr &) - { - return m_allowFrontendNotifications; - } - -private: - Qt3DCore::QScene *m_sceneInterface; - QList<Qt3DCore::QSceneChangePtr> m_lastChanges; - bool m_allowFrontendNotifications; -}; - -void tst_QChangeArbiter::registerObservers() -{ - // GIVEN - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // WHEN - Qt3DCore::QNode *root = new tst_Node(); - Qt3DCore::QNode *child = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - scene->addObservable(root); - - QList<tst_SimpleObserver *> observers; - for (int i = 0; i < 5; i++) { - tst_SimpleObserver *s = new tst_SimpleObserver(); - arbiter->registerObserver(s, root->id()); - observers << s; - } - - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) - QVERIFY(o->lastChange().isNull()); - - child->setParent(root); - arbiter->syncChanges(); - for (tst_SimpleObserver *o : qAsConst(observers)) { - QCOMPARE(o->lastChanges().size(), 1); - QVERIFY(o->lastChanges().last()->type() == Qt3DCore::PropertyValueAdded); - } - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::registerSceneObserver() -{ - // GIVEN - Qt3DCore::QComponent dummyComponent; - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // WHEN - tst_Node *root = new tst_Node(); - Qt3DCore::QNode *child = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true; - scene->addObservable(root); - - QList<tst_SimpleObserver *> observers; - for (int i = 0; i < 5; i++) { - tst_SimpleObserver *s = new tst_SimpleObserver(); - arbiter->registerObserver(s, root->id()); - observers << s; - } - - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) - QVERIFY(o->lastChange().isNull()); - - // WHEN - child->setParent(root); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueAdded); - } - - // WHEN - root->sendComponentAddedNotification(&dummyComponent); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::ComponentAdded); - } - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::unregisterObservers() -{ - // GIVEN - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // WHEN - tst_Node *root = new tst_Node(); - Qt3DCore::QNode *child = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - scene->addObservable(root); - - QList<tst_SimpleObserver *> observers; - for (int i = 0; i < 5; i++) { - tst_SimpleObserver *s = new tst_SimpleObserver(); - arbiter->registerObserver(s, root->id()); - observers << s; - } - - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) - QVERIFY(o->lastChange().isNull()); - - // WHEN - child->setParent(root); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueAdded); - } - - // WHEN - for (tst_SimpleObserver *o : qAsConst(observers)) - arbiter->unregisterObserver(o, root->id()); - - root->sendAllChangesNotification(); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueAdded); - } - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::unregisterSceneObservers() -{ - // GIVEN - Qt3DCore::QComponent dummyComponent; - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // WHEN - tst_Node *root = new tst_Node(); - Qt3DCore::QNode *child = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true; - Qt3DCore::QNodePrivate::get(child)->m_hasBackendNode = true; - scene->addObservable(root); - - QList<tst_SimpleObserver *> observers; - for (int i = 0; i < 5; i++) { - tst_SimpleObserver *s = new tst_SimpleObserver(); - arbiter->registerObserver(s, root->id()); - observers << s; - } - - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) - QVERIFY(o->lastChange().isNull()); - - // WHEN - child->setParent(root); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueAdded); - } - - // WHEN - root->sendComponentAddedNotification(&dummyComponent); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::ComponentAdded); - } - - // WHEN - child->setParent(Q_NODE_NULLPTR); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueRemoved); - } - - // WHEN - child->setParent(root); - arbiter->syncChanges(); - - // THEN - for (tst_SimpleObserver *o : qAsConst(observers)) { - QVERIFY(!o->lastChange().isNull()); - QVERIFY(o->lastChange()->type() == Qt3DCore::PropertyValueAdded); - } - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::distributeFrontendChanges() -{ - // GIVEN - Qt3DCore::QComponent dummyComponent; - Qt3DCore::QNode dummyNode; - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // WHEN - tst_Node *root = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - scene->addObservable(root); - - tst_SimpleObserver *backendAllChangedObserver = new tst_SimpleObserver(); - tst_SimpleObserver *backendNodeAddedObserver = new tst_SimpleObserver(); - tst_SimpleObserver *backendNodeRemovedObserver = new tst_SimpleObserver(); - tst_SimpleObserver *backendNodeUpdatedObserver = new tst_SimpleObserver(); - tst_SimpleObserver *backendComponentAddedObserver = new tst_SimpleObserver(); - tst_SimpleObserver *backendComponentRemovedObserver = new tst_SimpleObserver(); - - arbiter->registerObserver(backendAllChangedObserver, root->id()); - arbiter->registerObserver(backendNodeAddedObserver, root->id(), Qt3DCore::PropertyValueAdded); - arbiter->registerObserver(backendNodeUpdatedObserver, root->id(), Qt3DCore::PropertyUpdated); - arbiter->registerObserver(backendNodeRemovedObserver, root->id(), Qt3DCore::PropertyValueRemoved); - arbiter->registerObserver(backendComponentAddedObserver, root->id(), Qt3DCore::ComponentAdded); - arbiter->registerObserver(backendComponentRemovedObserver, root->id(), Qt3DCore::ComponentRemoved); - - arbiter->syncChanges(); - - // THEN - QVERIFY(backendAllChangedObserver->lastChange().isNull()); - QVERIFY(backendNodeAddedObserver->lastChange().isNull()); - QVERIFY(backendNodeUpdatedObserver->lastChange().isNull()); - QVERIFY(backendNodeRemovedObserver->lastChange().isNull()); - QVERIFY(backendComponentAddedObserver->lastChange().isNull()); - QVERIFY(backendComponentRemovedObserver->lastChange().isNull()); - - // WHEN - root->sendNodeAddedNotification(&dummyNode); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 0); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 0); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 0); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 0); - - // WHEN - root->sendNodeUpdatedNotification(); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 2); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 0); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 0); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 0); - - // WHEN - root->sendNodeRemovedNotification(&dummyNode); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 3); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 1); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 0); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 0); - - // WHEN - root->sendComponentAddedNotification(&dummyComponent); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 4); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 1); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 0); - - // WHEN - root->sendComponentRemovedNotification(&dummyComponent); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 5); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 1); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 1); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 1); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 1); - - // WHEN - root->sendAllChangesNotification(); - arbiter->syncChanges(); - - // THEN - QCOMPARE(backendAllChangedObserver->lastChanges().count(), 6); - QCOMPARE(backendNodeAddedObserver->lastChanges().count(), 2); - QCOMPARE(backendNodeUpdatedObserver->lastChanges().count(), 2); - QCOMPARE(backendNodeRemovedObserver->lastChanges().count(), 2); - QCOMPARE(backendComponentAddedObserver->lastChanges().count(), 2); - QCOMPARE(backendComponentRemovedObserver->lastChanges().count(), 2); - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::distributePropertyChanges() +void tst_QChangeArbiter::recordsDirtyNodes() { // GIVEN - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); + QScopedPointer<TestArbiter> arbiter(new TestArbiter()); QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<Qt3DCore::QAbstractPostman> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); +// arbiter->setScene(scene.data()); scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // Test change notifications made to the root node: // WHEN - PropertyTestNode *root = new PropertyTestNode(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true; - scene->addObservable(root); + auto *root = new PropertyTestNode(); + auto *child = new PropertyTestNode(root); - tst_SimpleObserver *rootObserver = new tst_SimpleObserver(); - arbiter->registerObserver(rootObserver, root->id()); - arbiter->syncChanges(); + root->setProp1(883); + child->setProp2(1584); // THEN - QVERIFY(rootObserver->lastChange().isNull()); + QCOMPARE(arbiter->dirtyNodes.size(), 0); // WHEN - root->setProp1(root->prop1() + 1); + Qt3DCore::QNodePrivate::get(root)->setArbiter(arbiter.data()); + root->setProp1(884); + child->setProp2(1585); // THEN - auto dirtyNodes = arbiter->takeDirtyFrontEndNodes(); - QCOMPARE(dirtyNodes.size(), 1); - QCOMPARE(dirtyNodes.front(), root); + QCOMPARE(arbiter->dirtyNodes.size(), 1); + QCOMPARE(arbiter->dirtyNodes.front(), root); - // WHEN - root->setProp2(root->prop2() + 1.f); - - // THEN - 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() + arbiter->dirtyNodes.clear(); // WHEN - PropertyTestNode *setParentChild = new PropertyTestNode(); - setParentChild->setParent(root); - tst_SimpleObserver *setParentChildObserver = new tst_SimpleObserver(); - arbiter->registerObserver(setParentChildObserver, setParentChild->id()); - setParentChild->setProp2(setParentChild->prop2() + 1.f); + Qt3DCore::QNodePrivate::get(child)->setArbiter(arbiter.data()); + child->setProp2(1586); // THEN - dirtyNodes = arbiter->takeDirtyFrontEndNodes(); - QCOMPARE(dirtyNodes.size(), 1); - QCOMPARE(dirtyNodes.front(), setParentChild); + QCOMPARE(arbiter->dirtyNodes.size(), 1); + QCOMPARE(arbiter->dirtyNodes.front(), child); - // Test change notifications made to an entity that was added to the scene - // via the QNode() constructor parent parameter + arbiter->dirtyNodes.clear(); // WHEN - PropertyTestNode *directChild = new PropertyTestNode(root); - QCoreApplication::processEvents(); // make sure the post-ctor initialization is executed for the node - tst_SimpleObserver *directChildObserver = new tst_SimpleObserver(); - arbiter->registerObserver(directChildObserver, directChild->id()); - directChild->setProp1(directChild->prop1() + 1); - - // THEN - dirtyNodes = arbiter->takeDirtyFrontEndNodes(); - QCOMPARE(dirtyNodes.size(), 1); - QCOMPARE(dirtyNodes.front(), directChild); - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); -} - -void tst_QChangeArbiter::distributeBackendChanges() -{ - - // GIVEN - QScopedPointer<Qt3DCore::QChangeArbiter> arbiter(new Qt3DCore::QChangeArbiter()); - QScopedPointer<Qt3DCore::QScene> scene(new Qt3DCore::QScene()); - QScopedPointer<tst_PostManObserver> postman(new tst_PostManObserver); - arbiter->setPostman(postman.data()); - arbiter->setScene(scene.data()); - postman->setScene(scene.data()); - scene->setArbiter(arbiter.data()); - // Replaces initialize as we have no JobManager in this case - Qt3DCore::QChangeArbiter::createThreadLocalChangeQueue(arbiter.data()); - - // In order for backend -> frontend changes to work properly, - // the backend notification should only be sent - // from a worker thread which has a dedicated ChangeQueue in the - // ChangeArbiter different than the frontend ChangeQueue. In this - // test we will only check that the backend has received the frontend notification - - - // WHEN - tst_Node *root = new tst_Node(); - Qt3DCore::QNodePrivate::get(root)->setScene(scene.data()); - Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true; - scene->addObservable(root); - - tst_BackendObserverObservable *backenObserverObservable = new tst_BackendObserverObservable(); - arbiter->registerObserver(Qt3DCore::QBackendNodePrivate::get(backenObserverObservable), root->id()); - arbiter->scene()->addObservable(Qt3DCore::QBackendNodePrivate::get(backenObserverObservable), root->id()); - Qt3DCore::QBackendNodePrivate::get(backenObserverObservable)->setArbiter(arbiter.data()); - - arbiter->syncChanges(); + root->setProp1(887); + child->setProp2(1587); // THEN - QVERIFY(root->lastChange().isNull()); - QVERIFY(backenObserverObservable->lastChange().isNull()); - QCOMPARE(backenObserverObservable->lastChanges().count(), 0); - - // WHEN - root->sendAllChangesNotification(); - arbiter->syncChanges(); - - // THEN - // backend observer receives event from frontend node "root" - QCOMPARE(root->lastChanges().count(), 0); - QCOMPARE(postman->lastChanges().count(), 0); - QTRY_COMPARE(backenObserverObservable->lastChanges().count(), 1); - - backenObserverObservable->clear(); - - { - // WHEN - // simulate a worker thread - QScopedPointer<ThreadedAnswer> answer(new ThreadedAnswer(arbiter.data(), backenObserverObservable)); - postman->setAllowFrontendNotifications(false); - QWaitCondition *waitingForBackendReplyCondition = answer->waitingCondition(); - - QMutex mutex; - // sends reply from another thread (simulates job thread) - answer->start(); - mutex.lock(); - waitingForBackendReplyCondition->wait(&mutex); - mutex.unlock(); - - // To verify that backendObserver sent a reply - arbiter->syncChanges(); - - // THEN - // the repliers should receive it's reply - QTRY_COMPARE(backenObserverObservable->lastChanges().count(), 1); - // verify that postMan has received the change - QCOMPARE(postman->lastChanges().count(), 0); - answer->exit(); - answer->wait(); - backenObserverObservable->clear(); - } - - { - // WHEN - // simulate a worker thread - QScopedPointer<ThreadedAnswer> answer(new ThreadedAnswer(arbiter.data(), backenObserverObservable)); - postman->setAllowFrontendNotifications(true); - QWaitCondition *waitingForBackendReplyCondition = answer->waitingCondition(); - QMutex mutex; - // sends reply from another thread (simulates job thread) - answer->start(); - mutex.lock(); - waitingForBackendReplyCondition->wait(&mutex); - mutex.unlock(); - - // To verify that backendObserver sent a reply - arbiter->syncChanges(); - - // THEN - // the repliers should receive it's reply - QTRY_COMPARE(backenObserverObservable->lastChanges().count(), 1); - // verify that postMan has received the change - QCOMPARE(postman->lastChanges().count(), 1); - - // verify correctness of the reply - Qt3DCore::QPropertyUpdatedChangePtr c = qSharedPointerDynamicCast<Qt3DCore::QPropertyUpdatedChange>(postman->lastChange()); - QVERIFY(!c.isNull()); - QVERIFY(c->subjectId() == root->id()); - qDebug() << c->propertyName(); - QVERIFY(strcmp(c->propertyName(), "Reply") == 0); - QVERIFY(c->type() == Qt3DCore::PropertyUpdated); - answer->exit(); - answer->wait(); - } - - Qt3DCore::QChangeArbiter::destroyThreadLocalChangeQueue(arbiter.data()); + QCOMPARE(arbiter->dirtyNodes.size(), 2); } QTEST_MAIN(tst_QChangeArbiter) diff --git a/tests/auto/core/threadpooler/tst_threadpooler.cpp b/tests/auto/core/threadpooler/tst_threadpooler.cpp index 289f0b103..8941d8489 100644 --- a/tests/auto/core/threadpooler/tst_threadpooler.cpp +++ b/tests/auto/core/threadpooler/tst_threadpooler.cpp @@ -194,7 +194,7 @@ void tst_ThreadPooler::defaultPerThread() { // GIVEN QAtomicInt callCounter; - int maxThreadCount = QThread::idealThreadCount(); + int maxThreadCount = Qt3DCore::QAspectJobManager::idealThreadCount(); callCounter.storeRelaxed(0); // WHEN diff --git a/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp b/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp index 7ea79a5f5..e99dd0e6f 100644 --- a/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp +++ b/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp @@ -29,12 +29,15 @@ #include <QtTest/QtTest> #include <Qt3DCore/private/vector3d_sse_p.h> +#ifdef QT_COMPILER_SUPPORTS_SSE2 using namespace Qt3DCore; +#endif class tst_Vector3D_SSE: public QObject { Q_OBJECT private Q_SLOTS: +#ifdef QT_COMPILER_SUPPORTS_SSE2 void defaultConstruction() { // GIVEN @@ -812,6 +815,7 @@ private Q_SLOTS: QVERIFY(!v0.isNull()); } } +#endif // QT_COMPILER_SUPPORTS_SSE2 }; QTEST_APPLESS_MAIN(tst_Vector3D_SSE) diff --git a/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp b/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp index ed9722ffb..2e539491f 100644 --- a/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp +++ b/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp @@ -30,12 +30,16 @@ #include <Qt3DCore/private/vector4d_sse_p.h> #include <Qt3DCore/qt3dcore-config.h> +#ifdef QT_COMPILER_SUPPORTS_SSE2 using namespace Qt3DCore; +#endif class tst_Vector4D_SSE: public QObject { Q_OBJECT private Q_SLOTS: + +#ifdef QT_COMPILER_SUPPORTS_SSE2 void defaultConstruction() { // GIVEN @@ -915,6 +919,7 @@ private Q_SLOTS: QVERIFY(!v0.isNull()); } } +#endif // QT_COMPILER_SUPPORTS_SSE2 }; QTEST_APPLESS_MAIN(tst_Vector4D_SSE) diff --git a/tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp b/tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp index 6fcc2e637..35e241839 100644 --- a/tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp +++ b/tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp @@ -90,7 +90,7 @@ void tst_qtext2dentity::checkChangeArbiter() auto atlases = lookupNodeByClassName(rootEntity.data(), "Qt3DExtras::QTextureAtlas"); QVERIFY(atlases.length() == 1); auto atlas = atlases[0]; - QTRY_VERIFY(Qt3DCore::QNodePrivate::get(atlas)->m_changeArbiter); + QVERIFY(Qt3DCore::QNodePrivate::get(atlas)->m_changeArbiter); #endif } diff --git a/tests/auto/input/commons/commons.pri b/tests/auto/input/commons/commons.pri index 4913f5bbb..656f41980 100644 --- a/tests/auto/input/commons/commons.pri +++ b/tests/auto/input/commons/commons.pri @@ -1,6 +1,8 @@ HEADERS += $$PWD/testdevice.h \ $$PWD/testdeviceproxy.h +SOURCES += $$PWD/testdevice.cpp + INCLUDEPATH += $$PWD include(../../core/common/common.pri) diff --git a/tests/auto/input/commons/testdevice.cpp b/tests/auto/input/commons/testdevice.cpp new file mode 100644 index 000000000..91a2ad159 --- /dev/null +++ b/tests/auto/input/commons/testdevice.cpp @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "moc_testdevice.cpp" +#include "moc_testdeviceproxy.cpp" + diff --git a/tests/auto/quick3d/dynamicnodecreation/BLACKLIST b/tests/auto/quick3d/dynamicnodecreation/BLACKLIST new file mode 100644 index 000000000..5a740af23 --- /dev/null +++ b/tests/auto/quick3d/dynamicnodecreation/BLACKLIST @@ -0,0 +1,4 @@ +# See qtbase/src/testlib/qtestblacklist.cpp for format +[createEntityAndDynamicChild] +ci ubuntu-20.04 # QTBUG-106519 +sles-15.4 # QTBUG-102315 diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/data/createMultipleAsync.qml b/tests/auto/quick3d/quick3dnodeinstantiator/data/createMultipleAsync.qml new file mode 100644 index 000000000..be6c46582 --- /dev/null +++ b/tests/auto/quick3d/quick3dnodeinstantiator/data/createMultipleAsync.qml @@ -0,0 +1,13 @@ +import QtQml 2.1 +import Qt3D.Core 2.0 + +Entity { + NodeInstantiator { + model: 10 + asynchronous: true + delegate: Entity { + property bool success: true + property int idx: index + } + } +} diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp index d4d0d56e2..1e7d6c593 100644 --- a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp +++ b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp @@ -39,6 +39,7 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlcontext.h> +#include <QtQml/qqmlincubator.h> using namespace Qt3DCore::Quick; @@ -55,6 +56,8 @@ private slots: void activeProperty(); void intModelChange(); void createAndRemove(); + void asynchronous_data(); + void asynchronous(); }; void tst_quick3dnodeinstantiator::createNone() @@ -251,6 +254,49 @@ void tst_quick3dnodeinstantiator::createAndRemove() QCOMPARE(object->property("datum").toString(), names[i]); } } + +void tst_quick3dnodeinstantiator::asynchronous_data() +{ + QTest::addColumn<bool>("asyncIncubator"); + QTest::addColumn<QString>("fileName"); + + QTest::newRow("Asynchronous Instantiator") << false << "createMultipleAsync.qml"; + QTest::newRow("Nested-asynchronous Instantiator") << true << "createMultiple.qml"; +} + +void tst_quick3dnodeinstantiator::asynchronous() +{ + QFETCH(bool, asyncIncubator); + QFETCH(QString, fileName); + + QQmlEngine engine; + QQmlIncubationController incubationController; + engine.setIncubationController(&incubationController); + QQmlComponent component(&engine, testFileUrl(fileName)); + QQmlIncubator incubator(asyncIncubator ? QQmlIncubator::Asynchronous : QQmlIncubator::Synchronous); + component.create(incubator); + while (!incubator.isReady()) + incubationController.incubateFor(10); + QObject *rootObject = incubator.object(); + QVERIFY(rootObject != nullptr); + while (incubationController.incubatingObjectCount() > 0) + incubationController.incubateFor(10); + Quick3DNodeInstantiator *instantiator = rootObject->findChild<Quick3DNodeInstantiator *>(); + QVERIFY(instantiator != nullptr); + QCOMPARE(instantiator->isActive(), true); + QCOMPARE(instantiator->count(), 10); + + for (int i=0; i<10; i++) { + QObject *object = instantiator->objectAt(i); + QVERIFY(object); + QCOMPARE(object->parent(), rootObject); + QCOMPARE(object->property("success").toBool(), true); + QCOMPARE(object->property("idx").toInt(), i); + } +} + + QTEST_MAIN(tst_quick3dnodeinstantiator) #include "tst_quick3dnodeinstantiator.moc" +#include "moc_stringmodel.cpp" diff --git a/tests/auto/render/geometry/tst_geometry.cpp b/tests/auto/render/geometry/tst_geometry.cpp index a13f6fa40..4e7a94c42 100644 --- a/tests/auto/render/geometry/tst_geometry.cpp +++ b/tests/auto/render/geometry/tst_geometry.cpp @@ -204,16 +204,12 @@ private Q_SLOTS: // WHEN renderGeometry.updateExtent(QVector3D(-1.0f, -1.0f, -1.0f), QVector3D(1.0f, 1.0f, 1.0f)); - renderGeometry.notifyExtentChanged(); // THEN - QCOMPARE(arbiter.events.count(), 1); + QCOMPARE(arbiter.dirtyNodes.count(), 0); - Qt3DCore::QPropertyUpdatedChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>(); - QCOMPARE(change->propertyName(), "extent"); - const QPair<QVector3D, QVector3D> v = change->value().value<QPair<QVector3D, QVector3D>>(); - QCOMPARE(v.first, QVector3D(-1.0f, -1.0f, -1.0f)); - QCOMPARE(v.second, QVector3D(1.0f, 1.0f, 1.0f)); + QCOMPARE(renderGeometry.min(), QVector3D(-1.0f, -1.0f, -1.0f)); + QCOMPARE(renderGeometry.max(), QVector3D(1.0f, 1.0f, 1.0f)); arbiter.events.clear(); } diff --git a/tests/auto/render/opengl/graphicshelpergl4/BLACKLIST b/tests/auto/render/opengl/graphicshelpergl4/BLACKLIST new file mode 100644 index 000000000..08e743315 --- /dev/null +++ b/tests/auto/render/opengl/graphicshelpergl4/BLACKLIST @@ -0,0 +1,6 @@ +# See qtbase/src/testlib/qtestblacklist.cpp for format +#QTBUG-101556 +[bindFrameBufferAttachment] +ubuntu-20.04 +# QTBUG-111291 +sles-15.4 diff --git a/tests/auto/render/opengl/renderviews/tst_renderviews.cpp b/tests/auto/render/opengl/renderviews/tst_renderviews.cpp index aec13071a..196ee85d4 100644 --- a/tests/auto/render/opengl/renderviews/tst_renderviews.cpp +++ b/tests/auto/render/opengl/renderviews/tst_renderviews.cpp @@ -307,6 +307,68 @@ private Q_SLOTS: << (QVector<ShaderParameterPack>() << pack1 << minifiedPack1 << minifiedPack1 << pack1 << minifiedPack1 << minifiedPack1); } + void checkShaderParameterPackStoresSingleUBOPerBlockIndex() + { + // GIVEN + ShaderParameterPack pack; + auto nodeId1 = Qt3DCore::QNodeId::createId(); + auto nodeId2 = Qt3DCore::QNodeId::createId(); + + BlockToUBO ubo1 { 1, nodeId1, false, {}}; + BlockToUBO ubo2 { 1, nodeId2, false, {}}; + + // WHEN + pack.setUniformBuffer(ubo1); + pack.setUniformBuffer(ubo2); + + // THEN + QCOMPARE(pack.uniformBuffers().size(), 1); + QCOMPARE(pack.uniformBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.uniformBuffers().front().m_bufferID, nodeId2); + + // WHEN + BlockToUBO ubo3 { 2, nodeId2, false, {}}; + pack.setUniformBuffer(ubo3); + + // THEN + QCOMPARE(pack.uniformBuffers().size(), 2); + QCOMPARE(pack.uniformBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.uniformBuffers().front().m_bufferID, nodeId2); + QCOMPARE(pack.uniformBuffers().back().m_blockIndex, 2); + QCOMPARE(pack.uniformBuffers().back().m_bufferID, nodeId2); + } + + void checkShaderParameterPackStoresSingleSSBOPerBlockIndex() + { + // GIVEN + ShaderParameterPack pack; + auto nodeId1 = Qt3DCore::QNodeId::createId(); + auto nodeId2 = Qt3DCore::QNodeId::createId(); + + BlockToSSBO ssbo1 { 1, 0, nodeId1}; + BlockToSSBO ssbo2 { 1, 0, nodeId2}; + + // WHEN + pack.setShaderStorageBuffer(ssbo1); + pack.setShaderStorageBuffer(ssbo2); + + // THEN + QCOMPARE(pack.shaderStorageBuffers().size(), 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_bufferID, nodeId2); + + // WHEN + BlockToSSBO ssbo3 { 2, 1, nodeId2}; + pack.setShaderStorageBuffer(ssbo3); + + // THEN + QCOMPARE(pack.shaderStorageBuffers().size(), 2); + QCOMPARE(pack.shaderStorageBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_bufferID, nodeId2); + QCOMPARE(pack.shaderStorageBuffers().back().m_blockIndex, 2); + QCOMPARE(pack.shaderStorageBuffers().back().m_bufferID, nodeId2); + } + void checkRenderViewUniformMinification() { QFETCH(QVector<QShaderProgram*>, shaders); diff --git a/tests/auto/render/qgeometry/tst_qgeometry.cpp b/tests/auto/render/qgeometry/tst_qgeometry.cpp index e790ba9cc..b2c66ae72 100644 --- a/tests/auto/render/qgeometry/tst_qgeometry.cpp +++ b/tests/auto/render/qgeometry/tst_qgeometry.cpp @@ -208,31 +208,26 @@ private Q_SLOTS: QCOMPARE(geometry->maxExtent(), QVector3D()); // WHEN - Qt3DCore::QPropertyUpdatedChangePtr valueChange(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - valueChange->setPropertyName("extent"); - valueChange->setValue(QVariant::fromValue(QPair<QVector3D, QVector3D>(QVector3D(10.0f, 10.f, 10.0f), - QVector3D()))); - geometry->sceneChangeEvent(valueChange); + auto dNode = static_cast<Qt3DRender::QGeometryPrivate *>(Qt3DCore::QNodePrivate::get(geometry.data())); + const QVector3D minExt(-1.0f, -1.0f, -1.0f); + const QVector3D maxExt(1.0f, 1.0f, 1.0f); + dNode->setExtent(minExt, maxExt); // THEN QCOMPARE(spyMinExtent.count(), 1); - QCOMPARE(spyMaxExtent.count(), 0); - QCOMPARE(geometry->minExtent(), QVector3D(10.0f, 10.0f, 10.0f)); + QCOMPARE(spyMaxExtent.count(), 1); + QCOMPARE(geometry->minExtent(), minExt); + QCOMPARE(geometry->maxExtent(), maxExt); + spyMaxExtent.clear(); spyMinExtent.clear(); // WHEN - valueChange->setPropertyName("extent"); - valueChange->setValue(QVariant::fromValue(QPair<QVector3D, QVector3D>(QVector3D(10.0f, 10.f, 10.0f), - QVector3D(11.0f, 11.f, 11.0f)))); - geometry->sceneChangeEvent(valueChange); + dNode->setExtent(minExt, maxExt); // THEN QCOMPARE(spyMinExtent.count(), 0); - QCOMPARE(spyMaxExtent.count(), 1); - QCOMPARE(geometry->maxExtent(), QVector3D(11.0f, 11.0f, 11.0f)); - - spyMaxExtent.clear(); + QCOMPARE(spyMaxExtent.count(), 0); } }; diff --git a/tests/auto/render/qmlscenereader/qmlscenereader.cpp b/tests/auto/render/qmlscenereader/qmlscenereader.cpp index 182782edb..417a75880 100644 --- a/tests/auto/render/qmlscenereader/qmlscenereader.cpp +++ b/tests/auto/render/qmlscenereader/qmlscenereader.cpp @@ -82,3 +82,5 @@ void QmlSceneReader::loadComplete() } QT_END_NAMESPACE + +#include "moc_qmlscenereader.cpp" diff --git a/tests/auto/render/qmlscenereader/qmlscenereader.h b/tests/auto/render/qmlscenereader/qmlscenereader.h index 9d4643d93..75a74d03a 100644 --- a/tests/auto/render/qmlscenereader/qmlscenereader.h +++ b/tests/auto/render/qmlscenereader/qmlscenereader.h @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#ifndef QMLSCENEREADER_H +#define QMLSCENEREADER_H + #include <QObject> QT_BEGIN_NAMESPACE @@ -61,3 +64,5 @@ private: }; QT_END_NAMESPACE + +#endif diff --git a/tests/auto/render/raycasting/BLACKLIST b/tests/auto/render/raycasting/BLACKLIST new file mode 100644 index 000000000..8d957b4ca --- /dev/null +++ b/tests/auto/render/raycasting/BLACKLIST @@ -0,0 +1,3 @@ +# See qtbase/src/testlib/qtestblacklist.cpp for format +[shouldReturnAllResults] +ci ubuntu-20.04 # QTBUG-108918 diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp index 55041eeb4..d4a19164a 100644 --- a/tests/auto/shared/util.cpp +++ b/tests/auto/shared/util.cpp @@ -123,3 +123,5 @@ QQmlTestMessageHandler::~QQmlTestMessageHandler() qInstallMessageHandler(m_oldHandler); QQmlTestMessageHandler::m_instance = 0; } + +#include "moc_util.cpp" |