From 5e7a4d6bed8ab6c87ce530680e31aff2f7fdd408 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 13:51:12 +0100 Subject: [PATCH] Use new plugin system in plugin autotest. Fix up test use QFINDTESTDATA for shadow builds. Change-Id: I64731baa44f446ce360631ed6a638cea098d78a0 Reviewed-by: Lars Knoll --- .../auto/corelib/plugin/qplugin/debugplugin/main.cpp | 11 ++++++++++- .../corelib/plugin/qplugin/releaseplugin/main.cpp | 11 ++++++++++- tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp | 10 +++++++++- .../qpluginloader/almostplugin/almostplugin.cpp | 2 -- .../plugin/qpluginloader/almostplugin/almostplugin.h | 2 ++ tests/auto/corelib/plugin/qpluginloader/empty.json | 1 + .../plugin/qpluginloader/theplugin/plugininterface.h | 8 +++++++- .../plugin/qpluginloader/theplugin/theplugin.cpp | 3 --- .../plugin/qpluginloader/theplugin/theplugin.h | 2 ++ 9 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/auto/corelib/plugin/qpluginloader/empty.json diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp index 057db69174..e27085c293 100644 --- a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(DebugPlugin, QObject) +class DebugPlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + DebugPlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp index 9542695112..d0875d2902 100644 --- a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(ReleasePlugin, QObject) +class ReleasePlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + ReleasePlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index e6a83cf3d7..af76fcc4a2 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -55,15 +55,23 @@ public: tst_QPlugin(); private slots: + void initTestCase(); void loadDebugPlugin(); void loadReleasePlugin(); }; tst_QPlugin::tst_QPlugin() - : dir("plugins") + : dir(QFINDTESTDATA("plugins")) { } +void tst_QPlugin::initTestCase() +{ + QVERIFY2(dir.exists(), + qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). + arg(QDir::toNativeSeparators(QDir::currentPath())))); +} + void tst_QPlugin::loadDebugPlugin() { foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) { diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp index 4b2057087a..eaad3ceff5 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp @@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const unresolvedSymbol(); return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin) diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h index 6658a5be8d..d64f5985ec 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h @@ -42,11 +42,13 @@ #define ALMOSTPLUGIN_H #include +#include #include "../theplugin/plugininterface.h" class AlmostPlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: diff --git a/tests/auto/corelib/plugin/qpluginloader/empty.json b/tests/auto/corelib/plugin/qpluginloader/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h index a568dd118d..fe0892c0fe 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h @@ -41,13 +41,19 @@ #ifndef PLUGININTERFACE_H #define PLUGININTERFACE_H +#include + struct PluginInterface { virtual ~PluginInterface() {} virtual QString pluginName() const = 0; }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(PluginInterface, "com.trolltect.autotests.plugininterface/1.0") + +#define PluginInterface_iid "org.qt-project.Qt.autotests.plugininterface" + +Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid) + QT_END_NAMESPACE #endif // PLUGININTERFACE_H diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp index b064901a4d..8c97956a5f 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp @@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const { return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(theplugin, ThePlugin) - diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h index b769aa6eed..3b8f12140e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h @@ -42,11 +42,13 @@ #define THEPLUGIN_H #include +#include #include "plugininterface.h" class ThePlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: