diff --git a/tests/libkopete/CMakeLists.txt b/tests/libkopete/CMakeLists.txt --- a/tests/libkopete/CMakeLists.txt +++ b/tests/libkopete/CMakeLists.txt @@ -25,4 +25,4 @@ ecm_add_test(kopetemessagetest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopeteaccounttest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopetemetacontacttest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) - +ecm_add_test(kopeteplugintest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) diff --git a/tests/libkopete/kopeteplugintest.cpp b/tests/libkopete/kopeteplugintest.cpp new file mode 100644 --- /dev/null +++ b/tests/libkopete/kopeteplugintest.cpp @@ -0,0 +1,55 @@ +#include "kopeteplugin.h" + +#include +#include + +#include + +Q_DECLARE_METATYPE(Kopete::Plugin::AddressBookFieldAddMode); + +class KopetePluginTest : public QObject +{ + Q_OBJECT; +private slots: + void PluginTest(); +}; + +void KopetePluginTest::PluginTest() +{ + const KAboutData instance(QStringLiteral("kopete"),QStringLiteral("kopete"),QStringLiteral("kopete")); + Kopete::Plugin* plugin = new Kopete::Plugin(instance, nullptr); + + QVERIFY(!plugin->showCloseWindowMessage()); + QVERIFY(plugin->shouldExitOnclose()); + + QSignalSpy spy(plugin, &Kopete::Plugin::readyForUnload); + plugin->aboutToUnload(); + QVERIFY(spy.count() == 1); + plugin->aboutToUnload(); + QVERIFY(spy.count() == 2); + + QString pluginId = plugin->pluginId(); + QCOMPARE(pluginId, QStringLiteral("Kopete::Plugin")); + + QString displayName = plugin->displayName(); + QCOMPARE(displayName, QStringLiteral("")); + + QString pluginIcon = plugin->pluginIcon(); + QCOMPARE(pluginIcon, QStringLiteral("")); + + plugin->addAddressBookField(QStringLiteral("Kopete")); + QStringList addressBookField = plugin->addressBookFields(); + QCOMPARE(addressBookField[0],QStringLiteral("Kopete")); + QCOMPARE(plugin->addressBookIndexField(), QStringLiteral("")); + + Kopete::Plugin::AddressBookFieldAddMode mode = Kopete::Plugin::AddressBookFieldAddMode::MakeIndexField; + plugin->addAddressBookField(QStringLiteral("KopetePlugin"), mode); + addressBookField = plugin->addressBookFields(); + QCOMPARE(addressBookField[1],QStringLiteral("KopetePlugin")); + QCOMPARE(plugin->addressBookIndexField(), QStringLiteral("KopetePlugin")); + + delete plugin; +} + +QTEST_MAIN(KopetePluginTest) +#include "kopeteplugintest.moc"