summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-04-19 17:16:52 +0100
committerPaul Lemire <paul.lemire@kdab.com>2016-04-29 16:22:24 +0000
commit948d0357850918596b56f38a6dc6e25cd186f5a0 (patch)
tree2a522442757660b6eadecd3a6decde1f34ab5740 /tests
parentae5ac1128bc61176f797f6e248d18b9ced051ad9 (diff)
Strip out cloning subsystem
Change-Id: I4def54a11de0f9c676ef6b2d7bd8e723ded25ab9 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/cloning/cloning.pro8
-rw-r--r--tests/auto/core/cloning/tst_cloning.cpp138
-rw-r--r--tests/auto/core/core.pro7
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp134
-rw-r--r--tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp9
-rw-r--r--tests/auto/core/qentity/tst_qentity.cpp76
-rw-r--r--tests/auto/core/qscene/tst_qscene.cpp6
-rw-r--r--tests/auto/core/qtransform/tst_qtransform.cpp35
-rw-r--r--tests/auto/input/commons/testdevice.h9
-rw-r--r--tests/auto/input/qaction/tst_qaction.cpp36
-rw-r--r--tests/auto/input/qactioninput/tst_qactioninput.cpp38
-rw-r--r--tests/auto/input/qaxis/tst_qaxis.cpp33
-rw-r--r--tests/auto/input/qaxisinput/tst_qaxisinput.cpp41
-rw-r--r--tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp52
-rw-r--r--tests/auto/render/qabstractlight/tst_qabstractlight.cpp165
-rw-r--r--tests/auto/render/qattribute/tst_qattribute.cpp57
-rw-r--r--tests/auto/render/qboundingvolumedebug/tst_qboundingvolumedebug.cpp37
-rw-r--r--tests/auto/render/qbuffer/tst_qbuffer.cpp49
-rw-r--r--tests/auto/render/qcameraselector/tst_qcameraselector.cpp39
-rw-r--r--tests/auto/render/qclearbuffers/tst_qclearbuffers.cpp39
-rw-r--r--tests/auto/render/qdefaultmeshes/tst_qdefaultmeshes.cpp91
-rw-r--r--tests/auto/render/qframegraphnode/tst_qframegraphnode.cpp35
-rw-r--r--tests/auto/render/qgeometry/tst_qgeometry.cpp42
-rw-r--r--tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp63
-rw-r--r--tests/auto/render/qlayerfilter/tst_qlayerfilter.cpp37
-rw-r--r--tests/auto/render/qmaterial/tst_qmaterial.cpp42
-rw-r--r--tests/auto/render/qobjectpicker/tst_qobjectpicker.cpp41
-rw-r--r--tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp64
-rw-r--r--tests/auto/render/qrenderstateset/tst_qrenderstateset.cpp41
-rw-r--r--tests/auto/render/qrendertargetselector/tst_qrendertargetselector.cpp38
-rw-r--r--tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp42
-rw-r--r--tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp34
-rw-r--r--tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp51
-rw-r--r--tests/auto/render/qviewport/tst_qviewport.cpp35
34 files changed, 642 insertions, 1022 deletions
diff --git a/tests/auto/core/cloning/cloning.pro b/tests/auto/core/cloning/cloning.pro
deleted file mode 100644
index d6ecaf489..000000000
--- a/tests/auto/core/cloning/cloning.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TARGET = tst_cloning
-CONFIG += testcase
-TEMPLATE = app
-
-SOURCES += \
- tst_cloning.cpp
-
-QT += testlib core-private 3dcore 3dcore-private
diff --git a/tests/auto/core/cloning/tst_cloning.cpp b/tests/auto/core/cloning/tst_cloning.cpp
deleted file mode 100644
index 3ab68e34a..000000000
--- a/tests/auto/core/cloning/tst_cloning.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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 <QtTest/QtTest>
-#include <Qt3DCore/qentity.h>
-#include <Qt3DCore/qcomponent.h>
-#include <Qt3DCore/private/qnode_p.h>
-#include <Qt3DCore/private/qscene_p.h>
-
-class tst_Cloning : public QObject
-{
- Q_OBJECT
-public:
- tst_Cloning() : QObject() {}
- ~tst_Cloning() {}
-
-private slots:
- void checkEntityCloning();
-};
-
-class MyQNode : public Qt3DCore::QNode
-{
- Q_OBJECT
-public:
- explicit MyQNode(Qt3DCore::QNode *parent = 0) : QNode(parent)
- {}
-
- void setCustomProperty(const QString &s) { m_customProperty = s; }
- QString customProperty() const { return m_customProperty; }
-
- QT3D_CLONEABLE(MyQNode)
-
- QString m_customProperty;
-
- static QNode *clone(QNode *node) {
- return QNode::clone(node);
- }
-
-protected:
- void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE
- {
- Qt3DCore::QNode::copy(ref);
- const MyQNode *refNode = qobject_cast<const MyQNode *>(ref);
- setCustomProperty(refNode->customProperty());
- }
-};
-
-class MyQComponent : public Qt3DCore::QComponent
-{
- Q_OBJECT
-public:
- explicit MyQComponent(Qt3DCore::QNode *parent = 0) : QComponent(parent)
- {}
-
- QT3D_CLONEABLE(MyQComponent)
-};
-
-void tst_Cloning::checkEntityCloning()
-{
- // GIVEN
- Qt3DCore::QScene *scene = new Qt3DCore::QScene();
- MyQNode *root = new MyQNode();
- Qt3DCore::QNodePrivate::get(root)->setScene(scene);
-
- Qt3DCore::QEntity *entity = new Qt3DCore::QEntity(root);
-
- // WHEN
- MyQComponent *comp1 = new MyQComponent();
- MyQComponent *comp2 = new MyQComponent();
- MyQComponent *comp3 = new MyQComponent();
-
- MyQNode *childNode = new MyQNode(entity);
- entity->addComponent(comp1);
- entity->addComponent(comp2);
- entity->addComponent(comp3);
-
- root->setCustomProperty(QStringLiteral("Corvette"));
-
- // THEN
- QVERIFY(root->customProperty() == QStringLiteral("Corvette"));
- QCOMPARE(root->children().count(), 1);
- QCOMPARE(entity->children().count(), 4);
- QCOMPARE(entity->components().count(), 3);
-
- //WHEN
- MyQNode *cloneRoot = qobject_cast<MyQNode *>(MyQNode::clone(root));
-
- // THEN
- QCOMPARE(cloneRoot->children().count(), 1);
- QCOMPARE(cloneRoot->id(), root->id());
- QVERIFY(cloneRoot->customProperty() == root->customProperty());
-
- Qt3DCore::QEntity *cloneEntity = qobject_cast<Qt3DCore::QEntity *>(cloneRoot->children().first());
- QVERIFY(cloneEntity != Q_NULLPTR);
- QCOMPARE(cloneEntity->id(), entity->id());
- QCOMPARE(cloneEntity->children().count(), 4);
- QCOMPARE(cloneEntity->components().count(), 3);
-
- QVector<Qt3DCore::QNodeId> ids = QVector<Qt3DCore::QNodeId>() << comp1->id() << comp2->id() << comp3->id() << childNode->id();
-
- Q_FOREACH (QObject *c, cloneEntity->children()) {
- Qt3DCore::QNode *n = qobject_cast<Qt3DCore::QNode *>(c);
- QVERIFY(ids.contains(n->id()));
- ids.removeAll(n->id());
- }
-
- delete cloneRoot;
-}
-
-QTEST_APPLESS_MAIN(tst_Cloning)
-
-#include "tst_cloning.moc"
-
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro
index 9d5b1a1b4..317bef16e 100644
--- a/tests/auto/core/core.pro
+++ b/tests/auto/core/core.pro
@@ -7,18 +7,17 @@ SUBDIRS = \
qcircularbuffer \
qboundedcircularbuffer \
nodes \
- qentity \
qaspectengine \
qaspectfactory \
qaspectjob \
qchangearbiter \
qscene \
- qservicelocator \
- qtransform
+ qservicelocator
contains(QT_CONFIG, private_tests) {
SUBDIRS += \
+ qentity \
qframeallocator \
- cloning \
+ qtransform \
threadpooler
}
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 418625c31..b64e63bd3 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -78,7 +78,6 @@ private slots:
void changeCustomProperty();
void checkDestruction();
- void verifyCopy();
};
class ObserverSpy;
@@ -194,17 +193,10 @@ public:
Qt3DCore::QNodePrivate::get(this)->setScene(m_scene);
}
- void makeCopyOf(QNode *other)
- {
- QNode::copy(other);
- }
-
signals:
void customPropertyChanged();
protected:
- QT3D_CLONEABLE_CUSTOM_DTOR(MyQNode)
-
QString m_customProperty;
Qt3DCore::QScene *m_scene;
};
@@ -215,10 +207,6 @@ class MyQComponent : public Qt3DCore::QComponent
public:
explicit MyQComponent(Qt3DCore::QNode *parent = 0) : QComponent(parent)
{}
-
- // QNode interface
-protected:
- QT3D_CLONEABLE(MyQComponent)
};
@@ -369,12 +357,11 @@ void tst_Nodes::appendSingleChildNodeToNodeSceneExplicitParenting()
QVERIFY(spy.events.first().wasLocked());
QCOMPARE(node->children().count(), 1);
- Qt3DCore::QNodePropertyChangePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeCreated);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QCOMPARE(clone->parentNode()->id(), node->id());
+ Qt3DCore::QNodeCreatedChangeBasePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
+ QCOMPARE(event->subjectId(), child->id());
+ QCOMPARE(event->metaObject(), child->metaObject());
+ QCOMPARE(event->isNodeEnabled(), child->isEnabled());
+ QCOMPARE(event->parentId(), child->parentNode()->id());
}
void tst_Nodes::appendSingleChildNodeToNodeSceneImplicitParenting()
@@ -401,12 +388,11 @@ void tst_Nodes::appendSingleChildNodeToNodeSceneImplicitParenting()
QVERIFY(spy.events.first().wasLocked());
QCOMPARE(node->children().count(), 1);
- Qt3DCore::QNodePropertyChangePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeCreated);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QCOMPARE(clone->parentNode()->id(), node->id());
+ Qt3DCore::QNodeCreatedChangeBasePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
+ QCOMPARE(event->subjectId(), child->id());
+ QCOMPARE(event->metaObject(), child->metaObject());
+ QCOMPARE(event->isNodeEnabled(), child->isEnabled());
+ QCOMPARE(event->parentId(), child->parentNode()->id());
}
void tst_Nodes::appendMultipleChildNodesToNodeScene()
@@ -442,23 +428,16 @@ void tst_Nodes::appendMultipleChildNodesToNodeScene()
// THEN
QCOMPARE(spy.events.size(), 10);
+ int i = 0;
Q_FOREACH (const ObserverSpy::ChangeRecord &r, spy.events) {
QVERIFY(r.wasLocked());
- Qt3DCore::QNodePropertyChangePtr event = r.change().dynamicCast<Qt3DCore::QNodePropertyChange>();
+ const auto event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
+ Qt3DCore::QNode *child = node->childNodes().at(i++);
QCOMPARE(event->type(), Qt3DCore::NodeCreated);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
-
- bool found = false;
- Q_FOREACH (QObject *c, node->children()) {
- if (clone->id() == qobject_cast<Qt3DCore::QNode *>(c)->id()) {
- found = true;
- QCOMPARE(clone->parentNode()->id(), node->id());
- break;
- }
- }
- QVERIFY(found);
+ QCOMPARE(event->subjectId(), child->id());
+ QCOMPARE(event->metaObject(), child->metaObject());
+ QCOMPARE(event->isNodeEnabled(), child->isEnabled());
}
}
@@ -488,12 +467,9 @@ void tst_Nodes::checkParentChangeToNull()
QCOMPARE(spy.events.size(), 1);
QVERIFY(spy.events.first().wasLocked());
- Qt3DCore::QNodePropertyChangePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeAboutToBeDeleted);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QVERIFY(!clone->parentNode());
+ const auto event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeDestroyedChange>();
+ QCOMPARE(event->type(), Qt3DCore::NodeDeleted);
+ QCOMPARE(event->subjectId(), child->id());
}
void tst_Nodes::checkParentChangeToOtherParent()
@@ -535,21 +511,17 @@ void tst_Nodes::checkParentChangeToOtherParent()
// CHECK event 1 is a Node Deleted event
QVERIFY(spyParent1.events.first().wasLocked());
- Qt3DCore::QNodePropertyChangePtr event = spyParent1.events.takeFirst().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeAboutToBeDeleted);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QVERIFY(!clone->parentNode());
+ const auto event = spyParent1.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeDestroyedChange>();
+ QCOMPARE(event->type(), Qt3DCore::NodeDeleted);
+ QCOMPARE(event->subjectId(), child->id());
// CHECK event 2 is a Node Added event
QVERIFY(spyParent2.events.last().wasLocked());
- event = spyParent2.events.last().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeCreated);
- QCOMPARE(event->propertyName(), "node");
- clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QVERIFY(clone->parentNode());
+ const auto event2 = spyParent2.events.last().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
+ QCOMPARE(event2->type(), Qt3DCore::NodeCreated);
+ QCOMPARE(event2->subjectId(), child->id());
+ QCOMPARE(event2->metaObject(), child->metaObject());
+ QCOMPARE(event2->isNodeEnabled(), child->isEnabled());
}
@@ -560,6 +532,7 @@ void tst_Nodes::removingSingleChildNodeFromNode()
QScopedPointer<Qt3DCore::QNode> child(new MyQNode());
// WHEN
+ root->assignScene();
child->setParent(root.data());
// THEN
@@ -576,12 +549,9 @@ void tst_Nodes::removingSingleChildNodeFromNode()
QCOMPARE(spy.events.size(), 1);
QVERIFY(spy.events.first().wasLocked());
- Qt3DCore::QNodePropertyChangePtr event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeAboutToBeDeleted);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QCOMPARE(clone->id(), child->id());
- QVERIFY(!clone->parentNode());
+ const auto event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeDestroyedChange>();
+ QCOMPARE(event->type(), Qt3DCore::NodeDeleted);
+ QCOMPARE(event->subjectId(), child->id());
}
void tst_Nodes::removingMultipleChildNodesFromNode()
@@ -597,8 +567,11 @@ void tst_Nodes::removingMultipleChildNodesFromNode()
QVERIFY(Qt3DCore::QNodePrivate::get(root.data())->scene() != Q_NULLPTR);
// WHEN
- for (int i = 0; i < 10; i++)
- (void) new MyQNode(root.data());
+ Qt3DCore::QNodeIdVector childIds(10);
+ for (int i = 0; i < 10; i++) {
+ auto child = new MyQNode(root.data());
+ childIds[i] = child->id();
+ }
QCoreApplication::processEvents();
@@ -614,13 +587,12 @@ void tst_Nodes::removingMultipleChildNodesFromNode()
// THEN
QVERIFY(root->children().count() == 0);
QCOMPARE(spy.events.size(), 10);
+ int i = 0;
Q_FOREACH (const ObserverSpy::ChangeRecord &r, spy.events) {
QVERIFY(r.wasLocked());
- Qt3DCore::QNodePropertyChangePtr event = r.change().dynamicCast<Qt3DCore::QNodePropertyChange>();
- QCOMPARE(event->type(), Qt3DCore::NodeAboutToBeDeleted);
- QCOMPARE(event->propertyName(), "node");
- Qt3DCore::QNodePtr clone = event->value().value<Qt3DCore::QNodePtr>();
- QVERIFY(!clone->parentNode());
+ const auto event = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeDestroyedChange>();
+ QCOMPARE(event->type(), Qt3DCore::NodeDeleted);
+ QCOMPARE(event->subjectId(), childIds.at(i++));
}
}
@@ -801,32 +773,6 @@ void tst_Nodes::checkDestruction()
QVERIFY(root->children().isEmpty());
}
-void tst_Nodes::verifyCopy()
-{
- // GIVEN
- QScopedPointer<MyQNode> root(new MyQNode());
- MyQNode *other1 = new MyQNode();
- MyQNode *other2 = new MyQNode();
-
- // THEN
- QVERIFY(root->id() != other1->id());
- QVERIFY(root->id() != other2->id());
- QVERIFY(other1->id() != other2->id());
-
- // WHEN
- other1->makeCopyOf(root.data());
-
- // THEN
- QVERIFY(root->id() == other1->id());
- QVERIFY(root->id() != other2->id());
-
- // WHEN
- other2->makeCopyOf(other1);
-
- // THEN
- QVERIFY(root->id() == other1->id() && root->id() == other2->id());
-}
-
QTEST_MAIN(tst_Nodes)
#include "tst_nodes.moc"
diff --git a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
index 62e624106..e7214f4ad 100644
--- a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
+++ b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
@@ -122,15 +122,6 @@ public:
return m_lastChanges;
}
- // QNode interface
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- tst_Node *clone = new tst_Node();
- clone->copy(this);
- return clone;
- }
-
private:
QList<Qt3DCore::QSceneChangePtr> m_lastChanges;
};
diff --git a/tests/auto/core/qentity/tst_qentity.cpp b/tests/auto/core/qentity/tst_qentity.cpp
index 208191d33..616ce3a33 100644
--- a/tests/auto/core/qentity/tst_qentity.cpp
+++ b/tests/auto/core/qentity/tst_qentity.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/private/qentity_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DCore/qcomponent.h>
#include <QtCore/qscopedpointer.h>
@@ -56,7 +57,9 @@ private slots:
void addSeveralTimesSameComponent();
void removeSeveralTimesSameComponent();
- void verifyCopy();
+
+ void checkCloning_data();
+ void checkCloning();
};
class MyQComponent : public Qt3DCore::QComponent
@@ -66,9 +69,6 @@ public:
explicit MyQComponent(Qt3DCore::QNode *parent = 0)
: QComponent(parent)
{}
-
-protected:
- QT3D_CLONEABLE(MyQComponent)
};
@@ -78,11 +78,6 @@ public:
explicit MyEntity(Qt3DCore::QNode *parent = 0)
: QEntity(parent)
{}
-
- void makeCopyOf(Qt3DCore::QEntity *other)
- {
- QEntity::copy(other);
- }
};
void tst_Entity::constructionDestruction()
@@ -553,45 +548,58 @@ void tst_Entity::removeSeveralTimesSameComponent()
QCOMPARE(comp->entities().size(), 0);
}
-Qt3DCore::QNodeId parentEntityId(Qt3DCore::QEntity *entity)
+void tst_Entity::checkCloning_data()
{
- Qt3DCore::QEntityPrivate *d = static_cast<Qt3DCore::QEntityPrivate*>(Qt3DCore::QNodePrivate::get(entity));
- return d->parentEntityId();
+ QTest::addColumn<Qt3DCore::QEntity *>("entity");
+
+ QTest::newRow("defaultConstructed") << new MyEntity();
+
+ Qt3DCore::QEntity *entityWithComponents = new MyEntity();
+ Qt3DCore::QComponent *component1 = new MyQComponent();
+ Qt3DCore::QComponent *component2 = new MyQComponent();
+ Qt3DCore::QComponent *component3 = new MyQComponent();
+ entityWithComponents->addComponent(component1);
+ entityWithComponents->addComponent(component2);
+ entityWithComponents->addComponent(component3);
+ QTest::newRow("entityWithComponents") << entityWithComponents;
}
-void tst_Entity::verifyCopy()
+void tst_Entity::checkCloning()
{
// GIVEN
- QScopedPointer<Qt3DCore::QEntity> root(new Qt3DCore::QEntity());
- MyEntity *parentLessEntity = new MyEntity();
- MyEntity *parentedEntity = new MyEntity(root.data());
-
- QCoreApplication::processEvents();
-
- // THEN
- QVERIFY(root->id() != parentLessEntity->id());
- QVERIFY(root->id() != parentedEntity->id());
- QVERIFY(parentEntityId(root.data()).isNull());
- QVERIFY(!parentEntityId(parentedEntity).isNull());
- QVERIFY(parentEntityId(parentLessEntity).isNull());
+ QFETCH(Qt3DCore::QEntity *, entity);
// WHEN
- MyEntity *parentedEntityCopy = new MyEntity();
- parentedEntityCopy->makeCopyOf(parentedEntity);
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(entity);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(parentedEntityCopy->id() == parentedEntity->id());
- QVERIFY(parentEntityId(parentedEntityCopy) == parentEntityId(parentedEntity));
+ QCOMPARE(creationChanges.size(), 1 + entity->components().size());
- // WHEN
- MyEntity *parentLessEntityCopy = new MyEntity();
- parentLessEntityCopy->makeCopyOf(parentLessEntity);
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DCore::QEntityData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DCore::QEntityData>>(creationChanges.first());
+ const Qt3DCore::QEntityData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(parentLessEntityCopy->id() == parentLessEntity->id());
- QVERIFY(parentEntityId(parentLessEntityCopy) == parentEntityId(parentLessEntity));
+ QCOMPARE(creationChangeData->subjectId(), entity->id());
+ QCOMPARE(creationChangeData->isNodeEnabled(), entity->isEnabled());
+ QCOMPARE(creationChangeData->metaObject(), entity->metaObject());
+ QCOMPARE(creationChangeData->parentId(), entity->parentNode() ? entity->parentNode()->id() : Qt3DCore::QNodeId());
+ QCOMPARE(cloneData.parentEntityId, entity->parentEntity() ? entity->parentEntity()->id() : Qt3DCore::QNodeId());
+ QCOMPARE(cloneData.componentIdsAndTypes.size(), entity->components().size());
+
+ const QVector<Qt3DCore::QComponent *> &components = entity->components();
+ for (int i = 0, m = components.size(); i < m; ++i) {
+ QCOMPARE(cloneData.componentIdsAndTypes.at(i).id, components.at(i)->id());
+ QCOMPARE(cloneData.componentIdsAndTypes.at(i).type, components.at(i)->metaObject());
+ }
}
+Qt3DCore::QNodeId parentEntityId(Qt3DCore::QEntity *entity)
+{
+ Qt3DCore::QEntityPrivate *d = static_cast<Qt3DCore::QEntityPrivate*>(Qt3DCore::QNodePrivate::get(entity));
+ return d->parentEntityId();
+}
QTEST_MAIN(tst_Entity)
diff --git a/tests/auto/core/qscene/tst_qscene.cpp b/tests/auto/core/qscene/tst_qscene.cpp
index 67e8855d8..1c4003467 100644
--- a/tests/auto/core/qscene/tst_qscene.cpp
+++ b/tests/auto/core/qscene/tst_qscene.cpp
@@ -83,9 +83,6 @@ class tst_Node : public Qt3DCore::QNode
public:
tst_Node() : Qt3DCore::QNode()
{}
-
-protected:
- QT3D_CLONEABLE(tst_Node)
};
class tst_Component : public Qt3DCore::QComponent
@@ -94,9 +91,6 @@ class tst_Component : public Qt3DCore::QComponent
public:
tst_Component() : Qt3DCore::QComponent()
{}
-
-protected:
- QT3D_CLONEABLE(tst_Component)
};
void tst_QScene::addObservable()
diff --git a/tests/auto/core/qtransform/tst_qtransform.cpp b/tests/auto/core/qtransform/tst_qtransform.cpp
index 43ee5cfed..7668e6c67 100644
--- a/tests/auto/core/qtransform/tst_qtransform.cpp
+++ b/tests/auto/core/qtransform/tst_qtransform.cpp
@@ -29,12 +29,14 @@
#include <QtTest/QtTest>
#include <Qt3DCore/qtransform.h>
#include <Qt3DCore/qcomponent.h>
+#include <Qt3DCore/private/qtransform_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <QtCore/qscopedpointer.h>
#include "testpostmanarbiter.h"
using namespace Qt3DCore;
-class tst_QTransform : public QNode
+class tst_QTransform : public QObject
{
Q_OBJECT
@@ -75,17 +77,24 @@ private Q_SLOTS:
QFETCH(Qt3DCore::QTransform *, transform);
// WHEN
- Qt3DCore::QTransform *clone = static_cast<Qt3DCore::QTransform *>(QNode::clone(transform));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(transform);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
-
- QCOMPARE(transform->id(), clone->id());
- QCOMPARE(transform->matrix(), clone->matrix());
- QCOMPARE(transform->translation(), clone->translation());
- QCOMPARE(transform->scale3D(), clone->scale3D());
- QCOMPARE(transform->scale(), clone->scale());
- QCOMPARE(transform->rotation(), clone->rotation());
+ QCOMPARE(creationChanges.size(), 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DCore::QTransformData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DCore::QTransformData>>(creationChanges.first());
+ const Qt3DCore::QTransformData &cloneData = creationChangeData->data;
+
+ // THEN
+ QCOMPARE(creationChangeData->subjectId(), transform->id());
+ QCOMPARE(creationChangeData->isNodeEnabled(), transform->isEnabled());
+ QCOMPARE(creationChangeData->metaObject(), transform->metaObject());
+ QCOMPARE(creationChangeData->parentId(), transform->parentNode() ? transform->parentNode()->id() : Qt3DCore::QNodeId());
+ QCOMPARE(transform->translation(), cloneData.translation);
+ QCOMPARE(transform->scale3D(), cloneData.scale);
+ QCOMPARE(transform->rotation(), cloneData.rotation);
}
void checkPropertyUpdates()
@@ -187,12 +196,6 @@ private Q_SLOTS:
// Note: t.matrix() != t2.matrix() since different matrices
// can result in the same scale, rotation, translation
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
};
QTEST_MAIN(tst_QTransform)
diff --git a/tests/auto/input/commons/testdevice.h b/tests/auto/input/commons/testdevice.h
index fac185710..af956a3b9 100644
--- a/tests/auto/input/commons/testdevice.h
+++ b/tests/auto/input/commons/testdevice.h
@@ -43,13 +43,4 @@ public:
QStringList buttonNames() const Q_DECL_FINAL { return QStringList(); }
int axisIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; }
int buttonIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; }
-
-protected:
- void copy(const Qt3DCore::QNode *ref) Q_DECL_FINAL
- {
- QAbstractPhysicalDevice::copy(ref);
- }
-
-private:
- QT3D_CLONEABLE(TestDevice)
};
diff --git a/tests/auto/input/qaction/tst_qaction.cpp b/tests/auto/input/qaction/tst_qaction.cpp
index 2ad62e2e3..063d0e499 100644
--- a/tests/auto/input/qaction/tst_qaction.cpp
+++ b/tests/auto/input/qaction/tst_qaction.cpp
@@ -29,9 +29,12 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DInput/QAction>
#include <Qt3DInput/QActionInput>
+#include <Qt3DInput/private/qaction_p.h>
+#include <Qt3DInput/private/qactioninput_p.h>
#include <Qt3DCore/QNodePropertyChange>
#include <Qt3DCore/QNodeAddedPropertyChange>
@@ -78,19 +81,26 @@ private Q_SLOTS:
QFETCH(Qt3DInput::QAction *, action);
// WHEN
- Qt3DInput::QAction *clone = static_cast<Qt3DInput::QAction *>(QNode::clone(action));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(action);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(action->id(), clone->id());
- QCOMPARE(action->inputs().count(), clone->inputs().count());
- QCOMPARE(action->isActive(), clone->isActive());
+ QCOMPARE(creationChanges.size(), 1 + action->inputs().size());
- for (int i = 0, m = action->inputs().count(); i < m; ++i) {
- QCOMPARE(action->inputs().at(i)->id(), clone->inputs().at(i)->id());
- }
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DInput::QActionData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DInput::QActionData>>(creationChanges.first());
+ const Qt3DInput::QActionData &cloneActionData = creationChangeData->data;
+ // THEN
+ QCOMPARE(creationChangeData->subjectId(), action->id());
+ QCOMPARE(creationChangeData->isNodeEnabled(), action->isEnabled());
+ QCOMPARE(creationChangeData->metaObject(), action->metaObject());
+ QCOMPARE(creationChangeData->parentId(), action->parentNode() ? action->parentNode()->id() : Qt3DCore::QNodeId());
+ QCOMPARE(cloneActionData.inputIds.size(), action->inputs().size());
+
+ const QVector<Qt3DInput::QAbstractActionInput *> &inputs = action->inputs();
+ for (int i = 0, m = inputs.size(); i < m; ++i)
+ QCOMPARE(cloneActionData.inputIds.at(i), inputs.at(i)->id());
}
void checkPropertyUpdates()
@@ -142,14 +152,6 @@ private Q_SLOTS:
// THEN
QCOMPARE(isActive(), true);
}
-
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QAction)
diff --git a/tests/auto/input/qactioninput/tst_qactioninput.cpp b/tests/auto/input/qactioninput/tst_qactioninput.cpp
index 22f06bc4f..fb357a711 100644
--- a/tests/auto/input/qactioninput/tst_qactioninput.cpp
+++ b/tests/auto/input/qactioninput/tst_qactioninput.cpp
@@ -27,18 +27,19 @@
****************************************************************************/
#include <QtTest/QTest>
+#include <Qt3DCore/qnodeid.h>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
+#include <Qt3DInput/private/qactioninput_p.h>
#include <Qt3DInput/QActionInput>
#include <Qt3DInput/QAbstractPhysicalDevice>
#include "testpostmanarbiter.h"
#include "testdevice.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QActionInput: public Qt3DCore::QNode
+class tst_QActionInput: public QObject
{
Q_OBJECT
public:
@@ -72,18 +73,22 @@ private Q_SLOTS:
QFETCH(Qt3DInput::QActionInput *, actionInput);
// WHEN
- Qt3DInput::QActionInput *clone = static_cast<Qt3DInput::QActionInput *>(QNode::clone(actionInput));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(actionInput);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1 + (actionInput->sourceDevice() ? 1 : 0));
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DInput::QActionInputData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DInput::QActionInputData>>(creationChanges.first());
+ const Qt3DInput::QActionInputData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(actionInput->id(), clone->id());
- QCOMPARE(actionInput->buttons(), clone->buttons());
-
- if (actionInput->sourceDevice() != Q_NULLPTR) {
- QVERIFY(clone->sourceDevice() != Q_NULLPTR);
- QCOMPARE(clone->sourceDevice()->id(), actionInput->sourceDevice()->id());
- }
+ QCOMPARE(actionInput->id(), creationChangeData->subjectId());
+ QCOMPARE(actionInput->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(actionInput->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(actionInput->buttons(), cloneData.buttons);
+ QCOMPARE(actionInput->sourceDevice() ? actionInput->sourceDevice()->id() : Qt3DCore::QNodeId(), cloneData.sourceDeviceId);
}
void checkPropertyUpdates()
@@ -120,13 +125,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QActionInput)
diff --git a/tests/auto/input/qaxis/tst_qaxis.cpp b/tests/auto/input/qaxis/tst_qaxis.cpp
index 74a36584d..a0add024c 100644
--- a/tests/auto/input/qaxis/tst_qaxis.cpp
+++ b/tests/auto/input/qaxis/tst_qaxis.cpp
@@ -29,9 +29,11 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DInput/QAxis>
#include <Qt3DInput/QAxisInput>
+#include <Qt3DInput/private/qaxis_p.h>
#include <Qt3DCore/QNodePropertyChange>
#include <Qt3DCore/QNodeAddedPropertyChange>
@@ -78,19 +80,24 @@ private Q_SLOTS:
QFETCH(Qt3DInput::QAxis *, axis);
// WHEN
- Qt3DInput::QAxis *clone = static_cast<Qt3DInput::QAxis *>(QNode::clone(axis));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(axis);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(axis->id(), clone->id());
- QCOMPARE(axis->inputs().count(), clone->inputs().count());
- QCOMPARE(axis->value(), clone->value());
+ QCOMPARE(creationChanges.size(), 1 + axis->inputs().size());
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DInput::QAxisData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DInput::QAxisData>>(creationChanges.first());
+ const Qt3DInput::QAxisData &cloneData = creationChangeData->data;
- for (int i = 0, m = axis->inputs().count(); i < m; ++i) {
- QCOMPARE(axis->inputs().at(i)->id(), clone->inputs().at(i)->id());
- }
+ // THEN
+ QCOMPARE(axis->id(), creationChangeData->subjectId());
+ QCOMPARE(axis->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(axis->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(axis->inputs().count(), cloneData.inputIds.count());
+ for (int i = 0, m = axis->inputs().count(); i < m; ++i)
+ QCOMPARE(axis->inputs().at(i)->id(), cloneData.inputIds.at(i));
}
void checkPropertyUpdates()
@@ -142,14 +149,6 @@ private Q_SLOTS:
// THEN
QCOMPARE(value(), 383.0f);
}
-
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QAxis)
diff --git a/tests/auto/input/qaxisinput/tst_qaxisinput.cpp b/tests/auto/input/qaxisinput/tst_qaxisinput.cpp
index cc196ff82..c9e5dbae8 100644
--- a/tests/auto/input/qaxisinput/tst_qaxisinput.cpp
+++ b/tests/auto/input/qaxisinput/tst_qaxisinput.cpp
@@ -29,16 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DInput/QAxisInput>
#include <Qt3DInput/QAbstractPhysicalDevice>
+#include <Qt3DInput/private/qaxisinput_p.h>
#include "testpostmanarbiter.h"
#include "testdevice.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QAxisInput: public Qt3DCore::QNode
+class tst_QAxisInput: public QObject
{
Q_OBJECT
public:
@@ -76,20 +76,24 @@ private Q_SLOTS:
QFETCH(Qt3DInput::QAxisInput *, axisInput);
// WHEN
- Qt3DInput::QAxisInput *clone = static_cast<Qt3DInput::QAxisInput *>(QNode::clone(axisInput));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(axisInput);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1 + (axisInput->sourceDevice() ? 1 : 0));
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DInput::QAxisInputData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DInput::QAxisInputData>>(creationChanges.first());
+ const Qt3DInput::QAxisInputData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(axisInput->id(), clone->id());
- QCOMPARE(axisInput->buttons(), clone->buttons());
- QCOMPARE(axisInput->axis(), clone->axis());
- QCOMPARE(axisInput->scale(), clone->scale());
-
- if (axisInput->sourceDevice() != Q_NULLPTR) {
- QVERIFY(clone->sourceDevice() != Q_NULLPTR);
- QCOMPARE(clone->sourceDevice()->id(), axisInput->sourceDevice()->id());
- }
+ QCOMPARE(axisInput->id(), creationChangeData->subjectId());
+ QCOMPARE(axisInput->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(axisInput->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(axisInput->buttons(), cloneData.buttons);
+ QCOMPARE(axisInput->axis(), cloneData.axis);
+ QCOMPARE(axisInput->scale(), cloneData.scale);
+ QCOMPARE(axisInput->sourceDevice() ? axisInput->sourceDevice()->id() : Qt3DCore::QNodeId(), cloneData.sourceDeviceId);
}
void checkPropertyUpdates()
@@ -152,13 +156,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QAxisInput)
diff --git a/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp b/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
index 3982c3a97..dc8cf15c8 100644
--- a/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
+++ b/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
@@ -29,8 +29,10 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DInput/QLogicalDevice>
+#include <Qt3DInput/private/qlogicaldevice_p.h>
#include <Qt3DInput/QAxis>
#include <Qt3DInput/QAction>
@@ -40,9 +42,7 @@
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QLogicalDevice: public Qt3DCore::QNode
+class tst_QLogicalDevice: public QObject
{
Q_OBJECT
public:
@@ -79,26 +79,31 @@ private Q_SLOTS:
QFETCH(Qt3DInput::QLogicalDevice *, logicalDevice);
// WHEN
- Qt3DInput::QLogicalDevice *clone = static_cast<Qt3DInput::QLogicalDevice *>(QNode::clone(logicalDevice));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(logicalDevice);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
- // THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(logicalDevice->id(), clone->id());
const int axesCount = logicalDevice->axes().count();
const int actionsCount = logicalDevice->actions().count();
- QCOMPARE(axesCount, clone->axes().count());
- QCOMPARE(actionsCount, clone->actions().count());
-
- if (axesCount > 0) {
- for (int i = 0; i < axesCount; ++i)
- QCOMPARE(logicalDevice->axes().at(i)->id(), clone->axes().at(i)->id());
- }
-
- if (actionsCount > 0) {
- for (int i = 0; i < actionsCount; ++i)
- QCOMPARE(logicalDevice->actions().at(i)->id(), clone->actions().at(i)->id());
- }
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1 + axesCount + actionsCount);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DInput::QLogicalDeviceData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DInput::QLogicalDeviceData>>(creationChanges.first());
+ const Qt3DInput::QLogicalDeviceData &cloneData = creationChangeData->data;
+
+ // THEN
+ QCOMPARE(logicalDevice->id(), creationChangeData->subjectId());
+ QCOMPARE(logicalDevice->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(logicalDevice->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(axesCount, cloneData.axisIds.count());
+ QCOMPARE(actionsCount, cloneData.actionIds.count());
+
+ for (int i = 0; i < axesCount; ++i)
+ QCOMPARE(logicalDevice->axes().at(i)->id(), cloneData.axisIds.at(i));
+
+ for (int i = 0; i < actionsCount; ++i)
+ QCOMPARE(logicalDevice->actions().at(i)->id(), cloneData.actionIds.at(i));
}
void checkPropertyUpdates()
@@ -161,13 +166,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QLogicalDevice)
diff --git a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
index d8452a461..8496c6f43 100644
--- a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
+++ b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
@@ -29,12 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qabstractlight.h>
#include <Qt3DRender/private/qabstractlight_p.h>
#include <Qt3DRender/qpointlight.h>
#include <Qt3DRender/qdirectionallight.h>
#include <Qt3DRender/qspotlight.h>
+#include <Qt3DRender/private/qpointlight_p.h>
+#include <Qt3DRender/private/qdirectionallight_p.h>
+#include <Qt3DRender/private/qspotlight_p.h>
#include "testpostmanarbiter.h"
@@ -46,9 +50,6 @@ public:
explicit DummyLight(Qt3DCore::QNode *parent = Q_NULLPTR)
: QAbstractLight(*new Qt3DRender::QAbstractLightPrivate(QAbstractLight::PointLight), parent)
{}
-
-private:
- QT3D_CLONEABLE(DummyLight)
};
@@ -57,79 +58,88 @@ private:
class tst_QAbstractLight: public Qt3DCore::QNode
{
Q_OBJECT
-public:
- ~tst_QAbstractLight()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
-
- void checkLightCloning()
- {
- DummyLight light;
- light.setColor(Qt::red);
- light.setIntensity(0.5f);
-
- QScopedPointer<Qt3DRender::QAbstractLight> lightClone(static_cast<Qt3DRender::QAbstractLight *>(QNode::clone(&light)));
- QVERIFY(lightClone.data());
- QCOMPARE(light.color(), lightClone->color());
- QCOMPARE(light.intensity(), lightClone->intensity());
- }
-
- void checkPointLightCloning()
- {
- Qt3DRender::QPointLight pointLight;
- QCOMPARE(pointLight.type(), Qt3DRender::QAbstractLight::PointLight);
- pointLight.setColor(Qt::green);
- pointLight.setIntensity(0.5f);
- pointLight.setConstantAttenuation(0.5f);
- pointLight.setLinearAttenuation(0.0f); // No actual event triggered as 0.0f is default
- pointLight.setQuadraticAttenuation(1.0f);
-
- QScopedPointer<Qt3DRender::QPointLight> pointLightClone(static_cast<Qt3DRender::QPointLight *>(QNode::clone(&pointLight)));
- QVERIFY(pointLightClone.data());
- QCOMPARE(pointLightClone->type(), Qt3DRender::QAbstractLight::PointLight);
- QCOMPARE(pointLight.color(), pointLightClone->color());
- QCOMPARE(pointLight.intensity(), pointLightClone->intensity());
- QCOMPARE(pointLight.constantAttenuation(), pointLightClone->constantAttenuation());
- QCOMPARE(pointLight.linearAttenuation(), pointLightClone->linearAttenuation());
- QCOMPARE(pointLight.quadraticAttenuation(), pointLightClone->quadraticAttenuation());
- }
-
- void checkDirectionalLightCloning()
- {
- Qt3DRender::QDirectionalLight dirLight;
- QCOMPARE(dirLight.type(), Qt3DRender::QAbstractLight::DirectionalLight);
- dirLight.setColor(Qt::blue);
- dirLight.setIntensity(0.5f);
- dirLight.setWorldDirection(QVector3D(0, 0, -1));
-
- QScopedPointer<Qt3DRender::QDirectionalLight> dirLightClone(static_cast<Qt3DRender::QDirectionalLight *>(QNode::clone(&dirLight)));
- QVERIFY(dirLightClone.data());
- QCOMPARE(dirLightClone->type(), Qt3DRender::QAbstractLight::DirectionalLight);
- QCOMPARE(dirLight.color(), dirLightClone->color());
- QCOMPARE(dirLight.intensity(), dirLightClone->intensity());
- QCOMPARE(dirLight.worldDirection(), dirLightClone->worldDirection());
- }
-
- void checkSpotLightCloning()
- {
- Qt3DRender::QSpotLight spotLight;
- QCOMPARE(spotLight.type(), Qt3DRender::QAbstractLight::SpotLight);
- spotLight.setColor(Qt::lightGray);
- spotLight.setIntensity(0.5f);
- spotLight.setLocalDirection(QVector3D(0, 0, -1));
- spotLight.setCutOffAngle(0.75f);
-
- QScopedPointer<Qt3DRender::QSpotLight> spotLightClone(static_cast<Qt3DRender::QSpotLight *>(QNode::clone(&spotLight)));
- QVERIFY(spotLightClone.data());
- QCOMPARE(spotLightClone->type(), Qt3DRender::QAbstractLight::SpotLight);
- QCOMPARE(spotLight.color(), spotLightClone->color());
- QCOMPARE(spotLight.intensity(), spotLightClone->intensity());
- QCOMPARE(spotLight.localDirection(), spotLightClone->localDirection());
- QCOMPARE(spotLight.cutOffAngle(), spotLightClone->cutOffAngle());
- }
+ // TO DO: Test should be rewritten to query the properties from the attached QShaderData
+
+// void checkLightCloning()
+// {
+// // GIVEN
+// DummyLight light;
+// light.setColor(Qt::red);
+// light.setIntensity(0.5f);
+
+// // WHEN
+// Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(material);
+// QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+// // THEN
+// QVERIFY(creationChanges.size() >= 1);
+
+// const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QA> creationChangeData =
+// qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QMaterialData>>(creationChanges.first());
+// const Qt3DRender::QMaterialData &cloneData = creationChangeData->data;
+
+
+// QScopedPointer<Qt3DRender::QAbstractLight> lightClone(static_cast<Qt3DRender::QAbstractLight *>(QNode::clone(&light)));
+// QVERIFY(lightClone.data());
+// QCOMPARE(light.color(), lightClone->color());
+// QCOMPARE(light.intensity(), lightClone->intensity());
+// }
+
+// void checkPointLightCloning()
+// {
+// Qt3DRender::QPointLight pointLight;
+// QCOMPARE(pointLight.type(), Qt3DRender::QAbstractLight::PointLight);
+// pointLight.setColor(Qt::green);
+// pointLight.setIntensity(0.5f);
+// pointLight.setConstantAttenuation(0.5f);
+// pointLight.setLinearAttenuation(0.0f); // No actual event triggered as 0.0f is default
+// pointLight.setQuadraticAttenuation(1.0f);
+
+// QScopedPointer<Qt3DRender::QPointLight> pointLightClone(static_cast<Qt3DRender::QPointLight *>(QNode::clone(&pointLight)));
+// QVERIFY(pointLightClone.data());
+// QCOMPARE(pointLightClone->type(), Qt3DRender::QAbstractLight::PointLight);
+// QCOMPARE(pointLight.color(), pointLightClone->color());
+// QCOMPARE(pointLight.intensity(), pointLightClone->intensity());
+// QCOMPARE(pointLight.constantAttenuation(), pointLightClone->constantAttenuation());
+// QCOMPARE(pointLight.linearAttenuation(), pointLightClone->linearAttenuation());
+// QCOMPARE(pointLight.quadraticAttenuation(), pointLightClone->quadraticAttenuation());
+// }
+
+// void checkDirectionalLightCloning()
+// {
+// Qt3DRender::QDirectionalLight dirLight;
+// QCOMPARE(dirLight.type(), Qt3DRender::QAbstractLight::DirectionalLight);
+// dirLight.setColor(Qt::blue);
+// dirLight.setIntensity(0.5f);
+// dirLight.setWorldDirection(QVector3D(0, 0, -1));
+
+// QScopedPointer<Qt3DRender::QDirectionalLight> dirLightClone(static_cast<Qt3DRender::QDirectionalLight *>(QNode::clone(&dirLight)));
+// QVERIFY(dirLightClone.data());
+// QCOMPARE(dirLightClone->type(), Qt3DRender::QAbstractLight::DirectionalLight);
+// QCOMPARE(dirLight.color(), dirLightClone->color());
+// QCOMPARE(dirLight.intensity(), dirLightClone->intensity());
+// QCOMPARE(dirLight.worldDirection(), dirLightClone->worldDirection());
+// }
+
+// void checkSpotLightCloning()
+// {
+// Qt3DRender::QSpotLight spotLight;
+// QCOMPARE(spotLight.type(), Qt3DRender::QAbstractLight::SpotLight);
+// spotLight.setColor(Qt::lightGray);
+// spotLight.setIntensity(0.5f);
+// spotLight.setLocalDirection(QVector3D(0, 0, -1));
+// spotLight.setCutOffAngle(0.75f);
+
+// QScopedPointer<Qt3DRender::QSpotLight> spotLightClone(static_cast<Qt3DRender::QSpotLight *>(QNode::clone(&spotLight)));
+// QVERIFY(spotLightClone.data());
+// QCOMPARE(spotLightClone->type(), Qt3DRender::QAbstractLight::SpotLight);
+// QCOMPARE(spotLight.color(), spotLightClone->color());
+// QCOMPARE(spotLight.intensity(), spotLightClone->intensity());
+// QCOMPARE(spotLight.localDirection(), spotLightClone->localDirection());
+// QCOMPARE(spotLight.cutOffAngle(), spotLightClone->cutOffAngle());
+// }
void checkLightPropertyUpdates()
{
@@ -264,13 +274,6 @@ private Q_SLOTS:
spotLightArbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QAbstractLight)
diff --git a/tests/auto/render/qattribute/tst_qattribute.cpp b/tests/auto/render/qattribute/tst_qattribute.cpp
index d0a468a4d..7c05927f2 100644
--- a/tests/auto/render/qattribute/tst_qattribute.cpp
+++ b/tests/auto/render/qattribute/tst_qattribute.cpp
@@ -29,15 +29,15 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/QAttribute>
+#include <Qt3DRender/private/qattribute_p.h>
#include <Qt3DRender/QBuffer>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QAttribute: public Qt3DCore::QNode
+class tst_QAttribute: public QObject
{
Q_OBJECT
public:
@@ -46,11 +46,6 @@ public:
qRegisterMetaType<Qt3DRender::QBuffer*>("Qt3DCore::QBuffer*");
}
- ~tst_QAttribute()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
-
private Q_SLOTS:
void checkCloning_data()
@@ -93,27 +88,28 @@ private Q_SLOTS:
QFETCH(Qt3DRender::QAttribute *, attribute);
// WHEN
- Qt3DRender::QAttribute *clone = static_cast<Qt3DRender::QAttribute *>(QNode::clone(attribute));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(attribute);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
-
- QCOMPARE(attribute->id(), clone->id());
- QCOMPARE(attribute->name(), clone->name());
- QCOMPARE(attribute->count(), clone->count());
- QCOMPARE(attribute->byteStride(), clone->byteStride());
- QCOMPARE(attribute->byteOffset(), clone->byteOffset());
- QCOMPARE(attribute->divisor(), clone->divisor());
- QCOMPARE(attribute->vertexBaseType(), clone->vertexBaseType());
- QCOMPARE(attribute->vertexSize(), clone->vertexSize());
- QVERIFY(attribute->attributeType() == clone->attributeType());
-
- if (attribute->buffer() != Q_NULLPTR) {
- QVERIFY(clone->buffer() != Q_NULLPTR);
- QVERIFY(attribute->buffer()->id() == clone->buffer()->id());
- QVERIFY(attribute->buffer()->type() == clone->buffer()->type());
- }
+ QCOMPARE(creationChanges.size(), 1 + (attribute->buffer() ? 1 : 0));
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QAttributeData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QAttributeData>>(creationChanges.first());
+ const Qt3DRender::QAttributeData &cloneData = creationChangeData->data;
+
+ QCOMPARE(attribute->id(), creationChangeData->subjectId());
+ QCOMPARE(attribute->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(attribute->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(attribute->name(), cloneData.name);
+ QCOMPARE(attribute->count(), cloneData.count);
+ QCOMPARE(attribute->byteStride(), cloneData.byteStride);
+ QCOMPARE(attribute->byteOffset(), cloneData.byteOffset);
+ QCOMPARE(attribute->divisor(), cloneData.divisor);
+ QCOMPARE(attribute->vertexBaseType(), cloneData.dataType);
+ QCOMPARE(attribute->vertexSize(), cloneData.dataSize);
+ QVERIFY(attribute->attributeType() == cloneData.attributeType);
+ QCOMPARE(attribute->buffer() ? attribute->buffer()->id() : Qt3DCore::QNodeId(), cloneData.bufferId);
}
void checkPropertyUpdates()
@@ -253,13 +249,6 @@ private Q_SLOTS:
QCOMPARE(change->type(), Qt3DCore::NodeUpdated);
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QAttribute)
diff --git a/tests/auto/render/qboundingvolumedebug/tst_qboundingvolumedebug.cpp b/tests/auto/render/qboundingvolumedebug/tst_qboundingvolumedebug.cpp
index 615df7745..5a37d98a1 100644
--- a/tests/auto/render/qboundingvolumedebug/tst_qboundingvolumedebug.cpp
+++ b/tests/auto/render/qboundingvolumedebug/tst_qboundingvolumedebug.cpp
@@ -83,20 +83,21 @@ private Q_SLOTS:
QTest::newRow("recursive_bvd") << bvD;
}
- void checkCloning()
- {
- // GIVEN
- QFETCH(Qt3DRender::QBoundingVolumeDebug *, bvD);
-
- // WHEN
- Qt3DRender::QBoundingVolumeDebug *clone = static_cast<Qt3DRender::QBoundingVolumeDebug *>(QNode::clone(bvD));
- QCoreApplication::processEvents();
-
- // THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(bvD->id(), clone->id());
- QCOMPARE(bvD->recursive(), clone->recursive());
- }
+ // TODO: Avoid cloning here
+// void checkCloning()
+// {
+// // GIVEN
+// QFETCH(Qt3DRender::QBoundingVolumeDebug *, bvD);
+
+// // WHEN
+// Qt3DRender::QBoundingVolumeDebug *clone = static_cast<Qt3DRender::QBoundingVolumeDebug *>(QNode::clone(bvD));
+// QCoreApplication::processEvents();
+
+// // THEN
+// QVERIFY(clone != Q_NULLPTR);
+// QCOMPARE(bvD->id(), clone->id());
+// QCOMPARE(bvD->recursive(), clone->recursive());
+// }
void checkPropertyUpdates()
{
@@ -161,14 +162,6 @@ private Q_SLOTS:
QCOMPARE(entity->children().count(), 2);
QCOMPARE(bvD->children().count(), 0);
}
-
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QBoundingVolumeDebug)
diff --git a/tests/auto/render/qbuffer/tst_qbuffer.cpp b/tests/auto/render/qbuffer/tst_qbuffer.cpp
index fdbc568b2..bfdf82f7f 100644
--- a/tests/auto/render/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/render/qbuffer/tst_qbuffer.cpp
@@ -29,8 +29,10 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qbuffer.h>
+#include <Qt3DRender/private/qbuffer_p.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include "testpostmanarbiter.h"
@@ -61,16 +63,9 @@ private:
int m_size;
};
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QBuffer: public Qt3DCore::QNode
+class tst_QBuffer: public QObject
{
Q_OBJECT
-public:
- ~tst_QBuffer()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -101,20 +96,29 @@ private Q_SLOTS:
QFETCH(Qt3DRender::QBuffer *, buffer);
// WHEN
- Qt3DRender::QBuffer *clone = static_cast<Qt3DRender::QBuffer *>(QNode::clone(buffer));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(buffer);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
-
- QCOMPARE(buffer->id(), clone->id());
- QCOMPARE(buffer->data(), clone->data());
- QCOMPARE(buffer->usage(), clone->usage());
- QCOMPARE(buffer->type(), clone->type());
- QCOMPARE(buffer->dataGenerator(), clone->dataGenerator());
- QCOMPARE(buffer->isSyncData(), clone->isSyncData());
+ QCOMPARE(creationChanges.size(), 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QBufferData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QBufferData>>(creationChanges.first());
+ const Qt3DRender::QBufferData &cloneData = creationChangeData->data;
+
+
+ QCOMPARE(buffer->id(), creationChangeData->subjectId());
+ QCOMPARE(buffer->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(buffer->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(buffer->data(), cloneData.data);
+ QCOMPARE(buffer->usage(), cloneData.usage);
+ QCOMPARE(buffer->type(), cloneData.type);
+ QCOMPARE(buffer->dataGenerator(), cloneData.functor);
+ QCOMPARE(buffer->isSyncData(), cloneData.syncData);
if (buffer->dataGenerator()) {
- QVERIFY(clone->dataGenerator());
- QVERIFY(*clone->dataGenerator() == *buffer->dataGenerator());
+ QVERIFY(cloneData.functor);
+ QVERIFY(*cloneData.functor == *buffer->dataGenerator());
+ QCOMPARE((*cloneData.functor)(), (*buffer->dataGenerator())());
}
}
@@ -185,13 +189,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QBuffer)
diff --git a/tests/auto/render/qcameraselector/tst_qcameraselector.cpp b/tests/auto/render/qcameraselector/tst_qcameraselector.cpp
index 895cffcf5..fc69f5adf 100644
--- a/tests/auto/render/qcameraselector/tst_qcameraselector.cpp
+++ b/tests/auto/render/qcameraselector/tst_qcameraselector.cpp
@@ -29,22 +29,17 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qcameraselector.h>
+#include <Qt3DRender/private/qcameraselector_p.h>
#include <Qt3DCore/qentity.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QCameraSelector: public Qt3DCore::QNode
+class tst_QCameraSelector: public QObject
{
Q_OBJECT
-public:
- ~tst_QCameraSelector()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -69,21 +64,22 @@ private Q_SLOTS:
QFETCH(Qt3DCore::QEntity *, camera);
// WHEN
- Qt3DRender::QCameraSelector *clone = static_cast<Qt3DRender::QCameraSelector *>(QNode::clone(cameraSelector));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(cameraSelector);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
+ QCOMPARE(creationChanges.size(), 1 + (camera ? 1 : 0));
- QCOMPARE(cameraSelector->id(), clone->id());
- if (cameraSelector->camera()) {
- QVERIFY(clone->camera());
- QCOMPARE(clone->camera()->id(), camera->id());
- } else {
- QVERIFY(clone->camera() == Q_NULLPTR);
- }
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QCameraSelectorData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QCameraSelectorData>>(creationChanges.first());
+ const Qt3DRender::QCameraSelectorData &cloneData = creationChangeData->data;
+
+ QCOMPARE(cameraSelector->id(), creationChangeData->subjectId());
+ QCOMPARE(cameraSelector->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(cameraSelector->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(cameraSelector->camera() ? cameraSelector->camera()->id() : Qt3DCore::QNodeId(), cloneData.cameraId);
delete cameraSelector;
- delete clone;
}
void checkPropertyUpdates()
@@ -139,13 +135,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QCameraSelector)
diff --git a/tests/auto/render/qclearbuffers/tst_qclearbuffers.cpp b/tests/auto/render/qclearbuffers/tst_qclearbuffers.cpp
index 9442ced90..3e4de55b0 100644
--- a/tests/auto/render/qclearbuffers/tst_qclearbuffers.cpp
+++ b/tests/auto/render/qclearbuffers/tst_qclearbuffers.cpp
@@ -29,21 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qclearbuffers.h>
+#include <Qt3DRender/private/qclearbuffers_p.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QClearBuffers: public Qt3DCore::QNode
+class tst_QClearBuffers: public QObject
{
Q_OBJECT
-public:
- ~tst_QClearBuffers()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -78,15 +73,26 @@ private Q_SLOTS:
QCOMPARE(clearBuffers->buffers(), bufferType);
// WHEN
- Qt3DRender::QClearBuffers *clone = static_cast<Qt3DRender::QClearBuffers *>(QNode::clone(clearBuffers));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(clearBuffers);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QClearBuffersData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QClearBuffersData>>(creationChanges.first());
+ const Qt3DRender::QClearBuffersData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(clearBuffers->id(), clone->id());
- QCOMPARE(clearBuffers->buffers(), clone->buffers());
+ QCOMPARE(clearBuffers->id(), creationChangeData->subjectId());
+ QCOMPARE(clearBuffers->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(clearBuffers->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(clearBuffers->buffers(), cloneData.buffersType);
+ QCOMPARE(clearBuffers->clearColor(), cloneData.clearColor);
+ QCOMPARE(clearBuffers->clearDepthValue(), cloneData.clearDepthValue);
+ QCOMPARE(clearBuffers->clearStencilValue(), cloneData.clearStencilValue);
delete clearBuffers;
- delete clone;
}
void checkPropertyUpdates()
@@ -130,13 +136,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QClearBuffers)
diff --git a/tests/auto/render/qdefaultmeshes/tst_qdefaultmeshes.cpp b/tests/auto/render/qdefaultmeshes/tst_qdefaultmeshes.cpp
index cc20200ab..97d9a459f 100644
--- a/tests/auto/render/qdefaultmeshes/tst_qdefaultmeshes.cpp
+++ b/tests/auto/render/qdefaultmeshes/tst_qdefaultmeshes.cpp
@@ -34,6 +34,11 @@
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
+#include <Qt3DRender/private/qgeometryrenderer_p.h>
+#include <Qt3DRender/private/qgeometry_p.h>
+#include <Qt3DRender/private/qattribute_p.h>
+#include <Qt3DRender/private/qbuffer_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DExtras/qspheremesh.h>
#include <Qt3DExtras/qcylindermesh.h>
@@ -41,16 +46,10 @@
#include <Qt3DExtras/qcuboidmesh.h>
#include <Qt3DExtras/qplanemesh.h>
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QDefaultMeshes: public Qt3DCore::QNode
+
+class tst_QDefaultMeshes: public QObject
{
Q_OBJECT
-public:
- ~tst_QDefaultMeshes()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -70,69 +69,31 @@ private Q_SLOTS:
QFETCH(Qt3DRender::QGeometryRenderer *, geomRenderer);
// WHEN
- QScopedPointer<Qt3DRender::QGeometryRenderer> clone(static_cast<Qt3DRender::QGeometryRenderer *>(QNode::clone(geomRenderer)));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(geomRenderer);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
-
- QCOMPARE(clone->id(), geomRenderer->id());
- QCOMPARE(clone->instanceCount(), geomRenderer->instanceCount());
- QCOMPARE(clone->vertexCount(), geomRenderer->vertexCount());
- QCOMPARE(clone->indexOffset(), geomRenderer->indexOffset());
- QCOMPARE(clone->firstInstance(), geomRenderer->firstInstance());
- QCOMPARE(clone->restartIndexValue(), geomRenderer->restartIndexValue());
- QCOMPARE(clone->primitiveRestartEnabled(), geomRenderer->primitiveRestartEnabled());
- QCOMPARE(clone->primitiveType(), geomRenderer->primitiveType());
+ QVERIFY(creationChanges.size() >= 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QGeometryRendererData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QGeometryRendererData>>(creationChanges.first());
+ const Qt3DRender::QGeometryRendererData &cloneData = creationChangeData->data;
+
+ QCOMPARE(creationChangeData->subjectId(), geomRenderer->id());
+ QCOMPARE(cloneData.instanceCount, geomRenderer->instanceCount());
+ QCOMPARE(cloneData.vertexCount, geomRenderer->vertexCount());
+ QCOMPARE(cloneData.indexOffset, geomRenderer->indexOffset());
+ QCOMPARE(cloneData.firstInstance, geomRenderer->firstInstance());
+ QCOMPARE(cloneData.restartIndexValue, geomRenderer->restartIndexValue());
+ QCOMPARE(cloneData.primitiveRestart, geomRenderer->primitiveRestartEnabled());
+ QCOMPARE(cloneData.primitiveType, geomRenderer->primitiveType());
+ QCOMPARE(cloneData.geometryFactory, geomRenderer->geometryFactory());
- QCOMPARE(clone->geometryFactory(), geomRenderer->geometryFactory());
if (geomRenderer->geometryFactory()) {
- QVERIFY(clone->geometryFactory());
- QVERIFY(*clone->geometryFactory() == *geomRenderer->geometryFactory());
- }
-
- if (geomRenderer->geometry() != Q_NULLPTR) {
- QVERIFY(clone->geometry() != Q_NULLPTR);
- QCOMPARE(clone->geometry()->id(), geomRenderer->geometry()->id());
-
- const Qt3DRender::QGeometry *geometry = geomRenderer->geometry();
- const Qt3DRender::QGeometry *clonedGeometry = clone->geometry();
-
- QCOMPARE(clonedGeometry->attributes().count(), geometry->attributes().count());
-
- for (int i = 0; i < geometry->attributes().count(); ++i) {
- const Qt3DRender::QAttribute *originalAttribute = static_cast<Qt3DRender::QAttribute *>(geometry->attributes().at(i));
- const Qt3DRender::QAttribute *cloneAttribute = static_cast<Qt3DRender::QAttribute *>(clonedGeometry->attributes().at(i));
-
- QCOMPARE(originalAttribute->id(), cloneAttribute->id());
- QCOMPARE(originalAttribute->name(), cloneAttribute->name());
- QCOMPARE(originalAttribute->count(), cloneAttribute->count());
- QCOMPARE(originalAttribute->byteStride(), cloneAttribute->byteStride());
- QCOMPARE(originalAttribute->byteOffset(), cloneAttribute->byteOffset());
- QCOMPARE(originalAttribute->divisor(), cloneAttribute->divisor());
- QCOMPARE(originalAttribute->attributeType(), cloneAttribute->attributeType());
-
- const Qt3DRender::QBuffer *buffer = originalAttribute->buffer();
- const Qt3DRender::QBuffer *clonedBuffer = cloneAttribute->buffer();
- QCOMPARE(buffer->id(), clonedBuffer->id());
- QCOMPARE(buffer->data(), clonedBuffer->data());
- QCOMPARE(buffer->usage(), clonedBuffer->usage());
- QCOMPARE(buffer->type(), clonedBuffer->type());
- QCOMPARE(buffer->dataGenerator(), clonedBuffer->dataGenerator());
- QCOMPARE(buffer->isSyncData(), clonedBuffer->isSyncData());
- if (buffer->dataGenerator()) {
- QVERIFY(clonedBuffer->dataGenerator());
- QVERIFY(*clonedBuffer->dataGenerator() == *buffer->dataGenerator());
- }
- }
+ QVERIFY(cloneData.geometryFactory);
+ QVERIFY(*cloneData.geometryFactory == *geomRenderer->geometryFactory());
}
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QDefaultMeshes)
diff --git a/tests/auto/render/qframegraphnode/tst_qframegraphnode.cpp b/tests/auto/render/qframegraphnode/tst_qframegraphnode.cpp
index 9b3a35521..5b15d73c2 100644
--- a/tests/auto/render/qframegraphnode/tst_qframegraphnode.cpp
+++ b/tests/auto/render/qframegraphnode/tst_qframegraphnode.cpp
@@ -30,8 +30,10 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qframegraphnode.h>
+#include <Qt3DRender/private/qframegraphnode_p.h>
#include "testpostmanarbiter.h"
@@ -43,21 +45,11 @@ public:
: QFrameGraphNode(parent)
{
}
-
-private:
- QT3D_CLONEABLE(MyFrameGraphNode)
};
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QFrameGraphNode: public Qt3DCore::QNode
+class tst_QFrameGraphNode: public QObject
{
Q_OBJECT
-public:
- ~tst_QFrameGraphNode()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -92,15 +84,19 @@ private Q_SLOTS:
QCOMPARE(frameGraphNode->isEnabled(), enabled);
// WHEN
- Qt3DRender::QFrameGraphNode *clone = static_cast<Qt3DRender::QFrameGraphNode *>(QNode::clone(frameGraphNode));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(frameGraphNode);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(frameGraphNode->id(), clone->id());
- QCOMPARE(frameGraphNode->isEnabled(), enabled);
+ QCOMPARE(creationChanges.size(), 1);
+ const Qt3DCore::QNodeCreatedChangeBasePtr creationChangeData = creationChanges.first();
+
+ // THEN
+ QCOMPARE(frameGraphNode->id(), creationChangeData->subjectId());
+ QCOMPARE(frameGraphNode->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(frameGraphNode->metaObject(), creationChangeData->metaObject());
delete frameGraphNode;
- delete clone;
}
void checkPropertyUpdates()
@@ -185,13 +181,6 @@ private Q_SLOTS:
QVERIFY(child211->parent() == child21);
QVERIFY(child211->parentFrameGraphNode() == child2);
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QFrameGraphNode)
diff --git a/tests/auto/render/qgeometry/tst_qgeometry.cpp b/tests/auto/render/qgeometry/tst_qgeometry.cpp
index 8dcc6f9df..c284e85c4 100644
--- a/tests/auto/render/qgeometry/tst_qgeometry.cpp
+++ b/tests/auto/render/qgeometry/tst_qgeometry.cpp
@@ -29,8 +29,10 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qgeometry.h>
+#include <Qt3DRender/private/qgeometry_p.h>
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
@@ -40,9 +42,7 @@
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QGeometry: public Qt3DCore::QNode
+class tst_QGeometry: public QObject
{
Q_OBJECT
@@ -80,29 +80,28 @@ private Q_SLOTS:
QFETCH(int, attributeCount);
// WHEN
- Qt3DRender::QGeometry *clone = static_cast<Qt3DRender::QGeometry *>(QNode::clone(geometry));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(geometry);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
+ QCOMPARE(creationChanges.size(), 1 + geometry->childNodes().size());
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QGeometryData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QGeometryData>>(creationChanges.first());
+ const Qt3DRender::QGeometryData &cloneData = creationChangeData->data;
+
+ QCOMPARE(geometry->id(), creationChangeData->subjectId());
+ QCOMPARE(geometry->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(geometry->metaObject(), creationChangeData->metaObject());
- QCOMPARE(geometry->id(), clone->id());
QCOMPARE(attributeCount, geometry->attributes().count());
- QCOMPARE(attributeCount, clone->attributes().count());
+ QCOMPARE(attributeCount, cloneData.attributeIds.count());
if (geometry->boundingVolumePositionAttribute())
- QCOMPARE(geometry->boundingVolumePositionAttribute()->id(), clone->boundingVolumePositionAttribute()->id());
+ QCOMPARE(geometry->boundingVolumePositionAttribute()->id(), cloneData.boundingVolumePositionAttributeId);
for (int i = 0; i < attributeCount; ++i) {
Qt3DRender::QAttribute *originalAttribute = static_cast<Qt3DRender::QAttribute *>(geometry->attributes()[i]);
- Qt3DRender::QAttribute *cloneAttribute = static_cast<Qt3DRender::QAttribute *>(clone->attributes()[i]);
-
- QCOMPARE(originalAttribute->id(), cloneAttribute->id());
- QCOMPARE(originalAttribute->name(), cloneAttribute->name());
- QCOMPARE(originalAttribute->buffer(), cloneAttribute->buffer());
- QCOMPARE(originalAttribute->count(), cloneAttribute->count());
- QCOMPARE(originalAttribute->byteStride(), cloneAttribute->byteStride());
- QCOMPARE(originalAttribute->byteOffset(), cloneAttribute->byteOffset());
- QCOMPARE(originalAttribute->divisor(), cloneAttribute->divisor());
- QCOMPARE(originalAttribute->attributeType(), cloneAttribute->attributeType());
+ QCOMPARE(originalAttribute->id(), cloneData.attributeIds.at(i));
}
}
@@ -146,13 +145,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QGeometry)
diff --git a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
index c025619ad..626066a0d 100644
--- a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
+++ b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp
@@ -29,12 +29,14 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qgeometryrenderer.h>
#include <Qt3DRender/qgeometryfactory.h>
#include <Qt3DRender/qgeometry.h>
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
+#include <Qt3DRender/private/qgeometryrenderer_p.h>
#include <Qt3DCore/QNodePropertyChange>
#include <Qt3DCore/QNodeAddedPropertyChange>
@@ -68,9 +70,7 @@ private:
int m_size;
};
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QGeometryRenderer: public Qt3DCore::QNode
+class tst_QGeometryRenderer: public QObject
{
Q_OBJECT
@@ -116,31 +116,35 @@ private Q_SLOTS:
QFETCH(Qt3DRender::QGeometryRenderer *, geometryRenderer);
// WHEN
- Qt3DRender::QGeometryRenderer *clone = static_cast<Qt3DRender::QGeometryRenderer *>(QNode::clone(geometryRenderer));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(geometryRenderer);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
-
- QCOMPARE(clone->id(), geometryRenderer->id());
- QCOMPARE(clone->instanceCount(), geometryRenderer->instanceCount());
- QCOMPARE(clone->vertexCount(), geometryRenderer->vertexCount());
- QCOMPARE(clone->indexOffset(), geometryRenderer->indexOffset());
- QCOMPARE(clone->firstInstance(), geometryRenderer->firstInstance());
- QCOMPARE(clone->restartIndexValue(), geometryRenderer->restartIndexValue());
- QCOMPARE(clone->primitiveRestartEnabled(), geometryRenderer->primitiveRestartEnabled());
- QCOMPARE(clone->primitiveType(), geometryRenderer->primitiveType());
- QCOMPARE(clone->verticesPerPatch(), geometryRenderer->verticesPerPatch());
-
- if (geometryRenderer->geometry() != Q_NULLPTR) {
- QVERIFY(clone->geometry() != Q_NULLPTR);
- QCOMPARE(clone->geometry()->id(), geometryRenderer->geometry()->id());
- }
-
- QCOMPARE(clone->geometryFactory(), geometryRenderer->geometryFactory());
- if (geometryRenderer->geometryFactory()) {
- QVERIFY(clone->geometryFactory());
- QVERIFY(*clone->geometryFactory() == *geometryRenderer->geometryFactory());
- }
+ QCOMPARE(creationChanges.size(), 1 + (geometryRenderer->geometry() ? 1 : 0));
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QGeometryRendererData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QGeometryRendererData>>(creationChanges.first());
+ const Qt3DRender::QGeometryRendererData &cloneData = creationChangeData->data;
+
+ QCOMPARE(geometryRenderer->id(), creationChangeData->subjectId());
+ QCOMPARE(geometryRenderer->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(geometryRenderer->metaObject(), creationChangeData->metaObject());
+
+ QCOMPARE(cloneData.instanceCount, geometryRenderer->instanceCount());
+ QCOMPARE(cloneData.vertexCount, geometryRenderer->vertexCount());
+ QCOMPARE(cloneData.indexOffset, geometryRenderer->indexOffset());
+ QCOMPARE(cloneData.firstInstance, geometryRenderer->firstInstance());
+ QCOMPARE(cloneData.restartIndexValue, geometryRenderer->restartIndexValue());
+ QCOMPARE(cloneData.primitiveRestart, geometryRenderer->primitiveRestartEnabled());
+ QCOMPARE(cloneData.primitiveType, geometryRenderer->primitiveType());
+ QCOMPARE(cloneData.verticesPerPatch, geometryRenderer->verticesPerPatch());
+
+ if (geometryRenderer->geometry() != Q_NULLPTR)
+ QCOMPARE(cloneData.geometryId, geometryRenderer->geometry()->id());
+
+ QCOMPARE(cloneData.geometryFactory, geometryRenderer->geometryFactory());
+ if (geometryRenderer->geometryFactory())
+ QVERIFY(*cloneData.geometryFactory == *geometryRenderer->geometryFactory());
}
void checkPropertyUpdates()
@@ -300,13 +304,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QGeometryRenderer)
diff --git a/tests/auto/render/qlayerfilter/tst_qlayerfilter.cpp b/tests/auto/render/qlayerfilter/tst_qlayerfilter.cpp
index 175285a69..8ace74d30 100644
--- a/tests/auto/render/qlayerfilter/tst_qlayerfilter.cpp
+++ b/tests/auto/render/qlayerfilter/tst_qlayerfilter.cpp
@@ -29,21 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qlayerfilter.h>
+#include <Qt3DRender/private/qlayerfilter_p.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QLayerFilter: public Qt3DCore::QNode
+class tst_QLayerFilter: public QObject
{
Q_OBJECT
-public:
- ~tst_QLayerFilter()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -76,15 +71,24 @@ private Q_SLOTS:
QCOMPARE(layerFilter->layers(), layerNames);
// WHEN
- Qt3DRender::QLayerFilter *clone = static_cast<Qt3DRender::QLayerFilter *>(QNode::clone(layerFilter));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(layerFilter);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QLayerFilterData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QLayerFilterData>>(creationChanges.first());
+ const Qt3DRender::QLayerFilterData &cloneData = creationChangeData->data;
+
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(layerFilter->id(), clone->id());
- QCOMPARE(layerFilter->layers(), clone->layers());
+ QCOMPARE(layerFilter->id(), creationChangeData->subjectId());
+ QCOMPARE(layerFilter->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(layerFilter->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(layerFilter->layers(), cloneData.layers);
delete layerFilter;
- delete clone;
}
void checkPropertyUpdates()
@@ -145,13 +149,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QLayerFilter)
diff --git a/tests/auto/render/qmaterial/tst_qmaterial.cpp b/tests/auto/render/qmaterial/tst_qmaterial.cpp
index b831589f5..638f774e3 100644
--- a/tests/auto/render/qmaterial/tst_qmaterial.cpp
+++ b/tests/auto/render/qmaterial/tst_qmaterial.cpp
@@ -33,6 +33,7 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DRender/private/qrenderstate_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/QEffect>
#include <Qt3DRender/QMaterial>
@@ -47,6 +48,8 @@
#include <Qt3DExtras/QNormalDiffuseMapAlphaMaterial>
#include <Qt3DExtras/QNormalDiffuseSpecularMapMaterial>
+#include <Qt3DRender/private/qmaterial_p.h>
+
#include "testpostmanarbiter.h"
class TestMaterial : public Qt3DRender::QMaterial
@@ -71,14 +74,12 @@ public:
Qt3DRender::QShaderProgram *m_shaderProgram;
};
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QMaterial : public Qt3DCore::QNode
+class tst_QMaterial : public QObject
{
Q_OBJECT
public:
tst_QMaterial()
- : Qt3DCore::QNode()
+ : QObject()
{
qRegisterMetaType<Qt3DRender::QEffect*>("Qt3DRender::QEffect*");
}
@@ -216,13 +217,29 @@ private Q_SLOTS:
QFETCH(Qt3DRender::QMaterial *, material);
// WHEN
- Qt3DRender::QMaterial *clone = static_cast<Qt3DRender::QMaterial *>(QNode::clone(material));
- QCoreApplication::processEvents();
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(material);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QVERIFY(creationChanges.size() >= 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QMaterialData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QMaterialData>>(creationChanges.first());
+ const Qt3DRender::QMaterialData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(clone != Q_NULLPTR);
- compareParameters(material->parameters(), clone->parameters());
- compareEffects(material->effect(), clone->effect());
+ QCOMPARE(material->id(), creationChangeData->subjectId());
+ QCOMPARE(material->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(material->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(material->effect() ? material->effect()->id() : Qt3DCore::QNodeId(), cloneData.effectId);
+ QCOMPARE(material->parameters().size(), cloneData.parameterIds.size());
+
+ for (int i = 0, m = material->parameters().size(); i < m; ++i)
+ QCOMPARE(material->parameters().at(i)->id(), cloneData.parameterIds.at(i));
+
+ // TO DO: Add unit tests for parameter and effect that do check this
+ // compareParameters(material->parameters(), clone->parameters());
+ // compareEffects(material->effect(), clone->effect());
}
void checkEffectUpdate()
@@ -414,13 +431,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QMaterial)
diff --git a/tests/auto/render/qobjectpicker/tst_qobjectpicker.cpp b/tests/auto/render/qobjectpicker/tst_qobjectpicker.cpp
index 84e164778..c2100268f 100644
--- a/tests/auto/render/qobjectpicker/tst_qobjectpicker.cpp
+++ b/tests/auto/render/qobjectpicker/tst_qobjectpicker.cpp
@@ -83,22 +83,23 @@ private Q_SLOTS:
QTest::newRow("objectPicker_all_true") << objectPicker;
}
- void checkCloning()
- {
- // GIVEN
- QFETCH(Qt3DRender::QObjectPicker *, objectPicker);
-
- // WHEN
- Qt3DRender::QObjectPicker *clone = static_cast<Qt3DRender::QObjectPicker *>(QNode::clone(objectPicker));
- QCoreApplication::processEvents();
-
- // THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(objectPicker->id(), clone->id());
- QCOMPARE(objectPicker->isHoverEnabled(), clone->isHoverEnabled());
- QCOMPARE(objectPicker->isPressed(), clone->isPressed());
- QCOMPARE(objectPicker->containsMouse(), clone->containsMouse());
- }
+ // TODO: Avoid cloning here
+// void checkCloning()
+// {
+// // GIVEN
+// QFETCH(Qt3DRender::QObjectPicker *, objectPicker);
+
+// // WHEN
+// Qt3DRender::QObjectPicker *clone = static_cast<Qt3DRender::QObjectPicker *>(QNode::clone(objectPicker));
+// QCoreApplication::processEvents();
+
+// // THEN
+// QVERIFY(clone != Q_NULLPTR);
+// QCOMPARE(objectPicker->id(), clone->id());
+// QCOMPARE(objectPicker->isHoverEnabled(), clone->isHoverEnabled());
+// QCOMPARE(objectPicker->isPressed(), clone->isPressed());
+// QCOMPARE(objectPicker->containsMouse(), clone->containsMouse());
+// }
void checkPropertyUpdates()
{
@@ -178,14 +179,6 @@ private Q_SLOTS:
// Check that the QObjectPicker triggers the expected signal
QCOMPARE(spy.count(), 1);
}
-
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QObjectPicker)
diff --git a/tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp b/tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp
index 4e3b217dc..3d4d885d6 100644
--- a/tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp
+++ b/tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp
@@ -30,8 +30,10 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qrenderpassfilter.h>
+#include <Qt3DRender/private/qrenderpassfilter_p.h>
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qfilterkey.h>
@@ -41,16 +43,9 @@
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QRenderPassFilter: public Qt3DCore::QNode
+class tst_QRenderPassFilter: public QObject
{
Q_OBJECT
-public:
- ~tst_QRenderPassFilter()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -109,6 +104,7 @@ private Q_SLOTS:
QTest::newRow("renderPassFilterWithParamsAndAnnotations") << renderPassFilterWithParamsAndAnnotations << params2 << filterKeys2 ;
}
+ // TODO: Avoid cloning here
void checkCloning()
{
// GIVEN
@@ -121,37 +117,28 @@ private Q_SLOTS:
QCOMPARE(renderPassFilter->matchAny(), filterKeys);
// WHEN
- Qt3DRender::QRenderPassFilter *clone = static_cast<Qt3DRender::QRenderPassFilter *>(QNode::clone(renderPassFilter));
+ // WHEN
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(renderPassFilter);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+ // THEN
+ QCOMPARE(creationChanges.size(), 1 + renderPassFilter->parameters().size() + renderPassFilter->matchAny().size());
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QRenderPassFilterData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QRenderPassFilterData>>(creationChanges.first());
+ const Qt3DRender::QRenderPassFilterData &cloneData = creationChangeData->data;
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(renderPassFilter->id(), clone->id());
-
- QCOMPARE(renderPassFilter->matchAny().count(), clone->matchAny().count());
- QCOMPARE(renderPassFilter->parameters().count(), clone->parameters().count());
-
- for (int i = 0, m = parameters.count(); i < m; ++i) {
- Qt3DRender::QParameter *pClone = clone->parameters().at(i);
- Qt3DRender::QParameter *pOrig = parameters.at(i);
- QCOMPARE(pOrig->id(),pClone->id());
- QCOMPARE(pOrig->name(), pClone->name());
- QCOMPARE(pOrig->value(), pClone->value());
- QVERIFY(pClone->parent() == clone);
- QVERIFY(pOrig->parent() == renderPassFilter);
- }
-
- for (int i = 0, m = filterKeys.count(); i < m; ++i) {
- Qt3DRender::QFilterKey *aClone = clone->matchAny().at(i);
- Qt3DRender::QFilterKey *aOrig = filterKeys.at(i);
- QCOMPARE(aOrig->id(),aClone->id());
- QCOMPARE(aOrig->name(), aClone->name());
- QCOMPARE(aOrig->value(), aClone->value());
- QVERIFY(aClone->parent() == clone);
- QVERIFY(aOrig->parent() == renderPassFilter);
- }
+ QCOMPARE(renderPassFilter->id(), creationChangeData->subjectId());
+ QCOMPARE(renderPassFilter->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(renderPassFilter->metaObject(), creationChangeData->metaObject());
+
+ QCOMPARE(renderPassFilter->matchAny().count(), cloneData.matchIds.count());
+ QCOMPARE(renderPassFilter->parameters().count(), cloneData.parameterIds.count());
+
+ // TO DO: Add unit tests for QParameter / QFilterKey
delete renderPassFilter;
- delete clone;
}
void checkPropertyUpdates()
@@ -232,13 +219,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QRenderPassFilter)
diff --git a/tests/auto/render/qrenderstateset/tst_qrenderstateset.cpp b/tests/auto/render/qrenderstateset/tst_qrenderstateset.cpp
index 7cd08c1ec..2c03df736 100644
--- a/tests/auto/render/qrenderstateset/tst_qrenderstateset.cpp
+++ b/tests/auto/render/qrenderstateset/tst_qrenderstateset.cpp
@@ -30,10 +30,12 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qrenderstateset.h>
#include <Qt3DRender/private/qrenderstate_p.h>
#include <Qt3DRender/qrenderstate.h>
+#include <Qt3DRender/private/qrenderstateset_p.h>
#include <Qt3DCore/qnodepropertychange.h>
#include <Qt3DCore/qnodeaddedpropertychange.h>
@@ -60,27 +62,18 @@ public:
{}
private:
- QT3D_CLONEABLE(MyStateSet)
Q_DECLARE_PRIVATE(MyStateSet)
};
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QRenderStateSet: public Qt3DCore::QNode
+class tst_QRenderStateSet: public QObject
{
Q_OBJECT
-public:
- ~tst_QRenderStateSet()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
void checkSaneDefaults()
{
QScopedPointer<Qt3DRender::QRenderStateSet> defaultstateSet(new Qt3DRender::QRenderStateSet);
-
QVERIFY(defaultstateSet->renderStates().isEmpty());
}
@@ -111,24 +104,27 @@ private Q_SLOTS:
QCOMPARE(stateSet->renderStates(), states);
// WHEN
- Qt3DRender::QRenderStateSet *clone = static_cast<Qt3DRender::QRenderStateSet *>(QNode::clone(stateSet));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(stateSet);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(stateSet->id(), clone->id());
+ QCOMPARE(creationChanges.size(), 1 + states.size());
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QRenderStateSetData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QRenderStateSetData>>(creationChanges.first());
+ const Qt3DRender::QRenderStateSetData &cloneData = creationChangeData->data;
- QCOMPARE(stateSet->renderStates().count(), clone->renderStates().count());
+ QCOMPARE(stateSet->id(), creationChangeData->subjectId());
+ QCOMPARE(stateSet->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(stateSet->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(stateSet->renderStates().count(), cloneData.renderStateIds.count());
for (int i = 0, m = states.count(); i < m; ++i) {
- Qt3DRender::QRenderState *sClone = clone->renderStates().at(i);
Qt3DRender::QRenderState *sOrig = states.at(i);
- QCOMPARE(sOrig->id(),sClone->id());
- QVERIFY(sClone->parent() == clone);
- QVERIFY(sOrig->parent() == stateSet);
+ QCOMPARE(sOrig->id(), cloneData.renderStateIds.at(i));
}
delete stateSet;
- delete clone;
}
void checkPropertyUpdates()
@@ -173,13 +169,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QRenderStateSet)
diff --git a/tests/auto/render/qrendertargetselector/tst_qrendertargetselector.cpp b/tests/auto/render/qrendertargetselector/tst_qrendertargetselector.cpp
index bbe28f85f..4f1494c78 100644
--- a/tests/auto/render/qrendertargetselector/tst_qrendertargetselector.cpp
+++ b/tests/auto/render/qrendertargetselector/tst_qrendertargetselector.cpp
@@ -30,21 +30,16 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qrendertargetselector.h>
+#include <Qt3DRender/private/qrendertargetselector_p.h>
#include <Qt3DRender/qrendertarget.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QRenderTargetSelector: public Qt3DCore::QNode
+class tst_QRenderTargetSelector: public QObject
{
Q_OBJECT
-public:
- ~tst_QRenderTargetSelector()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -90,21 +85,23 @@ private Q_SLOTS:
QCOMPARE(renderTargetSelector->target(), target);
// WHEN
- Qt3DRender::QRenderTargetSelector *clone = static_cast<Qt3DRender::QRenderTargetSelector *>(QNode::clone(renderTargetSelector));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(renderTargetSelector);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(renderTargetSelector->id(), clone->id());
+ QCOMPARE(creationChanges.size(), 1 + (renderTargetSelector->target() ? 1 : 0));
- QCOMPARE(renderTargetSelector->outputs(), clone->outputs());
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QRenderTargetSelectorData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QRenderTargetSelectorData>>(creationChanges.first());
+ const Qt3DRender::QRenderTargetSelectorData &cloneData = creationChangeData->data;
- if (renderTargetSelector->target() != Q_NULLPTR) {
- QVERIFY(clone->target() != Q_NULLPTR);
- QCOMPARE(clone->target()->id(), renderTargetSelector->target()->id());
- }
+ // THEN
+ QCOMPARE(renderTargetSelector->id(), creationChangeData->subjectId());
+ QCOMPARE(renderTargetSelector->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(renderTargetSelector->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(renderTargetSelector->target() ? renderTargetSelector->target()->id() : Qt3DCore::QNodeId(), cloneData.targetId);
delete renderTargetSelector;
- delete clone;
}
void checkPropertyUpdates()
@@ -187,13 +184,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QRenderTargetSelector)
diff --git a/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp b/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp
index eb202132b..bac9fb3e8 100644
--- a/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp
+++ b/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp
@@ -29,21 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qsortcriterion.h>
+#include <Qt3DRender/private/qsortcriterion_p.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QSortCriterion: public Qt3DCore::QNode
+class tst_QSortCriterion: public QObject
{
Q_OBJECT
-public:
- ~tst_QSortCriterion()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -73,16 +68,26 @@ private Q_SLOTS:
// THEN
QCOMPARE(sortCriterion->sort(), sortType);
- // WHEN
- Qt3DRender::QSortCriterion *clone = static_cast<Qt3DRender::QSortCriterion *>(QNode::clone(sortCriterion));
+// TO DO: Add creation change
+// // WHEN
+// Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(sortCriterion);
+// QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
+
+// // THEN
+// QCOMPARE(creationChanges.size(), 1);
+
+// const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QCameraSelectorData> creationChangeData =
+// qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QSortCriterion>>(creationChanges.first());
+// const Qt3DRender::QCameraSelectorData &cloneData = creationChangeData->data;
- // THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(sortCriterion->id(), clone->id());
- QCOMPARE(sortCriterion->sort(), clone->sort());
+
+// // THEN
+// QCOMPARE(sortCriterion->id(), creationChangeData->subjectId());
+// QCOMPARE(sortCriterion->isEnabled(), creationChangeData->isNodeEnabled());
+// QCOMPARE(sortCriterion->metaObject(), creationChangeData->metaObject());
+// QCOMPARE(sortCriterion->sort(), cloneData.sort);
delete sortCriterion;
- delete clone;
}
void checkPropertyUpdates()
@@ -126,13 +131,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QSortCriterion)
diff --git a/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp b/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp
index 092149c49..bd419f0e1 100644
--- a/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp
+++ b/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp
@@ -30,8 +30,10 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qsortpolicy.h>
+#include <Qt3DRender/private/qsortpolicy_p.h>
#include "testpostmanarbiter.h"
@@ -82,34 +84,33 @@ private Q_SLOTS:
QCOMPARE(sortPolicy->sortTypes(), sortTypes);
// WHEN
- Qt3DRender::QSortPolicy *clone = static_cast<Qt3DRender::QSortPolicy *>(QNode::clone(sortPolicy));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(sortPolicy);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(sortPolicy->id(), clone->id());
+ QCOMPARE(creationChanges.size(), 1);
- QCOMPARE(sortPolicy->sortTypes().count(), clone->sortTypes().count());
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QSortPolicyData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QSortPolicyData>>(creationChanges.first());
+ const Qt3DRender::QSortPolicyData &cloneData = creationChangeData->data;
- for (int i = 0, m = sortTypes.count(); i < m; ++i) {
- Qt3DRender::QSortPolicy::SortType cClone = clone->sortTypes().at(i);
- Qt3DRender::QSortPolicy::SortType cOrig = sortTypes.at(i);
- QCOMPARE(cOrig,cClone);
- }
+ QCOMPARE(sortPolicy->id(), creationChangeData->subjectId());
+ QCOMPARE(sortPolicy->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(sortPolicy->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(sortPolicy->sortTypes().count(), cloneData.sortTypes.count());
+ QCOMPARE(sortPolicy->sortTypes(), cloneData.sortTypes);
delete sortPolicy;
- delete clone;
}
void checkPropertyUpdates()
{
- QSKIP("Wait for cloning mechanism to be fixed");
-
// GIVEN
QScopedPointer<Qt3DRender::QSortPolicy> sortPolicy(new Qt3DRender::QSortPolicy());
TestArbiter arbiter(sortPolicy.data());
// WHEN
- Qt3DRender::QSortPolicy::SortType sortType1;
+ Qt3DRender::QSortPolicy::SortType sortType1 = Qt3DRender::QSortPolicy::BackToFront;
sortPolicy->addSortType(sortType1);
QCoreApplication::processEvents();
@@ -144,13 +145,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QSortPolicy)
diff --git a/tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp b/tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp
index 1a3109c47..6b6e849d7 100644
--- a/tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp
+++ b/tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp
@@ -30,8 +30,10 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qtechniquefilter.h>
+#include <Qt3DRender/private/qtechniquefilter_p.h>
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qfilterkey.h>
@@ -41,16 +43,9 @@
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QTechniqueFilter: public Qt3DCore::QNode
+class tst_QTechniqueFilter: public QObject
{
Q_OBJECT
-public:
- ~tst_QTechniqueFilter()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -121,37 +116,34 @@ private Q_SLOTS:
QCOMPARE(techniqueFilter->matchAll(), filterKeys);
// WHEN
- Qt3DRender::QTechniqueFilter *clone = static_cast<Qt3DRender::QTechniqueFilter *>(QNode::clone(techniqueFilter));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(techniqueFilter);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(techniqueFilter->id(), clone->id());
+ QCOMPARE(creationChanges.size(), 1 + parameters.size() + filterKeys.size());
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QTechniqueFilterData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QTechniqueFilterData>>(creationChanges.first());
+ const Qt3DRender::QTechniqueFilterData &cloneData = creationChangeData->data;
+
+ QCOMPARE(techniqueFilter->id(), creationChangeData->subjectId());
+ QCOMPARE(techniqueFilter->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(techniqueFilter->metaObject(), creationChangeData->metaObject());
- QCOMPARE(techniqueFilter->matchAll().count(), clone->matchAll().count());
- QCOMPARE(techniqueFilter->parameters().count(), clone->parameters().count());
+ QCOMPARE(techniqueFilter->matchAll().count(), cloneData.matchIds.count());
+ QCOMPARE(techniqueFilter->parameters().count(), cloneData.parameterIds.count());
for (int i = 0, m = parameters.count(); i < m; ++i) {
- Qt3DRender::QParameter *pClone = clone->parameters().at(i);
Qt3DRender::QParameter *pOrig = parameters.at(i);
- QCOMPARE(pOrig->id(),pClone->id());
- QCOMPARE(pOrig->name(), pClone->name());
- QCOMPARE(pOrig->value(), pClone->value());
- QVERIFY(pClone->parent() == clone);
- QVERIFY(pOrig->parent() == techniqueFilter);
+ QCOMPARE(pOrig->id(), cloneData.parameterIds.at(i));
}
for (int i = 0, m = filterKeys.count(); i < m; ++i) {
- Qt3DRender::QFilterKey *aClone = clone->matchAll().at(i);
Qt3DRender::QFilterKey *aOrig = filterKeys.at(i);
- QCOMPARE(aOrig->id(),aClone->id());
- QCOMPARE(aOrig->name(), aClone->name());
- QCOMPARE(aOrig->value(), aClone->value());
- QVERIFY(aClone->parent() == clone);
- QVERIFY(aOrig->parent() == techniqueFilter);
+ QCOMPARE(aOrig->id(), cloneData.matchIds.at(i));
}
delete techniqueFilter;
- delete clone;
}
void checkPropertyUpdates()
@@ -232,13 +224,6 @@ private Q_SLOTS:
arbiter.events.clear();
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QTechniqueFilter)
diff --git a/tests/auto/render/qviewport/tst_qviewport.cpp b/tests/auto/render/qviewport/tst_qviewport.cpp
index 88b54cac6..30c3bcccc 100644
--- a/tests/auto/render/qviewport/tst_qviewport.cpp
+++ b/tests/auto/render/qviewport/tst_qviewport.cpp
@@ -29,21 +29,16 @@
#include <QtTest/QTest>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DRender/qviewport.h>
+#include <Qt3DRender/private/qviewport_p.h>
#include "testpostmanarbiter.h"
-// We need to call QNode::clone which is protected
-// So we sublcass QNode instead of QObject
-class tst_QViewport: public Qt3DCore::QNode
+class tst_QViewport: public QObject
{
Q_OBJECT
-public:
- ~tst_QViewport()
- {
- QMetaObject::invokeMethod(this, "_q_cleanup", Qt::DirectConnection);
- }
private Q_SLOTS:
@@ -71,15 +66,22 @@ private Q_SLOTS:
QCOMPARE(viewport->normalizedRect(), normalizedRect);
// WHEN
- Qt3DRender::QViewport *clone = static_cast<Qt3DRender::QViewport *>(QNode::clone(viewport));
+ Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(viewport);
+ QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges();
// THEN
- QVERIFY(clone != Q_NULLPTR);
- QCOMPARE(viewport->id(), clone->id());
- QCOMPARE(viewport->normalizedRect(), clone->normalizedRect());
+ QCOMPARE(creationChanges.size(), 1);
+
+ const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QViewportData> creationChangeData =
+ qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QViewportData>>(creationChanges.first());
+ const Qt3DRender::QViewportData &cloneData = creationChangeData->data;
+
+ QCOMPARE(viewport->id(), creationChangeData->subjectId());
+ QCOMPARE(viewport->isEnabled(), creationChangeData->isNodeEnabled());
+ QCOMPARE(viewport->metaObject(), creationChangeData->metaObject());
+ QCOMPARE(viewport->normalizedRect(), cloneData.normalizedRect);
delete viewport;
- delete clone;
}
void checkPropertyUpdates()
@@ -122,13 +124,6 @@ private Q_SLOTS:
QCOMPARE(change->type(), Qt3DCore::NodeUpdated);
}
-
-protected:
- Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE
- {
- return Q_NULLPTR;
- }
-
};
QTEST_MAIN(tst_QViewport)