diff options
Diffstat (limited to 'tests')
40 files changed, 1637 insertions, 6 deletions
diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml new file mode 100644 index 0000000000..b47d2e98f4 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property int test: 0 +} diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir new file mode 100644 index 0000000000..8df57f6d47 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir @@ -0,0 +1,3 @@ +module tests.dumper.CompositeSingleton +singleton Singleton 1.0 Singleton.qml +depends QtQuick 2.0 diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 28d687bd1c..eb05e8cde7 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -47,6 +47,7 @@ public: private slots: void initTestCase(); void builtins(); + void singleton(); private: QString qmlplugindumpPath; @@ -102,6 +103,19 @@ void tst_qmlplugindump::builtins() QVERIFY(result.contains(QLatin1String("Module {"))); } +void tst_qmlplugindump::singleton() +{ + QProcess dumper; + QStringList args; + args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") + << QLatin1String("."); + dumper.start(qmlplugindumpPath, args); + dumper.waitForFinished(); + + const QString &result = dumper.readAllStandardOutput(); + QVERIFY(result.contains(QLatin1String("exports: [\"Singleton 1.0\"]"))); +} + QTEST_MAIN(tst_qmlplugindump) #include "tst_qmlplugindump.moc" diff --git a/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml b/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml new file mode 100644 index 0000000000..f2c378e4b5 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/animatorInvalidTargetCrash.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQuick module 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$ +** +****************************************************************************/ + +import QtQuick 2.3 +import QtQuick.Window 2.2 + +Window { + visible: true + width: 100 + height: 100 + + OpacityAnimator { + id: anim + from: 1 + to:0 + duration: 5000 + running: false + } + + Loader { + id: loader + sourceComponent: Text { + text: "Hello World" + anchors.centerIn: parent + } + } + + Component.onCompleted: { + anim.target = loader.item; + anim.start(); + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml b/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml new file mode 100644 index 0000000000..94692add60 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/defaultRotationAnimation.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + id: rect + + RotationAnimation { + target: rect + from: 0 + to: 360 + running: true + duration: 1000 + loops: Animation.Infinite + } +} diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index 2b805e9eeb..5cad68b275 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -104,6 +104,8 @@ private slots: void scriptActionBug(); void groupAnimationNullChildBug(); void scriptActionCrash(); + void animatorInvalidTargetCrash(); + void defaultPropertyWarning(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1491,7 +1493,40 @@ void tst_qquickanimations::scriptActionCrash() delete obj; } +// QTBUG-49364 +// Test that we don't crash when the target of an Animator becomes +// invalid between the time the animator is started and the time the +// animator job is actually started +void tst_qquickanimations::animatorInvalidTargetCrash() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("animatorInvalidTargetCrash.qml")); + QObject *obj = c.create(); + + //just testing that we don't crash + QTest::qWait(5000); //animator duration + + delete obj; +} + +Q_DECLARE_METATYPE(QList<QQmlError>) +// QTBUG-22141 +void tst_qquickanimations::defaultPropertyWarning() +{ + QQmlEngine engine; + + qRegisterMetaType<QList<QQmlError> >(); + + QSignalSpy warnings(&engine, SIGNAL(warnings(QList<QQmlError>))); + QVERIFY(warnings.isValid()); + + QQmlComponent component(&engine, testFileUrl("defaultRotationAnimation.qml")); + QScopedPointer<QQuickItem> root(qobject_cast<QQuickItem*>(component.create())); + QVERIFY(root); + + QVERIFY(warnings.isEmpty()); +} QTEST_MAIN(tst_qquickanimations) diff --git a/tests/auto/quick/qquicklistview/data/qtbug48870.qml b/tests/auto/quick/qquicklistview/data/qtbug48870.qml new file mode 100644 index 0000000000..217f58af48 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/qtbug48870.qml @@ -0,0 +1,24 @@ +import QtQuick 2.6 + +Rectangle { + width: 500 + height: 500 + color: "blue" + + ListView { + objectName: "list" + anchors.fill: parent + model: testModel + + delegate: Rectangle { + height: 50 + width: ListView.view ? ListView.view.width : height + color: "green" + + Text { + anchors.centerIn: parent + text: "Item " + index + } + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ad6c6ec12d..86add7435c 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -40,6 +40,7 @@ #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlexpression.h> #include <QtQml/qqmlincubator.h> +#include <QtQuick/private/qquickitemview_p_p.h> #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQml/private/qqmlobjectmodel_p.h> @@ -249,6 +250,7 @@ private slots: void contentHeightWithDelayRemove_data(); void QTBUG_48044_currentItemNotVisibleAfterTransition(); + void QTBUG_48870_fastModelUpdates(); void keyNavigationEnabled(); @@ -592,8 +594,7 @@ void tst_QQuickListView::inserted(const QUrl &source) QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0); QVERIFY(item); - QCOMPARE(item->y(), 0.); - QTRY_COMPARE(listview->contentY(), qreal(0)); + QTRY_COMPARE(item->y() - listview->contentY(), 0.); delete window; delete testObject; @@ -644,7 +645,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QTRY_COMPARE(listview->property("count").toInt(), model.count()); - + // FIXME This is NOT checking anything about visibleItems.first() +#if 0 // check visibleItems.first() is in correct position QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0); QVERIFY(item0); @@ -652,6 +654,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QCOMPARE(item0->y(), -item0->height() - itemsOffsetAfterMove); else QCOMPARE(item0->y(), itemsOffsetAfterMove); +#endif QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; @@ -667,12 +670,21 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v // Confirm items positioned correctly and indexes correct QQuickText *name; QQuickText *number; + const qreal visibleFromPos = listview->contentY() - listview->displayMarginBeginning() - listview->cacheBuffer(); + const qreal visibleToPos = listview->contentY() + listview->height() + listview->displayMarginEnd() + listview->cacheBuffer(); for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); qreal pos = i*20.0 + itemsOffsetAfterMove; if (verticalLayoutDirection == QQuickItemView::BottomToTop) - pos = -item0->height() - pos; + pos = -item->height() - pos; + // Items outside the visible area (including cache buffer) should be skipped + if (pos > visibleToPos || pos < visibleFromPos) { + QTRY_VERIFY2(QQuickItemPrivate::get(item)->culled || item->y() < visibleFromPos || item->y() > visibleToPos, + QTest::toString(QString("index %5, y %1, from %2, to %3, expected pos %4, culled %6"). + arg(item->y()).arg(visibleFromPos).arg(visibleToPos).arg(pos).arg(i).arg(bool(QQuickItemPrivate::get(item)->culled)))); + continue; + } QTRY_COMPARE(item->y(), pos); name = findItem<QQuickText>(contentItem, "textName", i); QVERIFY(name != 0); @@ -8363,6 +8375,136 @@ void tst_QQuickListView::keyNavigationEnabled() QCOMPARE(listView->currentIndex(), 1); } +static bool testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx) +{ + QHash<QQuickItem*, int> uniqueItems; + + int skip = 0; + for (int i = 0; i < priv->visibleItems.count(); ++i) { + FxViewItem *item = priv->visibleItems.at(i); + if (!item) { + *failItem = Q_NULLPTR; + return false; + } +#if 0 + qDebug() << "\t" << item->index + << item->item + << item->position() + << (!item->item || QQuickItemPrivate::get(item->item)->culled ? "hidden" : "visible"); +#endif + if (item->index == -1) { + ++skip; + } else if (item->index != priv->visibleIndex + i - skip) { + *nonUnique = false; + *failItem = item; + *expectedIdx = priv->visibleIndex + i - skip; + return false; + } else if (uniqueItems.contains(item->item)) { + *nonUnique = true; + *failItem = item; + *expectedIdx = uniqueItems.find(item->item).value(); + return false; + } + + uniqueItems.insert(item->item, item->index); + } + + return true; +} + +class QTBUG_48870_Model : public QAbstractListModel +{ + Q_OBJECT + +public: + + QTBUG_48870_Model() + : QAbstractListModel() + , m_rowCount(20) + { + QTimer *t = new QTimer(this); + t->setInterval(500); + t->start(); + + qsrand(qHash(QDateTime::currentDateTime())); + connect(t, &QTimer::timeout, this, &QTBUG_48870_Model::updateModel); + } + + int rowCount(const QModelIndex &) const + { + return m_rowCount; + } + + QVariant data(const QModelIndex &, int) const + { + return QVariant(); + } + +public Q_SLOTS: + void updateModel() + { + if (m_rowCount > 10) { + for (int i = 0; i < 10; ++i) { + int rnum = qrand() % m_rowCount; + beginRemoveRows(QModelIndex(), rnum, rnum); + m_rowCount--; + endRemoveRows(); + } + } + if (m_rowCount < 20) { + for (int i = 0; i < 10; ++i) { + int rnum = qrand() % m_rowCount; + beginInsertRows(QModelIndex(), rnum, rnum); + m_rowCount++; + endInsertRows(); + } + } + } + +private: + int m_rowCount; +}; + +void tst_QQuickListView::QTBUG_48870_fastModelUpdates() +{ + QTBUG_48870_Model model; + + QQuickView *window = createView(); + QVERIFY(window); + QQmlContext *ctxt = window->rootContext(); + QVERIFY(ctxt); + ctxt->setContextProperty("testModel", &model); + + window->setSource(testFileUrl("qtbug48870.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItemViewPrivate *priv = QQuickItemViewPrivate::get(listview); + bool nonUnique; + FxViewItem *item = Q_NULLPTR; + int expectedIdx; + QVERIFY(testVisibleItems(priv, &nonUnique, &item, &expectedIdx)); + + for (int i = 0; i < 10; i++) { + QTest::qWait(100); + QVERIFY2(testVisibleItems(priv, &nonUnique, &item, &expectedIdx), + qPrintable(!item ? QString("Unexpected null item") + : nonUnique ? QString("Non-unique item at %1 and %2").arg(item->index).arg(expectedIdx) + : QString("Found index %1, expected index is %3").arg(item->index).arg(expectedIdx))); + if (i % 3 != 0) { + if (i & 1) + flick(window, QPoint(100, 200), QPoint(100, 0), 100); + else + flick(window, QPoint(100, 200), QPoint(100, 400), 100); + } + } + + delete window; +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index c7de73da88..7f454aaa11 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -286,6 +286,9 @@ QList<Key> &operator <<(QList<Key> &keys, Qt::Key key) tst_qquicktextedit::tst_qquicktextedit() { + qRegisterMetaType<QQuickTextEdit::TextFormat>(); + qRegisterMetaType<QQuickTextEdit::SelectionMode>(); + standard << "the quick brown fox jumped over the lazy dog" << "the quick brown fox\n jumped over the lazy dog" << "Hello, world!" @@ -596,7 +599,7 @@ void tst_qquicktextedit::textFormat() QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data()); QVERIFY(edit); - QSignalSpy spy(edit, SIGNAL(textFormatChanged(TextFormat))); + QSignalSpy spy(edit, &QQuickTextEdit::textFormatChanged); QCOMPARE(edit->textFormat(), QQuickTextEdit::PlainText); @@ -2113,7 +2116,7 @@ void tst_qquicktextedit::mouseSelectionMode_accessors() QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data()); QVERIFY(edit); - QSignalSpy spy(edit, SIGNAL(mouseSelectionModeChanged(SelectionMode))); + QSignalSpy spy(edit, &QQuickTextEdit::mouseSelectionModeChanged); QCOMPARE(edit->mouseSelectionMode(), QQuickTextEdit::SelectCharacters); diff --git a/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml b/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml new file mode 100644 index 0000000000..1bdd0b3caf --- /dev/null +++ b/tests/auto/quick/touchmouse/data/hoverMouseAreas.qml @@ -0,0 +1,39 @@ +import QtQuick 2.4 + +Item { + width: 500 + height: 500 + + Rectangle { + width: 300 + height: 90 + color: mouseArea1.containsMouse ? "red" : "grey" + x: 100 + y: 100 + + MouseArea { + id: mouseArea1 + objectName: "mouseArea1" + anchors.fill: parent + hoverEnabled: true + onPressed: parent.border.width = 4 + onReleased: parent.border.width = 0 + } + } + Rectangle { + width: 300 + height: 100 + color: mouseArea2.containsMouse ? "red" : "lightblue" + x: 100 + y: 200 + + MouseArea { + id: mouseArea2 + objectName: "mouseArea2" + anchors.fill: parent + hoverEnabled: true + onPressed: parent.border.width = 4 + onReleased: parent.border.width = 0 + } + } +} diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 90ee8215a1..e14b7d7c84 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -161,6 +161,8 @@ private slots: void touchGrabCausesMouseUngrab(); + void hoverEnabled(); + protected: bool eventFilter(QObject *, QEvent *event) { @@ -1232,6 +1234,93 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab() delete window; } +void tst_TouchMouse::hoverEnabled() +{ + // QTouchDevice *device = new QTouchDevice; + // device->setType(QTouchDevice::TouchScreen); + // QWindowSystemInterface::registerTouchDevice(device); + + QQuickView *window = createView(); + window->setSource(testFileUrl("hoverMouseAreas.qml")); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + QQuickItem *root = window->rootObject(); + QVERIFY(root != 0); + + QQuickMouseArea *mouseArea1 = root->findChild<QQuickMouseArea*>("mouseArea1"); + QVERIFY(mouseArea1 != 0); + + QQuickMouseArea *mouseArea2 = root->findChild<QQuickMouseArea*>("mouseArea2"); + QVERIFY(mouseArea2 != 0); + + QSignalSpy enterSpy1(mouseArea1, SIGNAL(entered())); + QSignalSpy exitSpy1(mouseArea1, SIGNAL(exited())); + QSignalSpy clickSpy1(mouseArea1, SIGNAL(clicked(QQuickMouseEvent *))); + + QSignalSpy enterSpy2(mouseArea2, SIGNAL(entered())); + QSignalSpy exitSpy2(mouseArea2, SIGNAL(exited())); + QSignalSpy clickSpy2(mouseArea2, SIGNAL(clicked(QQuickMouseEvent *))); + + QPoint p0(50, 50); + QPoint p1(150, 150); + QPoint p2(150, 250); + + // ------------------------- Mouse move to mouseArea1 + QTest::mouseMove(window, p1); + + QVERIFY(enterSpy1.count() == 1); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea2->hovered()); + + // ------------------------- Touch click on mouseArea1 + QTest::touchEvent(window, device).press(0, p1, window); + + QVERIFY(enterSpy1.count() == 1); + QVERIFY(enterSpy2.count() == 0); + QVERIFY(mouseArea1->pressed()); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea2->hovered()); + + QTest::touchEvent(window, device).release(0, p1, window); + QVERIFY(clickSpy1.count() == 1); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea2->hovered()); + + // ------------------------- Touch click on mouseArea2 + QTest::touchEvent(window, device).press(0, p2, window); + + QVERIFY(mouseArea1->hovered()); + QVERIFY(mouseArea2->hovered()); + QVERIFY(mouseArea2->pressed()); + QVERIFY(enterSpy1.count() == 1); + QVERIFY(enterSpy2.count() == 1); + + QTest::touchEvent(window, device).release(0, p2, window); + + QVERIFY(clickSpy2.count() == 1); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea2->hovered()); + QVERIFY(exitSpy1.count() == 0); + QVERIFY(exitSpy2.count() == 1); + + // ------------------------- Another touch click on mouseArea1 + QTest::touchEvent(window, device).press(0, p1, window); + + QVERIFY(enterSpy1.count() == 1); + QVERIFY(enterSpy2.count() == 1); + QVERIFY(mouseArea1->pressed()); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea2->hovered()); + + QTest::touchEvent(window, device).release(0, p1, window); + QVERIFY(clickSpy1.count() == 2); + QVERIFY(mouseArea1->hovered()); + QVERIFY(!mouseArea1->pressed()); + QVERIFY(!mouseArea2->hovered()); +} + QTEST_MAIN(tst_TouchMouse) #include "tst_touchmouse.moc" diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 79ff18011d..bec3de524c 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -59,6 +59,7 @@ private slots: void engine(); void readback(); void renderingSignals(); + void grabBeforeShow(); }; @@ -297,6 +298,14 @@ void tst_qquickwidget::renderingSignals() QTRY_VERIFY(afterRenderingSpy.size() > 0); } +// QTBUG-49929, verify that Qt Designer grabbing the contents before drag +// does not crash due to missing GL contexts or similar. +void tst_qquickwidget::grabBeforeShow() +{ + QQuickWidget widget; + QVERIFY(!widget.grab().isNull()); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" 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": <project-name>, + "version": <version>, + "expected": [<regexp-patterns>*], + } + +where _project-name_, _version_, and _regexp-patterns_ are strings. + +The first two parameters are used to invoke qmlplugindump: + + qmlplugindump -nonrelocatable <uri> <version> <path> + +where: + + <uri> = tests.dumper.<project-name> + <path> = <test-root> + +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 <QQuickItem> + +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 <qqml.h> + +void DummyPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.dummy + qmlRegisterType<Dummy>(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 <QQmlExtensionPlugin> + +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 <QQuickItem> + +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 <qqml.h> + +void ImportsPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.imports + qmlRegisterType<Imports>(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 <QQmlExtensionPlugin> + +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 <QQuickItem> + +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 <qqml.h> + +void VersionsPlugin::registerTypes(const char *uri) +{ + // @uri tests.dumper.versions + qmlRegisterType<Versions>(uri, 1, 0, "Versions"); + qmlRegisterType<Versions, 1>(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 <QQmlExtensionPlugin> + +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 <qtest.h> +#include <QLibraryInfo> +#include <QDir> +#include <QDirIterator> +#include <QProcess> +#include <QRegularExpression> +#include <QJsonDocument> +#include <QJsonParseError> +#include <QJsonObject> +#include <QJsonArray> +#include <QJsonValue> + +#include <QDebug> + +#include <cstdlib> +#include <algorithm> + + +// 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> <VERSION> +// +// 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.<PROJECT>; the project +// path must be ./test/dumper/<PROJECT>. +// +// 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<Test> readAllTestDefinitions(const QString &path) +{ + QList<Test> 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<Test> 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<QString>("project"); + QTest::addColumn<QString>("version"); + QTest::addColumn<QStringList>("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<const QString> 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" |