summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-01-19 10:36:58 +0100
committerPaul Lemire <paul.lemire@kdab.com>2018-01-22 06:08:57 +0000
commitbf6d107b90b8a5e9f24da0c0f551c66952dbf57b (patch)
treeaf6cb25075ea8d8ea2fc68904f6a42950dc5e731 /tests/auto/render/meshfunctors/tst_meshfunctors.cpp
parent2ca0dbadaac328826807c6b9bf2b46dbb955e3d2 (diff)
QMesh: do not rely on QAspectEngine to create QGeometryFactory
- This would prevent QMesh created without parent/scene to have a proper geometry factory. - This avoid passing the engine around Change-Id: I5091970f96e87ab8b129475a1113ef84ce170388 Task-number: QTBUG-65506 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests/auto/render/meshfunctors/tst_meshfunctors.cpp')
-rw-r--r--tests/auto/render/meshfunctors/tst_meshfunctors.cpp68
1 files changed, 63 insertions, 5 deletions
diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
index 1904169fb..5d89767c7 100644
--- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
+++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp
@@ -100,6 +100,24 @@ class tst_MeshFunctors : public QObject
{
Q_OBJECT
private Q_SLOTS:
+
+ void checkInitialState()
+ {
+ // GIVEN
+ Qt3DRender::QMesh mesh;
+ mesh.setSource(QUrl(QStringLiteral("./some_path.obj")));
+
+ // WHEN
+ const Qt3DRender::MeshLoaderFunctor functor(&mesh);
+
+ // THEN
+ QVERIFY(functor.nodeManagers() == nullptr);
+ QVERIFY(functor.downloaderService() == nullptr);
+ QVERIFY(functor.sourceData().isEmpty());
+ QCOMPARE(functor.mesh(), mesh.id());
+ QCOMPARE(functor.sourcePath(), mesh.source());
+ }
+
void functorComparison()
{
// GIVEN
@@ -125,7 +143,6 @@ private Q_SLOTS:
void checkMeshFunctorEquality()
{
// GIVEN
- Qt3DCore::QAspectEngine engine;
auto meshA = new Qt3DRender::QMesh();
meshA->setSource(QUrl::fromLocalFile(QLatin1String("/foo")));
meshA->setMeshName(QLatin1String("bar"));
@@ -142,10 +159,10 @@ private Q_SLOTS:
meshD->setSource(QUrl::fromLocalFile(QLatin1String("/foo")));
meshD->setMeshName(QLatin1String("bar"));
- const Qt3DRender::MeshLoaderFunctor functorA(meshA, &engine);
- const Qt3DRender::MeshLoaderFunctor functorB(meshB, &engine);
- const Qt3DRender::MeshLoaderFunctor functorC(meshC, &engine);
- const Qt3DRender::MeshLoaderFunctor functorD(meshD, &engine);
+ const Qt3DRender::MeshLoaderFunctor functorA(meshA);
+ const Qt3DRender::MeshLoaderFunctor functorB(meshB);
+ const Qt3DRender::MeshLoaderFunctor functorC(meshC);
+ const Qt3DRender::MeshLoaderFunctor functorD(meshD);
// WHEN
const bool selfEquality = (functorA == functorA);
@@ -159,6 +176,47 @@ private Q_SLOTS:
QCOMPARE(sameMeshName, false);
QCOMPARE(perfectMatch, true);
}
+
+ void checkExecution()
+ {
+ {
+ // GIVEN
+ Qt3DRender::QMesh mesh;
+ Qt3DRender::MeshLoaderFunctor functor(&mesh);
+
+ // WHEN
+ const Qt3DRender::QGeometry *g = functor();
+
+ // THEN
+ QVERIFY(g == nullptr);
+ }
+
+ {
+ // GIVEN
+ Qt3DRender::QMesh mesh;
+ mesh.setSource(QUrl(QStringLiteral("./non_existing.obj")));
+ Qt3DRender::MeshLoaderFunctor functor(&mesh);
+
+ // WHEN
+ const Qt3DRender::QGeometry *g = functor();
+
+ // THEN
+ QVERIFY(g == nullptr);
+ }
+
+ {
+ // GIVEN
+ Qt3DRender::QMesh mesh;
+ mesh.setSource(QUrl(QStringLiteral("http://www.somedomain.org/non_exisiting.obj")));
+ Qt3DRender::MeshLoaderFunctor functor(&mesh);
+
+ // WHEN
+ const Qt3DRender::QGeometry *g = functor();
+
+ // THEN
+ QVERIFY(g == nullptr);
+ }
+ }
};
QTEST_MAIN(tst_MeshFunctors)