diff --git a/tests/libkopete/CMakeLists.txt b/tests/libkopete/CMakeLists.txt index 6bac94bef..205578907 100755 --- a/tests/libkopete/CMakeLists.txt +++ b/tests/libkopete/CMakeLists.txt @@ -1,22 +1,23 @@ include_directories( ${KOPETE_INCLUDES} ${CMAKE_SOURCE_DIR}/libkopete ) set(BLACKLIST_LIB kopeteblacklistertest.cpp ${CMAKE_SOURCE_DIR}/libkopete/kopeteblacklister.cpp ) set( KOPETE_TEST_LIBRARIES kopete Qt5::Test KF5::KIOCore ) ecm_add_test(kopetetasktest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopetestatusmessagetest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(${BLACKLIST_LIB} TEST_NAME blacklisttest LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopetecontactlistelementtest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopeteglobaltest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopeteidentitytest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopeteonlinestatusmanagertest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) +ecm_add_test(kopeteinfoeventtest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) \ No newline at end of file diff --git a/tests/libkopete/kopeteinfoeventtest.cpp b/tests/libkopete/kopeteinfoeventtest.cpp new file mode 100644 index 000000000..181271bff --- /dev/null +++ b/tests/libkopete/kopeteinfoeventtest.cpp @@ -0,0 +1,79 @@ +/* + Tests for Kopete::InfoEvent + + Copyright (c) 2017 by Vijay Krishnavanshi + + Kopete (c) 2002-2017 by the Kopete developers + + ************************************************************************* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ************************************************************************* +*/ + + +#include "kopeteinfoevent.h" + +#include +#include +class InfoEventTest : public QObject +{ + Q_OBJECT +private slots: + void testClassProperties(); + void testClassProperties_data(); +}; + +void InfoEventTest::testClassProperties_data() +{ + QTest::addColumn("Title"); + QTest::addColumn("Text"); + QTest::addColumn("AdditionalText"); + QTest::addColumn("ActionText"); + + QTest::newRow("Ideal Example") << QStringLiteral("Title") << QStringLiteral("Text") << QStringLiteral("AdditionalText") << QStringLiteral("ActionText"); +} + +void InfoEventTest::testClassProperties() +{ + Kopete::InfoEvent *event = new Kopete::InfoEvent(nullptr); + QFETCH(QString, Title); + QFETCH(QString, Text); + QFETCH(QString, AdditionalText); + uint ActionId = 125; + QFETCH(QString, ActionText); + QSignalSpy spy(event, &Kopete::InfoEvent::changed); + QVERIFY(spy.isValid()); + event->setTitle(Title); + QCOMPARE(event->title(), Title); + QCOMPARE(spy.count(), 1); + event->setText(Text); + QCOMPARE(event->text(), Text); + QCOMPARE(spy.count(), 2); + event->setAdditionalText(AdditionalText); + QCOMPARE(event->additionalText(), AdditionalText); + QCOMPARE(spy.count(), 3); + event->addAction(ActionId, ActionText); + QCOMPARE(spy.count(), 4); + QMap map = event->actions(); + QCOMPARE(map[ActionId], ActionText); + QSignalSpy spyActivate(event, &Kopete::InfoEvent::actionActivated); + QVERIFY(spyActivate.isValid()); + event->activate(ActionId); + QCOMPARE(spyActivate.count(), 1); + qRegisterMetaType(); + uint temp = qvariant_cast(spyActivate.at(0).at(0)); + QCOMPARE(temp, ActionId); + QSignalSpy spyClosed(event, &Kopete::InfoEvent::eventClosed); + QVERIFY(spyClosed.isValid()); + event->close(); + QVERIFY(event->isClosed()); + QCOMPARE(spyClosed.count(), 1); +} + +QTEST_MAIN(InfoEventTest) +#include "kopeteinfoeventtest.moc"