35 #include <QtCore/QObject>
36 #include <QtTest/QtTest>
38 using namespace ExtensionSystem;
47 void isValidVersion();
48 void versionCompare();
50 void locationAndPath();
51 void resolveDependencies();
53 void initializePlugin();
54 void initializeExtensions();
57 void tst_PluginSpec::read()
61 QVERIFY(spec.read(
"testspecs/spec1.xml"));
63 QVERIFY(!spec.hasError);
64 QVERIFY(spec.errorString.isEmpty());
65 QCOMPARE(spec.name, QString(
"test"));
66 QCOMPARE(spec.version, QString(
"1.0.1"));
67 QCOMPARE(spec.compatVersion, QString(
"1.0.0"));
68 QCOMPARE(spec.vendor, QString(
"Trolltech"));
69 QCOMPARE(spec.copyright, QString(
"(C) 2007 Trolltech ASA"));
70 QCOMPARE(spec.license, QString(
"This is a default license bla\nblubbblubb\nend of terms"));
71 QCOMPARE(spec.description, QString(
"This plugin is just a test.\n it demonstrates the great use of the plugin spec."));
72 QCOMPARE(spec.url, QString(
"http://www.trolltech.com"));
74 dep1.
name = QString(
"SomeOtherPlugin");
75 dep1.
version = QString(
"2.3.0_2");
77 dep2.
name = QString(
"EvenOther");
78 dep2.
version = QString(
"1.0.0");
82 QVERIFY(spec.read(
"testspecs/spec2.xml"));
83 QCOMPARE(spec.version, QString(
"3.1.4_10"));
84 QCOMPARE(spec.compatVersion, QString(
"3.1.4_10"));
87 void tst_PluginSpec::readError()
91 QVERIFY(!spec.read(
"non-existing-file.xml"));
93 QVERIFY(spec.hasError);
94 QVERIFY(!spec.errorString.isEmpty());
95 QVERIFY(!spec.read(
"testspecs/spec_wrong1.xml"));
97 QVERIFY(spec.hasError);
98 QVERIFY(!spec.errorString.isEmpty());
99 QVERIFY(!spec.read(
"testspecs/spec_wrong2.xml"));
101 QVERIFY(spec.hasError);
102 QVERIFY(!spec.errorString.isEmpty());
103 QVERIFY(!spec.read(
"testspecs/spec_wrong3.xml"));
105 QVERIFY(spec.hasError);
106 QVERIFY(!spec.errorString.isEmpty());
107 QVERIFY(!spec.read(
"testspecs/spec_wrong4.xml"));
109 QVERIFY(spec.hasError);
110 QVERIFY(!spec.errorString.isEmpty());
111 QVERIFY(!spec.read(
"testspecs/spec_wrong5.xml"));
113 QVERIFY(spec.hasError);
114 QVERIFY(!spec.errorString.isEmpty());
117 void tst_PluginSpec::isValidVersion()
133 void tst_PluginSpec::versionCompare()
154 void tst_PluginSpec::provides()
157 QVERIFY(spec.read(
"testspecs/simplespec.xml"));
158 QVERIFY(!spec.provides(
"SomeOtherPlugin",
"2.2.3_9"));
159 QVERIFY(!spec.provides(
"MyPlugin",
"2.2.3_10"));
160 QVERIFY(!spec.provides(
"MyPlugin",
"2.2.4"));
161 QVERIFY(!spec.provides(
"MyPlugin",
"2.3.11_1"));
162 QVERIFY(!spec.provides(
"MyPlugin",
"2.3"));
163 QVERIFY(!spec.provides(
"MyPlugin",
"3.0"));
164 QVERIFY(!spec.provides(
"MyPlugin",
"1.9.9_99"));
165 QVERIFY(!spec.provides(
"MyPlugin",
"1.9"));
166 QVERIFY(!spec.provides(
"MyPlugin",
"0.9"));
167 QVERIFY(!spec.provides(
"MyPlugin",
"1"));
169 QVERIFY(spec.provides(
"myplugin",
"2.2.3_9"));
170 QVERIFY(spec.provides(
"MyPlugin",
"2.2.3_9"));
171 QVERIFY(spec.provides(
"MyPlugin",
"2.2.3_8"));
172 QVERIFY(spec.provides(
"MyPlugin",
"2.2.3"));
173 QVERIFY(spec.provides(
"MyPlugin",
"2.2.2"));
174 QVERIFY(spec.provides(
"MyPlugin",
"2.1.2_10"));
175 QVERIFY(spec.provides(
"MyPlugin",
"2.0_10"));
176 QVERIFY(spec.provides(
"MyPlugin",
"2"));
179 void tst_PluginSpec::locationAndPath()
182 QVERIFY(spec.read(
"testspecs/simplespec.xml"));
183 QCOMPARE(spec.location, QDir::currentPath()+
"/testspecs");
184 QCOMPARE(spec.filePath, QDir::currentPath()+
"/testspecs/simplespec.xml");
185 QVERIFY(spec.read(
"testdir/../testspecs/simplespec.xml"));
186 QCOMPARE(spec.location, QDir::currentPath()+
"/testspecs");
187 QCOMPARE(spec.filePath, QDir::currentPath()+
"/testspecs/simplespec.xml");
188 QVERIFY(spec.read(
"testdir/spec.xml"));
189 QCOMPARE(spec.location, QDir::currentPath()+
"/testdir");
190 QCOMPARE(spec.filePath, QDir::currentPath()+
"/testdir/spec.xml");
193 void tst_PluginSpec::resolveDependencies()
195 QSet<PluginSpec *> specs;
199 spec1Priv->
read(
"testdependencies/spec1.xml");
209 spec4Priv->
read(
"testdependencies/spec4.xml");
223 void tst_PluginSpec::loadLibrary()
228 QVERIFY(spec->
read(
"testplugin/testplugin.xml"));
231 QVERIFY(qobject_cast<MyPlugin::MyPluginImpl*>(spec->
plugin) != 0);
239 void tst_PluginSpec::initializePlugin()
243 QVERIFY(spec.
read(
"testplugin/testplugin.xml"));
248 QVERIFY(!impl->isInitialized());
252 QVERIFY(impl->isInitialized());
255 void tst_PluginSpec::initializeExtensions()
259 QVERIFY(spec.
read(
"testplugin/testplugin.xml"));
268 QVERIFY(impl->isExtensionsInitialized());
273 #include "tst_pluginspec.moc"
static PluginSpec * createSpec()
bool initializeExtensions()
Core plugin system that manages the plugins, their life cycle and their registered objects...
static bool isValidVersion(const QString &version)
static PluginSpecPrivate * privateSpec(PluginSpec *spec)
bool read(const QString &fileName)
static int versionCompare(const QString &version1, const QString &version2)
QList< PluginSpec * > dependencySpecs
bool resolveDependencies(const QList< PluginSpec * > &specs)
Contains the information of the plugins xml description file and information about the plugin's curre...
Struct that contains the name and required compatible version number of a plugin's dependency...
PluginSpec * pluginSpec() const