diff options
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 12 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/CMakeLists.txt | 32 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/First/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/First/DoSomething.qml | 7 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/First/Neighbor.cpp | 33 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/First/Neighbor.h | 43 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/Second/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/Second/CheckIt.qml | 7 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/Ttt.qml | 3 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/main.cpp | 51 | ||||
-rw-r--r-- | tests/auto/cmake/tooling_imports/main.qml | 11 |
11 files changed, 210 insertions, 3 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 91521cecbc..1be8dbdf31 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -53,9 +53,15 @@ endif() _qt_internal_test_module_includes(${module_includes}) -# TODO: Plugin targets are not available in shared builds at the moment QTBUG-94066 -if(TARGET Qt::Qml AND NOT QT6_IS_SHARED_LIBS_BUILD) - _qt_internal_test_expect_pass(test_plugins) +if(TARGET Qt::Qml) + _qt_internal_test_expect_pass(tooling_imports TESTNAME cmake_tooling_imports BINARY cmake_test) + set_tests_properties(cmake_tooling_imports PROPERTIES + FAIL_REGULAR_EXPRESSION "(Info|Warning|Error): [a-zA-Z]*\\.qml:[0-9]" + ) + # TODO: Plugin targets are not available in shared builds at the moment QTBUG-94066 + if(NOT QT6_IS_SHARED_LIBS_BUILD) + _qt_internal_test_expect_pass(test_plugins) + endif() endif() if(TARGET Qt::Quick) diff --git a/tests/auto/cmake/tooling_imports/CMakeLists.txt b/tests/auto/cmake/tooling_imports/CMakeLists.txt new file mode 100644 index 0000000000..5e275f0739 --- /dev/null +++ b/tests/auto/cmake/tooling_imports/CMakeLists.txt @@ -0,0 +1,32 @@ + +cmake_minimum_required(VERSION 3.16) +project(cmake_test) + +find_package(Qt6 ${CMAKE_Core_MODULE_MAJOR_VERSION}.${CMAKE_Core_MODULE_MINOR_VERSION} + REQUIRED COMPONENTS Qml Gui Test +) + +set(CMAKE_AUTOMOC ON) + +# Simplify finding the backing targets' DLLs on Windows +if(WIN32) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endif() + +add_subdirectory(First) +add_subdirectory(Second) + +qt_add_executable(cmake_test main.cpp) +target_link_libraries(cmake_test PRIVATE Qt6::Test) + +qt_add_qml_module(cmake_test + URI Test + VERSION 1.0 + NO_RESOURCE_TARGET_PATH + QML_FILES + main.qml + Ttt.qml +) + +# Ensure linting runs when building the default "all" target +set_target_properties(all_qmllint PROPERTIES EXCLUDE_FROM_ALL FALSE) diff --git a/tests/auto/cmake/tooling_imports/First/CMakeLists.txt b/tests/auto/cmake/tooling_imports/First/CMakeLists.txt new file mode 100644 index 0000000000..64d3291612 --- /dev/null +++ b/tests/auto/cmake/tooling_imports/First/CMakeLists.txt @@ -0,0 +1,9 @@ +qt_add_qml_module(BackingFirst + URI First + VERSION 1.0 + SOURCES + Neighbor.cpp + Neighbor.h + QML_FILES + DoSomething.qml +) diff --git a/tests/auto/cmake/tooling_imports/First/DoSomething.qml b/tests/auto/cmake/tooling_imports/First/DoSomething.qml new file mode 100644 index 0000000000..82ee2b94f2 --- /dev/null +++ b/tests/auto/cmake/tooling_imports/First/DoSomething.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +import First // Self import + +QtObject { + property int success: 42 + property Neighbor other +} diff --git a/tests/auto/cmake/tooling_imports/First/Neighbor.cpp b/tests/auto/cmake/tooling_imports/First/Neighbor.cpp new file mode 100644 index 0000000000..38fedbaa6d --- /dev/null +++ b/tests/auto/cmake/tooling_imports/First/Neighbor.cpp @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "Neighbor.h" + +Neighbor::Neighbor(QObject *parent) : QObject(parent) { } + +#include "moc_Neighbor.cpp" diff --git a/tests/auto/cmake/tooling_imports/First/Neighbor.h b/tests/auto/cmake/tooling_imports/First/Neighbor.h new file mode 100644 index 0000000000..ef6cc2d58b --- /dev/null +++ b/tests/auto/cmake/tooling_imports/First/Neighbor.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef NEIGHBOR_H +#define NEIGHBOR_H + +#include <QtQml/qqml.h> + +class Neighbor : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(Neighbor) + +public: + Neighbor(QObject *parent = nullptr); +}; + +#endif // NEIGHBOR_H diff --git a/tests/auto/cmake/tooling_imports/Second/CMakeLists.txt b/tests/auto/cmake/tooling_imports/Second/CMakeLists.txt new file mode 100644 index 0000000000..e3513269fc --- /dev/null +++ b/tests/auto/cmake/tooling_imports/Second/CMakeLists.txt @@ -0,0 +1,5 @@ +qt_add_qml_module(BackingSecond + URI Second + VERSION 1.0 + QML_FILES CheckIt.qml +) diff --git a/tests/auto/cmake/tooling_imports/Second/CheckIt.qml b/tests/auto/cmake/tooling_imports/Second/CheckIt.qml new file mode 100644 index 0000000000..6bf8659bfc --- /dev/null +++ b/tests/auto/cmake/tooling_imports/Second/CheckIt.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +import First + +QtObject { + property DoSomething otherModule: DoSomething {} + property int dummy: otherModule.success + 13 +} diff --git a/tests/auto/cmake/tooling_imports/Ttt.qml b/tests/auto/cmake/tooling_imports/Ttt.qml new file mode 100644 index 0000000000..8fc36a40da --- /dev/null +++ b/tests/auto/cmake/tooling_imports/Ttt.qml @@ -0,0 +1,3 @@ +import QtQml + +QtObject {} diff --git a/tests/auto/cmake/tooling_imports/main.cpp b/tests/auto/cmake/tooling_imports/main.cpp new file mode 100644 index 0000000000..65663f84cc --- /dev/null +++ b/tests/auto/cmake/tooling_imports/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtQml> +#include <QtTest> + +class tst_cmake_qmllint : public QObject +{ + Q_OBJECT +private slots: + void canImport(); +}; + +void tst_cmake_qmllint::canImport() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:/main.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY2(!obj.isNull(), qPrintable(component.errorString())); + QCOMPARE(obj->property("result").toInt(), 97); +} + +QTEST_MAIN(tst_cmake_qmllint) + +#include "main.moc" diff --git a/tests/auto/cmake/tooling_imports/main.qml b/tests/auto/cmake/tooling_imports/main.qml new file mode 100644 index 0000000000..cc2c49ad41 --- /dev/null +++ b/tests/auto/cmake/tooling_imports/main.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import First +import Second +import Test // Self import + +QtObject { + property DoSomething firstModule: DoSomething{} + property CheckIt secondModule: CheckIt{} + property int result: firstModule.success + secondModule.dummy + property Ttt mine: Ttt{} +} |