Changeset View
Changeset View
Standalone View
Standalone View
framework/src/domain/mime/tests/mailtemplatetest.cpp
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | 207 | { | |||
---|---|---|---|---|---|
219 | auto content = removeFirstLine(result->body()); | 219 | auto content = removeFirstLine(result->body()); | ||
220 | QVERIFY(!content.isEmpty()); | 220 | QVERIFY(!content.isEmpty()); | ||
221 | QCOMPARE(unquote(content), QLatin1String("test")); | 221 | QCOMPARE(unquote(content), QLatin1String("test")); | ||
222 | QCOMPARE(result->to()->addresses(), {{"konqi@example.org"}}); | 222 | QCOMPARE(result->to()->addresses(), {{"konqi@example.org"}}); | ||
223 | auto l = QVector<QByteArray>{{"kde-devel@kde.org"}}; | 223 | auto l = QVector<QByteArray>{{"kde-devel@kde.org"}}; | ||
224 | QCOMPARE(result->cc()->addresses(), l); | 224 | QCOMPARE(result->cc()->addresses(), l); | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | void testForwardAsAttachment() | ||||
228 | { | ||||
229 | auto msg = readMail("plaintext.mbox"); | ||||
230 | KMime::Message::Ptr result; | ||||
231 | MailTemplates::forward(msg, [&] (const KMime::Message::Ptr &r) { | ||||
232 | result = r; | ||||
233 | }); | ||||
234 | QTRY_VERIFY(result); | ||||
235 | QCOMPARE(result->subject(false)->asUnicodeString(), {"FW: A random subject with alternative contenttype"}); | ||||
236 | QCOMPARE(result->to()->addresses(), {}); | ||||
237 | QCOMPARE(result->cc()->addresses(), {}); | ||||
238 | | ||||
239 | auto attachments = result->attachments(); | ||||
240 | QCOMPARE(attachments.size(), 1); | ||||
241 | auto attachment = attachments[0]; | ||||
242 | QCOMPARE(attachment->contentDisposition(false)->disposition(), KMime::Headers::CDinline); | ||||
243 | QCOMPARE(attachment->contentDisposition(false)->filename(), {"A random subject with alternative contenttype.eml"}); | ||||
244 | QVERIFY(attachment->bodyIsMessage()); | ||||
245 | | ||||
246 | attachment->parse(); | ||||
247 | auto origMsg = attachment->bodyAsMessage(); | ||||
248 | QCOMPARE(origMsg->subject(false)->asUnicodeString(), {"A random subject with alternative contenttype"}); | ||||
249 | } | ||||
250 | | ||||
227 | void testCreatePlainMail() | 251 | void testCreatePlainMail() | ||
228 | { | 252 | { | ||
229 | QStringList to = {{"to@example.org"}}; | 253 | QStringList to = {{"to@example.org"}}; | ||
230 | QStringList cc = {{"cc@example.org"}}; | 254 | QStringList cc = {{"cc@example.org"}}; | ||
231 | QStringList bcc = {{"bcc@example.org"}};; | 255 | QStringList bcc = {{"bcc@example.org"}};; | ||
232 | KMime::Types::Mailbox from; | 256 | KMime::Types::Mailbox from; | ||
233 | from.fromUnicodeString("from@example.org"); | 257 | from.fromUnicodeString("from@example.org"); | ||
234 | QString subject = "subject"; | 258 | QString subject = "subject"; | ||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |