diff options
Diffstat (limited to 'tests/auto/qml')
6 files changed, 107 insertions, 15 deletions
diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index 82616ffa8a..3427a5f760 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -164,28 +164,28 @@ void tst_qqmldirparser::parse_data() QTest::newRow("incomplete-module") << "incomplete-module/qmldir" - << (QStringList() << "qmldir:1: module directive requires one argument, but 0 were provided") + << (QStringList() << "qmldir:1: module identifier directive requires one argument, but 0 were provided") << QStringList() << QStringList() << QStringList(); QTest::newRow("excessive-module") << "excessive-module/qmldir" - << (QStringList() << "qmldir:1: module directive requires one argument, but 2 were provided") + << (QStringList() << "qmldir:1: module identifier directive requires one argument, but 2 were provided") << QStringList() << QStringList() << QStringList(); QTest::newRow("repeated-module") << "repeated-module/qmldir" - << (QStringList() << "qmldir:2: only one module directive may be defined in a qmldir file") + << (QStringList() << "qmldir:2: only one module identifier directive may be defined in a qmldir file") << QStringList() << QStringList() << QStringList(); QTest::newRow("non-first-module") << "non-first-module/qmldir" - << (QStringList() << "qmldir:2: module directive must be the first directive in a qmldir file") + << (QStringList() << "qmldir:2: module identifier directive must be the first directive in a qmldir file") << (QStringList() << "foo|") << QStringList() << QStringList(); diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro new file mode 100644 index 0000000000..8e37a2d16b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/InvalidFirstCommandModule + +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/invalidFirstCommandModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp new file mode 100644 index 0000000000..74a1bb6802 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/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.InvalidFirstCommandModule"); + qmlRegisterType<MyPluginType>("com.nokia.InvalidFirstCommandModule", 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir new file mode 100644 index 0000000000..90b607e793 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir @@ -0,0 +1,3 @@ +plugin invalidNamespaceModule +module com.nokia.InvalidFirstCommandModule +# comment. diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro index c020ce955d..4806d34699 100644 --- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -14,7 +14,8 @@ SUBDIRS =\ nonstrictModule\ preemptiveModule\ preemptedStrictModule\ - invalidNamespaceModule + invalidNamespaceModule\ + invalidFirstCommandModule 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 99e2874060..66b1505f51 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -50,7 +50,7 @@ #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 +// Note: this test does not use module identifier 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. @@ -141,7 +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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -158,7 +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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -175,7 +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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); foreach (QQmlError err, component.errors()) qWarning() << err; @@ -224,7 +224,7 @@ 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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestPluginWithQmlFile' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml"))); foreach (QQmlError err, component.errors()) @@ -286,7 +286,7 @@ 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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlMixedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); { QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml"))); @@ -329,7 +329,7 @@ void tst_qqmlmoduleplugin::versionNotInstalled() 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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlVersionPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -401,7 +401,7 @@ void tst_qqmlmoduleplugin::importsNested() 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."); + QTest::ignoreMessage(QtWarningMsg, "Module 'com.nokia.AutoTestQmlNestedPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); QQmlComponent component(&engine, testFile(file)); QObject *obj = component.create(); @@ -515,14 +515,14 @@ void tst_qqmlmoduleplugin::importStrictModule_data() 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." + << "Module 'com.nokia.NonstrictModule' does not contain a module identifier 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." + << "Module 'com.nokia.PreemptiveModule' does not contain a module identifier 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") @@ -530,6 +530,12 @@ void tst_qqmlmoduleplugin::importStrictModule_data() "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::newRow("module directive must be first") + << "import com.nokia.InvalidFirstCommandModule 1.0\n" + "MyPluginType {}" + << QString() + << ":1:1: module identifier directive must be the first command in a qmldir file"; } QTEST_MAIN(tst_qqmlmoduleplugin) |