summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_static_resources/test_init_resources_static_plugin')
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt36
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp24
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp33
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt0
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt0
5 files changed, 93 insertions, 0 deletions
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt
new file mode 100644
index 0000000000..dec5588a6d
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC
+ NO_UNITY_BUILD
+ OUTPUT_NAME
+ testinitresourcesstaticplugin
+ PLUGIN_TYPE mockstaticresources
+ SOURCES
+ pluginmain.cpp
+ SKIP_INSTALL
+ LIBRARIES
+ Qt::Core
+)
+
+qt_internal_add_resource(TestInitResourcesStaticPlugin "teststaticplugin1"
+ PREFIX
+ "/teststaticplugin1"
+ FILES
+ "testfile1.txt"
+)
+
+qt_internal_add_resource(TestInitResourcesStaticPlugin "teststaticplugin2"
+ PREFIX
+ "/teststaticplugin2"
+ FILES
+ "testfile2.txt"
+)
+
+qt_internal_add_test(test_init_resources_static_plugin
+ SOURCES
+ test_init_resources_static_plugin.cpp
+ LIBRARIES
+ Qt::Core
+ TestInitResourcesStaticPlugin
+)
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp
new file mode 100644
index 0000000000..a95e54ee4f
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class TestStaticPlugin : public QObject
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "TestStaticPlugin" URI "qt.teststaticplugin")
+public:
+ TestStaticPlugin() = default;
+ Q_INVOKABLE bool checkResources()
+ {
+ return QFile::exists(":/teststaticplugin1/testfile1.txt")
+ && QFile::exists(":/teststaticplugin2/testfile2.txt");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "pluginmain.moc"
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp
new file mode 100644
index 0000000000..2067b8c920
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QtCore/qfile.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qpluginloader.h>
+#include <QtPlugin>
+
+Q_IMPORT_PLUGIN(TestStaticPlugin)
+
+class TestInitResourcesStaticPlugin : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceFilesExist();
+};
+
+void TestInitResourcesStaticPlugin::resourceFilesExist()
+{
+ bool result = false;
+ for (QObject *obj : QPluginLoader::staticInstances()) {
+ if (obj->metaObject()->className() == QLatin1String("TestStaticPlugin")) {
+ QMetaObject::invokeMethod(obj, "checkResources", Qt::DirectConnection,
+ Q_RETURN_ARG(bool, result));
+ }
+ break;
+ }
+ QVERIFY(result);
+}
+
+QTEST_MAIN(TestInitResourcesStaticPlugin)
+#include "test_init_resources_static_plugin.moc"
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt