summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-08-04 12:40:59 +0200
committerPaul Lemire <paul.lemire@kdab.com>2015-08-07 14:31:54 +0000
commit975624820bbb086f0d7957236128ddb043e792d0 (patch)
tree542c17edee5cb5238704e7aa6c083f15045a6149 /tests/auto
parent4bbe0ad81a06fb42f3aab592e5645e546bfb90db (diff)
QAbstractAttribute: Type abstracted with an enum
Also added a dataSize property to know the number of components per vertice (1 - 4) Change-Id: Iaa7cee2a53958ed2ec2f603f3ffc7971c027991d Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/render/qattribute/tst_qattribute.cpp38
-rw-r--r--tests/auto/render/qgeometry/tst_qgeometry.cpp10
-rw-r--r--tests/auto/render/renderattribute/tst_renderattribute.cpp34
3 files changed, 58 insertions, 24 deletions
diff --git a/tests/auto/render/qattribute/tst_qattribute.cpp b/tests/auto/render/qattribute/tst_qattribute.cpp
index 64305c3fe..889a9c244 100644
--- a/tests/auto/render/qattribute/tst_qattribute.cpp
+++ b/tests/auto/render/qattribute/tst_qattribute.cpp
@@ -148,19 +148,21 @@ private Q_SLOTS:
customVertex->setByteOffset(305);
customVertex->setDivisor(235);
customVertex->setName("BB");
- customVertex->setType(GL_FLOAT_VEC4);
+ customVertex->setDataType(Qt3D::QAttribute::Float);
+ customVertex->setDataSize(4);
QTest::newRow("vertex") << customVertex;
Qt3D::QAttribute *customIndex = new Qt3D::QAttribute();
Qt3D::QBuffer *indexBuffer = new Qt3D::QBuffer(Qt3D::QBuffer::IndexBuffer);
customIndex->setBuffer(indexBuffer);
customIndex->setAttributeType(Qt3D::QAbstractAttribute::IndexAttribute);
- customVertex->setCount(383);
- customVertex->setByteStride(350);
- customVertex->setByteOffset(327);
- customVertex->setDivisor(355);
- customVertex->setName("SB");
- customVertex->setType(GL_FLOAT_VEC3);
+ customIndex->setCount(383);
+ customIndex->setByteStride(350);
+ customIndex->setByteOffset(327);
+ customIndex->setDivisor(355);
+ customIndex->setName("SB");
+ customIndex->setDataType(Qt3D::QAttribute::Float);
+ customIndex->setDataSize(3);
QTest::newRow("index") << customIndex;
}
@@ -182,7 +184,8 @@ private Q_SLOTS:
QCOMPARE(attribute->byteStride(), clone->byteStride());
QCOMPARE(attribute->byteOffset(), clone->byteOffset());
QCOMPARE(attribute->divisor(), clone->divisor());
- QCOMPARE(attribute->type(), clone->type());
+ QCOMPARE(attribute->dataType(), clone->dataType());
+ QCOMPARE(attribute->dataSize(), clone->dataSize());
QVERIFY(attribute->attributeType() == clone->attributeType());
if (attribute->buffer() != Q_NULLPTR) {
@@ -199,14 +202,27 @@ private Q_SLOTS:
TestArbiter arbiter(attribute.data());
// WHEN
- attribute->setType(GL_FLOAT_VEC2);
+ attribute->setDataType(Qt3D::QAttribute::Double);
QCoreApplication::processEvents();
// THEN
QCOMPARE(arbiter.events.size(), 1);
Qt3D::QScenePropertyChangePtr change = arbiter.events.first().staticCast<Qt3D::QScenePropertyChange>();
- QCOMPARE(change->propertyName(), "type");
- QCOMPARE(change->value().value<int>(), GL_FLOAT_VEC2);
+ QCOMPARE(change->propertyName(), "dataType");
+ QCOMPARE(change->value().value<int>(), static_cast<int>(Qt3D::QAttribute::Double));
+ QCOMPARE(change->type(), Qt3D::NodeUpdated);
+
+ arbiter.events.clear();
+
+ // WHEN
+ attribute->setDataSize(4);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 1);
+ change = arbiter.events.first().staticCast<Qt3D::QScenePropertyChange>();
+ QCOMPARE(change->propertyName(), "dataSize");
+ QCOMPARE(change->value().value<uint>(), 4U);
QCOMPARE(change->type(), Qt3D::NodeUpdated);
arbiter.events.clear();
diff --git a/tests/auto/render/qgeometry/tst_qgeometry.cpp b/tests/auto/render/qgeometry/tst_qgeometry.cpp
index 187147067..3214981a8 100644
--- a/tests/auto/render/qgeometry/tst_qgeometry.cpp
+++ b/tests/auto/render/qgeometry/tst_qgeometry.cpp
@@ -142,16 +142,16 @@ private Q_SLOTS:
QTest::newRow("defaultConstructed") << defaultConstructed << 0;
Qt3D::QGeometry *geometry1 = new Qt3D::QGeometry();
- geometry1->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), GL_FLOAT_VEC3, 454));
- geometry1->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), GL_FLOAT_VEC4, 555));
+ geometry1->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), Qt3D::QAttribute::Float, 3, 454));
+ geometry1->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), Qt3D::QAttribute::Float, 4, 555));
QTest::newRow("2 attributes") << geometry1 << 2;
Qt3D::QGeometry *geometry2 = new Qt3D::QGeometry();
- Qt3D::QAttribute *attribute = new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), GL_FLOAT_VEC4, 383);
- geometry2->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), GL_FLOAT_VEC3, 427));
+ Qt3D::QAttribute *attribute = new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr2"), Qt3D::QAttribute::Float, 4, 383);
+ geometry2->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr1"), Qt3D::QAttribute::Float, 3, 427));
geometry2->addAttribute(attribute);
- geometry2->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr3"), GL_FLOAT_VEC2, 327));
+ geometry2->addAttribute(new Qt3D::QAttribute(Q_NULLPTR, QStringLiteral("Attr3"), Qt3D::QAttribute::Float, 2, 327));
geometry2->removeAttribute(attribute);
QTest::newRow("3 - 1 attributes") << geometry2 << 2;
}
diff --git a/tests/auto/render/renderattribute/tst_renderattribute.cpp b/tests/auto/render/renderattribute/tst_renderattribute.cpp
index 6589d0b61..bbf800e42 100644
--- a/tests/auto/render/renderattribute/tst_renderattribute.cpp
+++ b/tests/auto/render/renderattribute/tst_renderattribute.cpp
@@ -56,7 +56,8 @@ private Q_SLOTS:
attribute.setCount(427);
attribute.setDivisor(305);
attribute.setName(QStringLiteral("C3"));
- attribute.setType(GL_FLOAT_VEC4);
+ attribute.setDataType(Qt3D::QAbstractAttribute::UnsignedShort);
+ attribute.setDataSize(3);
Qt3D::QBuffer buffer(Qt3D::QBuffer::IndexBuffer);
buffer.setUsage(Qt3D::QBuffer::DynamicCopy);
@@ -69,7 +70,8 @@ private Q_SLOTS:
// THEN
QCOMPARE(renderAttribute.peerUuid(), attribute.id());
QCOMPARE(renderAttribute.isDirty(), true);
- QCOMPARE(renderAttribute.type(), attribute.type());
+ QCOMPARE(renderAttribute.dataType(), attribute.dataType());
+ QCOMPARE(renderAttribute.dataSize(), attribute.dataSize());
QCOMPARE(renderAttribute.attributeType(), attribute.attributeType());
QCOMPARE(renderAttribute.byteOffset(), attribute.byteOffset());
QCOMPARE(renderAttribute.byteStride(), attribute.byteStride());
@@ -89,7 +91,8 @@ private Q_SLOTS:
QVERIFY(renderAttribute.bufferId().isNull());
QVERIFY(renderAttribute.name().isEmpty());
QCOMPARE(renderAttribute.isDirty(), false);
- QCOMPARE(renderAttribute.type(), 0);
+ QCOMPARE(renderAttribute.dataType(), Qt3D::QAbstractAttribute::Float);
+ QCOMPARE(renderAttribute.dataSize(), 1U);
QCOMPARE(renderAttribute.attributeType(), Qt3D::QAttribute::VertexAttribute);
QCOMPARE(renderAttribute.byteOffset(), 0U);
QCOMPARE(renderAttribute.byteStride(), 0U);
@@ -104,7 +107,8 @@ private Q_SLOTS:
attribute.setCount(427);
attribute.setDivisor(305);
attribute.setName(QStringLiteral("C3"));
- attribute.setType(GL_FLOAT_VEC4);
+ attribute.setDataType(Qt3D::QAbstractAttribute::Double);
+ attribute.setDataSize(4);
Qt3D::QBuffer buffer(Qt3D::QBuffer::IndexBuffer);
buffer.setUsage(Qt3D::QBuffer::DynamicCopy);
buffer.setData(QByteArrayLiteral("C7"));
@@ -119,7 +123,8 @@ private Q_SLOTS:
QVERIFY(renderAttribute.bufferId().isNull());
QVERIFY(renderAttribute.name().isEmpty());
QCOMPARE(renderAttribute.isDirty(), false);
- QCOMPARE(renderAttribute.type(), 0);
+ QCOMPARE(renderAttribute.dataType(), Qt3D::QAbstractAttribute::Float);
+ QCOMPARE(renderAttribute.dataSize(), 1U);
QCOMPARE(renderAttribute.attributeType(), Qt3D::QAttribute::VertexAttribute);
QCOMPARE(renderAttribute.byteOffset(), 0U);
QCOMPARE(renderAttribute.byteStride(), 0U);
@@ -136,12 +141,25 @@ private Q_SLOTS:
// WHEN
Qt3D::QScenePropertyChangePtr updateChange(new Qt3D::QScenePropertyChange(Qt3D::NodeUpdated, Qt3D::QSceneChange::Node, Qt3D::QNodeId()));
- updateChange->setValue(GL_FLOAT_VEC2);
- updateChange->setPropertyName("type");
+ updateChange->setValue(static_cast<int>(Qt3D::QAbstractAttribute::Int));
+ updateChange->setPropertyName("dataType");
renderAttribute.sceneChangeEvent(updateChange);
// THEN
- QCOMPARE(renderAttribute.type(), GL_FLOAT_VEC2);
+ QCOMPARE(renderAttribute.dataType(), Qt3D::QAbstractAttribute::Int);
+ QVERIFY(renderAttribute.isDirty());
+
+ renderAttribute.unsetDirty();
+ QVERIFY(!renderAttribute.isDirty());
+
+ // WHEN
+ updateChange.reset(new Qt3D::QScenePropertyChange(Qt3D::NodeUpdated, Qt3D::QSceneChange::Node, Qt3D::QNodeId()));
+ updateChange->setValue(3);
+ updateChange->setPropertyName("dataSize");
+ renderAttribute.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(renderAttribute.dataSize(), 3U);
QVERIFY(renderAttribute.isDirty());
renderAttribute.unsetDirty();