diff options
Diffstat (limited to 'tests/auto/render/qabstractlight/tst_qabstractlight.cpp')
-rw-r--r-- | tests/auto/render/qabstractlight/tst_qabstractlight.cpp | 122 |
1 files changed, 17 insertions, 105 deletions
diff --git a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp index 011ad1036..7c2162ecf 100644 --- a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp +++ b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp @@ -29,7 +29,6 @@ #include <QtTest/QTest> #include <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/private/qscene_p.h> -#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> #include <Qt3DRender/qabstractlight.h> #include <Qt3DRender/private/qabstractlight_p.h> @@ -40,7 +39,7 @@ #include <Qt3DRender/private/qdirectionallight_p.h> #include <Qt3DRender/private/qspotlight_p.h> -#include "testpostmanarbiter.h" +#include "testarbiter.h" class DummyLight : public Qt3DRender::QAbstractLight { @@ -60,87 +59,6 @@ class tst_QAbstractLight: public Qt3DCore::QNode Q_OBJECT private Q_SLOTS: - // TO DO: Test should be rewritten to query the properties from the attached QShaderData - -// void checkLightCloning() -// { -// // GIVEN -// DummyLight light; -// light.setColor(Qt::red); -// light.setIntensity(0.5f); - -// // WHEN -// Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(material); -// QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges(); - -// // THEN -// QVERIFY(creationChanges.size() >= 1); - -// const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QA> creationChangeData = -// qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QMaterialData>>(creationChanges.first()); -// const Qt3DRender::QMaterialData &cloneData = creationChangeData->data; - - -// QScopedPointer<Qt3DRender::QAbstractLight> lightClone(static_cast<Qt3DRender::QAbstractLight *>(QNode::clone(&light))); -// QVERIFY(lightClone.data()); -// QCOMPARE(light.color(), lightClone->color()); -// QCOMPARE(light.intensity(), lightClone->intensity()); -// } - -// void checkPointLightCloning() -// { -// Qt3DRender::QPointLight pointLight; -// QCOMPARE(pointLight.type(), Qt3DRender::QAbstractLight::PointLight); -// pointLight.setColor(Qt::green); -// pointLight.setIntensity(0.5f); -// pointLight.setConstantAttenuation(0.5f); -// pointLight.setLinearAttenuation(0.0f); // No actual event triggered as 0.0f is default -// pointLight.setQuadraticAttenuation(1.0f); - -// QScopedPointer<Qt3DRender::QPointLight> pointLightClone(static_cast<Qt3DRender::QPointLight *>(QNode::clone(&pointLight))); -// QVERIFY(pointLightClone.data()); -// QCOMPARE(pointLightClone->type(), Qt3DRender::QAbstractLight::PointLight); -// QCOMPARE(pointLight.color(), pointLightClone->color()); -// QCOMPARE(pointLight.intensity(), pointLightClone->intensity()); -// QCOMPARE(pointLight.constantAttenuation(), pointLightClone->constantAttenuation()); -// QCOMPARE(pointLight.linearAttenuation(), pointLightClone->linearAttenuation()); -// QCOMPARE(pointLight.quadraticAttenuation(), pointLightClone->quadraticAttenuation()); -// } - -// void checkDirectionalLightCloning() -// { -// Qt3DRender::QDirectionalLight dirLight; -// QCOMPARE(dirLight.type(), Qt3DRender::QAbstractLight::DirectionalLight); -// dirLight.setColor(Qt::blue); -// dirLight.setIntensity(0.5f); -// dirLight.setWorldDirection(QVector3D(0, 0, -1)); - -// QScopedPointer<Qt3DRender::QDirectionalLight> dirLightClone(static_cast<Qt3DRender::QDirectionalLight *>(QNode::clone(&dirLight))); -// QVERIFY(dirLightClone.data()); -// QCOMPARE(dirLightClone->type(), Qt3DRender::QAbstractLight::DirectionalLight); -// QCOMPARE(dirLight.color(), dirLightClone->color()); -// QCOMPARE(dirLight.intensity(), dirLightClone->intensity()); -// QCOMPARE(dirLight.worldDirection(), dirLightClone->worldDirection()); -// } - -// void checkSpotLightCloning() -// { -// Qt3DRender::QSpotLight spotLight; -// QCOMPARE(spotLight.type(), Qt3DRender::QAbstractLight::SpotLight); -// spotLight.setColor(Qt::lightGray); -// spotLight.setIntensity(0.5f); -// spotLight.setLocalDirection(QVector3D(0, 0, -1)); -// spotLight.setCutOffAngle(0.75f); - -// QScopedPointer<Qt3DRender::QSpotLight> spotLightClone(static_cast<Qt3DRender::QSpotLight *>(QNode::clone(&spotLight))); -// QVERIFY(spotLightClone.data()); -// QCOMPARE(spotLightClone->type(), Qt3DRender::QAbstractLight::SpotLight); -// QCOMPARE(spotLight.color(), spotLightClone->color()); -// QCOMPARE(spotLight.intensity(), spotLightClone->intensity()); -// QCOMPARE(spotLight.localDirection(), spotLightClone->localDirection()); -// QCOMPARE(spotLight.cutOffAngle(), spotLightClone->cutOffAngle()); -// } - void checkLightPropertyUpdates() { TestArbiter arbiter; @@ -150,16 +68,11 @@ private Q_SLOTS: light->setColor(Qt::red); light->setIntensity(0.8f); // change from the default of 0.5f - QCOMPARE(arbiter.events.size(), 0); - QCOMPARE(arbiter.dirtyNodes.size(), 2); - QVERIFY(arbiter.dirtyNodes[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); - QCOMPARE(arbiter.dirtyNodes[1], light.data()); - - arbiter.dirtyNodes.clear(); - - QCOMPARE(arbiter.events.size(), 0); + QCOMPARE(arbiter.dirtyNodes().size(), 2); + QVERIFY(arbiter.dirtyNodes()[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); + QCOMPARE(arbiter.dirtyNodes()[1], light.data()); - arbiter.events.clear(); + arbiter.clear(); } void checkPointLightPropertyUpdates() @@ -174,12 +87,11 @@ private Q_SLOTS: pointLight->setLinearAttenuation(0.0f); // No actual event triggered as 0.0f is default pointLight->setQuadraticAttenuation(1.0f); - QCOMPARE(arbiter.events.size(), 0); - QCOMPARE(arbiter.dirtyNodes.size(), 2); - QVERIFY(arbiter.dirtyNodes[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); - QCOMPARE(arbiter.dirtyNodes[1], pointLight.data()); + QCOMPARE(arbiter.dirtyNodes().size(), 2); + QVERIFY(arbiter.dirtyNodes()[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); + QCOMPARE(arbiter.dirtyNodes()[1], pointLight.data()); - arbiter.dirtyNodes.clear(); + arbiter.clear(); } void checkDirectionalLightPropertyUpdates() @@ -192,11 +104,11 @@ private Q_SLOTS: dirLight->setIntensity(0.8f); dirLight->setWorldDirection(QVector3D(0.5f, 0.0f, -1.0f)); - QCOMPARE(arbiter.dirtyNodes.size(), 2); - QVERIFY(arbiter.dirtyNodes[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); - QCOMPARE(arbiter.dirtyNodes[1], dirLight.data()); + QCOMPARE(arbiter.dirtyNodes().size(), 2); + QVERIFY(arbiter.dirtyNodes()[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); + QCOMPARE(arbiter.dirtyNodes()[1], dirLight.data()); - arbiter.dirtyNodes.clear(); + arbiter.clear(); } void checkSpotLightPropertyUpdates() @@ -210,11 +122,11 @@ private Q_SLOTS: spotLight->setLocalDirection(QVector3D(0.5f, 0.0f, -1.0f)); spotLight->setCutOffAngle(0.75f); - QCOMPARE(arbiter.dirtyNodes.size(), 2); - QVERIFY(arbiter.dirtyNodes[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); - QCOMPARE(arbiter.dirtyNodes[1], spotLight.data()); + QCOMPARE(arbiter.dirtyNodes().size(), 2); + QVERIFY(arbiter.dirtyNodes()[0]->metaObject()->inherits(&Qt3DRender::QShaderData::staticMetaObject)); + QCOMPARE(arbiter.dirtyNodes()[1], spotLight.data()); - arbiter.dirtyNodes.clear(); + arbiter.clear(); } }; |