plasma-framework/autotests/pluginloadertest.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
3.0 KiB
C++
Raw Normal View History

/*
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>
#include <qtest.h>
2013-09-12 01:31:37 +02:00
2020-07-08 07:44:43 +02:00
#include <KPluginInfo>
#include <KPluginMetaData>
2013-09-12 01:31:37 +02:00
#include <plasma/dataengineconsumer.h>
#include <plasma/pluginloader.h>
2013-09-12 01:31:37 +02:00
QTEST_MAIN(PluginTest)
PluginTest::PluginTest()
: m_buildonly(false)
{
}
2013-09-12 01:31:37 +02:00
void PluginTest::listEngines()
{
QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listDataEngineMetaData();
// 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";
// 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;
QVERIFY(cats.count() > 0 || m_buildonly);
2013-09-12 01:31:37 +02:00
}
void PluginTest::listContainmentActions()
{
const QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listContainmentActionsMetaData(QStringLiteral("plasma-shell"));
qDebug() << "Categories: " << plugins.count();
// QVERIFY(plugins.count() > 0 || m_buildonly);
}
void PluginTest::listContainmentsOfType()
{
const KPluginInfo::List plugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Desktop"));
qDebug() << "Desktop Containments: " << plugins.count();
QVERIFY(plugins.count() > 0 || m_buildonly);
const QList<KPluginMetaData> pluginsMetaData = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Desktop"));
qDebug() << "Desktop Containments MetaData: " << pluginsMetaData.count();
QVERIFY(pluginsMetaData.count() > 0 || m_buildonly);
}
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()
{
if (m_buildonly) {
return;
}
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 01:31:37 +02:00
#include "moc_pluginloadertest.cpp"