diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-02-21 13:56:21 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-27 07:09:13 +0100 |
commit | 790fe22c52f15d4ba1c9e48d6f6847d286cb916f (patch) | |
tree | 0ca374dd76f3a13e99be2478a35d3937396cbbbd /tests/auto/corelib | |
parent | 2c51bc0289e5f4a8a2cfb4a57562633c1018ab58 (diff) |
Autotest: check that the plugin was actually unloaded in QPluginLoader
Change-Id: I66d26da4e86add244d37ff670ad79ff2aff17ca1
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index f0be8cf6f1..e056fe2b95 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -106,6 +106,8 @@ QT_FORWARD_DECLARE_CLASS(QPluginLoader) class tst_QPluginLoader : public QObject { Q_OBJECT +public slots: + void cleanup(); private slots: void errorString(); void loadHints(); @@ -119,6 +121,21 @@ private slots: void reloadPlugin(); }; +void tst_QPluginLoader::cleanup() +{ + // check if the library/plugin was leaked + // we can't use QPluginLoader::isLoaded here because on some platforms the plugin is always loaded by QPluginLoader. + // Also, if this test fails once, it will keep on failing because we can't force the unload, + // so we report it only once. + static bool failedAlready = false; + if (!failedAlready) { + QLibrary lib(sys_qualifiedLibraryName("theplugin")); + failedAlready = true; + QVERIFY2(!lib.isLoaded(), "Plugin was leaked - will not check again"); + failedAlready = false; + } +} + void tst_QPluginLoader::errorString() { #if defined(Q_OS_WINCE) @@ -334,6 +351,9 @@ void tst_QPluginLoader::reloadPlugin() PluginInterface *instance2 = qobject_cast<PluginInterface*>(loader.instance()); QVERIFY(instance2); QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok")); + + QVERIFY(loader.unload()); +} } QTEST_MAIN(tst_QPluginLoader) |