| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QtTest/QTest> |
| 5 | #include <Qt3DExtras/QText2DEntity> |
| 6 | #include <Qt3DQuickExtras/qt3dquickwindow.h> |
| 7 | #include <Qt3DQuick/QQmlAspectEngine> |
| 8 | #include <Qt3DCore/private/qnode_p.h> |
| 9 | |
| 10 | QList<Qt3DCore::QNode *>lookupNodeByClassName(Qt3DCore::QNode *root, const QString &className) |
| 11 | { |
| 12 | auto children = root->childNodes(); |
| 13 | QList<Qt3DCore::QNode *> childrenList; |
| 14 | for (auto i : children) { |
| 15 | if (i->metaObject()->className() == className) |
| 16 | childrenList << i; |
| 17 | else |
| 18 | childrenList << lookupNodeByClassName(i, className); |
| 19 | } |
| 20 | return childrenList; |
| 21 | } |
| 22 | |
| 23 | class tst_qtext2dentity : public QObject |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | |
| 27 | private slots: |
| 28 | void checkChangeArbiter(); |
| 29 | }; |
| 30 | |
| 31 | void tst_qtext2dentity::checkChangeArbiter() |
| 32 | { |
| 33 | QSKIP("Skipping for now as creating windows with RHI on cross compiled targets seems to fail"); |
| 34 | |
| 35 | // GIVEN |
| 36 | Qt3DExtras::Quick::Qt3DQuickWindow view; |
| 37 | view.setSource(QUrl("qrc:/qtext2dentity.qml")); |
| 38 | view.show(); |
| 39 | QCoreApplication::processEvents(); |
| 40 | |
| 41 | // THEN |
| 42 | auto rootEntity = view.engine()->aspectEngine()->rootEntity(); |
| 43 | QVERIFY(rootEntity != nullptr); |
| 44 | auto atlases = lookupNodeByClassName(rootEntity.data(), "Qt3DExtras::QTextureAtlas"); |
| 45 | QVERIFY(atlases.size() == 1); |
| 46 | auto atlas = atlases[0]; |
| 47 | QVERIFY(Qt3DCore::QNodePrivate::get(atlas)->m_changeArbiter); |
| 48 | } |
| 49 | |
| 50 | QTEST_MAIN(tst_qtext2dentity) |
| 51 | #include "tst_qtext2dentity.moc" |