diff options
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin')
21 files changed, 605 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt index 9cafb78740..08492af787 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt @@ -1,3 +1,4 @@ 1:12:unexpected token -1:-1:expected '.' +1:-1:invalid qmldir directive contains too many tokens 2:17:unexpected token +2:-1:invalid qmldir directive contains too many tokens diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro new file mode 100644 index 0000000000..36b054064c --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/invalidNamespaceModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/InvalidNamespaceModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp new file mode 100644 index 0000000000..d682510153 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.InvalidStrictModule"); + qmlRegisterType<MyPluginType>("com.nokia.SomeOtherModule", 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir new file mode 100644 index 0000000000..5f349709f2 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/qmldir @@ -0,0 +1,2 @@ +module com.nokia.AwesomeModule +plugin invalidNamespaceModule diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro new file mode 100644 index 0000000000..7caa6c4605 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/invalidStrictModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/InvalidStrictModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp new file mode 100644 index 0000000000..d682510153 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.InvalidStrictModule"); + qmlRegisterType<MyPluginType>("com.nokia.SomeOtherModule", 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir new file mode 100644 index 0000000000..45752a9bca --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/qmldir @@ -0,0 +1,2 @@ +module com.nokia.InvalidStrictModule +plugin invalidStrictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro new file mode 100644 index 0000000000..e29578483b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/nonstrictModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/NonstrictModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp new file mode 100644 index 0000000000..73e1056d6f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.NonstrictModule"); + + // Install into a namespace that should be protected + qmlRegisterType<MyPluginType>("com.nokia.StrictModule", 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/qmldir new file mode 100644 index 0000000000..7371ee759f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/qmldir @@ -0,0 +1 @@ +plugin nonstrictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp new file mode 100644 index 0000000000..f7f7c77bb5 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.PreemptedStrictModule"); + qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro new file mode 100644 index 0000000000..76934e7657 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/preemptedStrictModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/PreemptedStrictModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir new file mode 100644 index 0000000000..c82acd2fd3 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/qmldir @@ -0,0 +1,2 @@ +module com.nokia.PreemptedStrictModule +plugin preemptedStrictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp new file mode 100644 index 0000000000..0b3dd78e79 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.PreemptiveModule"); + qmlRegisterType<MyPluginType>("com.nokia.PreemptiveModule", 1, 0, "MyPluginType"); + + // Install into another namespace that should be protected + qmlRegisterType<MyPluginType>("com.nokia.PreemptedStrictModule", 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro new file mode 100644 index 0000000000..e50c722543 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/preemptiveModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/PreemptiveModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/qmldir new file mode 100644 index 0000000000..d240cafac9 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/qmldir @@ -0,0 +1 @@ +plugin preemptiveModule diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro index 6da88320cd..c020ce955d 100644 --- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -1,6 +1,21 @@ QT = core TEMPLATE = subdirs -SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion nestedPlugin +SUBDIRS =\ + plugin\ + plugin.2\ + plugin.2.1\ + pluginWrongCase\ + pluginWithQmlFile\ + pluginMixed\ + pluginVersion\ + nestedPlugin\ + strictModule\ + invalidStrictModule\ + nonstrictModule\ + preemptiveModule\ + preemptedStrictModule\ + invalidNamespaceModule + tst_qqmlmoduleplugin_pro.depends += plugin SUBDIRS += tst_qqmlmoduleplugin.pro diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp new file mode 100644 index 0000000000..4bc8108901 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $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) == "com.nokia.StrictModule"); + qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir new file mode 100644 index 0000000000..ff06446fbd --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/qmldir @@ -0,0 +1,2 @@ +module com.nokia.StrictModule +plugin strictModule diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro b/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro new file mode 100644 index 0000000000..9c6d83f7a3 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/strictModule.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/StrictModule + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 67b3d00196..99e2874060 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -50,6 +50,10 @@ #define SERVER_ADDR "http://127.0.0.1:14456" #define SERVER_PORT 14456 +// Note: this test does not use module directives in the qmldir files, because +// it would result in repeated attempts to insert types into the same namespace. +// This occurs because type registration is process-global, while the test +// cases should really be run in proper per-process isolation. class tst_qqmlmoduleplugin : public QQmlDataTest { @@ -74,6 +78,8 @@ private slots: void importsNested_data(); void importLocalModule(); void importLocalModule_data(); + void importStrictModule(); + void importStrictModule_data(); private: QString m_importsDirectory; @@ -135,6 +141,7 @@ void tst_qqmlmoduleplugin::importsPlugin() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin created"); QTest::ignoreMessage(QtWarningMsg, "import worked"); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -151,6 +158,7 @@ void tst_qqmlmoduleplugin::importsPlugin2() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); QTest::ignoreMessage(QtWarningMsg, "import2 worked"); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -167,6 +175,7 @@ void tst_qqmlmoduleplugin::importsPlugin21() engine.addImportPath(m_importsDirectory); QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -215,6 +224,8 @@ void tst_qqmlmoduleplugin::importPluginWithQmlFile() QQmlEngine engine; engine.addImportPath(path); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestPluginWithQmlFile' does not contain a module directive - it cannot be protected from external registrations."); + QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -275,6 +286,8 @@ void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() QQmlEngine engine; engine.addImportPath(m_importsDirectory); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlMixedPluginType' does not contain a module directive - it cannot be protected from external registrations."); + { QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml"))); @@ -314,6 +327,10 @@ void tst_qqmlmoduleplugin::versionNotInstalled() QQmlEngine engine; engine.addImportPath(m_importsDirectory); + static int count = 0; + if (++count == 1) + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlVersionPluginType' does not contain a module directive - it cannot be protected from external registrations."); + QQmlComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(errorFile.toLatin1().constData()); } @@ -382,6 +399,10 @@ void tst_qqmlmoduleplugin::importsNested() QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); } + static int count = 0; + if (++count == 1) + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlNestedPluginType' does not contain a module directive - it cannot be protected from external registrations."); + QQmlComponent component(&engine, testFile(file)); QObject *obj = component.create(); @@ -446,6 +467,71 @@ void tst_qqmlmoduleplugin::importLocalModule_data() << 2 << 0; } +void tst_qqmlmoduleplugin::importStrictModule() +{ + QFETCH(QString, qml); + QFETCH(QString, warning); + QFETCH(QString, error); + + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + QUrl url(testFileUrl("empty.qml")); + + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), url); + + if (error.isEmpty()) { + QScopedPointer<QObject> object(component.create()); + QVERIFY(object != 0); + } else { + QVERIFY(!component.isReady()); + QCOMPARE(component.errors().count(), 1); + QCOMPARE(component.errors().first().toString(), url.toString() + error); + } +} + +void tst_qqmlmoduleplugin::importStrictModule_data() +{ + QTest::addColumn<QString>("qml"); + QTest::addColumn<QString>("warning"); + QTest::addColumn<QString>("error"); + + QTest::newRow("success") + << "import com.nokia.StrictModule 1.0\n" + "MyPluginType {}" + << QString() + << QString(); + + QTest::newRow("wrong target") + << "import com.nokia.InvalidStrictModule 1.0\n" + "MyPluginType {}" + << QString() + << ":1:1: plugin cannot be loaded for module \"com.nokia.InvalidStrictModule\": Cannot install element 'MyPluginType' into unregistered namespace 'com.nokia.SomeOtherModule'"; + + QTest::newRow("non-strict clash") + << "import com.nokia.NonstrictModule 1.0\n" + "MyPluginType {}" + << "Module 'com.nokia.NonstrictModule' does not contain a module directive - it cannot be protected from external registrations." + << ":1:1: plugin cannot be loaded for module \"com.nokia.NonstrictModule\": Cannot install element 'MyPluginType' into protected namespace 'com.nokia.StrictModule'"; + + QTest::newRow("non-strict preemption") + << "import com.nokia.PreemptiveModule 1.0\n" + "import com.nokia.PreemptedStrictModule 1.0\n" + "MyPluginType {}" + << "Module 'com.nokia.PreemptiveModule' does not contain a module directive - it cannot be protected from external registrations." + << ":2:1: plugin cannot be loaded for module \"com.nokia.PreemptedStrictModule\": Namespace 'com.nokia.PreemptedStrictModule' has already been used for type registration"; + + QTest::newRow("invalid namespace") + << "import com.nokia.InvalidNamespaceModule 1.0\n" + "MyPluginType {}" + << QString() + << ":1:1: plugin cannot be loaded for module \"com.nokia.InvalidNamespaceModule\": Module namespace 'com.nokia.AwesomeModule' does not match import URI 'com.nokia.InvalidNamespaceModule'"; +} + QTEST_MAIN(tst_qqmlmoduleplugin) #include "tst_qqmlmoduleplugin.moc" |