diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-08 14:33:32 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-08 14:33:32 +0200 |
commit | 00bcc137ab2d82d786f1b4423f3d3b4e5c30e71d (patch) | |
tree | 35823c71543a2804a90db5f8b1c3e86c7b328013 /framework/src/domain/mime/tests/mailtemplatetest.cpp | |
parent | 5948dfeef0685477c9bd98f7d08508a6688c04d1 (diff) | |
download | kube-00bcc137ab2d82d786f1b4423f3d3b4e5c30e71d.tar.gz kube-00bcc137ab2d82d786f1b4423f3d3b4e5c30e71d.zip |
Html with attachments
Diffstat (limited to 'framework/src/domain/mime/tests/mailtemplatetest.cpp')
-rw-r--r-- | framework/src/domain/mime/tests/mailtemplatetest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index 0ea5305f..b0d91182 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp | |||
@@ -14,6 +14,16 @@ | |||
14 | #include "mailtemplates.h" | 14 | #include "mailtemplates.h" |
15 | #include "mailcrypto.h" | 15 | #include "mailcrypto.h" |
16 | 16 | ||
17 | static KMime::Content *getSubpart(KMime::Content *msg, const QByteArray &mimeType) | ||
18 | { | ||
19 | for (const auto c : msg->contents()) { | ||
20 | if (c->contentType(false)->mimeType() == mimeType) { | ||
21 | return c; | ||
22 | } | ||
23 | } | ||
24 | return nullptr; | ||
25 | } | ||
26 | |||
17 | static std::vector< GpgME::Key, std::allocator< GpgME::Key > > getKeys(bool smime = false) | 27 | static std::vector< GpgME::Key, std::allocator< GpgME::Key > > getKeys(bool smime = false) |
18 | { | 28 | { |
19 | QGpgME::KeyListJob *job = nullptr; | 29 | QGpgME::KeyListJob *job = nullptr; |
@@ -276,6 +286,32 @@ private slots: | |||
276 | const auto contents = result->contents(); | 286 | const auto contents = result->contents(); |
277 | //1 Plain + 2 Attachments | 287 | //1 Plain + 2 Attachments |
278 | QCOMPARE(contents.size(), 3); | 288 | QCOMPARE(contents.size(), 3); |
289 | auto p = getSubpart(result.data(), "text/plain"); | ||
290 | QVERIFY(p); | ||
291 | } | ||
292 | |||
293 | void testCreateHtmlMailWithAttachments() | ||
294 | { | ||
295 | QStringList to = {{"to@example.org"}}; | ||
296 | QStringList cc = {{"cc@example.org"}};; | ||
297 | QStringList bcc = {{"bcc@example.org"}};; | ||
298 | KMime::Types::Mailbox from; | ||
299 | from.fromUnicodeString("from@example.org"); | ||
300 | QString subject = "subject"; | ||
301 | QString body = "body"; | ||
302 | QList<Attachment> attachments = {{"name", "filename", "mimetype", true, "inlineAttachment"}, {"name", "filename", "mimetype", false, "nonInlineAttachment"}}; | ||
303 | |||
304 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, true, attachments); | ||
305 | |||
306 | QVERIFY(result); | ||
307 | QCOMPARE(result->subject()->asUnicodeString(), subject); | ||
308 | QVERIFY(result->contentType()->isMimeType("multipart/mixed")); | ||
309 | QVERIFY(result->date(false)->dateTime().isValid()); | ||
310 | const auto contents = result->contents(); | ||
311 | //1 alternative + 2 Attachments | ||
312 | QCOMPARE(contents.size(), 3); | ||
313 | auto p = getSubpart(result.data(), "multipart/alternative"); | ||
314 | QVERIFY(p); | ||
279 | } | 315 | } |
280 | 316 | ||
281 | void testCreatePlainMailSigned() | 317 | void testCreatePlainMailSigned() |