aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-08-06 20:05:46 +1000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-11 08:28:38 +0000
commit723b411a23ca98555310e30236806a2780f0cdc2 (patch)
treee71844994caeabb905798e63b0b5731647eb062a /tests
parent193694375df3454ff0e24fb7a289558215f97d02 (diff)
Update and re-add qtquickcompiler cmake test
Change-Id: I9bd3147f102168fb6d901a27dc8dc9ec85e0a62b Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 8b2b39a000e4ff4605fd3f0dd7d9c63230c9f4a1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cmake/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/qtquickcompiler/CMakeLists.txt32
-rw-r--r--tests/auto/cmake/qtquickcompiler/empty.qrc0
-rw-r--r--tests/auto/cmake/qtquickcompiler/main.cpp38
-rw-r--r--tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc6
5 files changed, 55 insertions, 23 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index b52431f9f1..91521cecbc 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -59,7 +59,7 @@ if(TARGET Qt::Qml AND NOT QT6_IS_SHARED_LIBS_BUILD)
endif()
if(TARGET Qt::Quick)
- # _qt_internal_test_expect_pass(qtquickcompiler) # TODO: Replace with 6.2 qml module API
+ _qt_internal_test_expect_pass(qtquickcompiler BINARY qqc_test)
# _qt_internal_test_expect_pass(qmlimportscanner) # TODO: Replace with 6.2 qml module API
endif()
diff --git a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt
index 1eb4c4286c..c717ed01a3 100644
--- a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt
+++ b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt
@@ -1,17 +1,29 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.16)
project(qqc_test)
-find_package(Qt6Qml 6.0.0 REQUIRED)
-find_package(Qt6Gui 6.0.0 REQUIRED)
-find_package(Qt6Test 6.0.0 REQUIRED)
-find_package(Qt6QuickCompiler)
+find_package(Qt6 ${CMAKE_Core_MODULE_MAJOR_VERSION}.${CMAKE_Core_MODULE_MINOR_VERSION}
+ REQUIRED COMPONENTS Qml Gui Test
+)
-set(CMAKE_CXXFLAGS "${CMAKE_CXXFLAGS} ${Qt6Core_EXECUTABLE_COMPILE_FLAGS}")
+set(CMAKE_AUTOMOC ON)
-qtquick_compiler_add_resources(RESOURCES "empty.qrc" "resources with space/qqc_test.qrc")
+qt_add_executable(qqc_test
+ # Absolute path needed to avoid using the copied file in the build dir.
+ # That would still work, but it should use the file in the source dir.
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+)
+target_link_libraries(qqc_test PRIVATE Qt6::Gui Qt6::Qml Qt6::Test)
-set(CMAKE_AUTOMOC ON)
+set_source_files_properties("resources with space/main.qml" PROPERTIES
+ QT_RESOURCE_ALIAS main.qml
+)
-add_executable(qqc_test "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${RESOURCES})
-target_link_libraries(qqc_test Qt6::Gui Qt6::Qml Qt6::Test)
+qt_add_qml_module(qqc_test
+ URI Test
+ VERSION 1.0
+ QML_FILES
+ "resources with space/main.qml"
+ RESOURCES
+ main.cpp
+)
diff --git a/tests/auto/cmake/qtquickcompiler/empty.qrc b/tests/auto/cmake/qtquickcompiler/empty.qrc
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/auto/cmake/qtquickcompiler/empty.qrc
+++ /dev/null
diff --git a/tests/auto/cmake/qtquickcompiler/main.cpp b/tests/auto/cmake/qtquickcompiler/main.cpp
index c357ef60e6..3cdf4cf40b 100644
--- a/tests/auto/cmake/qtquickcompiler/main.cpp
+++ b/tests/auto/cmake/qtquickcompiler/main.cpp
@@ -1,3 +1,30 @@
+/****************************************************************************
+**
+** 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>
@@ -12,14 +39,13 @@ private slots:
void tst_QQC::packaging()
{
- QVERIFY(QFile::exists(":/main.qml"));
- QCOMPARE(QFileInfo(":/main.qml").size(), 0);
- QVERIFY(QFile::exists(":/main.cpp"));
- QVERIFY(QFileInfo(":/main.cpp").size() > 0);
-
+ QVERIFY(QFile::exists(":/Test/main.qml"));
+ QVERIFY(QFileInfo(":/Test/main.qml").size() > 0);
+ QVERIFY(QFile::exists(":/Test/main.cpp"));
+ QVERIFY(QFileInfo(":/Test/main.cpp").size() > 0);
QQmlEngine engine;
- QQmlComponent component(&engine, QUrl("qrc:/main.qml"));
+ QQmlComponent component(&engine, QUrl("qrc:/Test/main.qml"));
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
QCOMPARE(obj->property("success").toInt(), 42);
diff --git a/tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc b/tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc
deleted file mode 100644
index 63d8d1f37e..0000000000
--- a/tests/auto/cmake/qtquickcompiler/resources with space/qqc_test.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
-<file>./main.qml</file>
-<file alias="main.cpp">../main.cpp</file>
-</qresource>
-</RCC>