From 5f96bc07389382d534934120301c2d1a89d24657 Mon Sep 17 00:00:00 2001 From: Marco Benelli Date: Fri, 20 Nov 2015 17:14:25 +0100 Subject: qmlplugindump: add manual tests. Added a small test infrastructure in order to run tests on sample projects and quickly define new test cases. Running tests will also compile (and clean) sample tests. Change-Id: Ibd0e48201dafe335198479d605d676ca5b753566 Reviewed-by: Erik Verbruggen --- tests/manual/qmlplugindump/README | 42 +++ .../qmlplugindump/definitions/000_dummy.json | 5 + .../qmlplugindump/definitions/001_versions.json | 8 + .../qmlplugindump/definitions/002_revisions.json | 9 + tests/manual/qmlplugindump/qmlplugindump.pro | 8 + .../qmlplugindump/tests/dumper/Dummy/dummy.cpp | 49 +++ .../qmlplugindump/tests/dumper/Dummy/dummy.h | 49 +++ .../qmlplugindump/tests/dumper/Dummy/dummy.pro | 35 ++ .../tests/dumper/Dummy/dummy_plugin.cpp | 45 +++ .../tests/dumper/Dummy/dummy_plugin.h | 49 +++ .../manual/qmlplugindump/tests/dumper/Dummy/qmldir | 3 + .../tests/dumper/Imports/CompositeImports.qml | 5 + .../qmlplugindump/tests/dumper/Imports/imports.cpp | 49 +++ .../qmlplugindump/tests/dumper/Imports/imports.h | 49 +++ .../qmlplugindump/tests/dumper/Imports/imports.pro | 35 ++ .../tests/dumper/Imports/imports_plugin.cpp | 45 +++ .../tests/dumper/Imports/imports_plugin.h | 49 +++ .../qmlplugindump/tests/dumper/Imports/qmldir | 3 + .../tests/dumper/Singleton/CompositeSingleton.qml | 6 + .../qmlplugindump/tests/dumper/Singleton/qmldir | 2 + .../tests/dumper/Versions/plugin.qmltypes | 21 ++ .../qmlplugindump/tests/dumper/Versions/qmldir | 3 + .../tests/dumper/Versions/versions.cpp | 49 +++ .../qmlplugindump/tests/dumper/Versions/versions.h | 66 ++++ .../tests/dumper/Versions/versions.pro | 35 ++ .../tests/dumper/Versions/versions_plugin.cpp | 46 +++ .../tests/dumper/Versions/versions_plugin.h | 49 +++ tests/manual/qmlplugindump/tst_qmlplugindump.cpp | 376 +++++++++++++++++++++ 28 files changed, 1190 insertions(+) create mode 100644 tests/manual/qmlplugindump/README create mode 100644 tests/manual/qmlplugindump/definitions/000_dummy.json create mode 100644 tests/manual/qmlplugindump/definitions/001_versions.json create mode 100644 tests/manual/qmlplugindump/definitions/002_revisions.json create mode 100644 tests/manual/qmlplugindump/qmlplugindump.pro create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h create mode 100644 tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/imports.h create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h create mode 100644 tests/manual/qmlplugindump/tests/dumper/Imports/qmldir create mode 100644 tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml create mode 100644 tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/qmldir create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/versions.h create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp create mode 100644 tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h create mode 100644 tests/manual/qmlplugindump/tst_qmlplugindump.cpp (limited to 'tests/manual') diff --git a/tests/manual/qmlplugindump/README b/tests/manual/qmlplugindump/README new file mode 100644 index 0000000000..537afbba6e --- /dev/null +++ b/tests/manual/qmlplugindump/README @@ -0,0 +1,42 @@ +Tests for qmlplugindump +----------------------- + +The test are executed by compiling a series of sample projects and +running qmlplugindump on them, checking the generated plugin.qmltypes +files. Each test, except `builtins`, need a sample project in order +to be executed. A test is defined by: + + - test name + - sample project name + - sample project version + - expected results + +That means that different tests can use the same sample project, but +it is not possible to define a test that use more than one sample. +Test definitions are stored in the folder `definitions` as json files; +the file name is the test name, tests are executed in lexicographical +order on their names, and the contents defines the other properties in +the following format: + + { + "project": , + "version": , + "expected": [*], + } + +where _project-name_, _version_, and _regexp-patterns_ are strings. + +The first two parameters are used to invoke qmlplugindump: + + qmlplugindump -nonrelocatable + +where: + + = tests.dumper. + = + +therefore, it is important that the sample projects resides in +a subdirectory of `tests/dumper` named as the project itself. + +The last parameter is a list of regular expression patterns that +must match the `plugin.qmltypes` produced by qmlplugindump. diff --git a/tests/manual/qmlplugindump/definitions/000_dummy.json b/tests/manual/qmlplugindump/definitions/000_dummy.json new file mode 100644 index 0000000000..15f62bbc13 --- /dev/null +++ b/tests/manual/qmlplugindump/definitions/000_dummy.json @@ -0,0 +1,5 @@ +{ + "project": "Dummy", + "version": "1.0", + "expected": ["name: \"Dummy\""] +} diff --git a/tests/manual/qmlplugindump/definitions/001_versions.json b/tests/manual/qmlplugindump/definitions/001_versions.json new file mode 100644 index 0000000000..185057f90d --- /dev/null +++ b/tests/manual/qmlplugindump/definitions/001_versions.json @@ -0,0 +1,8 @@ +{ + "project": "Versions", + "version": "1.0", + "expected": [ + "name: \"Versions\"", + "tests\\.dumper\\.Versions/Versions 1\\.0" + ] +} diff --git a/tests/manual/qmlplugindump/definitions/002_revisions.json b/tests/manual/qmlplugindump/definitions/002_revisions.json new file mode 100644 index 0000000000..7f3d86ffe8 --- /dev/null +++ b/tests/manual/qmlplugindump/definitions/002_revisions.json @@ -0,0 +1,9 @@ +{ + "project": "Versions", + "version": "1.1", + "expected": [ + "name: \"Versions\"", + "tests\\.dumper\\.Versions/Versions 1\\.1", + "exportMetaObjectRevisions: \\[0, 1\\]" + ] +} diff --git a/tests/manual/qmlplugindump/qmlplugindump.pro b/tests/manual/qmlplugindump/qmlplugindump.pro new file mode 100644 index 0000000000..b072cdc0cf --- /dev/null +++ b/tests/manual/qmlplugindump/qmlplugindump.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qmlplugindump +QT += testlib gui-private +osx:CONFIG -= app_bundle +CONFIG += parallel_test + +SOURCES += tst_qmlplugindump.cpp +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp new file mode 100644 index 0000000000..cb5a01c231 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "dummy.h" + +Dummy::Dummy(QQuickItem *parent): + QQuickItem(parent) +{ + // By default, QQuickItem does not draw anything. If you subclass + // QQuickItem to create a visual item, you will need to uncomment the + // following line and re-implement updatePaintNode() + + // setFlag(ItemHasContents, true); +} + +Dummy::~Dummy() +{ +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h new file mode 100644 index 0000000000..a3a3fe5ee1 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DUMMY_H +#define DUMMY_H + +#include + +class Dummy : public QQuickItem +{ + Q_OBJECT + +public: + Dummy(QQuickItem *parent = 0); + ~Dummy(); +}; + +#endif // DUMMY_H + diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro new file mode 100644 index 0000000000..3e690d389f --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro @@ -0,0 +1,35 @@ +TEMPLATE = lib +TARGET = Dummy +QT += qml quick +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +uri = tests.dumper.Dummy + +# Input +SOURCES += \ + dummy_plugin.cpp \ + dummy.cpp + +HEADERS += \ + dummy_plugin.h \ + dummy.h + +DISTFILES = qmldir + +!equals(_PRO_FILE_PWD_, $$OUT_PWD) { + copy_qmldir.target = $$OUT_PWD/qmldir + copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir + copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_qmldir + PRE_TARGETDEPS += $$copy_qmldir.target +} + +qmldir.files = qmldir +unix { + installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) + qmldir.path = $$installPath + target.path = $$installPath + INSTALLS += target qmldir +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp new file mode 100644 index 0000000000..1596020334 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "dummy_plugin.h" +#include "dummy.h" + +#include + +void DummyPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.dummy + qmlRegisterType(uri, 1, 0, "Dummy"); +} + + diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h new file mode 100644 index 0000000000..8bb1a7bd16 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DUMMY_PLUGIN_H +#define DUMMY_PLUGIN_H + +#include + +class DummyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); +}; + +#endif // DUMMY_PLUGIN_H + diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir b/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir new file mode 100644 index 0000000000..a1b2e789ba --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir @@ -0,0 +1,3 @@ +module tests.dumper.Dummy +plugin Dummy + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml b/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml new file mode 100644 index 0000000000..b1055b6992 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 0 +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp new file mode 100644 index 0000000000..e4934065fc --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "imports.h" + +Imports::Imports(QQuickItem *parent): + QQuickItem(parent) +{ + // By default, QQuickItem does not draw anything. If you subclass + // QQuickItem to create a visual item, you will need to uncomment the + // following line and re-implement updatePaintNode() + + // setFlag(ItemHasContents, true); +} + +Imports::~Imports() +{ +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.h b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.h new file mode 100644 index 0000000000..77c63073da --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IMPORTS_H +#define IMPORTS_H + +#include + +class Imports : public QQuickItem +{ + Q_OBJECT + +public: + Imports(QQuickItem *parent = 0); + ~Imports(); +}; + +#endif // IMPORTS_H + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro new file mode 100644 index 0000000000..fe9caea13a --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro @@ -0,0 +1,35 @@ +TEMPLATE = lib +TARGET = Imports +QT += qml quick +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +uri = tests.dumper.Imports + +# Input +SOURCES += \ + imports_plugin.cpp \ + imports.cpp + +HEADERS += \ + imports_plugin.h \ + imports.h + +DISTFILES = qmldir + +!equals(_PRO_FILE_PWD_, $$OUT_PWD) { + copy_qmldir.target = $$OUT_PWD/qmldir + copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir + copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_qmldir + PRE_TARGETDEPS += $$copy_qmldir.target +} + +qmldir.files = qmldir +unix { + installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) + qmldir.path = $$installPath + target.path = $$installPath + INSTALLS += target qmldir +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp new file mode 100644 index 0000000000..c0ee61170d --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "imports_plugin.h" +#include "imports.h" + +#include + +void ImportsPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.imports + qmlRegisterType(uri, 1, 0, "Imports"); +} + + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h new file mode 100644 index 0000000000..e48dabd5e0 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IMPORTS_PLUGIN_H +#define IMPORTS_PLUGIN_H + +#include + +class ImportsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); +}; + +#endif // IMPORTS_PLUGIN_H + diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir b/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir new file mode 100644 index 0000000000..efab493dc8 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir @@ -0,0 +1,3 @@ +module tests.dumper.Imports +plugin Imports +CompositeImports 1.0 CompositeImports.qml diff --git a/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml b/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml new file mode 100644 index 0000000000..b47d2e98f4 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property int test: 0 +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir b/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir new file mode 100644 index 0000000000..dec4063fda --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir @@ -0,0 +1,2 @@ +module tests.dumper.Singleton +singleton CompositeSingleton 1.0 CompositeSingleton.qml diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes b/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes new file mode 100644 index 0000000000..0e09c2cfc7 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes @@ -0,0 +1,21 @@ +import QtQuick.tooling 1.2 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump tests.dumper.versions 1.1 .' + +Module { + dependencies: ["QtQuick 2.0"] + Component { + name: "Versions" + defaultProperty: "data" + prototype: "QQuickItem" + exports: ["Versions 1.0", "Versions 1.1"] + exportMetaObjectRevisions: [0, 1] + Property { name: "foo"; type: "int" } + Property { name: "bar"; revision: 1; type: "int" } + Property { name: "baz"; revision: 2; type: "int" } + } +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir b/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir new file mode 100644 index 0000000000..382225f517 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir @@ -0,0 +1,3 @@ +module tests.dumper.Versions +plugin Versions + diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp new file mode 100644 index 0000000000..ac2698aa53 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "versions.h" + +Versions::Versions(QQuickItem *parent): + QQuickItem(parent) +{ + // By default, QQuickItem does not draw anything. If you subclass + // QQuickItem to create a visual item, you will need to uncomment the + // following line and re-implement updatePaintNode() + + // setFlag(ItemHasContents, true); +} + +Versions::~Versions() +{ +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h new file mode 100644 index 0000000000..412f39f5d4 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VERSIONS_H +#define VERSIONS_H + +#include + +class Versions : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged) + Q_PROPERTY(int bar READ bar WRITE setBar NOTIFY barChanged REVISION 1) + Q_PROPERTY(int baz READ baz WRITE setBaz NOTIFY bazChanged REVISION 2) + +public: + Versions(QQuickItem *parent = 0); + ~Versions(); + int foo() const { return m_foo; } + void setFoo(int value) { m_foo = value; } + int bar() const { return m_bar; } + void setBar(int value) { m_bar = value; } + int baz() const { return m_baz; } + void setBaz(int value) { m_baz = value; } +signals: + void fooChanged(); + void barChanged(); + void bazChanged(); +private: + int m_foo; + int m_bar; + int m_baz; +}; + +#endif // VERSIONS_H + diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro new file mode 100644 index 0000000000..951f886368 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro @@ -0,0 +1,35 @@ +TEMPLATE = lib +TARGET = Versions +QT += qml quick +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +uri = tests.dumper.Versions + +# Input +SOURCES += \ + versions_plugin.cpp \ + versions.cpp + +HEADERS += \ + versions_plugin.h \ + versions.h + +DISTFILES = qmldir + +!equals(_PRO_FILE_PWD_, $$OUT_PWD) { + copy_qmldir.target = $$OUT_PWD/qmldir + copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir + copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_qmldir + PRE_TARGETDEPS += $$copy_qmldir.target +} + +qmldir.files = qmldir +unix { + installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) + qmldir.path = $$installPath + target.path = $$installPath + INSTALLS += target qmldir +} + diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp new file mode 100644 index 0000000000..33f59b7f78 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "versions_plugin.h" +#include "versions.h" + +#include + +void VersionsPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.versions + qmlRegisterType(uri, 1, 0, "Versions"); + qmlRegisterType(uri, 1, 1, "Versions"); +} + + diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h new file mode 100644 index 0000000000..8466f6ec63 --- /dev/null +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VERSIONS_PLUGIN_H +#define VERSIONS_PLUGIN_H + +#include + +class VersionsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); +}; + +#endif // VERSIONS_PLUGIN_H + diff --git a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp new file mode 100644 index 0000000000..8afe051618 --- /dev/null +++ b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + + +// System dependent definitions + +#if defined(Q_OS_WIN) + +static const char* systemMakeProgram = "jom"; +static const char* systemQmlplugindumpProgram = "qmlplugindump.exe"; + +static const QString libname(const QString &name) +{ + return name + QLatin1String(".dll"); +} + +#elif defined(Q_OS_DARWIN) + +static const char* systemMakeProgram = "make"; +static const char* systemQmlplugindumpProgram = "qmlplugindump"; + +static const QString libname(const QString &name) +{ + return QLatin1String("lib") + name + QLatin1String(".dynlib"); +} + +#else + +static const char* systemMakeProgram = "make"; +static const char* systemQmlplugindumpProgram = "qmlplugindump"; + +static const QString libname(const QString &name) +{ + return QLatin1String("lib") + name + QLatin1String(".so"); +} + +#endif + + +// Utilities + + +// Functor for matching a list of regular expression on a buffer. +// +class RegexpsChecker +{ +public: + RegexpsChecker(const QStringList &expected) : m_expected(expected) {} + bool operator()(const QByteArray &buffer) const + { + QRegularExpression re; + QRegularExpressionMatch m; + Q_FOREACH (const QString &e, m_expected) { + re.setPattern(e); + m = re.match(QString::fromLatin1(buffer)); + if (!m.hasMatch()) { + qWarning() << "Pattern not found: " << e; + return false; + } + } + return true; + } +private: + const QStringList m_expected; +}; + + +// Run an external process in given path and with given arguments, if presents. +// Optionally run a regexp check on the process standard output. +// +bool run(const QString &path, const QString &cmd, const QStringList &args=QStringList(), + const RegexpsChecker *checker=0) { + QProcess process; + process.setWorkingDirectory(path); + process.start(cmd, args); + process.waitForFinished(); + if (process.error() == QProcess::FailedToStart) { + qWarning() << cmd << args << "failed to start."; + return false; + } + if (process.error() == QProcess::Crashed) { + qWarning() << cmd << args << "crashed."; + return false; + } + if (process.exitStatus() != QProcess::NormalExit) { + qWarning() << cmd << args << "exited with code: " << process.exitCode(); + return false; + } + if (checker) + (*checker)(process.readAllStandardOutput()); + return true; +} + + +// Test Definition +// +// A test is defined by id, project, version and expected patterns that should +// match the output of qmlplugindump. +// +class Test +{ +public: + Test(const QString &testId) : id(testId) {} + Test(const QString &testId, const QString &prjName, const QString &prjVersion, + const QStringList &expectedResult) : + id(testId), project(prjName), version(prjVersion), expected(expectedResult) {} + QString id; + QString project; + QString version; + QStringList expected; + bool isNull() const + { + return project.isEmpty() || version.isEmpty(); + } + friend bool operator<(const Test &t1, const Test &t2) { return t1.id < t2.id; } +}; + + +// Create test from a json document. +// +// The json document must contains these fields: +// +// project: string +// version: string +// expected: [string*] +// +// qmlplugindumper will be invoked with these arguments: +// +// qmlplugindumper tests.dumper. +// +// PROJECT is the name of the sample project. It is used as a project name +// and as the last components of the URI: tests.dumper.; the project +// path must be ./test/dumper/. +// +// EXPECTED is a list of regular expression patterns that must match the +// plugin.qmltypes produced by qmlplugindump. +// +Test createTest(const QString &id, const QJsonObject &def) +{ + QJsonValue project = def.value(QLatin1String("project")); + QJsonValue version = def.value(QLatin1String("version")); + QJsonValue expected = def.value(QLatin1String("expected")); + if (!project.isString() || !version.isString() || !expected.isArray()){ + qWarning() << "Wrong definition for test: " << id << "."; + return Test(id); + } + QStringList patterns; + Q_FOREACH (const QJsonValue &x, expected.toArray()) { + if (!x.isString()) { + qWarning() << "Wrong definition for test: " << id << "."; + return Test(id); + } else { + patterns << x.toString(); + } + } + return Test(id, project.toString(), version.toString(), patterns); +} + +// Read a test definition from a file. +// +// The file must define a json document that `createTest' can understand. +// +Test readTestDefinition(const QFileInfo &file) +{ + const QString path = file.filePath(); + const QString id = file.baseName(); + QFile fd(path); + if (fd.open(QIODevice::ReadOnly)) { + QTextStream in(&fd); + QJsonParseError err; + QJsonDocument doc = QJsonDocument::fromJson(in.readAll().toLatin1(), &err); + fd.close(); + if (err.error != QJsonParseError::NoError) { + qWarning() << "Parse error in test \"" << id << "\":" << err.errorString(); + return Test(id); + } + QJsonObject obj = doc.object(); + return createTest(id, obj); + } + qWarning() << "Cannot open " << path << "."; + return Test(id); +} + +// Read all files in `path' as test definitions. +// +// Returns a list of tests sorted lexicographically. +// +QList readAllTestDefinitions(const QString &path) +{ + QList samples; + QDirIterator it(path, QDir::Files); + while (it.hasNext()) { + it.next(); + samples << readTestDefinition(it.fileInfo()); + } + std::sort(samples.begin(), samples.end()); + return samples; +} + + +// TEST SUITE + +class tst_qmlplugindump : public QObject +{ + Q_OBJECT +public: + tst_qmlplugindump(); + +private slots: + void initTestCase(); + void builtins(); + void plugin_data(); + void plugin(); + void cleanupTestCase(); + +private: + static const char *prefix; + QString dumper; + QList tests; + QString samplePath(const QString &name); + bool compileSample(const QString &name); + bool cleanUpSample(const QString &name); +}; + +const char *tst_qmlplugindump::prefix = "tests.dumper."; + +tst_qmlplugindump::tst_qmlplugindump() +{ +} + +QString tst_qmlplugindump::samplePath(const QString &name) +{ + return QCoreApplication::applicationDirPath() + + QLatin1Char('/') + + QString(QLatin1String(prefix)).replace(QRegularExpression(QLatin1String("\\.")), + QLatin1String("/")).append(name); +} + +bool tst_qmlplugindump::compileSample(const QString &name) +{ + const QString path = samplePath(name); + return run(path, QLatin1String("qmake")) + && run(path, QLatin1String(systemMakeProgram)); +} + +bool tst_qmlplugindump::cleanUpSample(const QString &name) +{ + const QString path = samplePath(name); + const QStringList args(QLatin1String("clean")); + if (!run(path, QLatin1String(systemMakeProgram), args)) + return false; + + const QString libfile = path + QLatin1Char('/') + libname(name); + + if (!QFile::remove(libfile)) { + qWarning() << "Cannot remove" << libfile << "."; + return false; + } + return true; +} + +void tst_qmlplugindump::initTestCase() +{ + dumper = QLibraryInfo::location(QLibraryInfo::BinariesPath); + tests = readAllTestDefinitions(QCoreApplication::applicationDirPath() + + QLatin1String("/definitions")); + + dumper += QLatin1Char('/') + QLatin1String(systemQmlplugindumpProgram); + + if (!QFileInfo(dumper).exists()) { + QString message = QString::fromLatin1("qmlplugindump executable not found (looked for %0)") + .arg(dumper); + QFAIL(qPrintable(message)); + } +} + +void tst_qmlplugindump::builtins() +{ + QStringList args; + args += QLatin1String("-builtins"); + RegexpsChecker check(QStringList(QLatin1String("Module {"))); + QString cwd = QCoreApplication::applicationDirPath(); + QVERIFY(run(cwd, dumper, args, &check)); +} + +void tst_qmlplugindump::plugin_data() +{ + QTest::addColumn("project"); + QTest::addColumn("version"); + QTest::addColumn("expected"); + + Q_FOREACH (const Test &t, tests) { + if (t.isNull()) + QSKIP("Errors in test definition."); + QTest::newRow(t.id.toLatin1().data()) << t.project << t.version << t.expected; + } +} + +void tst_qmlplugindump::plugin() +{ + QFETCH(QString, project); + QFETCH(QString, version); + QFETCH(QStringList, expected); + + QVERIFY(compileSample(project)); + + QStringList args; + QString url = QLatin1String("tests.dumper.") + project; + QString cwd = QCoreApplication::applicationDirPath(); + args << QLatin1String("-nonrelocatable") << url << version << cwd; + RegexpsChecker check(expected); + QVERIFY(run(cwd, dumper, args, &check)); +} + +void tst_qmlplugindump::cleanupTestCase() +{ + QSet projects; + Q_FOREACH (const Test &t, tests) + projects.insert(t.project); + Q_FOREACH (const QString &p, projects) { + if (!cleanUpSample(p)) + qWarning() << "Error in cleaning up project" << p << "."; + } +} + + +QTEST_MAIN(tst_qmlplugindump) + +#include "tst_qmlplugindump.moc" -- cgit v1.2.3