summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_add_resource_prefix
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_add_resource_prefix')
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt25
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/main.cpp26
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/resource_file.txt1
3 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt
new file mode 100644
index 0000000000..65faa4cb09
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_add_resource_prefix)
+
+find_package(Qt6 REQUIRED
+ COMPONENTS Core Test
+)
+
+set(CMAKE_AUTOMOC ON)
+
+add_executable(test_add_resource_prefix main.cpp)
+
+# Tests if "/" is being used when PREFIX is missing
+qt_add_resources(test_add_resource_prefix "resources_without_prefix"
+ FILES resource_file.txt)
+
+# Tests if the PREFIX parameter is being respected
+qt_add_resources(test_add_resource_prefix "resources_with_prefix"
+ PREFIX "/resources"
+ FILES resource_file.txt)
+
+target_link_libraries(test_add_resource_prefix PRIVATE Qt::Core Qt::Test)
diff --git a/tests/auto/cmake/test_add_resource_prefix/main.cpp b/tests/auto/cmake/test_add_resource_prefix/main.cpp
new file mode 100644
index 0000000000..1a8b37715b
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/main.cpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QFile>
+#include <QtTest>
+
+class TestAddResourcePrefix : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceInDefaultPathExists();
+ void resourceInGivenPathExists();
+};
+
+void TestAddResourcePrefix::resourceInDefaultPathExists()
+{
+ QVERIFY(QFile::exists(":/resource_file.txt"));
+}
+
+void TestAddResourcePrefix::resourceInGivenPathExists()
+{
+ QVERIFY(QFile::exists(":/resources/resource_file.txt"));
+}
+
+QTEST_MAIN(TestAddResourcePrefix)
+#include "main.moc"
diff --git a/tests/auto/cmake/test_add_resource_prefix/resource_file.txt b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt
new file mode 100644
index 0000000000..2c604a4f18
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt
@@ -0,0 +1 @@
+Ken sent me.