1/****************************************************************************
2**
3** Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29
30#include <QtTest/QTest>
31#include <Qt3DRender/qcameralens.h>
32#include <Qt3DRender/private/qcameralens_p.h>
33#include <QObject>
34#include <QSignalSpy>
35#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
36#include <Qt3DCore/qnodecreatedchange.h>
37#include "testpostmanarbiter.h"
38
39class tst_QCameraLens : public QObject
40{
41 Q_OBJECT
42
43private Q_SLOTS:
44
45 void initTestCase()
46 {
47 qRegisterMetaType<Qt3DRender::QCameraLens::ProjectionType>(typeName: "QCameraLens::ProjectionType");
48 }
49
50 void checkDefaultConstruction()
51 {
52 // GIVEN
53 Qt3DRender::QCameraLens cameraLens;
54
55 // THEN
56 QCOMPARE(cameraLens.projectionType(), Qt3DRender::QCameraLens::PerspectiveProjection);
57 QCOMPARE(cameraLens.nearPlane(), 0.1f);
58 QCOMPARE(cameraLens.farPlane(), 1024.0f);
59 QCOMPARE(cameraLens.fieldOfView(), 25.0f);
60 QCOMPARE(cameraLens.aspectRatio(), 1.0f);
61 QCOMPARE(cameraLens.left(), -0.5f);
62 QCOMPARE(cameraLens.right(), 0.5f);
63 QCOMPARE(cameraLens.bottom(), -0.5f);
64 QCOMPARE(cameraLens.top(), 0.5f);
65 QCOMPARE(cameraLens.exposure(), 0.0f);
66 }
67
68 void checkPropertyChanges()
69 {
70 // GIVEN
71 Qt3DRender::QCameraLens cameraLens;
72
73 {
74 // WHEN
75 QSignalSpy spy(&cameraLens, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType)));
76 const Qt3DRender::QCameraLens::ProjectionType newValue = Qt3DRender::QCameraLens::OrthographicProjection;
77 cameraLens.setProjectionType(newValue);
78
79 // THEN
80 QVERIFY(spy.isValid());
81 QCOMPARE(cameraLens.projectionType(), newValue);
82 QCOMPARE(spy.count(), 1);
83
84 // WHEN
85 spy.clear();
86 cameraLens.setProjectionType(newValue);
87
88 // THEN
89 QCOMPARE(cameraLens.projectionType(), newValue);
90 QCOMPARE(spy.count(), 0);
91 }
92 {
93 // WHEN
94 QSignalSpy spy(&cameraLens, SIGNAL(nearPlaneChanged(float)));
95 const float newValue = 10.0f;
96 cameraLens.setNearPlane(newValue);
97
98 // THEN
99 QVERIFY(spy.isValid());
100 QCOMPARE(cameraLens.nearPlane(), newValue);
101 QCOMPARE(spy.count(), 1);
102
103 // WHEN
104 spy.clear();
105 cameraLens.setNearPlane(newValue);
106
107 // THEN
108 QCOMPARE(cameraLens.nearPlane(), newValue);
109 QCOMPARE(spy.count(), 0);
110 }
111 {
112 // WHEN
113 QSignalSpy spy(&cameraLens, SIGNAL(farPlaneChanged(float)));
114 const float newValue = 1.0f;
115 cameraLens.setFarPlane(newValue);
116
117 // THEN
118 QVERIFY(spy.isValid());
119 QCOMPARE(cameraLens.farPlane(), newValue);
120 QCOMPARE(spy.count(), 1);
121
122 // WHEN
123 spy.clear();
124 cameraLens.setFarPlane(newValue);
125
126 // THEN
127 QCOMPARE(cameraLens.farPlane(), newValue);
128 QCOMPARE(spy.count(), 0);
129 }
130 {
131 // WHEN
132 QSignalSpy spy(&cameraLens, SIGNAL(fieldOfViewChanged(float)));
133 const float newValue = 5.0f;
134 cameraLens.setFieldOfView(newValue);
135
136 // THEN
137 QVERIFY(spy.isValid());
138 QCOMPARE(cameraLens.fieldOfView(), newValue);
139 QCOMPARE(spy.count(), 1);
140
141 // WHEN
142 spy.clear();
143 cameraLens.setFieldOfView(newValue);
144
145 // THEN
146 QCOMPARE(cameraLens.fieldOfView(), newValue);
147 QCOMPARE(spy.count(), 0);
148 }
149 {
150 // WHEN
151 QSignalSpy spy(&cameraLens, SIGNAL(aspectRatioChanged(float)));
152 const float newValue = 4.0f / 3.0f;
153 cameraLens.setAspectRatio(newValue);
154
155 // THEN
156 QVERIFY(spy.isValid());
157 QCOMPARE(cameraLens.aspectRatio(), newValue);
158 QCOMPARE(spy.count(), 1);
159
160 // WHEN
161 spy.clear();
162 cameraLens.setAspectRatio(newValue);
163
164 // THEN
165 QCOMPARE(cameraLens.aspectRatio(), newValue);
166 QCOMPARE(spy.count(), 0);
167 }
168 {
169 // WHEN
170 QSignalSpy spy(&cameraLens, SIGNAL(leftChanged(float)));
171 const float newValue = 0.0f;
172 cameraLens.setLeft(newValue);
173
174 // THEN
175 QVERIFY(spy.isValid());
176 QCOMPARE(cameraLens.left(), newValue);
177 QCOMPARE(spy.count(), 1);
178
179 // WHEN
180 spy.clear();
181 cameraLens.setLeft(newValue);
182
183 // THEN
184 QCOMPARE(cameraLens.left(), newValue);
185 QCOMPARE(spy.count(), 0);
186 }
187 {
188 // WHEN
189 QSignalSpy spy(&cameraLens, SIGNAL(rightChanged(float)));
190 const float newValue = 1.0f;
191 cameraLens.setRight(newValue);
192
193 // THEN
194 QVERIFY(spy.isValid());
195 QCOMPARE(cameraLens.right(), newValue);
196 QCOMPARE(spy.count(), 1);
197
198 // WHEN
199 spy.clear();
200 cameraLens.setRight(newValue);
201
202 // THEN
203 QCOMPARE(cameraLens.right(), newValue);
204 QCOMPARE(spy.count(), 0);
205 }
206 {
207 // WHEN
208 QSignalSpy spy(&cameraLens, SIGNAL(bottomChanged(float)));
209 const float newValue = 2.0f;
210 cameraLens.setBottom(newValue);
211
212 // THEN
213 QVERIFY(spy.isValid());
214 QCOMPARE(cameraLens.bottom(), newValue);
215 QCOMPARE(spy.count(), 1);
216
217 // WHEN
218 spy.clear();
219 cameraLens.setBottom(newValue);
220
221 // THEN
222 QCOMPARE(cameraLens.bottom(), newValue);
223 QCOMPARE(spy.count(), 0);
224 }
225 {
226 // WHEN
227 QSignalSpy spy(&cameraLens, SIGNAL(topChanged(float)));
228 const float newValue = -2.0f;
229 cameraLens.setTop(newValue);
230
231 // THEN
232 QVERIFY(spy.isValid());
233 QCOMPARE(cameraLens.top(), newValue);
234 QCOMPARE(spy.count(), 1);
235
236 // WHEN
237 spy.clear();
238 cameraLens.setTop(newValue);
239
240 // THEN
241 QCOMPARE(cameraLens.top(), newValue);
242 QCOMPARE(spy.count(), 0);
243 }
244 {
245 // WHEN
246 QSignalSpy spy(&cameraLens, SIGNAL(exposureChanged(float)));
247 const float newValue = -2.0f;
248 cameraLens.setExposure(newValue);
249
250 // THEN
251 QVERIFY(spy.isValid());
252 QCOMPARE(cameraLens.exposure(), newValue);
253 QCOMPARE(spy.count(), 1);
254 QCOMPARE(spy.takeFirst().first().toFloat(), -2.0f);
255
256 // WHEN
257 spy.clear();
258 cameraLens.setExposure(newValue);
259
260 // THEN
261 QCOMPARE(cameraLens.exposure(), newValue);
262 QCOMPARE(spy.count(), 0);
263 }
264 {
265 // WHEN
266 QSignalSpy spy(&cameraLens, SIGNAL(projectionMatrixChanged(QMatrix4x4)));
267 QMatrix4x4 newValue;
268 newValue.translate(x: 5.0f, y: 2.0f, z: 4.3f);
269 cameraLens.setProjectionMatrix(newValue);
270
271 // THEN
272 QVERIFY(spy.isValid());
273 QCOMPARE(cameraLens.projectionMatrix(), newValue);
274 QCOMPARE(cameraLens.projectionType(), Qt3DRender::QCameraLens::CustomProjection);
275 QCOMPARE(spy.count(), 1);
276
277 // WHEN
278 spy.clear();
279 cameraLens.setProjectionMatrix(newValue);
280
281 // THEN
282 QCOMPARE(cameraLens.projectionMatrix(), newValue);
283 QCOMPARE(spy.count(), 0);
284 }
285 }
286
287 void checkSetOrthographicProjection()
288 {
289 // GIVEN
290 Qt3DRender::QCameraLens cameraLens;
291
292 {
293 // WHEN
294 QSignalSpy spy(&cameraLens, SIGNAL(projectionMatrixChanged(QMatrix4x4)));
295 cameraLens.setOrthographicProjection(left: -1.0f, right: 1.0f, bottom: -1.0f, top: 1.0f, nearPlane: 0.5f, farPlane: 50.0f);
296
297 // THEN
298 QVERIFY(spy.isValid());
299 QCOMPARE(spy.count(), 8); // Triggered for each property being set + 1
300 QCOMPARE(cameraLens.projectionType(), Qt3DRender::QCameraLens::OrthographicProjection);
301 QCOMPARE(cameraLens.nearPlane(), 0.5f);
302 QCOMPARE(cameraLens.farPlane(), 50.0f);
303 QCOMPARE(cameraLens.left(), -1.0f);
304 QCOMPARE(cameraLens.right(), 1.0f);
305 QCOMPARE(cameraLens.bottom(), -1.0f);
306 QCOMPARE(cameraLens.top(), 1.0f);
307 }
308 }
309
310 void checkSetPerspectiveProjection()
311 {
312 // GIVEN
313 Qt3DRender::QCameraLens cameraLens;
314
315 {
316 // WHEN
317 QSignalSpy spy(&cameraLens, SIGNAL(projectionMatrixChanged(QMatrix4x4)));
318 cameraLens.setPerspectiveProjection(fieldOfView: 20.0f, aspect: 16.0f / 9.0f, nearPlane: 0.5f, farPlane: 50.0f);
319
320 // THEN
321 QVERIFY(spy.isValid());
322 QCOMPARE(spy.count(), 5); // Triggered for each property being set (- projectionTye which is the default value) + 1
323 QCOMPARE(cameraLens.projectionType(), Qt3DRender::QCameraLens::PerspectiveProjection);
324 QCOMPARE(cameraLens.nearPlane(), 0.5f);
325 QCOMPARE(cameraLens.farPlane(), 50.0f);
326 QCOMPARE(cameraLens.fieldOfView(), 20.0f);
327 QCOMPARE(cameraLens.aspectRatio(), 16.0f / 9.0f);
328 }
329 }
330
331 void checkSetFrustumProjection()
332 {
333 // GIVEN
334 Qt3DRender::QCameraLens cameraLens;
335
336 {
337 // WHEN
338 QSignalSpy spy(&cameraLens, SIGNAL(projectionMatrixChanged(QMatrix4x4)));
339 cameraLens.setFrustumProjection(left: -1.0f, right: 1.0f, bottom: -1.0f, top: 1.0f, nearPlane: 0.5f, farPlane: 50.0f);
340
341 // THEN
342 QVERIFY(spy.isValid());
343 QCOMPARE(spy.count(), 8); // Triggered for each property being set + 1
344 QCOMPARE(cameraLens.projectionType(), Qt3DRender::QCameraLens::FrustumProjection);
345 QCOMPARE(cameraLens.nearPlane(), 0.5f);
346 QCOMPARE(cameraLens.farPlane(), 50.0f);
347 QCOMPARE(cameraLens.left(), -1.0f);
348 QCOMPARE(cameraLens.right(), 1.0f);
349 QCOMPARE(cameraLens.bottom(), -1.0f);
350 QCOMPARE(cameraLens.top(), 1.0f);
351 }
352 }
353
354 void checkCreationData()
355 {
356 // GIVEN
357 Qt3DRender::QCameraLens cameraLens;
358
359 cameraLens.setNearPlane(0.5);
360 cameraLens.setFarPlane(1005.0f);
361 cameraLens.setFieldOfView(35.0f);
362 cameraLens.setAspectRatio(16.0f/9.0f);
363 cameraLens.setExposure(1.0f);
364
365 // WHEN
366 QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges;
367
368 {
369 Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(&cameraLens);
370 creationChanges = creationChangeGenerator.creationChanges();
371 }
372
373 // THEN
374 {
375 QCOMPARE(creationChanges.size(), 1);
376
377 const auto creationChangeData = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QCameraLensData>>(src: creationChanges.first());
378 const Qt3DRender::QCameraLensData cloneData = creationChangeData->data;
379
380 QCOMPARE(cameraLens.projectionMatrix(), cloneData.projectionMatrix);
381 QCOMPARE(cameraLens.exposure(), cloneData.exposure);
382 QCOMPARE(cameraLens.id(), creationChangeData->subjectId());
383 QCOMPARE(cameraLens.isEnabled(), true);
384 QCOMPARE(cameraLens.isEnabled(), creationChangeData->isNodeEnabled());
385 QCOMPARE(cameraLens.metaObject(), creationChangeData->metaObject());
386 }
387
388 // WHEN
389 cameraLens.setEnabled(false);
390
391 {
392 Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(&cameraLens);
393 creationChanges = creationChangeGenerator.creationChanges();
394 }
395
396 // THEN
397 {
398 QCOMPARE(creationChanges.size(), 1);
399
400 const auto creationChangeData = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QCameraLensData>>(src: creationChanges.first());
401 const Qt3DRender::QCameraLensData cloneData = creationChangeData->data;
402
403 QCOMPARE(cameraLens.projectionMatrix(), cloneData.projectionMatrix);
404 QCOMPARE(cameraLens.exposure(), cloneData.exposure);
405 QCOMPARE(cameraLens.id(), creationChangeData->subjectId());
406 QCOMPARE(cameraLens.isEnabled(), false);
407 QCOMPARE(cameraLens.isEnabled(), creationChangeData->isNodeEnabled());
408 QCOMPARE(cameraLens.metaObject(), creationChangeData->metaObject());
409 }
410 }
411
412 void checkProjectionTypeUpdate()
413 {
414 // GIVEN
415 TestArbiter arbiter;
416 Qt3DRender::QCameraLens cameraLens;
417 arbiter.setArbiterOnNode(&cameraLens);
418
419 {
420 // WHEN
421 cameraLens.setProjectionType(Qt3DRender::QCameraLens::FrustumProjection);
422 QCoreApplication::processEvents();
423
424 // THEN
425 QCOMPARE(arbiter.events.size(), 0);
426 QCOMPARE(arbiter.dirtyNodes.size(), 1);
427 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
428
429 arbiter.dirtyNodes.clear();
430 }
431
432 {
433 // WHEN
434 cameraLens.setProjectionType(Qt3DRender::QCameraLens::FrustumProjection);
435 QCoreApplication::processEvents();
436
437 // THEN
438 QCOMPARE(arbiter.events.size(), 0);
439 QCOMPARE(arbiter.dirtyNodes.size(), 0);
440 }
441
442 }
443
444 void checkNearPlaneUpdate()
445 {
446 // GIVEN
447 TestArbiter arbiter;
448 Qt3DRender::QCameraLens cameraLens;
449 arbiter.setArbiterOnNode(&cameraLens);
450
451 {
452 // WHEN
453 cameraLens.setNearPlane(5.0f);
454
455 // THEN
456 QCOMPARE(arbiter.events.size(), 0);
457 QCOMPARE(arbiter.dirtyNodes.size(), 1);
458 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
459
460 arbiter.dirtyNodes.clear();
461 }
462
463 {
464 // WHEN
465 cameraLens.setNearPlane(5.0f);
466
467 // THEN
468 QCOMPARE(arbiter.events.size(), 0);
469 QCOMPARE(arbiter.dirtyNodes.size(), 0);
470 }
471
472 }
473
474 void checkFarPlaneUpdate()
475 {
476 // GIVEN
477 TestArbiter arbiter;
478 Qt3DRender::QCameraLens cameraLens;
479 arbiter.setArbiterOnNode(&cameraLens);
480
481 {
482 // WHEN
483 cameraLens.setFarPlane(5.0f);
484
485 // THEN
486 QCOMPARE(arbiter.events.size(), 0);
487 QCOMPARE(arbiter.dirtyNodes.size(), 1);
488 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
489
490 arbiter.dirtyNodes.clear();
491 }
492
493 {
494 // WHEN
495 cameraLens.setFarPlane(5.0f);
496
497 // THEN
498 QCOMPARE(arbiter.events.size(), 0);
499 QCOMPARE(arbiter.dirtyNodes.size(), 0);
500 }
501
502 }
503
504 void checkFieldOfViewUpdate()
505 {
506 // GIVEN
507 TestArbiter arbiter;
508 Qt3DRender::QCameraLens cameraLens;
509 arbiter.setArbiterOnNode(&cameraLens);
510
511 {
512 // WHEN
513 cameraLens.setFieldOfView(5.0f);
514
515 // THEN
516 QCOMPARE(arbiter.events.size(), 0);
517 QCOMPARE(arbiter.dirtyNodes.size(), 1);
518 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
519
520 arbiter.dirtyNodes.clear();
521 }
522
523 {
524 // WHEN
525 cameraLens.setFieldOfView(5.0f);
526
527 // THEN
528 QCOMPARE(arbiter.events.size(), 0);
529 QCOMPARE(arbiter.dirtyNodes.size(), 0);
530 }
531
532 }
533
534 void checkAspectRatioUpdate()
535 {
536 // GIVEN
537 TestArbiter arbiter;
538 Qt3DRender::QCameraLens cameraLens;
539 arbiter.setArbiterOnNode(&cameraLens);
540
541 {
542 // WHEN
543 cameraLens.setAspectRatio(9.0f);
544
545 // THEN
546 QCOMPARE(arbiter.events.size(), 0);
547 QCOMPARE(arbiter.dirtyNodes.size(), 1);
548 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
549
550 arbiter.dirtyNodes.clear();
551 }
552
553 {
554 // WHEN
555 cameraLens.setAspectRatio(9.0f);
556
557 // THEN
558 QCOMPARE(arbiter.events.size(), 0);
559 QCOMPARE(arbiter.dirtyNodes.size(), 0);
560 }
561
562 }
563
564 void checkLeftUpdate()
565 {
566 // GIVEN
567 TestArbiter arbiter;
568 Qt3DRender::QCameraLens cameraLens;
569 arbiter.setArbiterOnNode(&cameraLens);
570
571 {
572 // WHEN
573 cameraLens.setLeft(0.0f);
574
575 // THEN
576 QCOMPARE(arbiter.events.size(), 0);
577 QCOMPARE(arbiter.dirtyNodes.size(), 1);
578 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
579
580 arbiter.dirtyNodes.clear();
581 }
582
583 {
584 // WHEN
585 cameraLens.setLeft(0.0f);
586
587 // THEN
588 QCOMPARE(arbiter.events.size(), 0);
589 QCOMPARE(arbiter.dirtyNodes.size(), 0);
590 }
591
592 }
593
594 void checkRightUpdate()
595 {
596 // GIVEN
597 TestArbiter arbiter;
598 Qt3DRender::QCameraLens cameraLens;
599 arbiter.setArbiterOnNode(&cameraLens);
600
601 {
602 // WHEN
603 cameraLens.setRight(24.0f);
604
605 // THEN
606 QCOMPARE(arbiter.events.size(), 0);
607 QCOMPARE(arbiter.dirtyNodes.size(), 1);
608 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
609
610 arbiter.dirtyNodes.clear();
611 }
612
613 {
614 // WHEN
615 cameraLens.setRight(24.0f);
616
617 // THEN
618 QCOMPARE(arbiter.events.size(), 0);
619 QCOMPARE(arbiter.dirtyNodes.size(), 0);
620 }
621
622 }
623
624 void checkBottomUpdate()
625 {
626 // GIVEN
627 TestArbiter arbiter;
628 Qt3DRender::QCameraLens cameraLens;
629 arbiter.setArbiterOnNode(&cameraLens);
630
631 {
632 // WHEN
633 cameraLens.setBottom(-12.0f);
634
635 // THEN
636 QCOMPARE(arbiter.events.size(), 0);
637 QCOMPARE(arbiter.dirtyNodes.size(), 1);
638 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
639
640 arbiter.dirtyNodes.clear();
641 }
642
643 {
644 // WHEN
645 cameraLens.setBottom(-12.0f);
646
647 // THEN
648 QCOMPARE(arbiter.events.size(), 0);
649 QCOMPARE(arbiter.dirtyNodes.size(), 0);
650 }
651
652 }
653
654 void checkTopUpdate()
655 {
656 // GIVEN
657 TestArbiter arbiter;
658 Qt3DRender::QCameraLens cameraLens;
659 arbiter.setArbiterOnNode(&cameraLens);
660
661 {
662 // WHEN
663 cameraLens.setTop(12.0f);
664
665 // THEN
666 QCOMPARE(arbiter.events.size(), 0);
667 QCOMPARE(arbiter.dirtyNodes.size(), 1);
668 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
669
670 arbiter.dirtyNodes.clear();
671 }
672
673 {
674 // WHEN
675 cameraLens.setTop(12.0f);
676
677 // THEN
678 QCOMPARE(arbiter.events.size(), 0);
679 QCOMPARE(arbiter.dirtyNodes.size(), 0);
680 }
681
682 }
683
684 void checkExposureUpdate()
685 {
686 // GIVEN
687 TestArbiter arbiter;
688 Qt3DRender::QCameraLens cameraLens;
689 arbiter.setArbiterOnNode(&cameraLens);
690
691 {
692 // WHEN
693 cameraLens.setExposure(2.0f);
694
695 // THEN
696 QCOMPARE(arbiter.events.size(), 0);
697 QCOMPARE(arbiter.dirtyNodes.size(), 1);
698 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
699
700 arbiter.dirtyNodes.clear();
701 }
702
703 {
704 // WHEN
705 cameraLens.setExposure(2.0f);
706
707 // THEN
708 QCOMPARE(arbiter.events.size(), 0);
709 QCOMPARE(arbiter.dirtyNodes.size(), 0);
710 }
711
712 }
713
714 void checkProjectionMatrixUpdate()
715 {
716 // GIVEN
717 TestArbiter arbiter;
718 Qt3DRender::QCameraLens cameraLens;
719 arbiter.setArbiterOnNode(&cameraLens);
720
721 QMatrix4x4 m;
722 m.translate(x: -5.0f, y: 5.0f, z: 25.0f);
723
724 {
725 // WHEN
726 cameraLens.setProjectionMatrix(m);
727
728 // THEN
729 QCOMPARE(arbiter.events.size(), 0);
730 QCOMPARE(arbiter.dirtyNodes.size(), 1);
731 QCOMPARE(arbiter.dirtyNodes.front(), &cameraLens);
732
733 arbiter.dirtyNodes.clear();
734 }
735
736 {
737 // WHEN
738 cameraLens.setProjectionMatrix(m);
739
740 // THEN
741 QCOMPARE(arbiter.events.size(), 0);
742 QCOMPARE(arbiter.events.size(), 0);
743 }
744
745 }
746
747};
748
749QTEST_MAIN(tst_QCameraLens)
750
751#include "tst_qcameralens.moc"
752

source code of qt3d/tests/auto/render/qcameralens/tst_qcameralens.cpp