aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_common_import_path/main.cpp
blob: 5cc81b15739cd3b5c052e48c328817924a58ea5c (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0


#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtTest>

Q_IMPORT_QML_PLUGIN(duck_tickPlugin)
Q_IMPORT_QML_PLUGIN(duck_trickPlugin)
Q_IMPORT_QML_PLUGIN(duck_trackPlugin)

using namespace Qt::StringLiterals;

class test : public QObject
{
    Q_OBJECT
private slots:
    void test_loadable();
};

void test::test_loadable()
{
    QQmlEngine engine;
    engine.addImportPath(QStringLiteral(":/"));
    QQmlComponent c(&engine, QUrl(u"qrc:/duck/main.qml"_s));
    QVERIFY2(c.isReady(), qPrintable(c.errorString()));
    QScopedPointer<QObject> o(c.create());
    QVERIFY(!o.isNull());
    QCOMPARE(o->property("x1").toInt(), 5);
    QCOMPARE(o->property("x2").toInt(), 10);
}

QTEST_MAIN(test)

#include "main.moc"