summaryrefslogtreecommitdiff
path: root/tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-05-25 16:49:42 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-11-26 15:56:59 +0100
commit96c1337aef41694c1af4863ad6f0d4d1f961363a (patch)
tree740efd456b0daa15445a3eab0f16b06b7fa23a47 /tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp
parenta3deb2ff59e7dce66da09d0287313575b34b291c (diff)
downloadqtdeclarative-96c1337aef41694c1af4863ad6f0d4d1f961363a.tar.gz
Support QML type registration split: build system + tools integration
This change addresses the following issue: - Module A wants to have an optional QML API without depending on declarative (e.g., because it has a C++ only API usable for Widgets based applications that normally would not link against declarative). - Thus we add a module B with all the QML support (type registration, maybe additional types/functions/image providers). - Currently, this would require to wrap every type from module A into QML_FOREIGN manually, adding large amounts of boilerplate. To solve this, we extend qmltyperegistrar and the CMake API: - qmltyperegistrar gains a new --extract option to generate a file with all QML_FOREIGN declarations. More precisely, it generates a header and source file; the source file includes the header and the moc generated file. - We expose this in cmake via a new qt6_generate_foreign_qml_types function. That function takes two targets, the source library's target and the QML module's target. It then runs qmltyperegistrar on the source library, and adds the generated files to the QML module's target, and adds the proper dependencies between the targets. The remaining step to achieve the goal of split registration is to provide the QML registration macros in a separate header. Task-number: QTBUG-92258 Change-Id: I51c4ef660ca7476b556b1991a6c76bbcad2c69af Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp')
-rw-r--r--tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp b/tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp
new file mode 100644
index 0000000000..55818aa9fd
--- /dev/null
+++ b/tests/auto/qml/qmlsplitlib/tst_qmlsplitlib.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QObject>
+#include <qtest.h>
+#include "lib.h"
+
+class tst_splitlib : public QObject
+{
+ Q_OBJECT
+private slots:
+ void verifyComponent();
+};
+
+void tst_splitlib::verifyComponent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QStringLiteral("qrc:/SplitLib/main.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer o(c.create());
+ QVERIFY(!o.isNull());
+ auto lib = qobject_cast<SplitLib *>(o.get());
+ QVERIFY(lib);
+}
+
+QTEST_MAIN(tst_splitlib)
+#include "tst_qmlsplitlib.moc"