From 58a2a8d6bba57375f211e33381b6544e4219ef26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 12 Sep 2013 01:31:37 +0200 Subject: [PATCH] Tests for Plasma::PluginLoader --- src/plasma/autotests/CMakeLists.txt | 4 +- src/plasma/autotests/pluginloadertest.cpp | 57 +++++++++++++++++++++++ src/plasma/autotests/pluginloadertest.h | 38 +++++++++++++++ src/plasma/pluginloader.cpp | 1 + 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/plasma/autotests/pluginloadertest.cpp create mode 100644 src/plasma/autotests/pluginloadertest.h diff --git a/src/plasma/autotests/CMakeLists.txt b/src/plasma/autotests/CMakeLists.txt index 51d306528..97b7d7df6 100644 --- a/src/plasma/autotests/CMakeLists.txt +++ b/src/plasma/autotests/CMakeLists.txt @@ -16,7 +16,8 @@ MACRO(PLASMA_UNIT_TESTS) target_link_libraries(${_testname} ${QT_QTTEST_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${KDE4_KIO_LIBS} plasma ${KArchive_LIBRARIES} ${KCoreAddons_LIBRARIES} KF5::KConfigGui - KF5::KI18n) + KF5::KI18n + KF5::KService) if(QT_QTOPENGL_FOUND) target_link_libraries(${_testname} ${QT_QTOPENGL_LIBRARY}) endif(QT_QTOPENGL_FOUND) @@ -28,6 +29,7 @@ ENDMACRO(PLASMA_UNIT_TESTS) PLASMA_UNIT_TESTS( configloadertest packagestructuretest + pluginloadertest # plasmoidpackagetest runnercontexttest ) diff --git a/src/plasma/autotests/pluginloadertest.cpp b/src/plasma/autotests/pluginloadertest.cpp new file mode 100644 index 000000000..2c2fc3d5a --- /dev/null +++ b/src/plasma/autotests/pluginloadertest.cpp @@ -0,0 +1,57 @@ +/****************************************************************************** +* Copyright 2013 Sebastian Kügler * +* * +* 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 +#include +//#include + +#include +//#include + +#include +#include + +QTEST_MAIN(PluginTest) + +// 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 +bool buildonly = true; + +void PluginTest::listEngines() +{ + KPluginInfo::List plugins = Plasma::PluginLoader::listEngineInfo(); + foreach (const KPluginInfo info, plugins) { + //qDebug() << " Found DataEngine: " << info.pluginName() << info.name(); + } + qDebug() << " Found " << plugins.count() << " DataEngines"; + QVERIFY(plugins.count() > 0 || buildonly); +} + +void PluginTest::listAppletCategories() +{ + const QStringList cats = Plasma::PluginLoader::self()->listAppletCategories(); + qDebug() << "Categories" << cats; + QVERIFY(cats.count() > 0 || buildonly); +} + + +#include "moc_pluginloadertest.cpp" + diff --git a/src/plasma/autotests/pluginloadertest.h b/src/plasma/autotests/pluginloadertest.h new file mode 100644 index 000000000..91352294e --- /dev/null +++ b/src/plasma/autotests/pluginloadertest.h @@ -0,0 +1,38 @@ +/****************************************************************************** +* Copyright 2013 Sebastian Kügler * +* * +* 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. * +*******************************************************************************/ + +#ifndef PLUGINTEST_H +#define PLUGINTEST_H + +#include + +class PluginTest : public QObject +{ + Q_OBJECT + public: + PluginTest() {} + + private Q_SLOTS: + void listEngines(); + void listAppletCategories(); + + private: +}; + +#endif diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 9156754e1..281aa6d20 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "config-plasma.h"