| 1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QtTest/QTest> |
| 5 | #include <Qt3DCore/private/qnode_p.h> |
| 6 | #include <Qt3DCore/private/qscene_p.h> |
| 7 | |
| 8 | #include <Qt3DRender/qlevelofdetail.h> |
| 9 | #include <Qt3DRender/private/qlevelofdetail_p.h> |
| 10 | |
| 11 | #include "testarbiter.h" |
| 12 | |
| 13 | class tst_QLevelOfDetail: public QObject |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | |
| 17 | private Q_SLOTS: |
| 18 | |
| 19 | void checkPropertyUpdates() |
| 20 | { |
| 21 | // GIVEN |
| 22 | TestArbiter arbiter; |
| 23 | QScopedPointer<Qt3DRender::QLevelOfDetail> lod(new Qt3DRender::QLevelOfDetail()); |
| 24 | arbiter.setArbiterOnNode(lod.data()); |
| 25 | |
| 26 | { |
| 27 | // WHEN |
| 28 | lod->setThresholdType(Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSizeThreshold); |
| 29 | QCoreApplication::processEvents(); |
| 30 | |
| 31 | // THEN |
| 32 | QCOMPARE(arbiter.dirtyNodes().size(), 1); |
| 33 | QCOMPARE(arbiter.dirtyNodes().front(), lod.data()); |
| 34 | |
| 35 | arbiter.clear(); |
| 36 | } |
| 37 | |
| 38 | { |
| 39 | // WHEN |
| 40 | const QList<qreal> thresholds = { 10., 20., 30. }; |
| 41 | lod->setThresholds(thresholds); |
| 42 | QCoreApplication::processEvents(); |
| 43 | |
| 44 | // THEN |
| 45 | QCOMPARE(arbiter.dirtyNodes().size(), 1); |
| 46 | QCOMPARE(arbiter.dirtyNodes().front(), lod.data()); |
| 47 | |
| 48 | arbiter.clear(); |
| 49 | } |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | QTEST_MAIN(tst_QLevelOfDetail) |
| 54 | |
| 55 | #include "tst_qlevelofdetail.moc" |