Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d55efd5e authored by Laurent Montel's avatar Laurent Montel 😁

Improve unittest

parent 292983bd
......@@ -19,10 +19,11 @@
#define ATTACHMENTVCARDFROMADDRESSBOOKJOB_H
#include "messagecore/attachment/attachmentloadjob.h"
#include "messagecomposer_export.h"
#include <Akonadi/Item>
namespace MessageComposer {
class AttachmentVcardFromAddressBookJob : public MessageCore::AttachmentLoadJob
class MESSAGECOMPOSER_EXPORT AttachmentVcardFromAddressBookJob : public MessageCore::AttachmentLoadJob
{
Q_OBJECT
public:
......
......@@ -17,10 +17,12 @@ macro( add_messagecomposer_test _source )
get_filename_component( _name ${_source} NAME_WE )
kde4_add_unit_test( ${_name} TESTNAME messagecomposer-${_name} ${_test} )
target_link_libraries( ${_name} ${KDEPIMLIBS_KMIME_LIBS} messagecomposer messageviewer messagecore templateparser ${KDEPIMLIBS_KPIMTEXTEDIT_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_KPIMIDENTITIES_LIBS}
${KDEPIMLIBS_AKONADI_LIBS}
${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_KABC_LIBS}
)
endmacro()
macro( add_messagecomposer_cryptotest _source )
set( _test cryptofunctions.cpp ${CMAKE_SOURCE_DIR}/messagecore/tests/util.cpp ${_source} )
get_filename_component( _name ${_source} NAME_WE )
......
......@@ -21,6 +21,7 @@
#include "attachmentvcardfromaddressbookjobtest.h"
#include "messagecomposer/job/attachmentvcardfromaddressbookjob.h"
#include <qtest_kde.h>
#include <KABC/Addressee>
AttachmentVcardFromAddressBookJobTest::AttachmentVcardFromAddressBookJobTest(QObject *parent)
: QObject(parent)
......@@ -33,4 +34,39 @@ AttachmentVcardFromAddressBookJobTest::~AttachmentVcardFromAddressBookJobTest()
}
void AttachmentVcardFromAddressBookJobTest::testAttachmentVCardWithInvalidItem()
{
Akonadi::Item item;
MessageComposer::AttachmentVcardFromAddressBookJob *job = new MessageComposer::AttachmentVcardFromAddressBookJob(item);
QVERIFY(!job->exec());
}
void AttachmentVcardFromAddressBookJobTest::testAttachmentVCardWithValidItem()
{
Akonadi::Item item(42);
item.setMimeType( KABC::Addressee::mimeType() );
KABC::Addressee address;
address.setName(QLatin1String("foo1"));
item.setPayload<KABC::Addressee>( address );
MessageComposer::AttachmentVcardFromAddressBookJob *job = new MessageComposer::AttachmentVcardFromAddressBookJob(item);
QVERIFY(job->exec());
MessageCore::AttachmentPart::Ptr part = job->attachmentPart();
delete job;
job = 0;
QVERIFY( !part->data().isEmpty() );
#if 0 //TODO
QCOMPARE( part->mimeType(), mimeType );
QCOMPARE( part->name(), name );
QCOMPARE( part->description(), description );
//QCOMPARE( part->charset(), charset ); // TODO will probably need charsets in AttachmentPart :(
QCOMPARE( part->fileName(), fileName );
QVERIFY( part->encoding() == encoding );
QVERIFY( part->isInline() );
QCOMPARE( part->data(), data );
#endif
}
QTEST_KDEMAIN(AttachmentVcardFromAddressBookJobTest, GUI)
......@@ -29,6 +29,9 @@ class AttachmentVcardFromAddressBookJobTest : public QObject
public:
explicit AttachmentVcardFromAddressBookJobTest(QObject *parent = 0);
~AttachmentVcardFromAddressBookJobTest();
private Q_SLOTS:
void testAttachmentVCardWithInvalidItem();
void testAttachmentVCardWithValidItem();
};
#endif // ATTACHMENTVCARDFROMADDRESSBOOKJOBTEST_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment