aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qml.pro3
-rw-r--r--tests/auto/qml/qqmldirparser/data/designersupported-no/qmldir2
-rw-r--r--tests/auto/qml/qqmldirparser/data/designersupported-yes/qmldir2
-rw-r--r--tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp70
-rw-r--r--tests/auto/qml/qqmlimport/MyPluginSupported/MyItem.qml45
-rw-r--r--tests/auto/qml/qqmlimport/MyPluginSupported/qmldir3
-rw-r--r--tests/auto/qml/qqmlimport/MyPluginUnsupported/MyItem.qml45
-rw-r--r--tests/auto/qml/qqmlimport/MyPluginUnsupported/qmldir2
-rw-r--r--tests/auto/qml/qqmlimport/data/testfile_supported.qml48
-rw-r--r--tests/auto/qml/qqmlimport/data/testfile_unsupported.qml48
-rw-r--r--tests/auto/qml/qqmlimport/qqmlimport.pro11
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp100
12 files changed, 361 insertions, 18 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index c909a2d35a..ea15b5f495 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -58,7 +58,8 @@ PRIVATETESTS += \
qv4debugger \
qqmlenginecleanup \
v4misc \
- qqmltranslation
+ qqmltranslation \
+ qqmlimport
qtHaveModule(widgets) {
PUBLICTESTS += \
diff --git a/tests/auto/qml/qqmldirparser/data/designersupported-no/qmldir b/tests/auto/qml/qqmldirparser/data/designersupported-no/qmldir
new file mode 100644
index 0000000000..3b660e8c36
--- /dev/null
+++ b/tests/auto/qml/qqmldirparser/data/designersupported-no/qmldir
@@ -0,0 +1,2 @@
+plugin foo
+
diff --git a/tests/auto/qml/qqmldirparser/data/designersupported-yes/qmldir b/tests/auto/qml/qqmldirparser/data/designersupported-yes/qmldir
new file mode 100644
index 0000000000..2e86aca298
--- /dev/null
+++ b/tests/auto/qml/qqmldirparser/data/designersupported-yes/qmldir
@@ -0,0 +1,2 @@
+plugin foo
+designersupported
diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
index 0984da2e1e..017a92b590 100644
--- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
+++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
@@ -125,118 +125,135 @@ void tst_qqmldirparser::parse_data()
QTest::addColumn<QStringList>("plugins");
QTest::addColumn<QStringList>("components");
QTest::addColumn<QStringList>("scripts");
+ QTest::addColumn<bool>("designerSupported");
QTest::newRow("empty")
<< "empty/qmldir"
<< QStringList()
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("no-content")
<< "no-content/qmldir"
<< QStringList()
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("one-section")
<< "one-section/qmldir"
<< (QStringList() << "qmldir:1: a component declaration requires two or three arguments, but 1 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("four-sections")
<< "four-sections/qmldir"
<< (QStringList() << "qmldir:1: a component declaration requires two or three arguments, but 4 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("incomplete-module")
<< "incomplete-module/qmldir"
<< (QStringList() << "qmldir:1: module identifier directive requires one argument, but 0 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("excessive-module")
<< "excessive-module/qmldir"
<< (QStringList() << "qmldir:1: module identifier directive requires one argument, but 2 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("repeated-module")
<< "repeated-module/qmldir"
<< (QStringList() << "qmldir:2: only one module identifier directive may be defined in a qmldir file")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("non-first-module")
<< "non-first-module/qmldir"
<< (QStringList() << "qmldir:2: module identifier directive must be the first directive in a qmldir file")
<< (QStringList() << "foo|")
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("incomplete-plugin")
<< "incomplete-plugin/qmldir"
<< (QStringList() << "qmldir:1: plugin directive requires one or two arguments, but 0 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("excessive-plugin")
<< "excessive-plugin/qmldir"
<< (QStringList() << "qmldir:1: plugin directive requires one or two arguments, but 3 were provided")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("name-plugin")
<< "name-plugin/qmldir"
<< QStringList()
<< (QStringList() << "foo|")
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("name-path-plugin")
<< "name-path-plugin/qmldir"
<< QStringList()
<< (QStringList() << "foo|bar")
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("unversioned-component")
<< "unversioned-component/qmldir"
<< QStringList()
<< QStringList()
<< (QStringList() << "foo|bar|-1|-1|false")
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("invalid-versioned-component")
<< "invalid-versioned-component/qmldir"
<< (QStringList() << "qmldir:1: expected '.'")
<< QStringList()
<< QStringList()
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("versioned-component")
<< "versioned-component/qmldir"
<< QStringList()
<< QStringList()
<< (QStringList() << "foo|bar|33|66|false")
- << QStringList();
+ << QStringList()
+ << false;
QTest::newRow("versioned-script")
<< "versioned-script/qmldir"
<< QStringList()
<< QStringList()
<< QStringList()
- << (QStringList() << "foo|bar.js|33|66");
+ << (QStringList() << "foo|bar.js|33|66")
+ << false;
QTest::newRow("multiple")
<< "multiple/qmldir"
@@ -245,7 +262,24 @@ void tst_qqmldirparser::parse_data()
<< (QStringList() << "ComponentA|componenta-1_0.qml|1|0|false"
<< "ComponentA|componenta-1_5.qml|1|5|false"
<< "ComponentB|componentb-1_5.qml|1|5|false")
- << (QStringList() << "ScriptA|scripta-1_0.js|1|0");
+ << (QStringList() << "ScriptA|scripta-1_0.js|1|0")
+ << false;
+
+ QTest::newRow("designersupported-yes")
+ << "designersupported-yes/qmldir"
+ << QStringList()
+ << (QStringList() << "foo|")
+ << QStringList()
+ << QStringList()
+ << true;
+
+ QTest::newRow("designersupported-no")
+ << "designersupported-no/qmldir"
+ << QStringList()
+ << (QStringList() << "foo|")
+ << QStringList()
+ << QStringList()
+ << false;
}
void tst_qqmldirparser::parse()
@@ -255,6 +289,7 @@ void tst_qqmldirparser::parse()
QFETCH(QStringList, plugins);
QFETCH(QStringList, components);
QFETCH(QStringList, scripts);
+ QFETCH(bool, designerSupported);
QFile f(testFile(file));
f.open(QIODevice::ReadOnly);
@@ -272,6 +307,7 @@ void tst_qqmldirparser::parse()
QCOMPARE(toStringList(p.plugins()), plugins);
QCOMPARE(toStringList(p.components()), components);
QCOMPARE(toStringList(p.scripts()), scripts);
+ QCOMPARE(p.designerSupported(), designerSupported);
}
QTEST_MAIN(tst_qqmldirparser)
diff --git a/tests/auto/qml/qqmlimport/MyPluginSupported/MyItem.qml b/tests/auto/qml/qqmlimport/MyPluginSupported/MyItem.qml
new file mode 100644
index 0000000000..8b399b2d14
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/MyPluginSupported/MyItem.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+}
diff --git a/tests/auto/qml/qqmlimport/MyPluginSupported/qmldir b/tests/auto/qml/qqmlimport/MyPluginSupported/qmldir
new file mode 100644
index 0000000000..893e2892da
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/MyPluginSupported/qmldir
@@ -0,0 +1,3 @@
+module MyPluginSupported
+MyItem 1.0 MyItem.qml
+designersupported
diff --git a/tests/auto/qml/qqmlimport/MyPluginUnsupported/MyItem.qml b/tests/auto/qml/qqmlimport/MyPluginUnsupported/MyItem.qml
new file mode 100644
index 0000000000..515899cc2c
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/MyPluginUnsupported/MyItem.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+}
diff --git a/tests/auto/qml/qqmlimport/MyPluginUnsupported/qmldir b/tests/auto/qml/qqmlimport/MyPluginUnsupported/qmldir
new file mode 100644
index 0000000000..94d38f08b3
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/MyPluginUnsupported/qmldir
@@ -0,0 +1,2 @@
+module MyPluginUnsupported
+MyItem 1.0 MyItem.qml
diff --git a/tests/auto/qml/qqmlimport/data/testfile_supported.qml b/tests/auto/qml/qqmlimport/data/testfile_supported.qml
new file mode 100644
index 0000000000..be6dea0df9
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/testfile_supported.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import MyPluginSupported 1.0
+
+Item {
+ width: 400
+ height: 400
+}
diff --git a/tests/auto/qml/qqmlimport/data/testfile_unsupported.qml b/tests/auto/qml/qqmlimport/data/testfile_unsupported.qml
new file mode 100644
index 0000000000..584c81db87
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/testfile_unsupported.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import MyPluginUnsupported 1.0
+
+Item {
+ width: 400
+ height: 400
+}
diff --git a/tests/auto/qml/qqmlimport/qqmlimport.pro b/tests/auto/qml/qqmlimport/qqmlimport.pro
new file mode 100644
index 0000000000..6c99c00570
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/qqmlimport.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmlimport
+QT += qml testlib qml-private quick
+osx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlimport.cpp
+
+include (../../shared/util.pri)
+
+CONFIG += parallel_test
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
new file mode 100644
index 0000000000..bd29b8f18b
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 <QtTest/QtTest>
+#include <QQmlApplicationEngine>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+#include <private/qqmlimport_p.h>
+#include "../../shared/util.h"
+
+class tst_QQmlImport : public QQmlDataTest
+{
+ Q_OBJECT
+
+private slots:
+ void testDesignerSupported();
+ void cleanup();
+};
+
+void tst_QQmlImport::cleanup()
+{
+ QQmlImports::setDesignerSupportRequired(false);
+}
+
+void tst_QQmlImport::testDesignerSupported()
+{
+ QQuickView *window = new QQuickView();
+ window->engine()->addImportPath(QT_TESTCASE_BUILDDIR);
+
+ window->setSource(testFileUrl("testfile_supported.qml"));
+ QVERIFY(window->errors().isEmpty());
+
+ window->setSource(testFileUrl("testfile_unsupported.qml"));
+ QVERIFY(window->errors().isEmpty());
+
+ QQmlImports::setDesignerSupportRequired(true);
+
+ //imports are cached so we create a new window
+ delete window;
+ window = new QQuickView();
+
+ window->engine()->addImportPath(QT_TESTCASE_BUILDDIR);
+ window->engine()->clearComponentCache();
+
+ window->setSource(testFileUrl("testfile_supported.qml"));
+ QVERIFY(window->errors().isEmpty());
+
+ QString warningString("%1:43:1: module does not support the designer \"MyPluginUnsupported\" \n import MyPluginUnsupported 1.0\r \n ^ ");
+#ifndef Q_OS_WIN
+ warningString.remove('\r');
+#endif
+ warningString = warningString.arg(testFileUrl("testfile_unsupported.qml").toString());
+ QTest::ignoreMessage(QtWarningMsg, warningString.toAscii());
+ window->setSource(testFileUrl("testfile_unsupported.qml"));
+ QVERIFY(!window->errors().isEmpty());
+
+ delete window;
+}
+
+QTEST_MAIN(tst_QQmlImport)
+
+#include "tst_qqmlimport.moc"