2013-09-12 01:31:37 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
|
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include "pluginloadertest.h"
|
|
|
|
|
|
|
|
#include <qtest.h>
|
|
|
|
#include <QDebug>
|
|
|
|
//#include <QJsonObject>
|
2018-11-06 07:23:52 +01:00
|
|
|
#include <QSignalSpy>
|
2013-09-12 01:31:37 +02:00
|
|
|
|
|
|
|
#include <kplugininfo.h>
|
|
|
|
//#include <kplugintrader.h>
|
|
|
|
|
|
|
|
#include <plasma/pluginloader.h>
|
2016-05-19 21:45:29 +02:00
|
|
|
#include <plasma/dataengineconsumer.h>
|
2013-09-12 01:31:37 +02:00
|
|
|
|
|
|
|
QTEST_MAIN(PluginTest)
|
|
|
|
|
2016-05-20 12:16:21 +02:00
|
|
|
PluginTest::PluginTest()
|
|
|
|
: m_buildonly(false)
|
|
|
|
{
|
|
|
|
}
|
2013-09-12 01:31:37 +02:00
|
|
|
|
|
|
|
void PluginTest::listEngines()
|
|
|
|
{
|
|
|
|
KPluginInfo::List plugins = Plasma::PluginLoader::listEngineInfo();
|
2016-02-29 00:59:44 +01:00
|
|
|
// foreach (const KPluginInfo& info, plugins) {
|
2013-09-12 01:31:37 +02:00
|
|
|
//qDebug() << " Found DataEngine: " << info.pluginName() << info.name();
|
2016-02-29 00:59:44 +01:00
|
|
|
// }
|
2013-09-12 01:31:37 +02:00
|
|
|
qDebug() << " Found " << plugins.count() << " DataEngines";
|
2016-05-20 12:16:21 +02:00
|
|
|
// Switch to true in order to let tests pass, this test usually will only
|
|
|
|
// work with plugins installed, but there aren't any in plasma-framework
|
|
|
|
m_buildonly = plugins.count() == 0;
|
|
|
|
QVERIFY(plugins.count() > 0 || m_buildonly);
|
2013-09-12 01:31:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PluginTest::listAppletCategories()
|
|
|
|
{
|
|
|
|
const QStringList cats = Plasma::PluginLoader::self()->listAppletCategories();
|
|
|
|
qDebug() << "Categories" << cats;
|
2016-05-20 12:16:21 +02:00
|
|
|
QVERIFY(cats.count() > 0 || m_buildonly);
|
2013-09-12 01:31:37 +02:00
|
|
|
}
|
|
|
|
|
2013-09-12 02:04:32 +02:00
|
|
|
void PluginTest::listContainmentActions()
|
|
|
|
{
|
2016-02-29 00:08:05 +01:00
|
|
|
const KPluginInfo::List plugins = Plasma::PluginLoader::self()->listContainmentActionsInfo(QStringLiteral("plasma-shell"));
|
2013-09-12 02:04:32 +02:00
|
|
|
qDebug() << "Categories: " << plugins.count();
|
2016-05-20 12:16:21 +02:00
|
|
|
//QVERIFY(plugins.count() > 0 || m_buildonly);
|
2013-09-12 02:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PluginTest::listContainmentsOfType()
|
|
|
|
{
|
2016-02-29 00:08:05 +01:00
|
|
|
const KPluginInfo::List plugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Desktop"));
|
2013-09-12 02:04:32 +02:00
|
|
|
qDebug() << "Desktop Containments: " << plugins.count();
|
2016-05-20 12:16:21 +02:00
|
|
|
QVERIFY(plugins.count() > 0 || m_buildonly);
|
2013-09-12 02:04:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-19 21:45:29 +02:00
|
|
|
static const auto source = QStringLiteral("Europe/Sofia");
|
|
|
|
|
|
|
|
void EngineTest::dataUpdated(const QString &s, const Plasma::DataEngine::Data &data) {
|
|
|
|
QVERIFY(source == s);
|
|
|
|
QVERIFY(data["Timezone"] == source);
|
|
|
|
}
|
|
|
|
|
2013-09-12 02:29:33 +02:00
|
|
|
void PluginTest::loadDataEngine()
|
|
|
|
{
|
2016-05-20 12:16:21 +02:00
|
|
|
if (m_buildonly) {
|
|
|
|
return;
|
|
|
|
}
|
2016-05-19 21:45:29 +02:00
|
|
|
QPointer<Plasma::DataEngine> engine, nullEngine;
|
|
|
|
{
|
|
|
|
Plasma::DataEngineConsumer consumer;
|
|
|
|
engine = consumer.dataEngine(QStringLiteral("time"));
|
|
|
|
nullEngine = consumer.dataEngine(QStringLiteral("noop"));
|
|
|
|
QVERIFY(nullEngine && engine);
|
|
|
|
QVERIFY(!nullEngine->isValid() && engine->isValid());
|
|
|
|
{
|
|
|
|
EngineTest test;
|
|
|
|
engine->connectSource(source, &test);
|
|
|
|
QSignalSpy spy(engine, SIGNAL(sourceAdded(QString)));
|
|
|
|
spy.wait();
|
|
|
|
QVERIFY(!engine->isEmpty());
|
|
|
|
}
|
|
|
|
QSignalSpy spy(engine, SIGNAL(sourceRemoved(QString)));
|
|
|
|
spy.wait();
|
|
|
|
QVERIFY(engine->isEmpty());
|
|
|
|
}
|
|
|
|
QVERIFY(!nullEngine.isNull() && engine.isNull());
|
2013-09-12 02:29:33 +02:00
|
|
|
}
|
2013-09-12 02:04:32 +02:00
|
|
|
|
2013-09-12 01:31:37 +02:00
|
|
|
#include "moc_pluginloadertest.cpp"
|
|
|
|
|