aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-08-08 16:31:50 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-09 07:58:06 +0200
commitaeb4a38ebcf9325423ef0259e70ee8bb11a5a30c (patch)
tree0dfa0fb1d4affc67b6a9261b7249d70635272681
parent42f9444e983b5257241c17242471ca63f208c3f6 (diff)
Change error messages to reflect new module terminology
Previously, modules which registered types into a protected type namespace were known as "strict" modules; now they are known as "identified" modules. This commit also adds a unit test to ensure that the module identifier directive is the first command in the qmldir file. Change-Id: I90e9d2c5b51ecb2b9d058c9fe9d9310fd3cd4f45 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
-rw-r--r--src/qml/qml/qqmldirparser.cpp6
-rw-r--r--src/qml/qml/qqmlimport.cpp6
-rw-r--r--tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp8
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/invalidFirstCommandModule.pro13
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp69
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/qmldir3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp26
8 files changed, 113 insertions, 21 deletions
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp
index 705f715a00..0bfc4eb4bd 100644
--- a/src/qml/qml/qqmldirparser.cpp
+++ b/src/qml/qml/qqmldirparser.cpp
@@ -150,17 +150,17 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("module")) {
if (sectionCount != 2) {
reportError(lineNumber, -1,
- QString::fromUtf8("module directive requires one argument, but %1 were provided").arg(sectionCount - 1));
+ QString::fromUtf8("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1));
continue;
}
if (!_typeNamespace.isEmpty()) {
reportError(lineNumber, -1,
- QString::fromUtf8("only one module directive may be defined in a qmldir file"));
+ QString::fromUtf8("only one module identifier directive may be defined in a qmldir file"));
continue;
}
if (!firstLine) {
reportError(lineNumber, -1,
- QString::fromUtf8("module directive must be the first directive in a qmldir file"));
+ QString::fromUtf8("module identifier directive must be the first command in a qmldir file"));
continue;
}
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 6475621bee..739492b3d3 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1655,7 +1655,7 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur
QWriteLocker lock(QQmlMetaType::typeRegistrationLock());
if (!typeNamespace.isEmpty()) {
- // This is a 'strict' module
+ // This is an 'identified' module
if (typeNamespace != uri) {
// The namespace for type registrations must match the URI for locating the module
QQmlError error;
@@ -1674,8 +1674,8 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur
QQmlMetaType::protectNamespace(typeNamespace);
}
} else {
- // This is not a stict module - provide a warning
- qWarning().nospace() << qPrintable(tr("Module '%1' does not contain a module directive - it cannot be protected from external registrations.").arg(uri));
+ // This is not an identified module - provide a warning
+ qWarning().nospace() << qPrintable(tr("Module '%1' does not contain a module identifier directive - it cannot be protected from external registrations.").arg(uri));
}
QQmlMetaType::setTypeRegistrationNamespace(typeNamespace);
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)