diff --git a/tests/libkopete/CMakeLists.txt b/tests/libkopete/CMakeLists.txt --- a/tests/libkopete/CMakeLists.txt +++ b/tests/libkopete/CMakeLists.txt @@ -26,4 +26,4 @@ ecm_add_test(kopeteaccounttest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopetemetacontacttest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) ecm_add_test(kopetepluginmanagertest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) - +ecm_add_test(kopetepicturetest.cpp LINK_LIBRARIES ${KOPETE_TEST_LIBRARIES}) diff --git a/tests/libkopete/kopetepicturetest.cpp b/tests/libkopete/kopetepicturetest.cpp new file mode 100644 --- /dev/null +++ b/tests/libkopete/kopetepicturetest.cpp @@ -0,0 +1,37 @@ +#include "kopetepicture.h" + +#include +#include + +class KopetePictureTest : public QObject +{ + Q_OBJECT +private slots: + void PictureTest(); +}; + +void KopetePictureTest::PictureTest() +{ + QString path = QStringLiteral("./null_image_for_testing.png"); + QImage image(path); + + Kopete::Picture picture; + QVERIFY(picture.isNull()); + + picture.setPicture(path); + QVERIFY(!picture.isNull()); + Kopete::Picture newPicture(picture); + QVERIFY(!newPicture.isNull()); + const QImage newImage = picture.image(); + QCOMPARE(newImage, image); + QString newPath = picture.path(); + QCOMPARE(newPath, path); + + picture.clear(); + QVERIFY(picture.isNull()); + newPicture.clear(); + QVERIFY(newPicture.isNull()); +} + +QTEST_MAIN(KopetePictureTest) +#include "kopetepicturetest.moc"