Commit 06afc48d authored by con's avatar con
Browse files

Make extension system tests running again.

parent 7a770921
TEMPLATE = subdirs
SUBDIRS = pluginmanager pluginspec
SUBDIRS = pluginmanager \
pluginspec
#set COPYFILES and COPYDIR
# stolen from qtcreatorplugin.pri
copy2build.input = COPYFILES
copy2build.output = $$COPYDIR/${QMAKE_FUNC_FILE_IN_stripSrcDir}
isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS
copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
copy2build.name = COPY ${QMAKE_FILE_IN}
copy2build.CONFIG += no_link
QMAKE_EXTRA_COMPILERS += copy2build
TEMPLATE = lib
TARGET = plugin1
SOURCES += plugin1.cpp
HEADERS += plugin1.h
RELATIVEPATH=../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.xml
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin1)
TEMPLATE = lib
TARGET = plugin2
SOURCES += plugin2.cpp
HEADERS += plugin2.h
RELATIVEPATH = ../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.xml
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin2)
TEMPLATE = lib
TARGET = plugin3
SOURCES += plugin3.cpp
HEADERS += plugin3.h
RELATIVEPATH = ../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.xml
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin3)
TEMPLATE = lib
TARGET = plugin1
SOURCES += plugin1.cpp
HEADERS += plugin1.h
RELATIVEPATH = ../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.spec
LIBS += -L$${OUT_PWD}/../plugin2 -L$${OUT_PWD}/../plugin3 -lplugin2 -lplugin3
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin1)
LIBS += -L$${OUT_PWD}/../plugin2 -L$${OUT_PWD}/../plugin3 -l$$qtLibraryName(plugin2) -l$$qtLibraryName(plugin3)
macx {
} else:unix {
......
TEMPLATE = lib
TARGET = plugin2
SOURCES += plugin2.cpp
HEADERS += plugin2.h
RELATIVEPATH = ../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.spec
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin2)
macx {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$${OUT_PWD}/
......
TEMPLATE = lib
TARGET = plugin3
SOURCES += plugin3.cpp
HEADERS += plugin3.h
RELATIVEPATH = ../../../..
include(../../../../extensionsystem_test.pri)
OTHER_FILES = $$PWD/plugin.spec
LIBS += -L$${OUT_PWD}/../plugin2 -lplugin2
include(../../../../../../../../qtcreator.pri)
include(../../../../../extensionsystem.pri)
include(../../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../../../copy.pri)
TARGET = $$qtLibraryName(plugin3)
LIBS += -L$${OUT_PWD}/../plugin2 -l$$qtLibraryName(plugin2)
macx {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$${OUT_PWD}/
......
......@@ -2,14 +2,19 @@
# Automatically generated by qmake (2.01a) Fr Jul 27 23:12:52 2007
######################################################################
CONFIG += qtestlib
TEMPLATE = app
CONFIG -= app_bundle
TARGET = pluginmanager
# Input
RELATIVEPATH = ../..
include(../../extensionsystem_test.pri)
include(../../../../../../tests/auto/qttest.pri)
include(../../../extensionsystem.pri)
SOURCES += tst_pluginmanager.cpp
OTHER_FILES = $$PWD/plugins/otherplugin.xml \
$$PWD/plugins/plugin1.xml \
$$PWD/plugins/myplug/myplug.xml
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../copy.pri)
......@@ -55,30 +55,9 @@ private slots:
private:
PluginManager *m_pm;
SignalReceiver *m_sr;
};
class SignalReceiver : public QObject
{
Q_OBJECT
public:
SignalReceiver() :
objectAddedCount(0),
aboutToRemoveObjectCount(0),
pluginsChangedCount(0),
objectAddedObj(0),
aboutToRemoveObjectObj(0)
{ }
int objectAddedCount;
int aboutToRemoveObjectCount;
int pluginsChangedCount;
QObject *objectAddedObj;
QObject *aboutToRemoveObjectObj;
public slots:
void objectAdded(QObject *obj) { objectAddedCount++; objectAddedObj = obj; }
void aboutToRemoveObject(QObject *obj) { aboutToRemoveObjectCount++; aboutToRemoveObjectObj = obj; }
void pluginsChanged() { pluginsChangedCount++; }
QSignalSpy *m_objectAdded;
QSignalSpy *m_aboutToRemoveObject;
QSignalSpy *m_pluginsChanged;
};
class MyClass1 : public QObject
......@@ -99,16 +78,17 @@ class MyClass11 : public MyClass1
void tst_PluginManager::init()
{
m_pm = new PluginManager;
m_sr = new SignalReceiver;
connect(m_pm, SIGNAL(objectAdded(QObject*)), m_sr, SLOT(objectAdded(QObject*)));
connect(m_pm, SIGNAL(aboutToRemoveObject(QObject*)), m_sr, SLOT(aboutToRemoveObject(QObject*)));
connect(m_pm, SIGNAL(pluginsChanged()), m_sr, SLOT(pluginsChanged()));
m_objectAdded = new QSignalSpy(m_pm, SIGNAL(objectAdded(QObject*)));
m_aboutToRemoveObject = new QSignalSpy(m_pm, SIGNAL(aboutToRemoveObject(QObject*)));
m_pluginsChanged = new QSignalSpy(m_pm, SIGNAL(pluginsChanged()));
}
void tst_PluginManager::cleanup()
{
delete m_pm;
delete m_sr;
delete m_objectAdded;
delete m_aboutToRemoveObject;
delete m_pluginsChanged;
}
void tst_PluginManager::addRemoveObjects()
......@@ -117,30 +97,30 @@ void tst_PluginManager::addRemoveObjects()
QObject *object2 = new QObject;
QCOMPARE(m_pm->allObjects().size(), 0);
m_pm->addObject(object1);
QCOMPARE(m_sr->objectAddedCount, 1);
QCOMPARE(m_sr->objectAddedObj, object1);
QCOMPARE(m_sr->aboutToRemoveObjectCount, 0);
QCOMPARE(m_objectAdded->count(), 1);
QCOMPARE(m_objectAdded->at(0).first().value<QObject *>(), object1);
QCOMPARE(m_aboutToRemoveObject->count(), 0);
QVERIFY(m_pm->allObjects().contains(object1));
QVERIFY(!m_pm->allObjects().contains(object2));
QCOMPARE(m_pm->allObjects().size(), 1);
m_pm->addObject(object2);
QCOMPARE(m_sr->objectAddedCount, 2);
QCOMPARE(m_sr->objectAddedObj, object2);
QCOMPARE(m_sr->aboutToRemoveObjectCount, 0);
QCOMPARE(m_objectAdded->count(), 2);
QCOMPARE(m_objectAdded->at(1).first().value<QObject *>(), object2);
QCOMPARE(m_aboutToRemoveObject->count(), 0);
QVERIFY(m_pm->allObjects().contains(object1));
QVERIFY(m_pm->allObjects().contains(object2));
QCOMPARE(m_pm->allObjects().size(), 2);
m_pm->removeObject(object1);
QCOMPARE(m_sr->objectAddedCount, 2);
QCOMPARE(m_sr->aboutToRemoveObjectCount, 1);
QCOMPARE(m_sr->aboutToRemoveObjectObj, object1);
QCOMPARE(m_objectAdded->count(), 2);
QCOMPARE(m_aboutToRemoveObject->count(), 1);
QCOMPARE(m_aboutToRemoveObject->at(0).first().value<QObject *>(), object1);
QVERIFY(!m_pm->allObjects().contains(object1));
QVERIFY(m_pm->allObjects().contains(object2));
QCOMPARE(m_pm->allObjects().size(), 1);
m_pm->removeObject(object2);
QCOMPARE(m_sr->objectAddedCount, 2);
QCOMPARE(m_sr->aboutToRemoveObjectCount, 2);
QCOMPARE(m_sr->aboutToRemoveObjectObj, object2);
QCOMPARE(m_objectAdded->count(), 2);
QCOMPARE(m_aboutToRemoveObject->count(), 2);
QCOMPARE(m_aboutToRemoveObject->at(1).first().value<QObject *>(), object2);
QVERIFY(!m_pm->allObjects().contains(object1));
QVERIFY(!m_pm->allObjects().contains(object2));
QCOMPARE(m_pm->allObjects().size(), 0);
......@@ -197,7 +177,7 @@ void tst_PluginManager::getObjects()
void tst_PluginManager::plugins()
{
m_pm->setPluginPaths(QStringList() << "plugins");
QCOMPARE(m_sr->pluginsChangedCount, 1);
QCOMPARE(m_pluginsChanged->count(), 1);
QList<PluginSpec *> plugins = m_pm->plugins();
QCOMPARE(plugins.count(), 3);
foreach (const QString &expected, QStringList() << "helloworld" << "MyPlugin" << "dummyPlugin") {
......
CONFIG += qtestlib
TEMPLATE = app
CONFIG -= app_bundle
TARGET = pluginspec
# Input
SOURCES += tst_pluginspec.cpp
RELATIVEPATH = ../..
include(../../extensionsystem_test.pri)
OTHER_FILES += \
$$PWD/testspecs/simplespec.xml \
$$PWD/testspecs/simplespec_experimental.xml \
$$PWD/testspecs/spec1.xml \
$$PWD/testspecs/spec2.xml \
$$PWD/testspecs/spec_wrong1.xml \
$$PWD/testspecs/spec_wrong2.xml \
$$PWD/testspecs/spec_wrong3.xml \
$$PWD/testspecs/spec_wrong4.xml \
$$PWD/testspecs/spec_wrong5.xml \
$$PWD/testdependencies/spec1.xml \
$$PWD/testdependencies/spec2.xml \
$$PWD/testdependencies/spec3.xml \
$$PWD/testdependencies/spec4.xml \
$$PWD/testdependencies/spec5.xml \
$$PWD/testdir/spec.xml
LIBS += -L$${OUT_PWD}/testplugin -ltest
macx {
} else:unix {
QMAKE_RPATHDIR += $${OUT_PWD}/testplugin
}
include(../../../../../../tests/auto/qttest.pri)
include(../../../extensionsystem.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$OTHER_FILES
include(../copy.pri)
# -- run the plugin test from this directory.
export LD_LIBRARY_PATH=../../../../../../lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=../../../../../../bin/QtCreator.app/Contents/PlugIns:$DYLD_LIBRARY_PATH # mac
exec ./test
......@@ -47,8 +47,10 @@ public:
bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized();
public slots:
bool isInitialized() { return m_isInitialized; }
bool isExtensionsInitialized() { return m_isExtensionsInitialized; }
private:
bool m_isInitialized;
bool m_isExtensionsInitialized;
......
include(../../../../../../../qtcreator.pri)
TEMPLATE = lib
TARGET = test
TARGET = $$qtLibraryName(test)
DEFINES += MYPLUGIN_LIBRARY
SOURCES += testplugin.cpp
HEADERS += testplugin.h testplugin_global.h
RELATIVEPATH = ../../..
include(../../../extensionsystem_test.pri)
OTHER_FILES += testplugin.xml
include(../../../../extensionsystem.pri)
macx {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$${OUT_PWD}/
}
include(../../../../../../../tests/auto/qttestrpath.pri)
COPYDIR = $$OUT_PWD
COPYFILES = $$PWD/testplugin.xml
include(../../copy.pri)
......@@ -27,14 +27,13 @@
**
**************************************************************************/
#include "testplugin/testplugin.h"
#include <extensionsystem/pluginspec.h>
#include <extensionsystem/pluginspec_p.h>
#include <extensionsystem/pluginmanager_p.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QObject>
#include <QtCore/QMetaObject>
#include <QtTest/QtTest>
using namespace ExtensionSystem;
......@@ -241,7 +240,8 @@ void tst_PluginSpec::loadLibrary()
QVERIFY(spec->read("testplugin/testplugin.xml"));
QVERIFY(spec->resolveDependencies(QList<PluginSpec *>()));
QVERIFY(spec->loadLibrary());
QVERIFY(qobject_cast<MyPlugin::MyPluginImpl*>(spec->plugin) != 0);
QVERIFY(spec->plugin != 0);
QVERIFY(QString::fromLocal8Bit(spec->plugin->metaObject()->className()) == QString::fromLocal8Bit("MyPlugin::MyPluginImpl"));
QCOMPARE(spec->state, PluginSpec::Loaded);
QVERIFY(!spec->hasError);
QCOMPARE(spec->plugin->pluginSpec(), ps);
......@@ -252,33 +252,38 @@ void tst_PluginSpec::loadLibrary()
void tst_PluginSpec::initializePlugin()
{
Internal::PluginSpecPrivate spec(0);
MyPlugin::MyPluginImpl *impl;
QVERIFY(spec.read("testplugin/testplugin.xml"));
QVERIFY(spec.resolveDependencies(QList<PluginSpec *>()));
QVERIFY(spec.loadLibrary());
impl = qobject_cast<MyPlugin::MyPluginImpl*>(spec.plugin);
QVERIFY(impl != 0);
QVERIFY(!impl->isInitialized());
bool isInitialized;
QMetaObject::invokeMethod(spec.plugin, "isInitialized",
Qt::DirectConnection, Q_RETURN_ARG(bool, isInitialized));
QVERIFY(!isInitialized);
QVERIFY(spec.initializePlugin());
QCOMPARE(spec.state, PluginSpec::Initialized);
QVERIFY(!spec.hasError);
QVERIFY(impl->isInitialized());
QMetaObject::invokeMethod(spec.plugin, "isInitialized",
Qt::DirectConnection, Q_RETURN_ARG(bool, isInitialized));
QVERIFY(isInitialized);
}
void tst_PluginSpec::initializeExtensions()
{
Internal::PluginSpecPrivate spec(0);
MyPlugin::MyPluginImpl *impl;
QVERIFY(spec.read("testplugin/testplugin.xml"));
QVERIFY(spec.resolveDependencies(QList<PluginSpec *>()));
QVERIFY(spec.loadLibrary());
impl = qobject_cast<MyPlugin::MyPluginImpl*>(spec.plugin);
QVERIFY(impl != 0);
bool isExtensionsInitialized;
QVERIFY(spec.initializePlugin());
QMetaObject::invokeMethod(spec.plugin, "isExtensionsInitialized",
Qt::DirectConnection, Q_RETURN_ARG(bool, isExtensionsInitialized));
QVERIFY(!isExtensionsInitialized);
QVERIFY(spec.initializeExtensions());
QCOMPARE(spec.state, PluginSpec::Running);
QVERIFY(!spec.hasError);
QVERIFY(impl->isExtensionsInitialized());
QMetaObject::invokeMethod(spec.plugin, "isExtensionsInitialized",
Qt::DirectConnection, Q_RETURN_ARG(bool, isExtensionsInitialized));
QVERIFY(isExtensionsInitialized);
}
QTEST_MAIN(tst_PluginSpec)
......
......@@ -11,16 +11,7 @@ symbian:{
RSS_RULES ="group_name=\"QtTests\";"
}
linux-* {
QMAKE_RPATHDIR += $$IDE_BUILD_TREE/$$IDE_LIBRARY_BASENAME/qtcreator
QMAKE_RPATHDIR += $$IDE_PLUGIN_PATH/Nokia
IDE_PLUGIN_RPATH = $$join(QMAKE_RPATHDIR, ":")
QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${IDE_PLUGIN_RPATH}\'
} else:macx {
QMAKE_LFLAGS += -Wl,-rpath,\"$$IDE_BIN_PATH/../\"
}
include(qttestrpath.pri)
# prefix test binary with tst_
!contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_")
linux-* {
QMAKE_RPATHDIR += $$IDE_BUILD_TREE/$$IDE_LIBRARY_BASENAME/qtcreator
QMAKE_RPATHDIR += $$IDE_PLUGIN_PATH/Nokia
IDE_PLUGIN_RPATH = $$join(QMAKE_RPATHDIR, ":")
QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${IDE_PLUGIN_RPATH}\'
} else:macx {
QMAKE_LFLAGS += -Wl,-rpath,\"$$IDE_BIN_PATH/../\"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment