| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #include <QtTest/qtest.h> |
| 38 | #include <QtTest/qsignalspy.h> |
| 39 | #include <QtQml/qqmlengine.h> |
| 40 | #include <QtQml/qqmlcomponent.h> |
| 41 | |
| 42 | class tst_revisions : public QObject |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | |
| 46 | private slots: |
| 47 | void revisions_data(); |
| 48 | void revisions(); |
| 49 | |
| 50 | void window_data(); |
| 51 | void window(); |
| 52 | }; |
| 53 | |
| 54 | void tst_revisions::revisions_data() |
| 55 | { |
| 56 | QTest::addColumn<int>(name: "revision" ); |
| 57 | |
| 58 | // Qt 5.7: 2.0, Qt 5.8: 2.1, Qt 5.9: 2.2... |
| 59 | for (int i = 0; i <= QT_VERSION_MINOR - 7; ++i) |
| 60 | QTest::newRow(qPrintable(QString("2.%1" ).arg(i))) << i; |
| 61 | } |
| 62 | |
| 63 | void tst_revisions::revisions() |
| 64 | { |
| 65 | QFETCH(int, revision); |
| 66 | |
| 67 | QQmlEngine engine; |
| 68 | QQmlComponent component(&engine); |
| 69 | component.setData(QString("import QtQuick 2.0; \ |
| 70 | import QtQuick.Templates 2.%1 as T; \ |
| 71 | import QtQuick.Controls 2.%1; \ |
| 72 | import QtQuick.Controls.impl 2.%1; \ |
| 73 | import QtQuick.Controls.Material 2.%1; \ |
| 74 | import QtQuick.Controls.Material.impl 2.%1; \ |
| 75 | import QtQuick.Controls.Universal 2.%1; \ |
| 76 | import QtQuick.Controls.Universal.impl 2.%1; \ |
| 77 | Control { }" ).arg(a: revision).toUtf8(), baseUrl: QUrl()); |
| 78 | |
| 79 | QScopedPointer<QObject> object(component.create()); |
| 80 | QVERIFY2(!object.isNull(), qPrintable(component.errorString())); |
| 81 | } |
| 82 | |
| 83 | void tst_revisions::window_data() |
| 84 | { |
| 85 | QTest::addColumn<int>(name: "revision" ); |
| 86 | QTest::addColumn<QString>(name: "qml" ); |
| 87 | QTest::addColumn<QString>(name: "error" ); |
| 88 | |
| 89 | // Qt 5.7: 2.0, Qt 5.8: 2.1 |
| 90 | for (int i = 0; i <= 1; ++i) |
| 91 | QTest::newRow(qPrintable(QString("screen:2.%1" ).arg(i))) << i << "screen: null" << QString(":1 \"ApplicationWindow.screen\" is not available in QtQuick.Templates 2.%1" ).arg(a: i); |
| 92 | |
| 93 | // Qt 5.9: 2.2, Qt 5.10: 2.3... |
| 94 | for (int i = 2; i <= QT_VERSION_MINOR - 7; ++i) |
| 95 | QTest::newRow(qPrintable(QString("screen:2.%1" ).arg(i))) << i << "screen: null" << "" ; |
| 96 | } |
| 97 | |
| 98 | void tst_revisions::window() |
| 99 | { |
| 100 | QFETCH(int, revision); |
| 101 | QFETCH(QString, qml); |
| 102 | QFETCH(QString, error); |
| 103 | |
| 104 | QQmlEngine engine; |
| 105 | QQmlComponent component(&engine); |
| 106 | component.setData(QString("import QtQuick.Templates 2.%1; ApplicationWindow { %2 }" ).arg(a: revision).arg(a: qml).toUtf8(), baseUrl: QUrl()); |
| 107 | QScopedPointer<QObject> window(component.create()); |
| 108 | QCOMPARE(window.isNull(), !error.isEmpty()); |
| 109 | } |
| 110 | |
| 111 | QTEST_MAIN(tst_revisions) |
| 112 | |
| 113 | #include "tst_revisions.moc" |
| 114 | |