Use new plugin system in plugin autotest.

Fix up test use QFINDTESTDATA for shadow builds.

Change-Id: I64731baa44f446ce360631ed6a638cea098d78a0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-02-23 13:51:12 +01:00 committed by Qt by Nokia
parent 19a562a923
commit 5e7a4d6bed
9 changed files with 41 additions and 9 deletions

View File

@ -39,5 +39,14 @@
**
****************************************************************************/
#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"

View File

@ -39,5 +39,14 @@
**
****************************************************************************/
#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"

View 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)) {

View File

@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const
unresolvedSymbol();
return QLatin1String("Plugin ok");
}
Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin)

View File

@ -42,11 +42,13 @@
#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:

View File

@ -0,0 +1 @@
{}

View File

@ -41,13 +41,19 @@
#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

View File

@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const
{
return QLatin1String("Plugin ok");
}
Q_EXPORT_PLUGIN2(theplugin, ThePlugin)

View File

@ -42,11 +42,13 @@
#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: