diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-03-27 11:17:35 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-08-26 11:45:57 +0200 |
commit | 5246dd2de211ffb81313a5c29ae7894545a28c43 (patch) | |
tree | eedd1652642e519ccd8603612378eb5c0bfdca83 /tests/auto | |
parent | 9aafea810b8867fb31f9ec27a238628467e7ab56 (diff) |
Register C++ types declaratively
Adapt to the new way of registering C++ types. The types need to be
seen at compile time so that code can be generated that invokes them.
This patch:
- Adds QML_* macros where applicable.
- Adapts the build system files to the new way of registering modules.
- Splits up the QtQuick.Controls[.*].impl files into their own plugins,
as we can only register one QML module per .pro file.
- Removes C++ type registration calls in every plugin.
- Moves private types from src/quickcontrols2/quickcontrols2.pro
to src/quickcontrols2/impl/quickcontrols2-impl.pro. Some of these
types need to be exposed to QML, but quickcontrols2.pro is already in
use to declare the QtQuick.Controls import (and also provides the
public C++ QQuickStyle API), and the new QML_IMPORT_NAME/VERSION
syntax only allows one module per project. As some of the types that
need to be exposed to QML are also referenced by some C++ code (e.g.
tests, etc.), we just move all of the private types to the new
library.
Follow-up patches will register the QML types declaratively.
Task-number: QTBUG-82922
Change-Id: Iaf9ee106237d61701d57a8896f3822304c8151a6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qquickapplicationwindow/data/opacity.qml | 61 | ||||
-rw-r--r-- | tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qquickiconimage/qquickiconimage.pro | 2 | ||||
-rw-r--r-- | tests/auto/qquickiconimage/tst_qquickiconimage.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qquickiconlabel/qquickiconlabel.pro | 2 | ||||
-rw-r--r-- | tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp | 4 | ||||
-rw-r--r-- | tests/auto/revisions/tst_revisions.cpp | 10 | ||||
-rw-r--r-- | tests/auto/sanity/tst_sanity.cpp | 8 | ||||
-rw-r--r-- | tests/auto/shared/visualtestutil.cpp | 2 |
9 files changed, 91 insertions, 14 deletions
diff --git a/tests/auto/qquickapplicationwindow/data/opacity.qml b/tests/auto/qquickapplicationwindow/data/opacity.qml new file mode 100644 index 00000000..cd969307 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/opacity.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +ApplicationWindow { + title: "Test Application Window" + width: 300 + height: 300 + opacity: 0.5 + + property bool testActive: active +} diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp index baaa3503..347c955e 100644 --- a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp +++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp @@ -78,6 +78,7 @@ private slots: void clearFocusOnDestruction(); void layout(); void componentComplete(); + void opacity(); }; void tst_QQuickApplicationWindow::qmlCreation() @@ -871,6 +872,19 @@ void tst_QQuickApplicationWindow::componentComplete() QVERIFY(qmlWindow->isComponentComplete()); } +void tst_QQuickApplicationWindow::opacity() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("opacity.qml")); + + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + + QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(object.data()); + QVERIFY(window); +} + QTEST_MAIN(tst_QQuickApplicationWindow) #include "tst_qquickapplicationwindow.moc" diff --git a/tests/auto/qquickiconimage/qquickiconimage.pro b/tests/auto/qquickiconimage/qquickiconimage.pro index 1a37d4ba..91b6985a 100644 --- a/tests/auto/qquickiconimage/qquickiconimage.pro +++ b/tests/auto/qquickiconimage/qquickiconimage.pro @@ -3,7 +3,7 @@ macos:CONFIG -= app_bundle TARGET = tst_qquickiconimage QT += core gui qml quick testlib -QT_PRIVATE += quick-private quickcontrols2-private +QT_PRIVATE += quick-private quickcontrols2impl-private qtHaveModule(svg): QT += svg include (../shared/util.pri) diff --git a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp index bc24c4fb..bcf1231f 100644 --- a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp +++ b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp @@ -39,7 +39,7 @@ #include <QtQuick/qquickimageprovider.h> #include <QtQuick/qquickitemgrabresult.h> #include <QtQuick/private/qquickimage_p.h> -#include <QtQuickControls2/private/qquickiconimage_p.h> +#include <QtQuickControls2Impl/private/qquickiconimage_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" diff --git a/tests/auto/qquickiconlabel/qquickiconlabel.pro b/tests/auto/qquickiconlabel/qquickiconlabel.pro index 6b0f73b3..af0a76cd 100644 --- a/tests/auto/qquickiconlabel/qquickiconlabel.pro +++ b/tests/auto/qquickiconlabel/qquickiconlabel.pro @@ -3,7 +3,7 @@ macos:CONFIG -= app_bundle TARGET = tst_qquickiconlabel QT += core gui qml quick testlib -QT_PRIVATE += quick-private quickcontrols2-private +QT_PRIVATE += quick-private quickcontrols2impl-private include (../shared/util.pri) diff --git a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp index 7a1cb259..526ecf05 100644 --- a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp @@ -35,8 +35,8 @@ #include <QtQuick/qquickitemgrabresult.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuickTemplates2/private/qquickicon_p.h> -#include <QtQuickControls2/private/qquickiconimage_p.h> -#include <QtQuickControls2/private/qquickiconlabel_p.h> +#include <QtQuickControls2Impl/private/qquickiconimage_p.h> +#include <QtQuickControls2Impl/private/qquickiconlabel_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" diff --git a/tests/auto/revisions/tst_revisions.cpp b/tests/auto/revisions/tst_revisions.cpp index 82b32827..67f890bb 100644 --- a/tests/auto/revisions/tst_revisions.cpp +++ b/tests/auto/revisions/tst_revisions.cpp @@ -86,12 +86,14 @@ void tst_revisions::window_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("error"); - // Qt 5.7: 2.0, Qt 5.8: 2.1 - for (int i = 0; i <= 1; ++i) + // Qt 5.7: 2.0, Qt 5.8: 2.1, Qt 5.9: 2.2 + // Note that we can no longer map the same Screen type to different versions + // in QtQuick and QtQuick.Controls anymore. + for (int i = 0; i <= 2; ++i) 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(i); - // Qt 5.9: 2.2, Qt 5.10: 2.3... - for (int i = 2; i <= 15; ++i) + // Qt 5.10: 2.3... + for (int i = 3; i <= 15; ++i) QTest::newRow(qPrintable(QString("screen:2.%1").arg(i))) << i << "screen: null" << ""; } diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index 78e3beff..f2135fa4 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -365,10 +365,10 @@ void tst_Sanity::attachedObjects() void tst_Sanity::attachedObjects_data() { QTest::addColumn<QUrl>("url"); - addTestRowForEachControl(&engine, "controls/default", "QtQuick/Controls.2/Default"); - addTestRowForEachControl(&engine, "controls/fusion", "QtQuick/Controls.2/Fusion", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); - addTestRowForEachControl(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); - addTestRowForEachControl(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRowForEachControl(&engine, "controls/default", "QtQuick/Controls/Default"); + addTestRowForEachControl(&engine, "controls/fusion", "QtQuick/Controls/Fusion", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); + addTestRowForEachControl(&engine, "controls/material", "QtQuick/Controls/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); + addTestRowForEachControl(&engine, "controls/universal", "QtQuick/Controls/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); } QTEST_MAIN(tst_Sanity) diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp index 3eaaa588..1740a6a6 100644 --- a/tests/auto/shared/visualtestutil.cpp +++ b/tests/auto/shared/visualtestutil.cpp @@ -100,7 +100,7 @@ void QQuickVisualTestUtil::addTestRowForEachControl(QQmlEngine *engine, const QS // We cannot use QQmlComponent to load QML files directly from the source tree. // For styles that use internal QML types (eg. material/Ripple.qml), the source // dir would be added as an "implicit" import path overriding the actual import - // path (qtbase/qml/QtQuick/Controls.2/Material). => The QML engine fails to load + // path (qtbase/qml/QtQuick/Controls/Material). => The QML engine fails to load // the style C++ plugin from the implicit import path (the source dir). // // Therefore we only use the source tree for finding out the set of QML files that |