summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qfactoryloader
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-06-13 12:52:28 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-06-20 15:41:20 +0200
commit666ce51d4eb6b5dd312f98e2d7a18c54b59945e4 (patch)
treed0e16835bf644e3cbace5ec7cc7743ff679f521c /tests/auto/corelib/plugin/qfactoryloader
parenta12abc2614cf69be676436af99eb62363fdaff3d (diff)
QLibraryPrivate: Actually merge load hints
Or old and new load hints in mergeLoadHints() instead of just storing new ones. Andjust QLibraryPrivate::setLoadHints() to handle objects with no file name differently and just set load hints directly. Mention that load hints are merged once the file name is set in the documentation for QLibrary::setLoadHints(). Add a regression test into tst_qfactoryloader. Update and extend tst_QPluginLoader::loadHints() to take into account load hints merging. Fixes: QTBUG-114480 Change-Id: I3b9afaec7acde1f5ff992d913f8d7217392c7e00 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/plugin/qfactoryloader')
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h2
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.json5
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp25
3 files changed, 31 insertions, 1 deletions
diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h
index 8afb501f04..c1a1f6581a 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h
+++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h
@@ -10,7 +10,7 @@
class Plugin1 : public QObject, public PluginInterface1
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface1")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface1" FILE "plugin1.json")
Q_INTERFACES(PluginInterface1)
public:
diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.json b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.json
new file mode 100644
index 0000000000..ce67846d48
--- /dev/null
+++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.json
@@ -0,0 +1,5 @@
+{
+ "Keys": [
+ "plugin1"
+ ]
+}
diff --git a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp
index a3ee6fa3d4..51befe821a 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp
+++ b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp
@@ -6,6 +6,7 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/qplugin.h>
#include <private/qfactoryloader_p.h>
+#include <private/qlibrary_p.h>
#include "plugin1/plugininterface1.h"
#include "plugin2/plugininterface2.h"
@@ -29,6 +30,7 @@ public slots:
private slots:
void usingTwoFactoriesFromSameDir();
void extraSearchPath();
+ void multiplePaths();
};
static const char binFolderC[] = "bin";
@@ -109,5 +111,28 @@ void tst_QFactoryLoader::extraSearchPath()
#endif
}
+void tst_QFactoryLoader::multiplePaths()
+{
+#if !QT_CONFIG(library) || !(defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)) || defined(Q_OS_ANDROID)
+ QSKIP("Test not applicable in this configuration.");
+#else
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ QString pluginsPath = QFileInfo(binFolder, binFolderC).absolutePath();
+ QString linkPath = dir.filePath(binFolderC);
+ QVERIFY(QFile::link(pluginsPath, linkPath));
+
+ QCoreApplication::setLibraryPaths({ QFileInfo(binFolder).absolutePath(), dir.path() });
+
+ const QString suffix = QLatin1Char('/') + QLatin1String(binFolderC);
+ QFactoryLoader loader1(PluginInterface1_iid, suffix);
+
+ QLibraryPrivate *library1 = loader1.library("plugin1");
+ QVERIFY(library1);
+ QCOMPARE(library1->loadHints(), QLibrary::PreventUnloadHint);
+#endif
+}
+
QTEST_MAIN(tst_QFactoryLoader)
#include "tst_qfactoryloader.moc"