aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp69
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/protectedModule/protectedModule.pro13
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/protectedModule/qmldir1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp21
5 files changed, 106 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp
new file mode 100644
index 0000000000..c960a69a9e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 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:LGPL$
+** 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 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, 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.
+**
+** 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#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)
+ {
+ // Because the module is protected, this plugin should never be loaded
+ Q_UNUSED(uri);
+ Q_ASSERT(0);
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/protectedModule/protectedModule.pro b/tests/auto/qml/qqmlmoduleplugin/protectedModule/protectedModule.pro
new file mode 100644
index 0000000000..749a440ca8
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/protectedModule/protectedModule.pro
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/org/qtproject/ProtectedModule
+
+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/protectedModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/protectedModule/qmldir
new file mode 100644
index 0000000000..8d121bb17b
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/protectedModule/qmldir
@@ -0,0 +1 @@
+plugin protectedModule
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
index 4806d34699..54acabe8eb 100644
--- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -15,7 +15,8 @@ SUBDIRS =\
preemptiveModule\
preemptedStrictModule\
invalidNamespaceModule\
- invalidFirstCommandModule
+ invalidFirstCommandModule\
+ protectedModule
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 ab8ff0e1a4..4379a90d47 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -80,6 +80,7 @@ private slots:
void importLocalModule_data();
void importStrictModule();
void importStrictModule_data();
+ void importProtectedModule();
private:
QString m_importsDirectory;
@@ -542,6 +543,26 @@ void tst_qqmlmoduleplugin::importStrictModule_data()
<< ":1:1: module identifier directive must be the first directive in a qmldir file";
}
+void tst_qqmlmoduleplugin::importProtectedModule()
+{
+ //TODO: More than basic test (test errors,test inverse works...)
+ qmlRegisterType<QObject>("org.qtproject.ProtectedModule", 1, 0, "TestType");
+ qmlProtectModule("org.qtproject.ProtectedModule", 1);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QUrl url(testFileUrl("empty.qml"));
+
+ QString qml = "import org.qtproject.ProtectedModule 1.0\n TestType {}\n";
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), url);
+ //If plugin is loaded due to import, should assert
+ QScopedPointer<QObject> object(component.create());
+ //qDebug() << component.errorString();
+ QVERIFY(object != 0);
+}
+
QTEST_MAIN(tst_qqmlmoduleplugin)
#include "tst_qqmlmoduleplugin.moc"