diff options
Diffstat (limited to 'tests/auto/qml/qmltc')
56 files changed, 725 insertions, 55 deletions
diff --git a/tests/auto/qml/qmltc/BLACKLIST b/tests/auto/qml/qmltc/BLACKLIST deleted file mode 100644 index 004fbeb8d9..0000000000 --- a/tests/auto/qml/qmltc/BLACKLIST +++ /dev/null @@ -1,5 +0,0 @@ -[listView] -qnx ci -# QTBUG-101342 -[listView] -android diff --git a/tests/auto/qml/qmltc/CMakeLists.txt b/tests/auto/qml/qmltc/CMakeLists.txt index 4b86a6c018..1e6c6b9e30 100644 --- a/tests/auto/qml/qmltc/CMakeLists.txt +++ b/tests/auto/qml/qmltc/CMakeLists.txt @@ -1,8 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qmltc LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + add_subdirectory(QmltcTests) add_subdirectory(NamespaceTest/Subfolder) +add_subdirectory(QmltcExportedTests) +add_subdirectory(QmltcExportedNoFileNameTest) set(test_sources nameconflict.h nameconflict.cpp @@ -18,6 +26,11 @@ set(qmltc_module_libs # automatic type registration that comes from the plugin) qmltc_test_moduleplugin qmltc_namespace_test_module + qmltc_namespace_test_moduleplugin + qmltc_exported_tests_module + qmltc_exported_tests_moduleplugin + qmltc_exported_no_file_name_test_module + qmltc_exported_no_file_name_test_moduleplugin ) qt_internal_add_test(tst_qmltc_diskcache SOURCES ${test_sources} @@ -25,6 +38,7 @@ qt_internal_add_test(tst_qmltc_diskcache ) target_compile_definitions(tst_qmltc_diskcache PRIVATE QMLTC_TESTS_DISABLE_CACHE=0 + QT_NO_URL_CAST_FROM_STRING #QTBUG-113875 ) qt_internal_add_test(tst_qmltc_nodiskcache @@ -33,6 +47,7 @@ qt_internal_add_test(tst_qmltc_nodiskcache ) target_compile_definitions(tst_qmltc_nodiskcache PRIVATE QMLTC_TESTS_DISABLE_CACHE=1 + QT_NO_URL_CAST_FROM_STRING #QTBUG-113875 ) # Add qmltc documentation example to the tests. This is not beautiful but allows diff --git a/tests/auto/qml/qmltc/NamespaceTest/Subfolder/CMakeLists.txt b/tests/auto/qml/qmltc/NamespaceTest/Subfolder/CMakeLists.txt index f661cdea1e..daf1139a8f 100644 --- a/tests/auto/qml/qmltc/NamespaceTest/Subfolder/CMakeLists.txt +++ b/tests/auto/qml/qmltc/NamespaceTest/Subfolder/CMakeLists.txt @@ -24,9 +24,10 @@ qt_autogen_tools_initial_setup(qmltc_namespace_test_module) target_link_libraries(qmltc_namespace_test_module PUBLIC ${common_libraries}) +qt_policy(SET QTP0001 NEW) + qt6_add_qml_module(qmltc_namespace_test_module URI NamespaceTest.Subfolder - AUTO_RESOURCE_PREFIX SOURCES ${cpp_sources} QML_FILES diff --git a/tests/auto/qml/qmltc/NamespaceTest/Subfolder/Type.qml b/tests/auto/qml/qmltc/NamespaceTest/Subfolder/Type.qml index 101e9f69a1..3576353b02 100644 --- a/tests/auto/qml/qmltc/NamespaceTest/Subfolder/Type.qml +++ b/tests/auto/qml/qmltc/NamespaceTest/Subfolder/Type.qml @@ -1,5 +1,5 @@ import QtQuick Item { - property string data + property string data: "Hello from namespace" } diff --git a/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/CMakeLists.txt new file mode 100644 index 0000000000..47f920129a --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_library(qmltc_exported_no_file_name_test_module STATIC) +qt_autogen_tools_initial_setup(qmltc_exported_no_file_name_test_module) + +set(common_libraries + Qt::QuickPrivate +) + +target_link_libraries(qmltc_exported_no_file_name_test_module PUBLIC ${common_libraries}) + +qt_policy(SET QTP0001 NEW) + +qt6_add_qml_module(qmltc_exported_no_file_name_test_module + URI QmltcExportedNoFileNameTest + QML_FILES + HelloExportedWorldNoFileName.qml + DEPENDENCIES + Qt::Quick + ENABLE_TYPE_COMPILER + QMLTC_EXPORT_DIRECTIVE "Q_DECL_EXPORT" + # explicitly omitting QMLTC_EXPORT_FILE_NAME +) + +target_include_directories(qmltc_exported_no_file_name_test_module PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +qt_autogen_tools_initial_setup(qmltc_exported_no_file_name_test_moduleplugin) diff --git a/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/HelloExportedWorldNoFileName.qml b/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/HelloExportedWorldNoFileName.qml new file mode 100644 index 0000000000..89986df5a6 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcExportedNoFileNameTest/HelloExportedWorldNoFileName.qml @@ -0,0 +1,5 @@ +import QtQml + +QtObject { + property string myString: "Hello! I should be exported by qmltc" +} diff --git a/tests/auto/qml/qmltc/QmltcExportedTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcExportedTests/CMakeLists.txt new file mode 100644 index 0000000000..709297bed4 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcExportedTests/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_library(qmltc_exported_tests_module STATIC) +qt_autogen_tools_initial_setup(qmltc_exported_tests_module) + +include(GenerateExportHeader) +generate_export_header(qmltc_exported_tests_module) + +set(common_libraries + Qt::QuickPrivate +) + +target_link_libraries(qmltc_exported_tests_module PUBLIC ${common_libraries}) + +qt_policy(SET QTP0001 NEW) + +qt6_add_qml_module(qmltc_exported_tests_module + URI QmltcExportedTests + QML_FILES + HelloExportedWorld.qml + DEPENDENCIES + Qt::Quick + ENABLE_TYPE_COMPILER + QMLTC_EXPORT_DIRECTIVE "QMLTC_EXPORTED_TESTS_MODULE_EXPORT" + QMLTC_EXPORT_FILE_NAME "qmltc_exported_tests_module_export.h" +) + +target_include_directories(qmltc_exported_tests_module PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +qt_autogen_tools_initial_setup(qmltc_exported_tests_moduleplugin) diff --git a/tests/auto/qml/qmltc/QmltcExportedTests/HelloExportedWorld.qml b/tests/auto/qml/qmltc/QmltcExportedTests/HelloExportedWorld.qml new file mode 100644 index 0000000000..5e6886bced --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcExportedTests/HelloExportedWorld.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property string myString: "Hello! I should be exported by qmltc" +} diff --git a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt index 870d21f61d..4c472ec4ab 100644 --- a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt +++ b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt @@ -22,6 +22,8 @@ set(cpp_sources cpptypes/singletontype.h cpptypes/singletontype.cpp cpptypes/typewithnamespace.h cpptypes/typewithnamespace.cpp cpptypes/typewithsignal.h + cpptypes/custominitialization.h + cpptypes/typewithrequiredproperties.h ) set(qml_sources @@ -44,11 +46,16 @@ set(qml_sources regexpBindings.qml AliasBase.qml aliasAssignments.qml + Connections.qml qtbug103956/SubComponent.qml qtbug103956/MainComponent.qml qtbug103956/qtbug103956_main.qml + qtbug120700_main.qml + + qtbug123476.qml + signalHandlers.qml javaScriptFunctions.qml changingBindings.qml @@ -108,6 +115,9 @@ set(qml_sources inlineComponentsFromDifferentFiles.qml singletons.qml mySignals.qml + stringToUrl.qml + myCheckBox.qml + signalConnections.qml # support types: DefaultPropertySingleChild.qml @@ -125,6 +135,8 @@ set(qml_sources NamespacedTypes.qml badFile.qml + + requiredProperties.qml ) set(js_sources @@ -135,10 +147,16 @@ set(common_libraries Qt::Core Qt::QmlPrivate Qt::QuickPrivate + Qt::QuickTemplates2Private Qt::TestPrivate Qt::Gui # QColor, QMatrix4x4, ... ) +if (QT_FEATURE_qml_table_model) + list(APPEND qml_sources QmlTableModel.qml) + list(APPEND common_libraries Qt::LabsQmlModelsPrivate) +endif() + set_source_files_properties(NameConflict.qml PROPERTIES QT_QMLTC_FILE_BASENAME ResolvedNameConflict) @@ -166,10 +184,11 @@ qt_internal_add_resource(qmltc_test_module "qmake_immediate" ${qmake_immediate_resource_files} ) +qt_policy(SET QTP0001 NEW) + qt6_add_qml_module(qmltc_test_module VERSION 1.0 URI QmltcTests - AUTO_RESOURCE_PREFIX SOURCES ${cpp_sources} QML_FILES diff --git a/tests/auto/qml/qmltc/QmltcTests/Connections.qml b/tests/auto/qml/qmltc/QmltcTests/Connections.qml new file mode 100644 index 0000000000..d7fc0d87c6 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/Connections.qml @@ -0,0 +1,12 @@ +import QtQuick + +Rectangle { + property string hello + + id: root + + Connections { + target: root + function onHelloChanged(argument) {} + } +} diff --git a/tests/auto/qml/qmltc/QmltcTests/InlineComponentProvider.qml b/tests/auto/qml/qmltc/QmltcTests/InlineComponentProvider.qml index 9dbe9d6fbe..d3c1cfe293 100644 --- a/tests/auto/qml/qmltc/QmltcTests/InlineComponentProvider.qml +++ b/tests/auto/qml/qmltc/QmltcTests/InlineComponentProvider.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/QmlTableModel.qml b/tests/auto/qml/qmltc/QmltcTests/QmlTableModel.qml new file mode 100644 index 0000000000..696c2b40bb --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/QmlTableModel.qml @@ -0,0 +1,62 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +TableView { + anchors.fill: parent + columnSpacing: 1 + rowSpacing: 1 + boundsBehavior: Flickable.StopAtBounds + + model: TableModel { + property string testName: "MyTableModel" + TableModelColumn { display: "checked" } + TableModelColumn { display: "amount" } + TableModelColumn { display: "fruitType" } + TableModelColumn { display: "fruitName" } + TableModelColumn { display: "fruitPrice" } + + // Each row is one type of fruit that can be ordered + rows: [ + { + // Each property is one cell/column. + checked: false, + amount: 1, + fruitType: "Apple", + fruitName: "Granny Smith", + fruitPrice: 1.50 + }, + { + checked: true, + amount: 4, + fruitType: "Orange", + fruitName: "Navel", + fruitPrice: 2.50 + }, + { + checked: false, + amount: 1, + fruitType: "Banana", + fruitName: "Cavendish", + fruitPrice: 3.50 + } + ] + } + delegate: TextInput { + text: model.display + padding: 12 + selectByMouse: true + + onAccepted: model.display = text + + Rectangle { + anchors.fill: parent + color: "#efefef" + z : -1 + } + } +} + diff --git a/tests/auto/qml/qmltc/QmltcTests/aliases.qml b/tests/auto/qml/qmltc/QmltcTests/aliases.qml index 9f13f7b17a..41c34b4187 100644 --- a/tests/auto/qml/qmltc/QmltcTests/aliases.qml +++ b/tests/auto/qml/qmltc/QmltcTests/aliases.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/appendToQQmlListProperty.qml b/tests/auto/qml/qmltc/QmltcTests/appendToQQmlListProperty.qml index 680e297edb..70636c0a2e 100644 --- a/tests/auto/qml/qmltc/QmltcTests/appendToQQmlListProperty.qml +++ b/tests/auto/qml/qmltc/QmltcTests/appendToQQmlListProperty.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QmltcTests diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/custominitialization.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/custominitialization.h new file mode 100644 index 0000000000..7546f344d2 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/custominitialization.h @@ -0,0 +1,64 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef CUSTOMINITIALIAZATION_H_ +#define CUSTOMINITIALIAZATION_H_ + +#include <QtCore/qobject.h> +#include <QtCore/qproperty.h> +#include <QtQuick/qquickitem.h> +#include <QtQml/qqmllist.h> +#include <QtQml/qqmlregistration.h> + +class ExtensionType : public QObject +{ + Q_OBJECT + QML_ANONYMOUS + Q_PROPERTY(double propertyFromExtension READ getPropertyFromExtension WRITE + setPropertyFromExtension) + Q_PROPERTY(QQmlListProperty<QQuickItem> extensionObjectList READ getExtensionObjectList) + + QProperty<double> m_propertyFromExtension{ 0 }; + QList<QQuickItem *> m_extensionObjectList; + +public: + ExtensionType(QObject *parent = nullptr) : QObject(parent) { } + + double getPropertyFromExtension() const { return m_propertyFromExtension; } + void setPropertyFromExtension(double v) { m_propertyFromExtension = v; } + + QQmlListProperty<QQuickItem> getExtensionObjectList() + { + return QQmlListProperty<QQuickItem>(this, &m_extensionObjectList); + } +}; + +class TypeForCustomInitialization : public QObject +{ + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(QQmlListProperty<QQuickItem> cppObjectList READ getCppObjectList) + Q_PROPERTY( + double defaultedBindable BINDABLE bindableDefaultedBindable READ default WRITE default) + + QML_EXTENDED(ExtensionType) + + QList<QQuickItem *> m_cppObjectList; + QProperty<double> m_defaultedBindable; + +public: + TypeForCustomInitialization(QObject *parent = nullptr) : QObject(parent) { } + + QQmlListProperty<QQuickItem> getCppObjectList() + { + return QQmlListProperty<QQuickItem>(this, &m_cppObjectList); + } + + QBindable<double> bindableDefaultedBindable() + { + return QBindable<double>(&m_defaultedBindable); + } +}; + +#endif // CUSTOMINITIALIAZATION_H_ diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.cpp index 422e0021f1..1487dbcf15 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "deferredpropertytypes.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.h index d9aa801c77..1701d6ee91 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/deferredpropertytypes.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef DEFERREDPROPERTYTYPES_H #define DEFERREDPROPERTYTYPES_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.cpp index 16f555c0b7..b6ed76eed4 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "extensiontypes.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.h index 667e2952ce..080d3b4380 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/extensiontypes.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef EXTENSIONTYPES_H #define EXTENSIONTYPES_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/private/testprivateproperty_p.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/private/testprivateproperty_p.h index 31cb385cfd..3135f4e3d3 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/private/testprivateproperty_p.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/private/testprivateproperty_p.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // NB: fake private header for testing purposes #ifndef TESTPRIVATEPROPERTY_P_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/singletontype.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/singletontype.h index 293aece065..a2e1518fc3 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/singletontype.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/singletontype.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SINGLETONTYPE_H #define SINGLETONTYPE_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.cpp index fd70c0a3f4..b44945fba0 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "testattachedtype.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.h index b7cc6348aa..2e3ef97009 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testattachedtype.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTATTACHEDTYPE_H #define TESTATTACHEDTYPE_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp index 410aae1528..45d6c3e322 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "testgroupedtype.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h index f895f19531..cef875545c 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTGROUPEDTYPE_H #define TESTGROUPEDTYPE_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.cpp index c1d101653c..f24728b597 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "private/testprivateproperty_p.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.h index 230c86affd..22863ba52a 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testprivateproperty.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTPRIVATEPROPERTY_H #define TESTPRIVATEPROPERTY_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithmanyproperties.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithmanyproperties.h index 873c38771e..b0f1a17adc 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithmanyproperties.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithmanyproperties.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PROPERTYALIASATTRIBUTES_H #define PROPERTYALIASATTRIBUTES_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.cpp index fbfaf447da..ae4aaa5092 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "typewithnamespace.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.h index 7b8bc7803a..173e8624ff 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithnamespace.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TYPEWITHNAMESPACE_H #define TYPEWITHNAMESPACE_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.cpp index 80557209a5..eb0dae7465 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.cpp +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "typewithproperties.h" diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.h index e06f9079f9..d7a0d03405 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithproperties.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TYPEWITHPROPERTIES_H #define TYPEWITHPROPERTIES_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithrequiredproperties.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithrequiredproperties.h new file mode 100644 index 0000000000..cc1ded9f74 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithrequiredproperties.h @@ -0,0 +1,75 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/qobject.h> +#include <QtCore/qproperty.h> +#include <QtQuick/qquickitem.h> +#include <QtQml/qqmllist.h> +#include <QtQml/qqmlregistration.h> + +#ifndef TYPEWITHREQUIREDPROPERTIES_H_ +# define TYPEWITHREQUIREDPROPERTIES_H_ + +class ExtensionTypeWithRequiredProperties : public QObject +{ + Q_OBJECT + QML_ANONYMOUS + + Q_PROPERTY(double requiredPropertyFromExtension READ getRequiredPropertyFromExtension WRITE + setRequiredPropertyFromExtension REQUIRED) + + QProperty<double> m_requiredPropertyFromExtension{}; + +public: + ExtensionTypeWithRequiredProperties(QObject *parent = nullptr) : QObject(parent) { } + + double getRequiredPropertyFromExtension() const { return m_requiredPropertyFromExtension; } + void setRequiredPropertyFromExtension(double v) { m_requiredPropertyFromExtension = v; } +}; + +class TypeWithRequiredProperties : public QObject +{ + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(QQuickItem *inheritedRequiredProperty READ getInheritedRequiredProperty WRITE + setInheritedRequiredProperty REQUIRED) + Q_PROPERTY(int inheritedRequiredPropertyThatWillBeBound READ + getInheritedRequiredPropertyThatWillBeBound WRITE + setInheritedRequiredPropertyThatWillBeBound REQUIRED) + Q_PROPERTY(int nonRequiredInheritedPropertyThatWillBeMarkedRequired READ + getNonRequiredInheritedPropertyThatWillBeMarkedRequired WRITE + setNonRequiredInheritedPropertyThatWillBeMarkedRequired REQUIRED) + + QML_EXTENDED(ExtensionTypeWithRequiredProperties) + + QProperty<QQuickItem *> m_inheritedRequiredProperty{}; + QProperty<int> m_inheritedRequiredPropertyThatWillBeBound{}; + QProperty<int> m_nonRequiredInheritedPropertyThatWillBeMarkedRequired{}; + +public: + TypeWithRequiredProperties(QObject *parent = nullptr) : QObject(parent) { } + + QQuickItem *getInheritedRequiredProperty() const { return m_inheritedRequiredProperty; } + void setInheritedRequiredProperty(QQuickItem *v) { m_inheritedRequiredProperty = v; } + + int getInheritedRequiredPropertyThatWillBeBound() const + { + return m_inheritedRequiredPropertyThatWillBeBound; + } + void setInheritedRequiredPropertyThatWillBeBound(int v) + { + m_inheritedRequiredPropertyThatWillBeBound = v; + } + + int getNonRequiredInheritedPropertyThatWillBeMarkedRequired() const + { + return m_nonRequiredInheritedPropertyThatWillBeMarkedRequired; + } + void setNonRequiredInheritedPropertyThatWillBeMarkedRequired(int v) + { + m_nonRequiredInheritedPropertyThatWillBeMarkedRequired = v; + } +}; + +#endif // TYPEWITHREQUIREDPROPERTIES_H_ diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithsignal.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithsignal.h index 139b431a40..6bb94ae051 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithsignal.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithsignal.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TYPEWITHSIGNAL_H #define TYPEWITHSIGNAL_H diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithspecialproperties.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithspecialproperties.h index 9d68275b1e..8bf068ba35 100644 --- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithspecialproperties.h +++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/typewithspecialproperties.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TYPEWITHSPECIALPROPERTIES_H #define TYPEWITHSPECIALPROPERTIES_H diff --git a/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml b/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml index a037776a52..2c21298c35 100644 --- a/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml +++ b/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQml import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/inlineComponents.qml b/tests/auto/qml/qmltc/QmltcTests/inlineComponents.qml index f9146083f6..284a8f5034 100644 --- a/tests/auto/qml/qmltc/QmltcTests/inlineComponents.qml +++ b/tests/auto/qml/qmltc/QmltcTests/inlineComponents.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtQuick as MyQtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/myCheckBox.qml b/tests/auto/qml/qmltc/QmltcTests/myCheckBox.qml new file mode 100644 index 0000000000..c5a2f5a7b8 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/myCheckBox.qml @@ -0,0 +1,5 @@ +import QtQuick.Templates + +CheckBox { + +} diff --git a/tests/auto/qml/qmltc/QmltcTests/mySignals.qml b/tests/auto/qml/qmltc/QmltcTests/mySignals.qml index c79a0518c2..0348a0af54 100644 --- a/tests/auto/qml/qmltc/QmltcTests/mySignals.qml +++ b/tests/auto/qml/qmltc/QmltcTests/mySignals.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QmltcTests import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/properties.qml b/tests/auto/qml/qmltc/QmltcTests/properties.qml index ca827519d5..f42b14a356 100644 --- a/tests/auto/qml/qmltc/QmltcTests/properties.qml +++ b/tests/auto/qml/qmltc/QmltcTests/properties.qml @@ -26,13 +26,13 @@ QtObject { property date dateP property font fontP property matrix4x4 matrix4x4P - property point pointP - property quaternion quatP - property rect rectP - property size sizeP - property vector2d vec2dP - property vector3d vec3dP - property vector4d vec4dP + property point pointP: ({ x: 100, y: 200 }) + property quaternion quatP: ({ x: 100, y: 200, z: 300, scalar: 400 }) + property rect rectP: ({ x: 100, y: 200, width: 300, height: 400 }) + property size sizeP: ({ width: 100, height: 200 }) + property vector2d vec2dP : ({ x: 100, y: 200 }) + property vector3d vec3dP: ({ x: 100, y: 200, z: 300 }) + property vector4d vec4dP: ({ x: 100, y: 200, z: 300, w: 400 }) default property QtObject defaultObjP readonly property string readonlyStringP: "foobar" diff --git a/tests/auto/qml/qmltc/QmltcTests/propertyAliasAttributes.qml b/tests/auto/qml/qmltc/QmltcTests/propertyAliasAttributes.qml index 66cd948ac4..fb57a2bbc8 100644 --- a/tests/auto/qml/qmltc/QmltcTests/propertyAliasAttributes.qml +++ b/tests/auto/qml/qmltc/QmltcTests/propertyAliasAttributes.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQml import QmltcTests diff --git a/tests/auto/qml/qmltc/QmltcTests/qtbug120700_main.qml b/tests/auto/qml/qmltc/QmltcTests/qtbug120700_main.qml new file mode 100644 index 0000000000..0796d00732 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/qtbug120700_main.qml @@ -0,0 +1,25 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QmltcTests 1.0 + +TypeForCustomInitialization { + id: myWindow + required property int someValue + + property alias someValueAlias: myWindow.someValue + property int someValueBinding: someValue + 1 + + property bool wasSomeValueChanged: false + + property int someComplexValueThatWillBeSet: { return 5 } + property int someComplexValueThatWillNotBeSet: { return 5 } + + property list<int> valueTypeList : [] + property list<Item> objectTypeList : [] + + //QTBUG-114403: onValueChanged should not trigger when setting + //the initial values. + onSomeValueChanged: { wasSomeValueChanged = true; } +} diff --git a/tests/auto/qml/qmltc/QmltcTests/qtbug123476.qml b/tests/auto/qml/qmltc/QmltcTests/qtbug123476.qml new file mode 100644 index 0000000000..79aa178de4 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/qtbug123476.qml @@ -0,0 +1,9 @@ +import QtQuick + +Item { + // qmltc should see that rectangle is used as the type argument + // for the list and produce an import for QQuickRectangle. + // Failure to do so will produce code that cannot compile and the + // test will fail at build time. + property list<Rectangle> listWithUniqueReferenceToType : [] +} diff --git a/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml index 7c4dad5a4e..d4eb72786b 100644 --- a/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml +++ b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/requiredProperties.qml b/tests/auto/qml/qmltc/QmltcTests/requiredProperties.qml new file mode 100644 index 0000000000..77e9c88b9b --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/requiredProperties.qml @@ -0,0 +1,61 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QmltcTests 1.0 + +TypeWithRequiredProperties { + id: self + required property int primitiveType + required property list<int> valueList + required property list<Item> objectList + + property int propertyThatWillBeMarkedRequired + + // This is already bound so it should not appear as part of the + // bundle. + inheritedRequiredPropertyThatWillBeBound : 10 + + // This should be ignored as it alias a required property we are + // already going to consider. It should thus not appear as part of + // the bundle. + property alias aliasToRequiredProperty : self.primitiveType + + required propertyThatWillBeMarkedRequired + required nonRequiredInheritedPropertyThatWillBeMarkedRequired + + property alias aliasToRequiredInner: inner.requiredInner + + // This should be ignored as the underlying property is already bound. + property alias aliasToRequiredBoundedInner: inner.requiredBoundedInner + + property alias aliasToInnerThatWillBeMarkedRequired: inner.nonRequiredInner + required aliasToInnerThatWillBeMarkedRequired + + property int notRequired + property alias requiredAliasToUnrequiredProperty : self.notRequired + required requiredAliasToUnrequiredProperty + + // When we have an alias to a required property in the same scope + // we exclude the alias in favor of setting the property directly. + // See for example aliasToRequiredProperty in this file. + // + // The following alias should instead be picked up, as it point to + // an inner scope. + // Nonetheless, an initial implementation had a bug that would + // discard the alias as long as a property with the same name as + // the target was present in the same scope. + // + // The following alias tests this initially failing case. + property alias aliasToPropertyThatShadows: inner.primitiveType + + property Item children : Item { + id: inner + required property int requiredInner + property int nonRequiredInner + required property int requiredBoundedInner + requiredBoundedInner: 43 + + required property int primitiveType + } +} diff --git a/tests/auto/qml/qmltc/QmltcTests/signalConnections.qml b/tests/auto/qml/qmltc/QmltcTests/signalConnections.qml new file mode 100644 index 0000000000..d88e3920c3 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/signalConnections.qml @@ -0,0 +1,46 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + id: root + + property bool cycleEnabled: false + property bool cycleFirst: false + property bool cycleSecond: false + + property Timer enableTimer: Timer { + running: root.cycleEnabled + interval: 1 + onTriggered: { + conn.enabled = !conn.enabled; + root.cycleEnabled = false; + } + } + + property Timer firstTimer: Timer { + id: firstTimer + objectName: "first" + running: root.cycleFirst + interval: 1 + onTriggered: root.cycleFirst = false + } + + property Timer secondTimer: Timer { + objectName: "second" + running: root.cycleSecond + interval: 1 + onTriggered: conn.target = this; + repeat: true + } + + property Connections conn: Connections { + id: conn + target: firstTimer + function onTriggered(m) { + root.objectName = target.objectName + root.cycleSecond = false; + } + } +} diff --git a/tests/auto/qml/qmltc/QmltcTests/singletons.qml b/tests/auto/qml/qmltc/QmltcTests/singletons.qml index a45e502bc0..d30a50dd6b 100644 --- a/tests/auto/qml/qmltc/QmltcTests/singletons.qml +++ b/tests/auto/qml/qmltc/QmltcTests/singletons.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QmltcTests diff --git a/tests/auto/qml/qmltc/QmltcTests/stringToUrl.qml b/tests/auto/qml/qmltc/QmltcTests/stringToUrl.qml new file mode 100644 index 0000000000..1172c42032 --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/stringToUrl.qml @@ -0,0 +1,12 @@ +import QtQuick 2.12 + +QtObject { + readonly property FontLoader iconLoader: FontLoader { + source: "qrc:/qt/qml/path/to/font.ttf" + } + property string myUrl: "qrc:/qt/qml/path/to/font2.ttf" + readonly property FontLoader iconLoader2: FontLoader { + source: myUrl + } +} + diff --git a/tests/auto/qml/qmltc/QmltcTests/subfolder/code.js b/tests/auto/qml/qmltc/QmltcTests/subfolder/code.js index a248743d29..7b552e7f67 100644 --- a/tests/auto/qml/qmltc/QmltcTests/subfolder/code.js +++ b/tests/auto/qml/qmltc/QmltcTests/subfolder/code.js @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only function isGood(value) { diff --git a/tests/auto/qml/qmltc/QmltcTests/translations.qml b/tests/auto/qml/qmltc/QmltcTests/translations.qml index e00d9f5b86..71e9298fd1 100644 --- a/tests/auto/qml/qmltc/QmltcTests/translations.qml +++ b/tests/auto/qml/qmltc/QmltcTests/translations.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/translationsById.qml b/tests/auto/qml/qmltc/QmltcTests/translationsById.qml index e3606d9b0f..98fd5cb846 100644 --- a/tests/auto/qml/qmltc/QmltcTests/translationsById.qml +++ b/tests/auto/qml/qmltc/QmltcTests/translationsById.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/qml/qmltc/QmltcTests/valueTypeListProperty.qml b/tests/auto/qml/qmltc/QmltcTests/valueTypeListProperty.qml index 7226abbb2e..300af9d31f 100644 --- a/tests/auto/qml/qmltc/QmltcTests/valueTypeListProperty.qml +++ b/tests/auto/qml/qmltc/QmltcTests/valueTypeListProperty.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQml import QtQuick diff --git a/tests/auto/qml/qmltc/nameconflict.cpp b/tests/auto/qml/qmltc/nameconflict.cpp index e95272913f..b1fb21977b 100644 --- a/tests/auto/qml/qmltc/nameconflict.cpp +++ b/tests/auto/qml/qmltc/nameconflict.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "nameconflict.h" #include <QtCore/qobject.h> diff --git a/tests/auto/qml/qmltc/nameconflict.h b/tests/auto/qml/qmltc/nameconflict.h index ea971b5159..64297af4d4 100644 --- a/tests/auto/qml/qmltc/nameconflict.h +++ b/tests/auto/qml/qmltc/nameconflict.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NAME_CONFLICT_FLAG #define NAME_CONFLICT_FLAG diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index 1fa4030642..ef33cebc00 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "tst_qmltc.h" @@ -21,10 +21,12 @@ #include "qjsvalueassignments.h" #include "extensiontypebindings.h" #include "qtbug103956_main.h" +#include "qtbug120700_main.h" #include "nonstandardinclude.h" #include "specialproperties.h" #include "regexpbindings.h" #include "aliasassignments.h" +#include "connections.h" #include "signalhandlers.h" #include "javascriptfunctions.h" @@ -77,12 +79,18 @@ #include "repeatercrash.h" #include "aliases.h" #include "inlinecomponentsfromdifferentfiles.h" +#include "helloexportedworld.h" +#include "helloexportedworldnofilename.h" #include "testprivateproperty.h" #include "singletons.h" #include "mysignals.h" #include "namespacedtypes.h" #include "type.h" +#include "qmltablemodel.h" +#include "stringtourl.h" +#include "signalconnections.h" +#include "requiredproperties.h" // Qt: #include <QtCore/qstring.h> @@ -147,11 +155,14 @@ void tst_qmltc::initTestCase() QUrl("qrc:/qt/qml/QmltcTests/regexpBindings.qml"), QUrl("qrc:/qt/qml/QmltcTests/AliasBase.qml"), QUrl("qrc:/qt/qml/QmltcTests/aliasAssignments.qml"), + QUrl("qrc:/qt/qml/QmltcTests/Connections.qml"), QUrl("qrc:/qt/qml/QmltcTests/qtbug103956/SubComponent.qml"), QUrl("qrc:/qt/qml/QmltcTests/qtbug103956/MainComponent.qml"), QUrl("qrc:/qt/qml/QmltcTests/qtbug103956/qtbug103956_main.qml"), + QUrl("qrc:/qt/qml/QmltcTests/qtbug120700_main.qml"), + QUrl("qrc:/qt/qml/QmltcTests/signalHandlers.qml"), QUrl("qrc:/qt/qml/QmltcTests/javaScriptFunctions.qml"), QUrl("qrc:/qt/qml/QmltcTests/changingBindings.qml"), @@ -192,6 +203,7 @@ void tst_qmltc::initTestCase() QUrl("qrc:/qt/qml/QmltcTests/calqlatrBits.qml"), QUrl("qrc:/qt/qml/QmltcTests/valueTypeListProperty.qml"), QUrl("qrc:/qt/qml/QmltcTests/appendToQQmlListProperty.qml"), + QUrl("qrc:/qt/qml/QmltcTests/requiredProperties.qml"), }; QQmlEngine e; @@ -374,7 +386,14 @@ void tst_qmltc::properties() QCOMPARE(created.intP(), 42); QCOMPARE(created.realP(), 2.32); QCOMPARE(created.stringP(), u"hello, world"_s); - QCOMPARE(created.urlP(), u"https://www.qt.io/"_s); + QCOMPARE(created.urlP(), QUrl(u"https://www.qt.io/"_s)); + QCOMPARE(created.pointP(), QPoint(100, 200)); + QCOMPARE(created.quatP(), QQuaternion(400, 100, 200, 300)); + QCOMPARE(created.rectP(), QRectF(100, 200, 300, 400)); + QCOMPARE(created.sizeP(), QSizeF(100, 200)); + QCOMPARE(created.vec2dP(), QVector2D(100, 200)); + QCOMPARE(created.vec3dP(), QVector3D(100, 200, 300)); + QCOMPARE(created.vec4dP(), QVector4D(100, 200, 300, 400)); QCOMPARE(created.varP(), 42.42); QCOMPARE(created.boolP(), true); @@ -818,6 +837,103 @@ void tst_qmltc::visibleAliasMethods() QCOMPARE(created.firstComponent()->setMe(), true); } +// QTBUG-120700 +void tst_qmltc::customInitialization() +{ + int valueToTest = 10; + + QQuickItem firstItem; + QQuickItem secondItem; + + QQmlEngine e; + PREPEND_NAMESPACE(qtbug120700_main) + created(&e, {valueToTest} ,nullptr, [valueToTest, &firstItem, &secondItem](auto& component) { + component.setSomeComplexValueThatWillBeSet(valueToTest); + component.setPropertyFromExtension(static_cast<double>(valueToTest)); + component.setDefaultedBindable(static_cast<double>(valueToTest)); + component.setValueTypeList({1, 2, 3, 4}); + component.setObjectTypeList({&firstItem, &secondItem}); + component.setExtensionObjectList({&firstItem, &secondItem}); + component.setCppObjectList({&firstItem, &secondItem}); + }); + + // QTBUG-114403: onValueChanged should have not been triggered + // when setting the initial value for the property. + // If this is true then the handler was called. + QCOMPARE(created.wasSomeValueChanged(), false); + + // someComplexValueThatWillBeSet is set through a binding in the + // QML code, but is initialized when the instance is created. + // The bindings, which is generally set after the custom + // initialization was perfomed, should not overwrite the initial + // value that the user provided. + // On the other side, someComplexValueThatWillNotBeSet should + // still respect the original binding as an initial value for it + // was not provided. + QCOMPARE(created.someComplexValueThatWillBeSet(), valueToTest); + QCOMPARE(created.someComplexValueThatWillNotBeSet(), 5); + + QCOMPARE(created.someValue(), valueToTest); + QCOMPARE(created.someValueAlias(), valueToTest); + QCOMPARE(created.someValueBinding(), valueToTest + 1); + QCOMPARE(created.property("propertyFromExtension").toDouble(), static_cast<double>(valueToTest)); + QCOMPARE(created.bindableDefaultedBindable().value(), static_cast<double>(valueToTest)); + QCOMPARE(created.valueTypeList(), QList({1, 2, 3, 4})); + QCOMPARE(created.objectTypeList().toList<QList<QQuickItem*>>(), QList({&firstItem, &secondItem})); + QCOMPARE( + created.property("extensionObjectList").value<QQmlListProperty<QQuickItem>>().toList<QList<QQuickItem*>>(), + QList({&firstItem, &secondItem}) + ); + QCOMPARE(created.getCppObjectList().toList<QList<QQuickItem*>>(), QList({&firstItem, &secondItem})); +} + +void tst_qmltc::requiredPropertiesInitialization() +{ + QQuickItem item{}; + + int aliasToInnerThatWillBeMarkedRequired = 10; + int aliasToPropertyThatShadows = 42; + int aliasToRequiredInner = 11; + QQuickItem inheritedRequiredProperty{}; + int nonRequiredInheritedPropertyThatWillBeMarkedRequired = 12; + QList<QQuickItem*> objectList{&item}; + int primitiveType = 13; + int propertyThatWillBeMarkedRequired = 14; + int requiredAliasToUnrequiredProperty = 15; + double requiredPropertyFromExtension = 16.0; + QList<int> valueList{1, 2, 3, 4}; + + QQmlEngine e; + PREPEND_NAMESPACE(requiredProperties) created( + &e, + { + aliasToInnerThatWillBeMarkedRequired, + aliasToPropertyThatShadows, + aliasToRequiredInner, + &inheritedRequiredProperty, + nonRequiredInheritedPropertyThatWillBeMarkedRequired, + objectList, + primitiveType, + propertyThatWillBeMarkedRequired, + requiredAliasToUnrequiredProperty, + requiredPropertyFromExtension, + valueList + } + ); + + QCOMPARE(created.aliasToInnerThatWillBeMarkedRequired(), aliasToInnerThatWillBeMarkedRequired); + QCOMPARE(created.aliasToPropertyThatShadows(), aliasToPropertyThatShadows); + QCOMPARE(created.aliasToRequiredInner(), aliasToRequiredInner); + QCOMPARE(created.getInheritedRequiredProperty(), &inheritedRequiredProperty); + QCOMPARE(created.getNonRequiredInheritedPropertyThatWillBeMarkedRequired(), nonRequiredInheritedPropertyThatWillBeMarkedRequired); + QCOMPARE(created.objectList().toList<QList<QQuickItem*>>(), objectList); + QCOMPARE(created.primitiveType(), primitiveType); + QCOMPARE(created.propertyThatWillBeMarkedRequired(), propertyThatWillBeMarkedRequired); + QCOMPARE(created.requiredAliasToUnrequiredProperty(), requiredAliasToUnrequiredProperty); + QCOMPARE(created.property("requiredPropertyFromExtension").toDouble(), requiredPropertyFromExtension); + QCOMPARE(created.valueList(), valueList); +} + // QTBUG-104094 void tst_qmltc::nonStandardIncludesInsideModule() { @@ -887,6 +1003,12 @@ void tst_qmltc::aliasAssignments() } } +void tst_qmltc::connections() +{ + QQmlEngine e; + PREPEND_NAMESPACE(Connections) created(&e); +} + void tst_qmltc::signalHandlers() { QQmlEngine e; @@ -1058,7 +1180,7 @@ void tst_qmltc::propertyAlias_external() void tst_qmltc::propertyAliasAttribute() { QQmlEngine e; - PREPEND_NAMESPACE(propertyAliasAttributes) fromQmltc(&e); + PREPEND_NAMESPACE(propertyAliasAttributes) fromQmltc(&e, {""}); QQmlComponent c(&e); c.loadUrl(QUrl("qrc:/qt/qml/QmltcTests/propertyAliasAttributes.qml")); @@ -3204,8 +3326,74 @@ void tst_qmltc::namespacedName() { // cmake script should be able to auto-fill the namespace of the generated modules, and to // replace . with :: - NamespaceTest::Subfolder::Type *t; - Q_UNUSED(t); + QQmlEngine e; + NamespaceTest::Subfolder::Type t(&e); + QCOMPARE(t.data(), u"Hello from namespace"_s); +} + +void tst_qmltc::checkExportsAreCompiling() +{ + QQmlEngine e; + QmltcExportedTests::HelloExportedWorld w(&e); + QCOMPARE(w.myString(), u"Hello! I should be exported by qmltc"_s); +} + +void tst_qmltc::checkExportsNoFileName() +{ + QQmlEngine e; + QmltcExportedNoFileNameTest::HelloExportedWorldNoFileName w(&e); + QCOMPARE(w.myString(), u"Hello! I should be exported by qmltc"_s); +} + +#if QT_CONFIG(qml_table_model) +void tst_qmltc::qmlTableModel() +{ + QQmlEngine e; + PREPEND_NAMESPACE(QmlTableModel) createdByQmltc(&e); + // check that the tableModel is not default constructed + QVariant model = createdByQmltc.model(); + QVERIFY(model.isValid()); + QQmlTableModel *tableModel = model.value<QQmlTableModel *>(); + QVERIFY(tableModel); + QCOMPARE(tableModel->property("testName").toString(), u"MyTableModel"_s); +} +#endif + +void tst_qmltc::urlToString() +{ + QQmlEngine e; + PREPEND_NAMESPACE(stringToUrl) createdByQmltc(&e); + // check that the tableModel is not default constructed + QUrl first = createdByQmltc.iconLoader()->source(); + QUrl second = createdByQmltc.iconLoader2()->source(); + QCOMPARE(first, QUrl("qrc:/qt/qml/path/to/font.ttf")); + QCOMPARE(second, QUrl("qrc:/qt/qml/path/to/font2.ttf")); +} + +void tst_qmltc::signalConnections() +{ + QQmlEngine e; + PREPEND_NAMESPACE(signalConnections) createdByQmltc(&e); + + QVERIFY(createdByQmltc.objectName().isEmpty()); + createdByQmltc.setCycleFirst(true); + QTRY_VERIFY(!createdByQmltc.cycleFirst()); + QCOMPARE(createdByQmltc.objectName(), QLatin1String("first")); + + createdByQmltc.setObjectName(QLatin1String("none")); + createdByQmltc.setCycleEnabled(true); + QTRY_VERIFY(!createdByQmltc.cycleEnabled()); + + createdByQmltc.setCycleFirst(true); + QTRY_VERIFY(!createdByQmltc.cycleFirst()); + QCOMPARE(createdByQmltc.objectName(), QLatin1String("none")); + + createdByQmltc.setCycleEnabled(true); + QTRY_VERIFY(!createdByQmltc.cycleEnabled()); + + createdByQmltc.setCycleSecond(true); + QTRY_VERIFY(!createdByQmltc.cycleSecond()); + QCOMPARE(createdByQmltc.objectName(), QLatin1String("second")); } QTEST_MAIN(tst_qmltc) diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h index af084dcc01..ede6d551a0 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.h +++ b/tests/auto/qml/qmltc/tst_qmltc.h @@ -1,7 +1,8 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qtest.h> +#include <private/qtqmlmodelsglobal_p.h> using namespace Qt::StringLiterals; @@ -34,10 +35,13 @@ private slots: void jsvalueAssignments(); void extensionTypeBindings(); void visibleAliasMethods(); // QTBUG-103956 + void customInitialization(); // QTBUG-120700 + void requiredPropertiesInitialization(); void nonStandardIncludesInsideModule(); // QTBUG-104094 void specialProperties(); void regexpBindings(); void aliasAssignments(); + void connections(); void signalHandlers(); void jsFunctions(); @@ -93,4 +97,12 @@ private slots: void constSignalParameters(); void cppNamespaces(); void namespacedName(); + void checkExportsAreCompiling(); + void checkExportsNoFileName(); + +#if QT_CONFIG(qml_table_model) + void qmlTableModel(); +#endif + void urlToString(); + void signalConnections(); }; |