2020-08-13 21:08:54 +02:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
2013-09-12 01:31:37 +02:00
|
|
|
|
|
|
|
#include "pluginloadertest.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
2018-11-06 07:23:52 +01:00
|
|
|
#include <QSignalSpy>
|
2021-03-05 19:15:32 +01:00
|
|
|
#include <qtest.h>
|
2013-09-12 01:31:37 +02:00
|
|
|
|
2020-07-08 07:44:43 +02:00
|
|
|
#include <KPluginInfo>
|
2020-11-21 16:53:48 +01:00
|
|
|
#include <KPluginMetaData>
|
2013-09-12 01:31:37 +02:00
|
|
|
|
2016-05-19 21:45:29 +02:00
|
|
|
#include <plasma/dataengineconsumer.h>
|
2021-03-05 19:15:32 +01:00
|
|
|
#include <plasma/pluginloader.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()
|
|
|
|
{
|
2020-11-21 16:53:48 +01:00
|
|
|
QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listDataEngineMetaData();
|
2021-03-05 19:15:32 +01:00
|
|
|
// foreach (const KPluginInfo& info, plugins) {
|
|
|
|
// qDebug() << " Found DataEngine: " << info.pluginName() << info.name();
|
|
|
|
// }
|
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()
|
|
|
|
{
|
2020-11-20 13:06:53 +01:00
|
|
|
const QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listContainmentActionsMetaData(QStringLiteral("plasma-shell"));
|
2013-09-12 02:04:32 +02:00
|
|
|
qDebug() << "Categories: " << plugins.count();
|
2021-03-05 19:15:32 +01: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);
|
2021-03-29 20:38:56 +02:00
|
|
|
|
|
|
|
const QList<KPluginMetaData> pluginsMetaData = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Desktop"));
|
|
|
|
qDebug() << "Desktop Containments MetaData: " << pluginsMetaData.count();
|
|
|
|
QVERIFY(pluginsMetaData.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");
|
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
void EngineTest::dataUpdated(const QString &s, const Plasma::DataEngine::Data &data)
|
|
|
|
{
|
2016-05-19 21:45:29 +02:00
|
|
|
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"
|