From 64436e0787382d5c7fb3dae5b6128e1d93a77979 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 2 Aug 2017 16:52:45 -0600 Subject: Moved mailcomposing into mailtemplates so we can start testing it. --- .../src/domain/mime/tests/mailtemplatetest.cpp | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'framework/src/domain/mime/tests') diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index e9752c9e..f393f1bd 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp @@ -58,7 +58,7 @@ private slots: QtWebEngine::initialize(); } - void testPlain() + void testPlainReply() { auto msg = readMail("plaintext.mbox"); KMime::Message::Ptr result; @@ -69,7 +69,7 @@ private slots: QCOMPARE(normalize(removeFirstLine(result->body())), normalize(msg->body())); } - void testHtml() + void testHtmlReply() { auto msg = readMail("html.mbox"); KMime::Message::Ptr result; @@ -80,7 +80,7 @@ private slots: QCOMPARE(unquote(removeFirstLine(result->body())), QLatin1String("HTML text")); } - void testMultipartSigned() + void testMultipartSignedReply() { auto msg = readMail("openpgp-signed-mailinglist.mbox"); KMime::Message::Ptr result; @@ -93,7 +93,7 @@ private slots: QVERIFY(content.contains("i noticed a new branch")); } - void testMultipartAlternative() + void testMultipartAlternativeReply() { auto msg = readMail("alternative.mbox"); KMime::Message::Ptr result; @@ -106,6 +106,26 @@ private slots: QCOMPARE(unquote(content), QLatin1String("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n")); } + void testCreatePlainMail() + { + QStringList to = {{"to@example.org"}}; + QStringList cc = {{"cc@example.org"}};; + QStringList bcc = {{"bcc@example.org"}};; + KMime::Types::Mailbox from; + from.fromUnicodeString("from@example.org"); + QString subject = "subject"; + QString body = "body"; + QList attachments; + + auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, attachments); + + QVERIFY(result); + auto content = removeFirstLine(result->body()); + QCOMPARE(result->subject()->asUnicodeString(), subject); + QCOMPARE(result->body(), body.toUtf8()); + QVERIFY(result->date(false)->dateTime().isValid()); + } + }; QTEST_MAIN(MailTemplateTest) -- cgit v1.2.3