summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/qgeometry
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-11-03 17:19:25 +0100
committerAndy Nichols <andy.nichols@theqtcompany.com>2015-11-16 09:17:27 +0000
commit67b22593aa986ae011e5e61d0eb71ea6757b014d (patch)
tree2229a2ae69a3162242f2e6e1cc5e6147e393345a /tests/auto/render/qgeometry
parent737bbd3395be9499971b089e5b0a362fd13c77ce (diff)
Update test for QGeometry with a QBoundingVolumeSpecifier
Change-Id: Iff43fe206cb262da5f1aca2700c0577ce1502995 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'tests/auto/render/qgeometry')
-rw-r--r--tests/auto/render/qgeometry/tst_qgeometry.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/auto/render/qgeometry/tst_qgeometry.cpp b/tests/auto/render/qgeometry/tst_qgeometry.cpp
index a9e09ae30..a417a82a4 100644
--- a/tests/auto/render/qgeometry/tst_qgeometry.cpp
+++ b/tests/auto/render/qgeometry/tst_qgeometry.cpp
@@ -41,6 +41,7 @@
#include <Qt3DRender/qgeometry.h>
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
+#include <Qt3DRender/qboundingvolumespecifier.h>
#include "testpostmanarbiter.h"
@@ -67,13 +68,15 @@ private Q_SLOTS:
Qt3DRender::QGeometry *geometry1 = new Qt3DRender::QGeometry();
geometry1->setVerticesPerPatch(2);
- geometry1->addAttribute(new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), Qt3DRender::QAttribute::Float, 3, 454));
+ Qt3DRender::QAttribute *attribute = new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), Qt3DRender::QAttribute::Float, 4, 454);
+ geometry1->addAttribute(attribute);
geometry1->addAttribute(new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), Qt3DRender::QAttribute::Float, 4, 555));
+ geometry1->boundingVolumeSpecifier()->setPositionAttribute(attribute);
QTest::newRow("2 attributes") << geometry1 << 2;
Qt3DRender::QGeometry *geometry2 = new Qt3DRender::QGeometry();
- Qt3DRender::QAttribute *attribute = new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), Qt3DRender::QAttribute::Float, 4, 383);
+ attribute = new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), Qt3DRender::QAttribute::Float, 4, 383);
geometry2->addAttribute(new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), Qt3DRender::QAttribute::Float, 3, 427));
geometry2->addAttribute(attribute);
geometry2->addAttribute(new Qt3DRender::QAttribute(Q_NULLPTR, QStringLiteral("Attr3"), Qt3DRender::QAttribute::Float, 2, 327));
@@ -98,6 +101,8 @@ private Q_SLOTS:
QCOMPARE(attributeCount, geometry->attributes().count());
QCOMPARE(attributeCount, clone->attributes().count());
QCOMPARE(geometry->verticesPerPatch(), clone->verticesPerPatch());
+ if (geometry->boundingVolumeSpecifier()->positionAttribute())
+ QCOMPARE(geometry->boundingVolumeSpecifier()->positionAttribute()->id(), clone->boundingVolumeSpecifier()->positionAttribute()->id());
for (int i = 0; i < attributeCount; ++i) {
Qt3DRender::QAttribute *originalAttribute = static_cast<Qt3DRender::QAttribute *>(geometry->attributes()[i]);
@@ -166,6 +171,19 @@ private Q_SLOTS:
QCOMPARE(change->type(), Qt3DCore::NodeUpdated);
arbiter.events.clear();
+
+ // WHEN
+ geometry->boundingVolumeSpecifier()->setPositionAttribute(&attr);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 1);
+ change = arbiter.events.first().staticCast<Qt3DCore::QScenePropertyChange>();
+ QCOMPARE(change->propertyName(), "boundingVolumeSpecifierPositionAttribute");
+ QCOMPARE(change->value().value<Qt3DCore::QNodeId>(), attr.id());
+ QCOMPARE(change->type(), Qt3DCore::NodeUpdated);
+
+ arbiter.events.clear();
}
protected: