aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-01-07 15:19:29 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-01-08 11:12:56 +0100
commit5cb8ca29c3815405d41d035f5f4ebb2af326a8ef (patch)
treea31bab609599cab55437c218775a20dae5677a3d /tests
parentbf10bf0331cb3d26e7f5f0bc9333acea1077273e (diff)
Allow importing protected modules with different major versions
This allows QtQuick.Controls 1.x and 2.x imports to co-exist even if they are two different plugins with the same module directive. Change-Id: Idee302439e3c2fd6813ba2f41b69144fbae7902c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp61
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/strictModule.2/qmldir2
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/strictModule.2/strictModule.2.pro13
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp21
5 files changed, 98 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
index 54acabe8eb..b715c6b82e 100644
--- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -10,6 +10,7 @@ SUBDIRS =\
pluginVersion\
nestedPlugin\
strictModule\
+ strictModule.2\
invalidStrictModule\
nonstrictModule\
preemptiveModule\
diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp
new file mode 100644
index 0000000000..75bcd04462
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent) {}
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ MyPlugin() {}
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "org.qtproject.StrictModule");
+ qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/qmldir
new file mode 100644
index 0000000000..26c408587d
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/qmldir
@@ -0,0 +1,2 @@
+module org.qtproject.StrictModule
+plugin strictModule
diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule.2/strictModule.2.pro b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/strictModule.2.pro
new file mode 100644
index 0000000000..14f3c59c21
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/strictModule.2.pro
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/org/qtproject/StrictModule.2
+
+QT += core-private gui-private qml-private
+
+IMPORT_FILES = \
+ qmldir
+
+include (../../../shared/imports.pri)
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index 0a8090ab07..6f4382f871 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -508,6 +508,27 @@ void tst_qqmlmoduleplugin::importStrictModule_data()
<< QString()
<< QString();
+ QTest::newRow("two strict modules with different major version")
+ << "import org.qtproject.StrictModule 1.0\n"
+ "import org.qtproject.StrictModule 2.0\n"
+ "MyPluginType {}"
+ << QString()
+ << QString();
+
+ QTest::newRow("old namespaced strict module")
+ << "import org.qtproject.StrictModule 1.0 as Old\n"
+ "import org.qtproject.StrictModule 2.0 as New\n"
+ "Old.MyPluginType {}"
+ << QString()
+ << QString();
+
+ QTest::newRow("new namespaced strict modules")
+ << "import org.qtproject.StrictModule 1.0 as Old\n"
+ "import org.qtproject.StrictModule 2.0 as New\n"
+ "New.MyPluginType {}"
+ << QString()
+ << QString();
+
QTest::newRow("wrong target")
<< "import org.qtproject.InvalidStrictModule 1.0\n"
"MyPluginType {}"