Use new plugin system in plugin autotest.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Thu, 23 Feb 2012 12:51:12 +0000 (13:51 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 23 Feb 2012 15:38:45 +0000 (16:38 +0100)
Fix up test use QFINDTESTDATA for shadow builds.

Change-Id: I64731baa44f446ce360631ed6a638cea098d78a0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp
tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp
tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
tests/auto/corelib/plugin/qpluginloader/empty.json [new file with mode: 0644]
tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h

index 057db69..e27085c 100644 (file)
 **
 ****************************************************************************/
 #include <QtPlugin>
+#include <QObject>
 
-Q_EXPORT_PLUGIN2(DebugPlugin, QObject)
+class DebugPlugin : public QObject
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "SomeIID")
+public:
+    DebugPlugin() {}
+};
+
+#include "main.moc"
index 9542695..d0875d2 100644 (file)
 **
 ****************************************************************************/
 #include <QtPlugin>
+#include <QObject>
 
-Q_EXPORT_PLUGIN2(ReleasePlugin, QObject)
+class ReleasePlugin : public QObject
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "SomeIID")
+public:
+    ReleasePlugin() {}
+};
+
+#include "main.moc"
index e6a83cf..af76fcc 100644 (file)
@@ -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)) {
index 4b20570..eaad3ce 100644 (file)
@@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const
     unresolvedSymbol();
     return QLatin1String("Plugin ok");
 }
-
-Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin)
index 6658a5b..d64f598 100644 (file)
 #define ALMOSTPLUGIN_H
 
 #include <QObject>
+#include <QtPlugin>
 #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 (file)
index 0000000..0967ef4
--- /dev/null
@@ -0,0 +1 @@
+{}
index a568dd1..fe0892c 100644 (file)
 #ifndef PLUGININTERFACE_H
 #define PLUGININTERFACE_H
 
+#include <QtCore/QtGlobal>
+
 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
index b064901..8c97956 100644 (file)
@@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const
 {
     return QLatin1String("Plugin ok");
 }
-
-Q_EXPORT_PLUGIN2(theplugin, ThePlugin)
-
index b769aa6..3b8f121 100644 (file)
 #define THEPLUGIN_H
 
 #include <QObject>
+#include <QtPlugin>
 #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: