summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/qcameralens/tst_qcameralens.cpp
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2017-01-31 16:23:06 +0100
committerKevin Ottens <kevin.ottens@kdab.com>2017-01-31 16:18:04 +0000
commitd7a8f157b78ab998b89e1ceb9cb321638f964e7f (patch)
tree4743c5c4bca5c03d7a29bcbf92745f8fece5d5e7 /tests/auto/render/qcameralens/tst_qcameralens.cpp
parent71f9506c143c93a3b1abb9225e1d930e6ecc289d (diff)
Add exposure to QCameraLens API
Change-Id: I2ad776ec6a7371c7d057d4d5f0feee715e9df188 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto/render/qcameralens/tst_qcameralens.cpp')
-rw-r--r--tests/auto/render/qcameralens/tst_qcameralens.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/render/qcameralens/tst_qcameralens.cpp b/tests/auto/render/qcameralens/tst_qcameralens.cpp
index aab43d553..adff66dc5 100644
--- a/tests/auto/render/qcameralens/tst_qcameralens.cpp
+++ b/tests/auto/render/qcameralens/tst_qcameralens.cpp
@@ -63,6 +63,7 @@ private Q_SLOTS:
QCOMPARE(cameraLens.right(), 0.5f);
QCOMPARE(cameraLens.bottom(), -0.5f);
QCOMPARE(cameraLens.top(), 0.5f);
+ QCOMPARE(cameraLens.exposure(), 0.0f);
}
void checkPropertyChanges()
@@ -243,6 +244,26 @@ private Q_SLOTS:
}
{
// WHEN
+ QSignalSpy spy(&cameraLens, SIGNAL(exposureChanged(float)));
+ const float newValue = -2.0f;
+ cameraLens.setExposure(newValue);
+
+ // THEN
+ QVERIFY(spy.isValid());
+ QCOMPARE(cameraLens.exposure(), newValue);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.takeFirst().first().toFloat(), -2.0f);
+
+ // WHEN
+ spy.clear();
+ cameraLens.setExposure(newValue);
+
+ // THEN
+ QCOMPARE(cameraLens.exposure(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
+ {
+ // WHEN
QSignalSpy spy(&cameraLens, SIGNAL(projectionMatrixChanged(QMatrix4x4)));
QMatrix4x4 newValue;
newValue.translate(5.0f, 2.0f, 4.3f);
@@ -340,6 +361,7 @@ private Q_SLOTS:
cameraLens.setFarPlane(1005.0f);
cameraLens.setFieldOfView(35.0f);
cameraLens.setAspectRatio(16.0f/9.0f);
+ cameraLens.setExposure(1.0f);
// WHEN
QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges;
@@ -357,6 +379,7 @@ private Q_SLOTS:
const Qt3DRender::QCameraLensData cloneData = creationChangeData->data;
QCOMPARE(cameraLens.projectionMatrix(), cloneData.projectionMatrix);
+ QCOMPARE(cameraLens.exposure(), cloneData.exposure);
QCOMPARE(cameraLens.id(), creationChangeData->subjectId());
QCOMPARE(cameraLens.isEnabled(), true);
QCOMPARE(cameraLens.isEnabled(), creationChangeData->isNodeEnabled());
@@ -379,6 +402,7 @@ private Q_SLOTS:
const Qt3DRender::QCameraLensData cloneData = creationChangeData->data;
QCOMPARE(cameraLens.projectionMatrix(), cloneData.projectionMatrix);
+ QCOMPARE(cameraLens.exposure(), cloneData.exposure);
QCOMPARE(cameraLens.id(), creationChangeData->subjectId());
QCOMPARE(cameraLens.isEnabled(), false);
QCOMPARE(cameraLens.isEnabled(), creationChangeData->isNodeEnabled());
@@ -674,6 +698,38 @@ private Q_SLOTS:
}
+ void checkExposureUpdate()
+ {
+ // GIVEN
+ TestArbiter arbiter;
+ Qt3DRender::QCameraLens cameraLens;
+ arbiter.setArbiterOnNode(&cameraLens);
+
+ {
+ // WHEN
+ cameraLens.setExposure(2.0f);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 1);
+ auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "exposure");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+
+ arbiter.events.clear();
+ }
+
+ {
+ // WHEN
+ cameraLens.setExposure(2.0f);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ }
+
+ }
+
void checkProjectionMatrixUpdate()
{
// GIVEN