diff options
23 files changed, 425 insertions, 19 deletions
diff --git a/src/imports/models/qmldir b/src/imports/models/qmldir index 4afbe5de33..2dd20b923e 100644 --- a/src/imports/models/qmldir +++ b/src/imports/models/qmldir @@ -1,3 +1,4 @@ module QtQml.Models plugin modelsplugin classname QtQmlModelsPlugin +designersupported diff --git a/src/imports/qtquick2/qmldir b/src/imports/qtquick2/qmldir index 4a79c82e76..8167e813df 100644 --- a/src/imports/qtquick2/qmldir +++ b/src/imports/qtquick2/qmldir @@ -2,3 +2,4 @@ module QtQuick plugin qtquick2plugin classname QtQuick2Plugin typeinfo plugins.qmltypes +designersupported diff --git a/src/imports/window/qmldir b/src/imports/window/qmldir index c9d1e5ace3..fb6202b3bb 100644 --- a/src/imports/window/qmldir +++ b/src/imports/window/qmldir @@ -2,3 +2,4 @@ module QtQuick.Window plugin windowplugin classname QtQuick2WindowPlugin typeinfo plugins.qmltypes +designersupported diff --git a/src/imports/xmllistmodel/qmldir b/src/imports/xmllistmodel/qmldir index d6c10c5c2a..1f17dbb112 100644 --- a/src/imports/xmllistmodel/qmldir +++ b/src/imports/xmllistmodel/qmldir @@ -2,3 +2,4 @@ module QtQuick.XmlListModel plugin qmlxmllistmodelplugin classname QmlXmlListModelPlugin typeinfo plugins.qmltypes +designersupported diff --git a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc index ef6c8b1b67..a3ea25c005 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc +++ b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc @@ -221,6 +221,28 @@ typeinfo mymodule.qmltypes \code # this is a comment \endcode + + \row + \li designersupported + \li + \code + designersupported + \endcode + + \li Set this property if the plugin is supported by Qt Quick Designer. + By default, the plugin will not be supported. + + A plugin that is supported by Qt Quick Designer has to be properly + tested. This means that the plugin does not crash when running inside + the qml2puppet that is used by Qt Quick Designer to execute QML. + Generally the plugin should work well in the Qt Quick Designer + and not cause any show stoppers, like taking huge amounts of memory, + slowing down the qml2puppet heavily or anything else that renders + the plugin effectively unusable in the Qt Quick Designer. + + The items of an unsupported plugin are not painted in the Qt Quick Designer, + but they are still available as empty boxes and the properties can be edited. + \endtable Each command in a \c qmldir file must be on a separate line. diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 5f5f7d4a38..7068818f15 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -55,7 +55,7 @@ static int parseInt(const QStringRef &str, bool *ok) return number; } -QQmlDirParser::QQmlDirParser() +QQmlDirParser::QQmlDirParser() : _designerSupported(false) { } @@ -87,6 +87,7 @@ bool QQmlDirParser::parse(const QString &source) _plugins.clear(); _components.clear(); _scripts.clear(); + _designerSupported = false; quint16 lineNumber = 0; bool firstLine = true; @@ -225,6 +226,11 @@ bool QQmlDirParser::parse(const QString &source) _typeInfos.append(typeInfo); #endif + } else if (sections[0] == QLatin1String("designersupported")) { + if (sectionCount != 1) + reportError(lineNumber, 0, QString::fromLatin1("designersupported does not expect any argument")); + else + _designerSupported = true; } else if (sectionCount == 2) { // No version specified (should only be used for relative qmldir files) const Component entry(sections[0], sections[1], -1, -1); @@ -354,6 +360,11 @@ QList<QQmlDirParser::TypeInfo> QQmlDirParser::typeInfos() const } #endif +bool QQmlDirParser::designerSupported() const +{ + return _designerSupported; +} + QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component) { const QString output = QString::fromLatin1("{%1 %2.%3}"). diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index faede99afd..54843a13b0 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -121,6 +121,7 @@ public: QHash<QString,Component> components() const; QList<Script> scripts() const; QList<Plugin> plugins() const; + bool designerSupported() const; #ifdef QT_CREATOR struct TypeInfo @@ -144,6 +145,7 @@ private: QHash<QString,Component> _components; // multi hash QList<Script> _scripts; QList<Plugin> _plugins; + bool _designerSupported; #ifdef QT_CREATOR QList<TypeInfo> _typeInfos; #endif diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index da37b0a76e..141cd4acbf 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -64,6 +64,7 @@ static const QLatin1Char Colon(':'); static const QLatin1String Slash_qmldir("/qmldir"); static const QLatin1String String_qmldir("qmldir"); static const QString dotqml_string(QLatin1String(".qml")); +static bool designerSupportRequired = false; namespace { @@ -881,6 +882,16 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath, qDebug().nospace() << "QQmlImports(" << qPrintable(base) << ")::importExtension: " << "loaded " << qmldirFilePath; + if (designerSupportRequired && !qmldir->designerSupported()) { + if (errors) { + QQmlError error; + error.setDescription(QQmlImportDatabase::tr("module does not support the designer \"%1\"").arg(qmldir->typeNamespace())); + error.setUrl(QUrl::fromLocalFile(qmldirFilePath)); + errors->prepend(error); + } + return false; + } + int qmldirPluginCount = qmldir->plugins().count(); if (qmldirPluginCount == 0) return true; @@ -1539,6 +1550,11 @@ bool QQmlImports::isLocal(const QUrl &url) return QQmlFile::isBundle(url) || !QQmlFile::urlToLocalFileOrQrc(url).isEmpty(); } +void QQmlImports::setDesignerSupportRequired(bool b) +{ + designerSupportRequired = b; +} + /*! \class QQmlImportDatabase diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index de29318f60..26eab669bc 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -129,6 +129,8 @@ public: static bool isLocal(const QString &url); static bool isLocal(const QUrl &url); + static void setDesignerSupportRequired(bool b); + private: friend class QQmlImportDatabase; QQmlImportsPrivate *d; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 6913019562..0b7cc8e911 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1571,6 +1571,10 @@ QString QQmlTypeLoader::QmldirContent::pluginLocation() const return m_location; } +bool QQmlTypeLoader::QmldirContent::designerSupported() const +{ + return m_parser.designerSupported(); +} /*! Constructs a new type loader that uses the given \a engine. diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 3d3ad28091..9f98e4fd40 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -320,6 +320,8 @@ public: QString pluginLocation() const; + bool designerSupported() const; + private: QQmlDirParser m_parser; QString m_location; 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" |