diff options
author | David Faure <faure+bluesystems@kde.org> | 2012-12-03 12:29:10 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-04 18:38:41 +0100 |
commit | 418890e0748384eb684f33b10dc6f32493aee54b (patch) | |
tree | f3a6e1064e71046556466a92eda0fc7adcfebd04 /tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | |
parent | f6cc1f3aeae795e7ed67338b17b860df9f5146a7 (diff) |
QPluginLoader: fix loading of plugins with a relative file name
This makes QT_PLUGIN_PATH / QCoreApplication::libraryPaths() actually work,
as a search path for plugins, when apps look for a specific plugin by name.
To make it possible to write portable code (unlike the current QPluginLoader
unittest), let QPluginLoader figure out the extension, too.
Change-Id: I895d597d7cb05ded268734bc5f313f32d8d12cb9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp')
-rw-r--r-- | tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 155267f80b..34ec66f63f 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -59,7 +59,11 @@ # define bundle_VALID true # define dylib_VALID true # define so_VALID true -# define SUFFIX ".dylib" +//# ifdef QT_NO_DEBUG +# define SUFFIX ".dylib" +//# else +//# define SUFFIX "_debug.dylib" +//#endif # define PREFIX "lib" #elif defined(Q_OS_HPUX) && !defined(__ia64) @@ -79,11 +83,11 @@ #elif defined(Q_OS_WIN) # undef dll_VALID # define dll_VALID true -# ifdef QT_NO_DEBUG +//# ifdef QT_NO_DEBUG # define SUFFIX ".dll" -# else -# define SUFFIX "d.dll" -# endif +//# else +//# define SUFFIX "d.dll" +//# endif # define PREFIX "" #else // all other Unix @@ -111,6 +115,7 @@ private slots: #if defined (Q_OS_UNIX) void loadGarbage(); #endif + void relativePath(); void reloadPlugin(); }; @@ -294,6 +299,20 @@ void tst_QPluginLoader::loadGarbage() } #endif +void tst_QPluginLoader::relativePath() +{ + // Windows binaries run from release and debug subdirs, so we can't rely on the current dir. + const QString binDir = QFINDTESTDATA("bin"); + QVERIFY(!binDir.isEmpty()); + QCoreApplication::addLibraryPath(binDir); + QPluginLoader loader("theplugin"); + loader.load(); // not recommended, instance() should do the job. + PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance()); + QVERIFY(instance); + QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok")); + QVERIFY(loader.unload()); +} + void tst_QPluginLoader::reloadPlugin() { QPluginLoader loader; |