summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-09-19 08:37:03 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-09-30 12:16:39 +0200
commit94bb50fba66435a078f30b1da9cf5507522ab136 (patch)
tree1c48f4e4463dd0f28fcd38efb259017987bbc8d6 /tests/auto
parent616e8083872c953a31acc871749e05c621c18bd1 (diff)
Improved/Refactored cloning and doClone off all subclasses
Note: As we are using QScene during cloning, it is important that node hierarchy be created and added in the proper order (parent then child). Change-Id: I8fd53f7ca696ec9aca19cc70dc116ccba4154911 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp21
-rw-r--r--tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp7
-rw-r--r--tests/auto/core/qscene/tst_qscene.cpp14
3 files changed, 29 insertions, 13 deletions
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index ef953465c..c05c5c83c 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -43,6 +43,7 @@
#include <Qt3DCore/qnode.h>
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qcomponent.h>
+#include <Qt3DCore/qscene.h>
class tst_Nodes : public QObject
{
@@ -84,9 +85,12 @@ public:
QString customProperty() const { return m_customProperty; }
protected:
- Qt3D::QNode *doClone(Qt3D::QNode *clonedParent) const Q_DECL_OVERRIDE
+ Qt3D::QNode *doClone(bool isClone = true) const Q_DECL_OVERRIDE
{
- return new MyQNode(clonedParent);
+ MyQNode *clone = new MyQNode();
+ clone->copy(this);
+ // clone->d_func()->m_isClone = isClone;
+ return clone;
}
QString m_customProperty;
@@ -102,9 +106,12 @@ public:
// QNode interface
protected:
- Qt3D::QNode *doClone(Qt3D::QNode *clonedParent) const Q_DECL_OVERRIDE
+ Qt3D::QNode *doClone(bool isClone = true) const Q_DECL_OVERRIDE
{
- return new MyQComponent(clonedParent);
+ MyQComponent *clone = new MyQComponent();
+ clone->copy(this);
+// clone->d_func()->m_isClone = isClone;
+ return clone;
}
};
@@ -341,8 +348,11 @@ void tst_Nodes::removingComponentsFromEntity()
void tst_Nodes::checkCloning()
{
+ Qt3D::QScene *scene = new Qt3D::QScene();
MyQNode *root = new MyQNode();
+ root->setScene(scene);
Qt3D::QEntity *entity = new Qt3D::QEntity(root);
+ root->addChild(entity);
MyQComponent *comp1 = new MyQComponent();
MyQComponent *comp2 = new MyQComponent();
@@ -350,13 +360,10 @@ void tst_Nodes::checkCloning()
MyQNode *childNode = new MyQNode();
entity->addChild(childNode);
-
-
entity->addComponent(comp1);
entity->addComponent(comp2);
entity->addComponent(comp3);
- root->addChild(entity);
root->setCustomProperty(QStringLiteral("Corvette"));
QVERIFY(root->customProperty() == QStringLiteral("Corvette"));
diff --git a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
index b35e146d5..423166865 100644
--- a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
+++ b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
@@ -139,9 +139,12 @@ public:
// QNode interface
protected:
- Qt3D::QNode *doClone(Qt3D::QNode *clonedParent) const
+ Qt3D::QNode *doClone(bool isClone = true) const
{
- return new tst_Node(clonedParent);
+ tst_Node *clone = new tst_Node();
+ clone->copy(this);
+// clone->d_func()->m_isClone = isClone;
+ return clone;
}
private:
diff --git a/tests/auto/core/qscene/tst_qscene.cpp b/tests/auto/core/qscene/tst_qscene.cpp
index f2e274298..273af3880 100644
--- a/tests/auto/core/qscene/tst_qscene.cpp
+++ b/tests/auto/core/qscene/tst_qscene.cpp
@@ -91,9 +91,12 @@ public:
tst_Node() : Qt3D::QNode()
{}
protected:
- Qt3D::QNode *doClone(Qt3D::QNode *clonedParent) const
+ Qt3D::QNode *doClone(bool isClone = true) const Q_DECL_OVERRIDE
{
- return new tst_Node();
+ tst_Node *clone = new tst_Node();
+ clone->copy(this);
+// clone->d_func()->m_isClone = isClone;
+ return clone;
}
};
@@ -103,9 +106,12 @@ public:
tst_Component() : Qt3D::QComponent()
{}
protected:
- Qt3D::QNode *doClone(Qt3D::QNode *clonedParent) const
+ Qt3D::QNode *doClone(bool isClone = true) const
{
- return new tst_Component;
+ tst_Component *clone = new tst_Component;
+ clone->copy(this);
+// clone->d_func()->m_isClone = isClone;
+ return clone;
}
};