aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltyperegistrar
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-03-25 13:24:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-26 10:42:41 +0100
commit089b3ed0e440b454038a9d3cd6311f9dc189b699 (patch)
tree14c2161571b577040b4cd10c17d1ed713dd05142 /tests/auto/qml/qmltyperegistrar
parent8ab467835cdf590bcbc3a4d520f0e44dc8b457d9 (diff)
qmltyperegistrar: Accept extra foreign types files
If you add your own libraries with metatypes, qmake cannot determine where to look for their metatypes.json files. Add a qmake variable that allows the user to specify them. Fixes: QTBUG-82709 Change-Id: I3f5685146c134c89e541e4097ff3928de9af2aee Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltyperegistrar')
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp43
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.h52
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.pro10
-rw-r--r--tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro4
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp41
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h50
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro17
7 files changed, 217 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp b/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp
new file mode 100644
index 0000000000..db080a5cad
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "foreign.h"
+
+int Foreign::things() const
+{
+ return m_things;
+}
+
+void Foreign::setThings(int things)
+{
+ if (m_things == things)
+ return;
+
+ m_things = things;
+ emit thingsChanged(m_things);
+}
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.h b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
new file mode 100644
index 0000000000..d5e5a060b4
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+#ifndef FOREIGN_H
+#define FOREIGN_H
+
+#include <QtCore/qobject.h>
+
+class Foreign : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int things READ things WRITE setThings NOTIFY thingsChanged)
+
+public:
+ int things() const;
+
+public slots:
+ void setThings(int things);
+
+signals:
+ void thingsChanged(int things);
+
+private:
+ int m_things = 0;
+};
+
+#endif // FOREIGN_H
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
new file mode 100644
index 0000000000..87521eac43
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+QT = core
+
+macos:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+
+SOURCES = foreign.cpp
+HEADERS = foreign.h
+
+CONFIG += metatypes static
diff --git a/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro
new file mode 100644
index 0000000000..738d099123
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = foreign tst_qmltyperegistrar.pro
+
+tst_qmltyperegistrar_pro.depends = foreign
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
new file mode 100644
index 0000000000..e464820656
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "tst_qmltyperegistrar.h"
+#include <QtTest/qtest.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qfile.h>
+
+void tst_qmltyperegistrar::qmltypesHasForeign()
+{
+ QFile file(QCoreApplication::applicationDirPath() + "/tst_qmltyperegistrar.qmltypes");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.readAll().contains("things"));
+}
+
+QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
new file mode 100644
index 0000000000..1cfcd25102
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+#ifndef TST_QMLTYPEREGISTRAR_H
+#define TST_QMLTYPEREGISTRAR_H
+
+#include "foreign.h"
+
+#include <QtQml/qqml.h>
+
+class Local : public Foreign
+{
+ Q_OBJECT
+ QML_ELEMENT
+};
+
+class tst_qmltyperegistrar : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void qmltypesHasForeign();
+};
+
+#endif // TST_QMLTYPEREGISTRAR_H
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
new file mode 100644
index 0000000000..02c04dec47
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+
+QT = core qml testlib
+CONFIG += testcase qmltypes
+CONFIG -= debug_and_release_target
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qmltyperegistrar.cpp
+HEADERS += tst_qmltyperegistrar.h
+
+QMLTYPES_FILENAME = tst_qmltyperegistrar.qmltypes
+QML_FOREIGN_METATYPES += foreign/foreign_metatypes.json
+QML_IMPORT_NAME = QmlTypeRegistrarTest
+QML_IMPORT_VERSION = 1.0
+
+INCLUDEPATH += foreign
+LIBS += -Lforeign -lforeign