summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJim Albamont <jim.albamont@kdab.com>2019-03-31 21:57:36 -0500
committerJim Albamont <jim.albamont@kdab.com>2019-04-16 14:13:11 +0000
commit993db3e119ed552843aac0d99e1c302eeb8c8582 (patch)
tree9c2c3923921092fad52f64a7e9b0a961e1c92e53 /tests
parent1fcdee0f313845f4e06b294cf520ab477191774b (diff)
Fix FrameGraph node parenting
Framegraph suffers from the same problem as Entities. When they are created they pass their parent FrameGraph node, and not their parent QNode. When reparenting them we need to make sure the same thing happens otherwise you get backend FrameGraph nodes parented to non-framegraph nodes and they are just dropped from backend. Change-Id: I1b9cab2c9e869c690c4c43208e62a1044b3359a4 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/render/framegraphnode/tst_framegraphnode.cpp52
1 files changed, 18 insertions, 34 deletions
diff --git a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
index 07ff4c0d9..22bd872dc 100644
--- a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
+++ b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
@@ -30,8 +30,7 @@
#include <QtTest/QTest>
#include <Qt3DRender/private/managers_p.h>
#include <Qt3DRender/private/nodemanagers_p.h>
-#include <Qt3DCore/qpropertynodeaddedchange.h>
-#include <Qt3DCore/qpropertynoderemovedchange.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include "testrenderer.h"
@@ -108,24 +107,9 @@ private Q_SLOTS:
// WHEN
n->setParentId(parentId);
- // THEN
- QCOMPARE(n->parentId(), parentId);
-
- // WHEN
- const Qt3DCore::QNodeId childId = Qt3DCore::QNodeId::createId();
- QScopedPointer<Qt3DRender::Render::FrameGraphNode> c(new MyFrameGraphNode());
- setIdInternal(c.data(), childId);
- manager->appendNode(childId, c.data());
- n->appendChildId(childId);
- // THEN
- QCOMPARE(n->childrenIds().count(), 1);
- // WHEN
- n->appendChildId(childId);
// THEN
- QCOMPARE(n->childrenIds().count(), 1);
-
- c.take();
+ QCOMPARE(n->parentId(), parentId);
}
void checkParentChange()
@@ -151,17 +135,8 @@ private Q_SLOTS:
QVERIFY(child->parentId().isNull());
// WHEN
- parent1->appendChildId(childId);
- // THEN
- QCOMPARE(child->parentId(), parentId);
- QCOMPARE(child->parent(), parent1);
- QCOMPARE(parent1->childrenIds().count(), 1);
- QCOMPARE(parent1->childrenIds().first(), childId);
- QCOMPARE(parent1->children().count(), parent1->childrenIds().count());
- QCOMPARE(parent1->children().first(), child);
+ child->setParentId(parentId);
- // WHEN
- parent1->appendChildId(childId);
// THEN
QCOMPARE(child->parentId(), parentId);
QCOMPARE(child->parent(), parent1);
@@ -171,7 +146,8 @@ private Q_SLOTS:
QCOMPARE(parent1->children().first(), child);
// WHEN
- parent1->removeChildId(childId);
+ child->setParentId(Qt3DCore::QNodeId());
+
// THEN
QVERIFY(child->parentId().isNull());
QVERIFY(child->parent() == nullptr);
@@ -251,6 +227,7 @@ private Q_SLOTS:
TestRenderer renderer;
backendFGNode->setRenderer(&renderer);
+ backendFGChild->setRenderer(&renderer);
setIdInternal(backendFGNode, fgNode1Id);
setIdInternal(backendFGChild, frontendFGChild->id());
@@ -269,20 +246,27 @@ private Q_SLOTS:
{
// WHEN
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), frontendFGChild);
- backendFGNode->sceneChangeEvent(change);
+ renderer.clearDirtyBits(0);
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(frontendFGChild->id());
+ change->setPropertyName("parentFrameGraphUpdated");
+ change->setValue(QVariant::fromValue(fgNode1Id));
+ backendFGChild->sceneChangeEvent(change);
// THEN
QCOMPARE(backendFGNode->childrenIds().size(), 1);
- QCOMPARE(backendFGNode->childrenIds().first(), frontendFGChild->id());
+ QCOMPARE(backendFGChild->parentId(), fgNode1Id);
}
{
// WHEN
- const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), frontendFGChild);
- backendFGNode->sceneChangeEvent(change);
+ renderer.clearDirtyBits(0);
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(frontendFGChild->id());
+ change->setPropertyName("parentFrameGraphUpdated");
+ change->setValue(QVariant::fromValue(Qt3DCore::QNodeId()));
+ backendFGChild->sceneChangeEvent(change);
// THEN
QCOMPARE(backendFGNode->childrenIds().size(), 0);
+ QVERIFY(backendFGChild->parentId().isNull());
}
}