aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmoduleplugin
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-11 17:17:19 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-04-21 09:32:25 +0000
commit3c5e438890db63ecde98c84d221f87a3af52e1bf (patch)
tree883eb2d776db23cff8940478fd37fd9634d913a8 /tests/auto/qml/qqmlmoduleplugin
parente3f1f8fa3dd26c76ee157f17f3eec970981ec368 (diff)
Allow target path version in a parent module
For example, the QML Engine is now able to locate QtQml.Models 2.x in both of the following target/installation paths: - QT_INSTALL_QML/QtQml/Models.2 - QT_INSTALL_QML/QtQml.2/Models This is required for QtQuick Controls 2. The target path of the module is QT_INSTALL_QML/QtQuick/Controls.2. The built-in styles are installed as sub-directories to be able to locate them from the controls module. Some of the built-in styles provide their own C++ extensions via style- specific imports (eg. the Material attached property is imported from QtQuick.Controls.Material 2.0). The problem is that the QML Engine does not find the module from QT_INSTALL_QML/QtQuick/Controls.2/Material, but requires it to be installed outside the main controls module ie. QT_INSTALL_QML/QtQuick/Controls/Material(.2). This makes it a) hard to locate the styles from the main controls module, and b) conflicts with the target path of QtQuick Controls 1. [ChangeLog][QtQml] Made the QML Engine capable of locating QML sub- modules from within a versioned parent module path. For example, QtQml.Models 2.x can be either in QT_INSTALL_QML/QtQml/Models.2 or in QT_INSTALL_QML/QtQml.2/Models. Change-Id: I2fe4bbdd6d04dd1e80cbe9b3e7e02617658a0756 Task-number: QTBUG-52556 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/child.qml3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/child2.qml3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/child21.qml3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.cpp71
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.pro12
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/qmldir1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.cpp71
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.pro13
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/qmldir1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.cpp70
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.pro12
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/qmldir1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro5
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp54
14 files changed, 319 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/child.qml b/tests/auto/qml/qqmlmoduleplugin/data/child.qml
new file mode 100644
index 0000000000..a11ae297d7
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/child.qml
@@ -0,0 +1,3 @@
+import org.qtproject.AutoTestQmlPluginType.ChildPlugin 1.0
+
+MyChildPluginType { value: 123 }
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/child2.qml b/tests/auto/qml/qqmlmoduleplugin/data/child2.qml
new file mode 100644
index 0000000000..667164516a
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/child2.qml
@@ -0,0 +1,3 @@
+import org.qtproject.AutoTestQmlPluginType.ChildPlugin 2.0
+
+MyChildPluginType { valueOnlyIn2: 123 }
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/child21.qml b/tests/auto/qml/qqmlmoduleplugin/data/child21.qml
new file mode 100644
index 0000000000..064d5474e0
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/child21.qml
@@ -0,0 +1,3 @@
+import org.qtproject.AutoTestQmlPluginType.ChildPlugin 2.1
+
+MyChildPluginType { valueOnlyIn2: 123 }
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.cpp
new file mode 100644
index 0000000000..53247e7912
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyChildPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyChildPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("child import2.1 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyChildPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ MyChildPlugin()
+ {
+ qWarning("child plugin2.1 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType.ChildPlugin");
+ qmlRegisterType<MyChildPluginType>(uri, 2, 1, "MyChildPluginType");
+ }
+};
+
+#include "childplugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.pro
new file mode 100644
index 0000000000..7a0cd6f80f
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/childplugin.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += childplugin
+SOURCES = childplugin.cpp
+QT = core qml
+DESTDIR = ../../imports/org/qtproject/AutoTestQmlPluginType.2.1/ChildPlugin
+
+QT += core-private gui-private qml-private
+
+IMPORT_FILES = \
+ qmldir
+
+include (../../../../shared/imports.pri)
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/qmldir
new file mode 100644
index 0000000000..c8d6488065
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/childplugin/qmldir
@@ -0,0 +1 @@
+plugin childplugin
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.cpp
new file mode 100644
index 0000000000..a59347d3a9
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyChildPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyChildPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("child import2 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyChildPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ MyChildPlugin()
+ {
+ qWarning("child plugin2 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType.ChildPlugin");
+ qmlRegisterType<MyChildPluginType>(uri, 2, 0, "MyChildPluginType");
+ }
+};
+
+#include "childplugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.pro
new file mode 100644
index 0000000000..c9283411f3
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/childplugin.pro
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+CONFIG += childplugin
+SOURCES = childplugin.cpp
+QT = core qml
+DESTDIR = ../../imports/org/qtproject/AutoTestQmlPluginType.2/ChildPlugin
+
+QT += core-private gui-private qml-private
+
+IMPORT_DIR = DESTDIR
+IMPORT_FILES = \
+ qmldir
+
+include (../../../../shared/imports.pri)
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/qmldir
new file mode 100644
index 0000000000..c8d6488065
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/childplugin/qmldir
@@ -0,0 +1 @@
+plugin childplugin
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.cpp
new file mode 100644
index 0000000000..5f4f96f7e4
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyChildPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyChildPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("child import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyChildPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ MyChildPlugin()
+ {
+ qWarning("child plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType.ChildPlugin");
+ qmlRegisterType<MyChildPluginType>(uri, 1, 0, "MyChildPluginType");
+ }
+};
+
+#include "childplugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.pro
new file mode 100644
index 0000000000..5f5c01f77e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/childplugin.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += childplugin
+SOURCES = childplugin.cpp
+QT = core qml
+DESTDIR = ../../imports/org/qtproject/AutoTestQmlPluginType/ChildPlugin
+
+QT += core-private gui-private qml-private
+
+IMPORT_FILES = \
+ qmldir
+
+include (../../../../shared/imports.pri)
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/qmldir
new file mode 100644
index 0000000000..c8d6488065
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/childplugin/qmldir
@@ -0,0 +1 @@
+plugin childplugin
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
index 5c30d8cc00..889968f6cc 100644
--- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -17,7 +17,10 @@ SUBDIRS =\
preemptedStrictModule\
invalidNamespaceModule\
invalidFirstCommandModule\
- protectedModule
+ protectedModule\
+ plugin/childplugin\
+ plugin.2/childplugin\
+ plugin.2.1/childplugin
tst_qqmlmoduleplugin_pro.depends += plugin
SUBDIRS += tst_qqmlmoduleplugin.pro
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index 6ae1a6654f..265492b435 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -70,6 +70,9 @@ private slots:
void importStrictModule();
void importStrictModule_data();
void importProtectedModule();
+ void importsChildPlugin();
+ void importsChildPlugin2();
+ void importsChildPlugin21();
private:
QString m_importsDirectory;
@@ -575,6 +578,57 @@ void tst_qqmlmoduleplugin::importProtectedModule()
QVERIFY(object != 0);
}
+void tst_qqmlmoduleplugin::importsChildPlugin()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "child plugin created");
+ QTest::ignoreMessage(QtWarningMsg, "child import worked");
+ QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType.ChildPlugin' does not contain a module identifier directive - it cannot be protected from external registrations.");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("child.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsChildPlugin2()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "child plugin2 created");
+ QTest::ignoreMessage(QtWarningMsg, "child import2 worked");
+ QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType.ChildPlugin' does not contain a module identifier directive - it cannot be protected from external registrations.");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("child2.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsChildPlugin21()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "child plugin2.1 created");
+ QTest::ignoreMessage(QtWarningMsg, "child import2.1 worked");
+ QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType.ChildPlugin' does not contain a module identifier directive - it cannot be protected from external registrations.");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("child21.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlmoduleplugin)
#include "tst_qqmlmoduleplugin.moc"