summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/handlemanager/tst_handlemanager.cpp14
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp2
-rw-r--r--tests/auto/core/qframeallocator/tst_qframeallocator.cpp6
-rw-r--r--tests/auto/core/qtransform/tst_qtransform.cpp8
-rw-r--r--tests/auto/extras/common/common.pri6
-rw-r--r--tests/auto/extras/common/geometrytesthelper.h105
-rw-r--r--tests/auto/extras/extras.pro3
-rw-r--r--tests/auto/extras/qcuboidgeometry/qcuboidgeometry.pro2
-rw-r--r--tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp72
-rw-r--r--tests/auto/extras/qtorusgeometry/qtorusgeometry.pro12
-rw-r--r--tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp366
-rw-r--r--tests/auto/input/input.pro3
-rw-r--r--tests/auto/input/qabstractphysicaldevicebackendnode/qabstractphysicaldevicebackendnode.pro11
-rw-r--r--tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp246
-rw-r--r--tests/auto/input/qbuttonaxisinput/tst_qbuttonaxisinput.cpp12
-rw-r--r--tests/auto/render/framegraphnode/tst_framegraphnode.cpp125
-rw-r--r--tests/auto/render/qray3d/tst_qray3d.cpp8
-rw-r--r--tests/auto/render/raycasting/tst_raycasting.cpp2
-rw-r--r--tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp2
-rw-r--r--tests/manual/dynamicscene-cpp/examplescene.cpp2
20 files changed, 909 insertions, 98 deletions
diff --git a/tests/auto/core/handlemanager/tst_handlemanager.cpp b/tests/auto/core/handlemanager/tst_handlemanager.cpp
index 3198b54a9..f4879a3df 100644
--- a/tests/auto/core/handlemanager/tst_handlemanager.cpp
+++ b/tests/auto/core/handlemanager/tst_handlemanager.cpp
@@ -75,7 +75,7 @@ void tst_HandleManager::correctPointer()
{
// GIVEN
Qt3DCore::QHandleManager<SimpleResource> manager;
- SimpleResource *p1 = (SimpleResource *)0xdeadbeef;
+ SimpleResource *p1 = (SimpleResource *)(quintptr)0xdeadbeef;
// WHEN
const Handle h = manager.acquire(p1);
@@ -93,9 +93,9 @@ void tst_HandleManager::correctPointers()
// GIVEN
Qt3DCore::QHandleManager<SimpleResource> manager;
SimpleResource *p[3];
- p[0] = (SimpleResource *)0xdeadbeef;
- p[1] = (SimpleResource *)0x11111111;
- p[2] = (SimpleResource *)0x22222222;
+ p[0] = (SimpleResource *)(quintptr)0xdeadbeef;
+ p[1] = (SimpleResource *)(quintptr)0x11111111;
+ p[2] = (SimpleResource *)(quintptr)0x22222222;
// WHEN
for (int i = 0; i < 3; ++i) {
@@ -211,7 +211,7 @@ void tst_HandleManager::resetRemovesAllEntries()
// WHEN
for (int i = 0; i < 100; ++i) {
- SimpleResource *p = (SimpleResource *) 0xdead0000 + i;
+ SimpleResource *p = (SimpleResource *)(quintptr)(0xdead0000 + i);
const Handle h = manager.acquire(p);
bool ok = false;
@@ -240,7 +240,7 @@ void tst_HandleManager::maximumEntries()
// WHEN
for (int i = 0; i < (int)Handle::maxIndex(); ++i) {
- SimpleResource *p = (SimpleResource *) 0xdead0000 + i;
+ SimpleResource *p = (SimpleResource *)(quintptr)(0xdead0000 + i);
const Handle h = manager.acquire(p);
bool ok = false;
@@ -264,7 +264,7 @@ void tst_HandleManager::checkNoCounterOverflow()
// GIVEN
const int indexBits = 16;
Qt3DCore::QHandleManager<SimpleResource, indexBits> manager;
- SimpleResource *p = (SimpleResource *) 0xdead0000;
+ SimpleResource *p = (SimpleResource *)(quintptr)0xdead0000;
Qt3DCore::QHandle<SimpleResource, indexBits> h = manager.acquire(p);
// THEN
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 695a93640..c221c5115 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -130,7 +130,7 @@ public:
void sceneChangeEventWithLock(const Qt3DCore::QSceneChangeList &e) Q_DECL_OVERRIDE
{
- for (uint i = 0, m = e.size(); i < m; ++i) {
+ for (size_t i = 0, m = e.size(); i < m; ++i) {
events << ChangeRecord(e.at(i), false);
}
}
diff --git a/tests/auto/core/qframeallocator/tst_qframeallocator.cpp b/tests/auto/core/qframeallocator/tst_qframeallocator.cpp
index 76d4d15ce..a098792ee 100644
--- a/tests/auto/core/qframeallocator/tst_qframeallocator.cpp
+++ b/tests/auto/core/qframeallocator/tst_qframeallocator.cpp
@@ -294,8 +294,8 @@ void tst_QFrameAllocator::containsCheckQFrameChunk()
ptrs << c.allocate(16);
}
- QVERIFY(!c.contains((void *)0xffffffff, 16));
- QVERIFY(!c2.contains((void *)0xffffffff, 16));
+ QVERIFY(!c.contains((void *)(quintptr)0xffffffff, 16));
+ QVERIFY(!c2.contains((void *)(quintptr)0xffffffff, 16));
QVERIFY(c.contains(ptrs.first(), 16));
QVERIFY(!c2.contains(ptrs.first(), 16));
QVERIFY(c.contains(ptrs.last(), 16));
@@ -305,7 +305,7 @@ void tst_QFrameAllocator::containsCheckQFrameChunk()
ptrs << c2.allocate(16);
}
- QVERIFY(!c.contains((void *)0xffffffff, 16));
+ QVERIFY(!c.contains((void *)(quintptr)0xffffffff, 16));
QVERIFY(!c.contains(ptrs.last(), 16));
QVERIFY(c.contains(ptrs.first(), 16));
QVERIFY(c2.contains(ptrs.last(), 16));
diff --git a/tests/auto/core/qtransform/tst_qtransform.cpp b/tests/auto/core/qtransform/tst_qtransform.cpp
index ee63255b8..f5527ebf5 100644
--- a/tests/auto/core/qtransform/tst_qtransform.cpp
+++ b/tests/auto/core/qtransform/tst_qtransform.cpp
@@ -66,15 +66,15 @@ private Q_SLOTS:
QTest::newRow("defaultConstructed") << defaultConstructed;
Qt3DCore::QTransform *matrixPropertySet = new Qt3DCore::QTransform();
- matrixPropertySet->setMatrix(Qt3DCore::QTransform::rotateAround(QVector3D(0.1877, 0.6868, 0.3884), 45.0, QVector3D(0, 0, 1)));
+ matrixPropertySet->setMatrix(Qt3DCore::QTransform::rotateAround(QVector3D(0.1877f, 0.6868f, 0.3884f), 45.0f, QVector3D(0.0f, 0.0f, 1.0f)));
QTest::newRow("matrixPropertySet") << matrixPropertySet;
Qt3DCore::QTransform *translationSet = new Qt3DCore::QTransform();
- translationSet->setTranslation(QVector3D(0.1877, 0.6868, 0.3884));
+ translationSet->setTranslation(QVector3D(0.1877f, 0.6868f, 0.3884f));
QTest::newRow("translationSet") << translationSet;
Qt3DCore::QTransform *scaleSet = new Qt3DCore::QTransform();
- scaleSet->setScale3D(QVector3D(0.1, 0.6, 0.3));
+ scaleSet->setScale3D(QVector3D(0.1f, 0.6f, 0.3f));
QTest::newRow("scaleSet") << scaleSet;
Qt3DCore::QTransform *rotationSet = new Qt3DCore::QTransform();
@@ -326,7 +326,7 @@ private Q_SLOTS:
// GIVEN
Qt3DCore::QTransform t;
Qt3DCore::QTransform t2;
- QMatrix4x4 m = Qt3DCore::QTransform::rotateAround(QVector3D(0.1877, 0.6868, 0.3884), 45.0, QVector3D(0, 0, 1));
+ QMatrix4x4 m = Qt3DCore::QTransform::rotateAround(QVector3D(0.1877f, 0.6868f, 0.3884f), 45.0f, QVector3D(0.0f, 0.0f, 1.0f));
// WHEN
t.setMatrix(m);
diff --git a/tests/auto/extras/common/common.pri b/tests/auto/extras/common/common.pri
new file mode 100644
index 000000000..4f73c65b5
--- /dev/null
+++ b/tests/auto/extras/common/common.pri
@@ -0,0 +1,6 @@
+HEADERS += \
+ $$PWD/geometrytesthelper.h
+
+INCLUDEPATH += $$PWD
+
+QT += core-private 3drender
diff --git a/tests/auto/extras/common/geometrytesthelper.h b/tests/auto/extras/common/geometrytesthelper.h
new file mode 100644
index 000000000..48e674cd9
--- /dev/null
+++ b/tests/auto/extras/common/geometrytesthelper.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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$
+**
+****************************************************************************/
+
+#ifndef GEOMETRYTESTHELPER_H
+#define GEOMETRYTESTHELPER_H
+
+#include <Qt3DRender/qattribute.h>
+#include <Qt3DRender/qbuffer.h>
+#include <Qt3DRender/qbufferdatagenerator.h>
+#include <Qt3DRender/qgeometry.h>
+
+inline void generateGeometry(Qt3DRender::QGeometry &geometry)
+{
+ // Get all attributes
+ const QVector<Qt3DRender::QAttribute *> attributes = geometry.attributes();
+
+ // Get all unique data generators from the buffers referenced by the attributes
+ QHash<Qt3DRender::QBufferDataGeneratorPtr, Qt3DRender::QBuffer *> dataGenerators;
+ for (const auto attribute : attributes) {
+ const auto dataGenerator = attribute->buffer()->dataGenerator();
+ if (!dataGenerators.contains(dataGenerator))
+ dataGenerators.insert(dataGenerator, attribute->buffer());
+ }
+
+ // Generate data for each buffer
+ const auto end = dataGenerators.end();
+ for (auto it = dataGenerators.begin(); it != end; ++it) {
+ Qt3DRender::QBufferDataGeneratorPtr dataGenerator = it.key();
+ const QByteArray data = (*dataGenerator)();
+
+ Qt3DRender::QBuffer *buffer = it.value();
+ buffer->setData(data);
+ }
+}
+
+template<typename IndexType>
+IndexType extractIndexData(Qt3DRender::QAttribute *attribute, int index)
+{
+ // Get the raw data
+ const IndexType *typedData = reinterpret_cast<const IndexType *>(attribute->buffer()->data().constData());
+
+ // Offset into the data taking stride and offset into account
+ const IndexType indexValue = *(typedData + index);
+ return indexValue;
+}
+
+template<typename VertexType, typename IndexType>
+VertexType extractVertexData(Qt3DRender::QAttribute *attribute, IndexType index)
+{
+ // Get the raw data
+ const char *rawData = attribute->buffer()->data().constData();
+
+ // Offset into the data taking stride and offset into account
+ const char *vertexData = rawData + (index * attribute->byteStride() + attribute->byteOffset());
+
+ // Construct vertex from the typed data
+ VertexType vertex;
+ const Qt3DRender::QAttribute::VertexBaseType type = attribute->vertexBaseType();
+ switch (type)
+ {
+ case Qt3DRender::QAttribute::Float: {
+ const float *typedVertexData = reinterpret_cast<const float *>(vertexData);
+ const int components = attribute->vertexSize();
+ for (int i = 0; i < components; ++i)
+ vertex[i] = typedVertexData[i];
+ break;
+
+ // TODO: Handle other types as needed
+ }
+
+ default:
+ qWarning() << "Unhandled type";
+ Q_UNREACHABLE();
+ break;
+ }
+
+ return vertex;
+}
+
+#endif // GEOMETRYTESTHELPER_H
diff --git a/tests/auto/extras/extras.pro b/tests/auto/extras/extras.pro
index 3bba4d37b..381924d7b 100644
--- a/tests/auto/extras/extras.pro
+++ b/tests/auto/extras/extras.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = \
- qcuboidgeometry
+ qcuboidgeometry \
+ qtorusgeometry
diff --git a/tests/auto/extras/qcuboidgeometry/qcuboidgeometry.pro b/tests/auto/extras/qcuboidgeometry/qcuboidgeometry.pro
index 7208f1c7b..1e55fffad 100644
--- a/tests/auto/extras/qcuboidgeometry/qcuboidgeometry.pro
+++ b/tests/auto/extras/qcuboidgeometry/qcuboidgeometry.pro
@@ -8,3 +8,5 @@ CONFIG += testcase
SOURCES += \
tst_qcuboidgeometry.cpp
+
+include(../common/common.pri)
diff --git a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp
index fa1657732..973a1d613 100644
--- a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp
+++ b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp
@@ -40,77 +40,7 @@
#include <QtCore/qsharedpointer.h>
#include <QSignalSpy>
-namespace {
-
-void generateGeometry(Qt3DRender::QGeometry &geometry)
-{
- // Get all attributes
- const QVector<Qt3DRender::QAttribute *> attributes = geometry.attributes();
-
- // Get all unique data generators from the buffers referenced by the attributes
- QHash<Qt3DRender::QBufferDataGeneratorPtr, Qt3DRender::QBuffer *> dataGenerators;
- for (const auto attribute : attributes) {
- const auto dataGenerator = attribute->buffer()->dataGenerator();
- if (!dataGenerators.contains(dataGenerator))
- dataGenerators.insert(dataGenerator, attribute->buffer());
- }
-
- // Generate data for each buffer
- const auto end = dataGenerators.end();
- for (auto it = dataGenerators.begin(); it != end; ++it) {
- Qt3DRender::QBufferDataGeneratorPtr dataGenerator = it.key();
- const QByteArray data = (*dataGenerator)();
-
- Qt3DRender::QBuffer *buffer = it.value();
- buffer->setData(data);
- }
-}
-
-template<typename IndexType>
-IndexType extractIndexData(Qt3DRender::QAttribute *attribute, int index)
-{
- // Get the raw data
- const IndexType *typedData = reinterpret_cast<const IndexType *>(attribute->buffer()->data().constData());
-
- // Offset into the data taking stride and offset into account
- const IndexType indexValue = *(typedData + index);
- return indexValue;
-}
-
-template<typename VertexType, typename IndexType>
-VertexType extractVertexData(Qt3DRender::QAttribute *attribute, IndexType index)
-{
- // Get the raw data
- const char *rawData = attribute->buffer()->data().constData();
-
- // Offset into the data taking stride and offset into account
- const char *vertexData = rawData + (index * attribute->byteStride() + attribute->byteOffset());
-
- // Construct vertex from the typed data
- VertexType vertex;
- const Qt3DRender::QAttribute::VertexBaseType type = attribute->vertexBaseType();
- switch (type)
- {
- case Qt3DRender::QAttribute::Float: {
- const float *typedVertexData = reinterpret_cast<const float *>(vertexData);
- const int components = attribute->vertexSize();
- for (int i = 0; i < components; ++i)
- vertex[i] = typedVertexData[i];
- break;
-
- // TODO: Handle other types as needed
- }
-
- default:
- qWarning() << "Unhandled type";
- Q_UNREACHABLE();
- break;
- }
-
- return vertex;
-}
-
-}
+#include "geometrytesthelper.h"
class tst_QCuboidGeometry : public QObject
{
diff --git a/tests/auto/extras/qtorusgeometry/qtorusgeometry.pro b/tests/auto/extras/qtorusgeometry/qtorusgeometry.pro
new file mode 100644
index 000000000..e20e447dc
--- /dev/null
+++ b/tests/auto/extras/qtorusgeometry/qtorusgeometry.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+TARGET = tst_qtorusgeometry
+
+QT += 3dextras testlib
+
+CONFIG += testcase
+
+SOURCES += \
+ tst_qtorusgeometry.cpp
+
+include(../common/common.pri)
diff --git a/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp b/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp
new file mode 100644
index 000000000..28fe76ae9
--- /dev/null
+++ b/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp
@@ -0,0 +1,366 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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/QTest>
+#include <QObject>
+#include <Qt3DExtras/qtorusgeometry.h>
+#include <Qt3DRender/qattribute.h>
+#include <Qt3DRender/qbuffer.h>
+#include <Qt3DRender/qbufferdatagenerator.h>
+#include <QtGui/qopenglcontext.h>
+#include <QtGui/qvector2d.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qsharedpointer.h>
+#include <QSignalSpy>
+#include <qmath.h>
+
+#include "geometrytesthelper.h"
+
+class tst_QTorusGeometry : public QObject
+{
+ Q_OBJECT
+private Q_SLOTS:
+ void defaultConstruction()
+ {
+ // WHEN
+ Qt3DExtras::QTorusGeometry geometry;
+
+ // THEN
+ QCOMPARE(geometry.rings(), 16);
+ QCOMPARE(geometry.slices(), 16);
+ QCOMPARE(geometry.radius(), 1.0f);
+ QCOMPARE(geometry.minorRadius(), 1.0f);
+ QVERIFY(geometry.positionAttribute() != nullptr);
+ QCOMPARE(geometry.positionAttribute()->name(), Qt3DRender::QAttribute::defaultPositionAttributeName());
+ QVERIFY(geometry.normalAttribute() != nullptr);
+ QCOMPARE(geometry.normalAttribute()->name(), Qt3DRender::QAttribute::defaultNormalAttributeName());
+ QVERIFY(geometry.texCoordAttribute() != nullptr);
+ QCOMPARE(geometry.texCoordAttribute()->name(), Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName());
+ // TODO: Expose tangent attribute in Qt 5.8 and see below
+// QVERIFY(geometry.tangentAttribute() != nullptr);
+// QCOMPARE(geometry.tangentAttribute()->name(), Qt3DRender::QAttribute::defaultTangentAttributeName());
+ QVERIFY(geometry.indexAttribute() != nullptr);
+ }
+
+ void properties()
+ {
+ // GIVEN
+ Qt3DExtras::QTorusGeometry geometry;
+
+ {
+ // WHEN
+ QSignalSpy spy(&geometry, SIGNAL(ringsChanged(int)));
+ const int newValue = 20;
+ geometry.setRings(newValue);
+
+ // THEN
+ QCOMPARE(geometry.rings(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ geometry.setRings(newValue);
+
+ // THEN
+ QCOMPARE(geometry.rings(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+
+ {
+ // WHEN
+ QSignalSpy spy(&geometry, SIGNAL(slicesChanged(int)));
+ const int newValue = 2.0f;
+ geometry.setSlices(newValue);
+
+ // THEN
+ QCOMPARE(geometry.slices(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ geometry.setSlices(newValue);
+
+ // THEN
+ QCOMPARE(geometry.slices(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+
+ {
+ // WHEN
+ QSignalSpy spy(&geometry, SIGNAL(radiusChanged(float)));
+ const float newValue = 2.0f;
+ geometry.setRadius(newValue);
+
+ // THEN
+ QCOMPARE(geometry.radius(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ geometry.setRadius(newValue);
+
+ // THEN
+ QCOMPARE(geometry.radius(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+
+ {
+ // WHEN
+ QSignalSpy spy(&geometry, SIGNAL(minorRadiusChanged(float)));
+ const float newValue = 0.25f;
+ geometry.setMinorRadius(newValue);
+
+ // THEN
+ QCOMPARE(geometry.minorRadius(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ geometry.setMinorRadius(newValue);
+
+ // THEN
+ QCOMPARE(geometry.minorRadius(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+ }
+
+ void generatedGeometryShouldBeConsistent_data()
+ {
+ QTest::addColumn<int>("rings");
+ QTest::addColumn<int>("slices");
+ QTest::addColumn<float>("radius");
+ QTest::addColumn<float>("minorRadius");
+ QTest::addColumn<int>("triangleIndex");
+ QTest::addColumn<QVector<quint16>>("indices");
+ QTest::addColumn<QVector<QVector3D>>("positions");
+ QTest::addColumn<QVector<QVector3D>>("normals");
+ QTest::addColumn<QVector<QVector2D>>("texCoords");
+ QTest::addColumn<QVector<QVector4D>>("tangents");
+
+ {
+ // Torus properties
+ const int rings = 8;
+ const int slices = 8;
+ const float radius = 2.0f;
+ const float minorRadius = 0.5f;
+
+ // Angular factors for the vertices:
+ // u iterates around the major radius
+ // v iterates around the minor radius (around each ring)
+ const float du = float(2.0 * M_PI / rings);
+ const float dv = float(2.0 * M_PI / slices);
+ const float u0 = 0.0f;
+ const float u1 = du;
+ const float v0 = 0.0f;
+ const float v1 = dv;
+
+ const float cosu0 = float(qCos(u0));
+ const float sinu0 = float(qSin(u0));
+ const float cosu1 = float(qCos(u1));
+ const float sinu1 = float(qSin(u1));
+
+ const float cosv0 = float(qCos(v0 + M_PI)); // Seam is on inner edge
+ const float sinv0 = float(qSin(v0));
+ const float cosv1 = float(qCos(v1 + M_PI));
+ const float sinv1 = float(qSin(v1));
+
+ // The triangle and indices
+ const int triangleIndex = 0;
+ const auto indices = (QVector<quint16>() << 0 << 1 << 9);
+
+ // Calculate attributes for vertices A, B, and C of the triangle
+ const float rA = radius + minorRadius * cosv0;
+ const float rB = radius + minorRadius * cosv1;
+ const float rC = radius + minorRadius * cosv0;
+
+ const auto posA = QVector3D(rA * cosu0, rA * sinu0, minorRadius * sinv0);
+ const auto posB = QVector3D(rB * cosu0, rB * sinu0, minorRadius * sinv1);
+ const auto posC = QVector3D(rC * cosu1, rC * sinu1, minorRadius * sinv0);
+ const auto positions = (QVector<QVector3D>() << posA << posB << posC);
+
+ const auto nA = QVector3D(cosv0 * cosu0, cosv0 * sinu0, sinv0).normalized();
+ const auto nB = QVector3D(cosv1 * cosu0, cosv1 * sinu0, sinv1).normalized();
+ const auto nC = QVector3D(cosv0 * cosu1, cosv0 * sinu1, sinv0).normalized();
+ const auto normals = (QVector<QVector3D>() << nA << nB << nC);
+
+ const auto tcA = QVector2D(u0, v0) / float(2.0 * M_PI);
+ const auto tcB = QVector2D(u0, v1) / float(2.0 * M_PI);
+ const auto tcC = QVector2D(u1, v0) / float(2.0 * M_PI);
+ const auto texCoords = (QVector<QVector2D>() << tcA << tcB << tcC);
+
+ const auto tA = QVector4D(-sinu0, cosu0, 0.0f, 1.0f);
+ const auto tB = QVector4D(-sinu0, cosu0, 0.0f, 1.0f);
+ const auto tC = QVector4D(-sinu1, cosu1, 0.0f, 1.0f);
+ const auto tangents = (QVector<QVector4D>() << tA << tB << tC);
+
+ // Add the row
+ QTest::newRow("8rings_8slices_firstTriangle")
+ << rings << slices << radius << minorRadius
+ << triangleIndex
+ << indices << positions << normals << texCoords << tangents;
+ }
+
+ {
+ // Note: The vertices used in this test case are different than the
+ // ones above. So, we cannot abstract this into a function easily.
+ // Here we use the 2nd triangle in a rectangular face, the test above
+ // uses the first triangle in the rectangular face.
+
+ // Torus properties
+ const int rings = 8;
+ const int slices = 8;
+ const float radius = 2.0f;
+ const float minorRadius = 0.5f;
+
+ // Angular factors for the vertices:
+ // u iterates around the major radius
+ // v iterates around the minor radius (around each ring)
+ const float du = float(2.0 * M_PI / rings);
+ const float dv = float(2.0 * M_PI / slices);
+ const float u0 = 7.0f * du;
+ const float u1 = float(2.0 * M_PI);
+ const float v0 = 7.0f * dv;
+ const float v1 = float(2.0 * M_PI);
+
+ const float cosu0 = float(qCos(u0));
+ const float sinu0 = float(qSin(u0));
+ const float cosu1 = float(qCos(u1));
+ const float sinu1 = float(qSin(u1));
+
+ const float cosv0 = float(qCos(v0 + M_PI)); // Seam is on inner edge
+ const float sinv0 = float(qSin(v0));
+ const float cosv1 = float(qCos(v1 + M_PI));
+ const float sinv1 = float(qSin(v1));
+
+ // The triangle and indices
+ const int triangleIndex = 127;
+ const auto indices = (QVector<quint16>() << 71 << 80 << 79);
+
+ // Calculate attributes for vertices A, B, and C of the triangle
+ const float rA = radius + minorRadius * cosv1;
+ const float rB = radius + minorRadius * cosv1;
+ const float rC = radius + minorRadius * cosv0;
+
+ const auto posA = QVector3D(rA * cosu0, rA * sinu0, minorRadius * sinv1);
+ const auto posB = QVector3D(rB * cosu1, rB * sinu1, minorRadius * sinv1);
+ const auto posC = QVector3D(rC * cosu1, rC * sinu1, minorRadius * sinv0);
+ const auto positions = (QVector<QVector3D>() << posA << posB << posC);
+
+ const auto nA = QVector3D(cosv1 * cosu0, cosv1 * sinu0, sinv1).normalized();
+ const auto nB = QVector3D(cosv1 * cosu1, cosv1 * sinu1, sinv1).normalized();
+ const auto nC = QVector3D(cosv0 * cosu1, cosv0 * sinu1, sinv0).normalized();
+ const auto normals = (QVector<QVector3D>() << nA << nB << nC);
+
+ const auto tcA = QVector2D(u0, v1) / float(2.0 * M_PI);
+ const auto tcB = QVector2D(u1, v1) / float(2.0 * M_PI);
+ const auto tcC = QVector2D(u1, v0) / float(2.0 * M_PI);
+ const auto texCoords = (QVector<QVector2D>() << tcA << tcB << tcC);
+
+ const auto tA = QVector4D(-sinu0, cosu1, 0.0f, 1.0f);
+ const auto tB = QVector4D(-sinu1, cosu1, 0.0f, 1.0f);
+ const auto tC = QVector4D(-sinu1, cosu1, 0.0f, 1.0f);
+ const auto tangents = (QVector<QVector4D>() << tA << tB << tC);
+
+ // Add the row
+ QTest::newRow("8rings_8slices_lastTriangle")
+ << rings << slices << radius << minorRadius
+ << triangleIndex
+ << indices << positions << normals << texCoords << tangents;
+ }
+ }
+
+ void generatedGeometryShouldBeConsistent()
+ {
+ // GIVEN
+ Qt3DExtras::QTorusGeometry geometry;
+ const QVector<Qt3DRender::QAttribute *> attributes = geometry.attributes();
+ Qt3DRender::QAttribute *positionAttribute = geometry.positionAttribute();
+ Qt3DRender::QAttribute *normalAttribute = geometry.normalAttribute();
+ Qt3DRender::QAttribute *texCoordAttribute = geometry.texCoordAttribute();
+// Qt3DRender::QAttribute *tangentAttribute = geometry.tangentAttribute();
+ Qt3DRender::QAttribute *indexAttribute = geometry.indexAttribute();
+
+ // WHEN
+ QFETCH(int, rings);
+ QFETCH(int, slices);
+ QFETCH(float, radius);
+ QFETCH(float, minorRadius);
+ geometry.setRings(rings);
+ geometry.setSlices(slices);
+ geometry.setRadius(radius);
+ geometry.setMinorRadius(minorRadius);
+
+ generateGeometry(geometry);
+
+ // THEN
+
+ // Check buffer of each attribute is valid and actually has some data
+ for (const auto &attribute : attributes) {
+ Qt3DRender::QBuffer *buffer = attribute->buffer();
+ QVERIFY(buffer != nullptr);
+ QVERIFY(buffer->data().size() != 0);
+ }
+
+ // Check some data in the buffers
+
+ // Check specific indices and vertex attributes of triangle under test
+ QFETCH(int, triangleIndex);
+ QFETCH(QVector<quint16>, indices);
+ QFETCH(QVector<QVector3D>, positions);
+ QFETCH(QVector<QVector3D>, normals);
+ QFETCH(QVector<QVector2D>, texCoords);
+// QFETCH(QVector<QVector4D>, tangents);
+
+ int i = 0;
+ for (auto index : indices) {
+ const auto testIndex = extractIndexData<quint16>(indexAttribute, 3 * triangleIndex + i);
+ QCOMPARE(testIndex, indices.at(i));
+
+ const auto position = extractVertexData<QVector3D, quint32>(positionAttribute, index);
+ QVERIFY(qFuzzyCompare(position, positions.at(i)));
+
+ const auto normal = extractVertexData<QVector3D, quint32>(normalAttribute, index);
+ QVERIFY(qFuzzyCompare(normal, normals.at(i)));
+
+ const auto texCoord = extractVertexData<QVector2D, quint32>(texCoordAttribute, index);
+ QVERIFY(qFuzzyCompare(texCoord, texCoords.at(i)));
+
+// const auto tangent = extractVertexData<QVector4D, quint32>(tangentAttribute, index);
+// QVERIFY(qFuzzyCompare(tangent, tangents.at(i)));
+
+ ++i;
+ }
+ }
+};
+
+
+QTEST_APPLESS_MAIN(tst_QTorusGeometry)
+
+#include "tst_qtorusgeometry.moc"
diff --git a/tests/auto/input/input.pro b/tests/auto/input/input.pro
index 05668c036..cf0af12cb 100644
--- a/tests/auto/input/input.pro
+++ b/tests/auto/input/input.pro
@@ -19,5 +19,6 @@ qtConfig(private_tests) {
keyboardhandler \
qaxisaccumulator \
inputsequence \
- inputchord
+ inputchord \
+ qabstractphysicaldevicebackendnode
}
diff --git a/tests/auto/input/qabstractphysicaldevicebackendnode/qabstractphysicaldevicebackendnode.pro b/tests/auto/input/qabstractphysicaldevicebackendnode/qabstractphysicaldevicebackendnode.pro
new file mode 100644
index 000000000..dc1734c41
--- /dev/null
+++ b/tests/auto/input/qabstractphysicaldevicebackendnode/qabstractphysicaldevicebackendnode.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+
+TARGET = tst_qabstractphysicaldevicebackendnode
+
+QT += 3dcore 3dcore-private 3dinput 3dinput-private testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qabstractphysicaldevicebackendnode.cpp
+
+include(../commons/commons.pri)
diff --git a/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
new file mode 100644
index 000000000..0cf37fe95
--- /dev/null
+++ b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
+** 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/QTest>
+#include <Qt3DInput/private/qabstractphysicaldevicebackendnode_p.h>
+#include <Qt3DInput/private/qabstractphysicaldevicebackendnode_p_p.h>
+#include <Qt3DInput/private/inputhandler_p.h>
+#include <Qt3DInput/qaxissetting.h>
+#include <Qt3DInput/qinputaspect.h>
+#include <Qt3DInput/private/qinputaspect_p.h>
+#include <Qt3DInput/private/inputmanagers_p.h>
+#include <Qt3DInput/private/axissetting_p.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/qpropertynodeaddedchange.h>
+#include <Qt3DCore/qpropertynoderemovedchange.h>
+#include "testdevice.h"
+
+class TestPhysicalDeviceBackendNode : public Qt3DInput::QAbstractPhysicalDeviceBackendNode
+{
+public:
+ TestPhysicalDeviceBackendNode(Qt3DCore::QBackendNode::Mode mode = Qt3DCore::QBackendNode::ReadOnly)
+ : Qt3DInput::QAbstractPhysicalDeviceBackendNode(mode)
+ {}
+
+ float axisValue(int axisIdentifier) const Q_DECL_OVERRIDE
+ {
+ if (axisIdentifier == 883)
+ return 883.0f;
+ return 0.0f;
+ }
+
+ bool isButtonPressed(int buttonIdentifier) const Q_DECL_OVERRIDE
+ {
+ if (buttonIdentifier == 454)
+ return true;
+ return false;
+ }
+
+};
+
+class tst_QAbstractPhysicalDeviceBackendNode : public Qt3DCore::QBackendNodeTester
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkInitialState()
+ {
+ // GIVEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), false);
+ QVERIFY(backendQAbstractPhysicalDeviceBackendNode.inputAspect() == nullptr);
+ QVERIFY(backendQAbstractPhysicalDeviceBackendNode.peerId().isNull());
+ }
+
+ void checkAxisValue()
+ {
+ // GIVEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+
+ // WHEN
+ float axisValue = backendQAbstractPhysicalDeviceBackendNode.axisValue(883);
+ // THEN
+ QCOMPARE(axisValue, 883.0f);
+
+ // WHEN
+ axisValue = backendQAbstractPhysicalDeviceBackendNode.axisValue(454);
+ // THEN
+ QCOMPARE(axisValue, 0.0f);
+ }
+
+ void checkButtonPressed()
+ {
+ // GIVEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+
+ // WHEN
+ bool buttonPressed = backendQAbstractPhysicalDeviceBackendNode.isButtonPressed(883);
+ // THEN
+ QCOMPARE(buttonPressed, false);
+
+ // WHEN
+ buttonPressed = backendQAbstractPhysicalDeviceBackendNode.isButtonPressed(454);
+ // THEN
+ QCOMPARE(buttonPressed, true);
+ }
+
+ void checkCleanupState()
+ {
+ // GIVEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+ Qt3DInput::QInputAspect aspect;
+
+ // WHEN
+ backendQAbstractPhysicalDeviceBackendNode.setEnabled(true);
+ backendQAbstractPhysicalDeviceBackendNode.setInputAspect(&aspect);
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.inputAspect(), &aspect);
+
+ // WHEN
+ backendQAbstractPhysicalDeviceBackendNode.cleanup();
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), false);
+ QVERIFY(backendQAbstractPhysicalDeviceBackendNode.inputAspect() == nullptr);
+ }
+
+ void checkInitializeFromPeer()
+ {
+ // GIVEN
+ TestDevice physicalDeviceNode;
+
+ {
+ // WHEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+ simulateInitialization(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), true);
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.peerId(), physicalDeviceNode.id());
+ }
+ {
+ // WHEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+ physicalDeviceNode.setEnabled(false);
+ simulateInitialization(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.peerId(), physicalDeviceNode.id());
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), false);
+ }
+ }
+
+ void checkSceneChangeEvents()
+ {
+ // GIVEN
+ TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
+ Qt3DInput::QInputAspect aspect;
+ backendQAbstractPhysicalDeviceBackendNode.setInputAspect(&aspect);
+
+ {
+ // WHEN
+ const bool newValue = false;
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
+ change->setPropertyName("enabled");
+ change->setValue(newValue);
+ backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), newValue);
+ }
+
+ {
+ Qt3DInput::QAxisSetting settings1;
+ Qt3DInput::QAxisSetting settings2;
+
+ settings1.setAxes(QVector<int>() << 883);
+ settings2.setAxes(QVector<int>() << 454);
+ Qt3DInput::QAbstractPhysicalDeviceBackendNodePrivate *priv = static_cast<Qt3DInput::QAbstractPhysicalDeviceBackendNodePrivate *>(
+ Qt3DCore::QBackendNodePrivate::get(&backendQAbstractPhysicalDeviceBackendNode));
+
+ // Create backend resource
+ {
+ Qt3DInput::QInputAspectPrivate *aspectPrivate = static_cast<Qt3DInput::QInputAspectPrivate *>(Qt3DCore::QAbstractAspectPrivate::get(&aspect));
+ Qt3DInput::Input::InputHandler *handler = aspectPrivate->m_inputHandler.data();
+ Qt3DInput::Input::AxisSetting *backendSetting1 = handler->axisSettingManager()->getOrCreateResource(settings1.id());
+ Qt3DInput::Input::AxisSetting *backendSetting2 = handler->axisSettingManager()->getOrCreateResource(settings2.id());
+ simulateInitialization(&settings1, backendSetting1);
+ simulateInitialization(&settings2, backendSetting2);
+ }
+
+ // Adding AxisSettings
+ {
+ // WHEN
+ auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &settings1);
+ change->setPropertyName("axisSettings");
+ backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(priv->m_axisSettings.size(), 1);
+
+ // WHEN
+ change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &settings2);
+ change->setPropertyName("axisSettings");
+ backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(priv->m_axisSettings.size(), 2);
+ }
+ // Removing AxisSettings
+ {
+ // WHEN
+ auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &settings1);
+ change->setPropertyName("axisSettings");
+ backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(priv->m_axisSettings.size(), 1);
+
+ // WHEN
+ change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &settings2);
+ change->setPropertyName("axisSettings");
+ backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(priv->m_axisSettings.size(), 0);
+ }
+
+ }
+ }
+
+};
+
+QTEST_MAIN(tst_QAbstractPhysicalDeviceBackendNode)
+
+#include "tst_qabstractphysicaldevicebackendnode.moc"
diff --git a/tests/auto/input/qbuttonaxisinput/tst_qbuttonaxisinput.cpp b/tests/auto/input/qbuttonaxisinput/tst_qbuttonaxisinput.cpp
index 1a0459958..618c75d42 100644
--- a/tests/auto/input/qbuttonaxisinput/tst_qbuttonaxisinput.cpp
+++ b/tests/auto/input/qbuttonaxisinput/tst_qbuttonaxisinput.cpp
@@ -49,6 +49,18 @@ public:
}
private Q_SLOTS:
+ void shouldHaveDefaultState()
+ {
+ // GIVEN
+ Qt3DInput::QButtonAxisInput axisInput;
+
+ // THEN
+ QVERIFY(axisInput.buttons().isEmpty());
+ QCOMPARE(axisInput.scale(), 1.0f);
+ QCOMPARE(axisInput.acceleration(), -1.0f);
+ QCOMPARE(axisInput.deceleration(), -1.0f);
+ }
+
void checkCloning_data()
{
QTest::addColumn<Qt3DInput::QButtonAxisInput *>("axisInput");
diff --git a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
index f3f3dbff1..07ff4c0d9 100644
--- a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
+++ b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp
@@ -29,6 +29,11 @@
#include <Qt3DRender/private/framegraphnode_p.h>
#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/private/qnodecreatedchangegenerator_p.h>
+#include "testrenderer.h"
class MyFrameGraphNode : public Qt3DRender::Render::FrameGraphNode
{
@@ -37,9 +42,15 @@ public:
{
FrameGraphNode::setEnabled(enabled);
}
+};
-protected:
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) Q_DECL_FINAL {}
+class MyQFrameGraphNode : public Qt3DRender::QFrameGraphNode
+{
+ Q_OBJECT
+public:
+ MyQFrameGraphNode(Qt3DCore::QNode *parent = nullptr)
+ : Qt3DRender::QFrameGraphNode(parent)
+ {}
};
class tst_FrameGraphNode : public QObject
@@ -167,8 +178,116 @@ private Q_SLOTS:
QCOMPARE(parent1->childrenIds().count(), 0);
QCOMPARE(parent1->children().count(), parent1->childrenIds().count());
}
+
+ void checkSetParent()
+ {
+ // GIVEN
+ QScopedPointer<Qt3DRender::Render::FrameGraphManager> manager(new Qt3DRender::Render::FrameGraphManager());
+ const Qt3DCore::QNodeId parent1Id = Qt3DCore::QNodeId::createId();
+ const Qt3DCore::QNodeId parent2Id = Qt3DCore::QNodeId::createId();
+ const Qt3DCore::QNodeId childId = Qt3DCore::QNodeId::createId();
+
+ Qt3DRender::Render::FrameGraphNode *parent1 = new MyFrameGraphNode();
+ Qt3DRender::Render::FrameGraphNode *parent2 = new MyFrameGraphNode();
+ Qt3DRender::Render::FrameGraphNode *child = new MyFrameGraphNode();
+
+ setIdInternal(parent1, parent1Id);
+ setIdInternal(parent2, parent2Id);
+ setIdInternal(child, childId);
+
+ manager->appendNode(parent1Id, parent1);
+ manager->appendNode(parent2Id, parent2);
+ manager->appendNode(childId, child);
+
+ parent1->setFrameGraphManager(manager.data());
+ parent2->setFrameGraphManager(manager.data());
+ child->setFrameGraphManager(manager.data());
+
+ // THEN
+ QCOMPARE(parent1->peerId(), parent1Id);
+ QCOMPARE(parent2->peerId(), parent2Id);
+ QCOMPARE(child->peerId(), childId);
+
+ QVERIFY(child->parentId().isNull());
+ QCOMPARE(parent1->childrenIds().size(), 0);
+ QCOMPARE(parent2->childrenIds().size(), 0);
+
+ // WHEN
+ child->setParentId(parent1Id);
+
+ // THEN
+ QCOMPARE(child->parentId(), parent1Id);
+ QCOMPARE(parent1->childrenIds().size(), 1);
+ QCOMPARE(parent2->childrenIds().size(), 0);
+
+ // WHEN
+ child->setParentId(parent2Id);
+
+ // THEN
+ QCOMPARE(child->parentId(), parent2Id);
+ QCOMPARE(parent1->childrenIds().size(), 0);
+ QCOMPARE(parent2->childrenIds().size(), 1);
+
+ // WHEN
+ child->setParentId(Qt3DCore::QNodeId());
+
+ // THEN
+ QVERIFY(child->parentId().isNull());
+ QCOMPARE(parent1->childrenIds().size(), 0);
+ QCOMPARE(parent2->childrenIds().size(), 0);
+ }
+
+ void checkSceneChangeEvents()
+ {
+ // GIVEN
+ const Qt3DCore::QNodeId fgNode1Id = Qt3DCore::QNodeId::createId();
+
+ Qt3DRender::Render::FrameGraphNode *backendFGNode = new MyFrameGraphNode();
+ Qt3DRender::QFrameGraphNode *frontendFGChild = new MyQFrameGraphNode();
+ Qt3DRender::Render::FrameGraphNode *backendFGChild = new MyFrameGraphNode();
+
+ QScopedPointer<Qt3DRender::Render::FrameGraphManager> manager(new Qt3DRender::Render::FrameGraphManager());
+
+ TestRenderer renderer;
+
+ backendFGNode->setRenderer(&renderer);
+
+ setIdInternal(backendFGNode, fgNode1Id);
+ setIdInternal(backendFGChild, frontendFGChild->id());
+
+ manager->appendNode(fgNode1Id, backendFGNode);
+ manager->appendNode(frontendFGChild->id(), backendFGChild);
+
+ backendFGNode->setFrameGraphManager(manager.data());
+ backendFGChild->setFrameGraphManager(manager.data());
+
+
+ // To geneate the type_info in the QNodePrivate of frontendFGChild
+ Qt3DCore::QNodeCreatedChangeGenerator generator(frontendFGChild);
+
+ QCOMPARE(backendFGNode->childrenIds().size(), 0);
+
+ {
+ // WHEN
+ const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), frontendFGChild);
+ backendFGNode->sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendFGNode->childrenIds().size(), 1);
+ QCOMPARE(backendFGNode->childrenIds().first(), frontendFGChild->id());
+ }
+ {
+ // WHEN
+ const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), frontendFGChild);
+ backendFGNode->sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendFGNode->childrenIds().size(), 0);
+ }
+ }
+
};
-QTEST_APPLESS_MAIN(tst_FrameGraphNode)
+QTEST_MAIN(tst_FrameGraphNode)
#include "tst_framegraphnode.moc"
diff --git a/tests/auto/render/qray3d/tst_qray3d.cpp b/tests/auto/render/qray3d/tst_qray3d.cpp
index 6297f1c73..d01156832 100644
--- a/tests/auto/render/qray3d/tst_qray3d.cpp
+++ b/tests/auto/render/qray3d/tst_qray3d.cpp
@@ -238,10 +238,10 @@ void tst_QRay3D::point()
QFETCH(QVector3D, point_on_line_pos_0_6);
QFETCH(QVector3D, point_on_line_neg_7_2);
Qt3DRender::QRay3D line(point, direction);
- QVERIFY(fuzzyCompare(line.point(0.6), point_on_line_pos_0_6));
- QVERIFY(fuzzyCompare(line.point(-7.2), point_on_line_neg_7_2));
- QVERIFY(fuzzyCompare(line.projectedDistance(point_on_line_pos_0_6), 0.6));
- QVERIFY(fuzzyCompare(line.projectedDistance(point_on_line_neg_7_2), -7.2));
+ QVERIFY(fuzzyCompare(line.point(0.6f), point_on_line_pos_0_6));
+ QVERIFY(fuzzyCompare(line.point(-7.2f), point_on_line_neg_7_2));
+ QVERIFY(fuzzyCompare(line.projectedDistance(point_on_line_pos_0_6), 0.6f));
+ QVERIFY(fuzzyCompare(line.projectedDistance(point_on_line_neg_7_2), -7.2f));
}
void tst_QRay3D::contains_point_data()
diff --git a/tests/auto/render/raycasting/tst_raycasting.cpp b/tests/auto/render/raycasting/tst_raycasting.cpp
index 04274f67a..49341a4c5 100644
--- a/tests/auto/render/raycasting/tst_raycasting.cpp
+++ b/tests/auto/render/raycasting/tst_raycasting.cpp
@@ -313,7 +313,7 @@ void tst_RayCasting::mousePicking()
Qt3DRender::QCamera camera;
camera.setProjectionType(QCameraLens::PerspectiveProjection);
camera.setFieldOfView(45.0f);
- camera.setAspectRatio(800.0/600.0f);
+ camera.setAspectRatio(800.0f/600.0f);
camera.setNearPlane(0.1f);
camera.setFarPlane(1000.0f);
camera.setPosition(QVector3D(0.0f, 0.0f, -40.0f));
diff --git a/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp b/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp
index ea9ccc2f5..9ffc26973 100644
--- a/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp
+++ b/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp
@@ -104,7 +104,7 @@ private Q_SLOTS:
Qt3DRender::QCamera camera;
camera.setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection);
camera.setFieldOfView(45.0f);
- camera.setAspectRatio(800.0/600.0f);
+ camera.setAspectRatio(800.0f/600.0f);
camera.setNearPlane(0.1f);
camera.setFarPlane(1000.0f);
camera.setPosition(QVector3D(0.0f, 0.0f, 40.0f));
diff --git a/tests/manual/dynamicscene-cpp/examplescene.cpp b/tests/manual/dynamicscene-cpp/examplescene.cpp
index b11e2f54a..0ec2294a7 100644
--- a/tests/manual/dynamicscene-cpp/examplescene.cpp
+++ b/tests/manual/dynamicscene-cpp/examplescene.cpp
@@ -73,7 +73,7 @@ ExampleScene::~ExampleScene()
void ExampleScene::updateScene()
{
for (int i = 0; i < m_entities.size(); ++i) {
- const bool visible = (i % 2) ^ m_even;
+ const bool visible = (i % 2) ^ static_cast<int>(m_even);
m_entities[i]->setParent(visible ? this : nullptr);
}
m_even = !m_even;