summaryrefslogtreecommitdiffstats
path: root/tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp
blob: 4bcb39276bdf3f1e7bb35123ee53f39f043fa6fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QtTest/QTest>
#include <Qt3DExtras/QText2DEntity>
#include <Qt3DQuickExtras/qt3dquickwindow.h>
#include <Qt3DQuick/QQmlAspectEngine>
#include <Qt3DCore/private/qnode_p.h>

QList<Qt3DCore::QNode *>lookupNodeByClassName(Qt3DCore::QNode *root, const QString &className)
{
    auto children = root->childNodes();
    QList<Qt3DCore::QNode *> childrenList;
    for (auto i : children) {
        if (i->metaObject()->className() == className)
            childrenList << i;
        else
            childrenList << lookupNodeByClassName(i, className);
    }
    return childrenList;
}

class tst_qtext2dentity : public QObject
{
    Q_OBJECT

private slots:
    void checkChangeArbiter();
};

void tst_qtext2dentity::checkChangeArbiter()
{
    QSKIP("Skipping for now as creating windows with RHI on cross compiled targets seems to fail");

    // GIVEN
    Qt3DExtras::Quick::Qt3DQuickWindow view;
    view.setSource(QUrl("qrc:/qtext2dentity.qml"));
    view.show();
    QCoreApplication::processEvents();

    // THEN
    auto rootEntity = view.engine()->aspectEngine()->rootEntity();
    QVERIFY(rootEntity != nullptr);
    auto atlases = lookupNodeByClassName(rootEntity.data(), "Qt3DExtras::QTextureAtlas");
    QVERIFY(atlases.size() == 1);
    auto atlas = atlases[0];
    QVERIFY(Qt3DCore::QNodePrivate::get(atlas)->m_changeArbiter);
}

QTEST_MAIN(tst_qtext2dentity)
#include "tst_qtext2dentity.moc"