Changeset View
Changeset View
Standalone View
Standalone View
messagecomposer/autotests/messagefactoryngtest.cpp
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 183 | { | |||
---|---|---|---|---|---|
199 | 199 | | |||
200 | factory.createReplyAsync(); | 200 | factory.createReplyAsync(); | ||
201 | QVERIFY(spy.wait()); | 201 | QVERIFY(spy.wait()); | ||
202 | QCOMPARE(spy.count(), 1); | 202 | QCOMPARE(spy.count(), 1); | ||
203 | 203 | | |||
204 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 204 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
205 | 205 | | |||
206 | reply.replyAll = true; | 206 | reply.replyAll = true; | ||
207 | //qDebug() << reply.msg->body(); | | |||
208 | 207 | | |||
209 | QDateTime date = msg->date()->dateTime(); | 208 | QDateTime date = msg->date()->dateTime(); | ||
210 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 209 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
211 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 210 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
212 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | 211 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | ||
213 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | 212 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | ||
214 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | 213 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | ||
215 | 214 | | |||
216 | QString dateStr = reply.msg->date()->asUnicodeString(); | 215 | QString dateStr = reply.msg->date()->asUnicodeString(); | ||
217 | QString ba = QString::fromLatin1("From: foo1 <identity1@bla.com>\n" | 216 | QString ba = QString::fromLatin1("From: foo1 <identity1@bla.com>\n" | ||
218 | "X-KMail-Identity: %1\n" | 217 | "X-KMail-Identity: %1\n" | ||
219 | "Date: %2\n" | 218 | "Date: %2\n" | ||
220 | "Cc: blo <blo@blo.org>, bli <bli@bli.org>, blu <blu@blu.org>, bly <bly@bly.org>, Bla <identity1@bla.com>\n" | 219 | "Cc: blu <blu@blu.org>, bly <bly@bly.org>\n" | ||
221 | "To: Bla <identity1@bla.com>\n" | 220 | "To: blo <blo@blo.org>, bli <bli@bli.org>\n" | ||
222 | "Subject: Re: Plain Message Test\n" | 221 | "Subject: Re: Plain Message Test\n" | ||
223 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | 222 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | ||
224 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | 223 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | ||
225 | "X-KMail-Link-Message: 0\n" | 224 | "X-KMail-Link-Message: 0\n" | ||
226 | "X-KMail-Link-Type: reply\n\n" | 225 | "X-KMail-Link-Type: reply\n\n" | ||
227 | "%3") | 226 | "%3") | ||
228 | .arg(i1.uoid()).arg(dateStr).arg(replyStr); | 227 | .arg(i1.uoid()).arg(dateStr).arg(replyStr); | ||
229 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | 228 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | ||
Show All 18 Lines | 232 | { | |||
248 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 247 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
249 | 248 | | |||
250 | factory.createReplyAsync(); | 249 | factory.createReplyAsync(); | ||
251 | QVERIFY(spy.wait()); | 250 | QVERIFY(spy.wait()); | ||
252 | QCOMPARE(spy.count(), 1); | 251 | QCOMPARE(spy.count(), 1); | ||
253 | 252 | | |||
254 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 253 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
255 | reply.replyAll = true; | 254 | reply.replyAll = true; | ||
256 | //qDebug() << reply.msg->body(); | | |||
257 | 255 | | |||
258 | QDateTime date = msg->date()->dateTime(); | 256 | QDateTime date = msg->date()->dateTime(); | ||
259 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 257 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
260 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 258 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
261 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | 259 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | ||
262 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | 260 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | ||
263 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | 261 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | ||
264 | 262 | | |||
265 | QString dateStr = reply.msg->date()->asUnicodeString(); | 263 | QString dateStr = reply.msg->date()->asUnicodeString(); | ||
266 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | 264 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | ||
267 | "Date: %1\n" | 265 | "Date: %1\n" | ||
268 | "Cc: blo <blo@blo.org>, bli <bli@bli.org>, blu <blu@blu.org>, bly <bly@bly.org>\n" | 266 | "Cc: blu <blu@blu.org>, bly <bly@bly.org>\n" | ||
269 | "To: Bla <identity1@bla.com>\n" | 267 | "To: blo <blo@blo.org>, bli <bli@bli.org>\n" | ||
270 | "Subject: Re: Plain Message Test\n" | 268 | "Subject: Re: Plain Message Test\n" | ||
271 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | 269 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | ||
272 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | 270 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | ||
273 | "X-KMail-Link-Message: 0\n" | 271 | "X-KMail-Link-Message: 0\n" | ||
274 | "X-KMail-Link-Type: reply\n\n" | 272 | "X-KMail-Link-Type: reply\n\n" | ||
275 | "%2") | 273 | "%2") | ||
276 | .arg(dateStr).arg(replyStr); | 274 | .arg(dateStr).arg(replyStr); | ||
277 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | 275 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | ||
Show All 18 Lines | 279 | { | |||
296 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 294 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
297 | 295 | | |||
298 | factory.createReplyAsync(); | 296 | factory.createReplyAsync(); | ||
299 | QVERIFY(spy.wait()); | 297 | QVERIFY(spy.wait()); | ||
300 | QCOMPARE(spy.count(), 1); | 298 | QCOMPARE(spy.count(), 1); | ||
301 | 299 | | |||
302 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 300 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
303 | reply.replyAll = true; | 301 | reply.replyAll = true; | ||
304 | //qDebug() << reply.msg->body(); | | |||
305 | 302 | | |||
306 | QDateTime date = msg->date()->dateTime(); | 303 | QDateTime date = msg->date()->dateTime(); | ||
307 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 304 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
308 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 305 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
309 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | 306 | QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender"); | ||
310 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | 307 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test")); | ||
311 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | 308 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | ||
312 | 309 | | |||
313 | QString dateStr = reply.msg->date()->asUnicodeString(); | 310 | QString dateStr = reply.msg->date()->asUnicodeString(); | ||
314 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | 311 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | ||
315 | "Date: %1\n" | 312 | "Date: %1\n" | ||
316 | "Cc: blo <blo@blo.org>, bli <bli@bli.org>, blu <blu@blu.org>, bly <bly@bly.org>\n" | 313 | "Cc: blu <blu@blu.org>, bly <bly@bly.org>\n" | ||
317 | "To: Bla <bloblo@bla.com>\n" | 314 | "To: blo <blo@blo.org>, bli <bli@bli.org>, Bla <bloblo@bla.com>\n" | ||
318 | "Subject: Re: Plain Message Test\n" | 315 | "Subject: Re: Plain Message Test\n" | ||
319 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | 316 | "Content-Type: text/plain; charset=\"US-ASCII\"\n" | ||
320 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | 317 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | ||
321 | "X-KMail-Link-Message: 0\n" | 318 | "X-KMail-Link-Message: 0\n" | ||
322 | "X-KMail-Link-Type: reply\n\n" | 319 | "X-KMail-Link-Type: reply\n\n" | ||
323 | "%2") | 320 | "%2") | ||
324 | .arg(dateStr).arg(replyStr); | 321 | .arg(dateStr).arg(replyStr); | ||
325 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | 322 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 364 | { | |||
374 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 371 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
375 | 372 | | |||
376 | factory.createReplyAsync(); | 373 | factory.createReplyAsync(); | ||
377 | QVERIFY(spy.wait()); | 374 | QVERIFY(spy.wait()); | ||
378 | QCOMPARE(spy.count(), 1); | 375 | QCOMPARE(spy.count(), 1); | ||
379 | 376 | | |||
380 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 377 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
381 | reply.replyAll = true; | 378 | reply.replyAll = true; | ||
382 | //qDebug() << reply.msg->body(); | | |||
383 | 379 | | |||
384 | QDateTime date = msg->date()->dateTime(); | 380 | QDateTime date = msg->date()->dateTime(); | ||
385 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 381 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
386 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 382 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
387 | QString replyStr | 383 | QString replyStr | ||
388 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | 384 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | ||
389 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | 385 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | ||
390 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | 386 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | ||
Show All 28 Lines | 408 | { | |||
419 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 415 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
420 | 416 | | |||
421 | factory.createReplyAsync(); | 417 | factory.createReplyAsync(); | ||
422 | QVERIFY(spy.wait()); | 418 | QVERIFY(spy.wait()); | ||
423 | QCOMPARE(spy.count(), 1); | 419 | QCOMPARE(spy.count(), 1); | ||
424 | 420 | | |||
425 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 421 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
426 | reply.replyAll = true; | 422 | reply.replyAll = true; | ||
427 | //qDebug() << reply.msg->body(); | | |||
428 | 423 | | |||
429 | QDateTime date = msg->date()->dateTime(); | 424 | QDateTime date = msg->date()->dateTime(); | ||
430 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 425 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
431 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 426 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
432 | QString replyStr | 427 | QString replyStr | ||
433 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | 428 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | ||
434 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | 429 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | ||
435 | 430 | | |||
436 | QString replyTo = reply.msg->inReplyTo()->asUnicodeString(); | 431 | QString replyTo = reply.msg->inReplyTo()->asUnicodeString(); | ||
437 | QString reference = reply.msg->references()->asUnicodeString(); | 432 | QString reference = reply.msg->references()->asUnicodeString(); | ||
438 | QString dateStr = reply.msg->date()->asUnicodeString(); | 433 | QString dateStr = reply.msg->date()->asUnicodeString(); | ||
439 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | 434 | QString ba = QString::fromLatin1("From: another <another@another.com>\n" | ||
440 | "Date: %1\n" | 435 | "Date: %1\n" | ||
441 | "X-KMail-Transport: 0\n" | 436 | "X-KMail-Transport: 0\n" | ||
442 | "Cc: you@you.you, you2@you.you, cc@cc.cc, cc2@cc.cc\n" | 437 | "Cc: cc@cc.cc, cc2@cc.cc\n" | ||
443 | "To: me@me.me\n" | 438 | "To: you@you.you, you2@you.you, me@me.me\n" | ||
444 | "References: %3\n" | 439 | "References: %3\n" | ||
445 | "In-Reply-To: %2\n" | 440 | "In-Reply-To: %2\n" | ||
446 | "Subject: Re: Test Email Subject\nContent-Type: text/plain; charset=\"US-ASCII\"\n" | 441 | "Subject: Re: Test Email Subject\nContent-Type: text/plain; charset=\"US-ASCII\"\n" | ||
447 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | 442 | "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n" | ||
448 | "X-KMail-Link-Message: 0\n" | 443 | "X-KMail-Link-Message: 0\n" | ||
449 | "X-KMail-Link-Type: reply\n\n> All happy families are alike; each unhappy family is unhappy in its own way.") | 444 | "X-KMail-Link-Type: reply\n\n> All happy families are alike; each unhappy family is unhappy in its own way.") | ||
450 | .arg(dateStr).arg(replyTo).arg(reference); | 445 | .arg(dateStr).arg(replyTo).arg(reference); | ||
451 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | 446 | QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1()); | ||
452 | } | 447 | } | ||
453 | 448 | | |||
454 | void MessageFactoryTest::testCreateReplyAllAsync() | 449 | void MessageFactoryTest::testCreateReplyAllAsync() | ||
455 | { | 450 | { | ||
456 | KMime::Message::Ptr msg = createPlainTestMessage(); | 451 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
457 | MessageFactoryNG factory(msg, 0); | 452 | MessageFactoryNG factory(msg, 0); | ||
458 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 453 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
459 | factory.setIdentityManager(mIdentMan); | 454 | factory.setIdentityManager(mIdentMan); | ||
460 | 455 | | |||
461 | factory.createReplyAsync(); | 456 | factory.createReplyAsync(); | ||
462 | QVERIFY(spy.wait()); | 457 | QVERIFY(spy.wait()); | ||
463 | QCOMPARE(spy.count(), 1); | 458 | QCOMPARE(spy.count(), 1); | ||
464 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 459 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
465 | reply.replyAll = true; | 460 | reply.replyAll = true; | ||
466 | //qDebug() << reply.msg->body(); | | |||
467 | 461 | | |||
468 | QDateTime date = msg->date()->dateTime(); | 462 | QDateTime date = msg->date()->dateTime(); | ||
469 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | 463 | QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat); | ||
470 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | 464 | datetime += QLatin1Char(' ') + QLocale::system().toString(date.time(), QLocale::LongFormat); | ||
471 | QString replyStr | 465 | QString replyStr | ||
472 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | 466 | = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n\n"))); | ||
473 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | 467 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject")); | ||
474 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | 468 | QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1()); | ||
Show All 12 Lines | 472 | { | |||
487 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 481 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
488 | factory.setIdentityManager(mIdentMan); | 482 | factory.setIdentityManager(mIdentMan); | ||
489 | 483 | | |||
490 | factory.createReplyAsync(); | 484 | factory.createReplyAsync(); | ||
491 | QVERIFY(spy.wait()); | 485 | QVERIFY(spy.wait()); | ||
492 | QCOMPARE(spy.count(), 1); | 486 | QCOMPARE(spy.count(), 1); | ||
493 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 487 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
494 | reply.replyAll = true; | 488 | reply.replyAll = true; | ||
495 | //qDebug() << "html reply" << reply.msg->encodedContent(); | | |||
496 | 489 | | |||
497 | QDateTime date = msg->date()->dateTime().toLocalTime(); | 490 | QDateTime date = msg->date()->dateTime().toLocalTime(); | ||
498 | QString datetime = QLocale().toString(date.date(), QLocale::LongFormat); | 491 | QString datetime = QLocale().toString(date.date(), QLocale::LongFormat); | ||
499 | datetime += QLatin1Char(' ') + QLocale().toString(date.time(), QLocale::LongFormat); | 492 | datetime += QLatin1Char(' ') + QLocale().toString(date.time(), QLocale::LongFormat); | ||
500 | QString replyStr = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> encoded?\n\n"))); | 493 | QString replyStr = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> encoded?\n\n"))); | ||
501 | QCOMPARE(reply.msg->contentType()->mimeType(), QByteArrayLiteral("multipart/alternative")); | 494 | QCOMPARE(reply.msg->contentType()->mimeType(), QByteArrayLiteral("multipart/alternative")); | ||
502 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: reply to please")); | 495 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: reply to please")); | ||
503 | QCOMPARE(reply.msg->contents().count(), 2); | 496 | QCOMPARE(reply.msg->contents().count(), 2); | ||
Show All 14 Lines | |||||
518 | TemplateParser::TemplateParserSettings::self()->setReplyUsingHtml(true); | 511 | TemplateParser::TemplateParserSettings::self()->setReplyUsingHtml(true); | ||
519 | } | 512 | } | ||
520 | 513 | | |||
521 | void MessageFactoryTest::testCreateReplyUTF16Base64Async() | 514 | void MessageFactoryTest::testCreateReplyUTF16Base64Async() | ||
522 | { | 515 | { | ||
523 | KMime::Message::Ptr msg = loadMessageFromFile(QStringLiteral("plain_utf16.mbox")); | 516 | KMime::Message::Ptr msg = loadMessageFromFile(QStringLiteral("plain_utf16.mbox")); | ||
524 | 517 | | |||
525 | TemplateParser::TemplateParserSettings::self()->setReplyUsingHtml(true); | 518 | TemplateParser::TemplateParserSettings::self()->setReplyUsingHtml(true); | ||
526 | // qDebug() << "plain base64 msg message:" << msg->encodedContent(); | | |||
527 | 519 | | |||
528 | MessageFactoryNG factory(msg, 0); | 520 | MessageFactoryNG factory(msg, 0); | ||
529 | factory.setIdentityManager(mIdentMan); | 521 | factory.setIdentityManager(mIdentMan); | ||
530 | 522 | | |||
531 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | 523 | QSignalSpy spy(&factory, &MessageFactoryNG::createReplyDone); | ||
532 | factory.setIdentityManager(mIdentMan); | 524 | factory.setIdentityManager(mIdentMan); | ||
533 | 525 | | |||
534 | factory.createReplyAsync(); | 526 | factory.createReplyAsync(); | ||
535 | QVERIFY(spy.wait()); | 527 | QVERIFY(spy.wait()); | ||
536 | QCOMPARE(spy.count(), 1); | 528 | QCOMPARE(spy.count(), 1); | ||
537 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | 529 | MessageFactoryNG::MessageReply reply = spy.at(0).at(0).value<MessageComposer::MessageFactoryNG::MessageReply>(); | ||
538 | reply.replyAll = true; | 530 | reply.replyAll = true; | ||
539 | // qDebug() << "html reply" << reply.msg->encodedContent(); | | |||
540 | 531 | | |||
541 | QDateTime date = msg->date()->dateTime().toLocalTime(); | 532 | QDateTime date = msg->date()->dateTime().toLocalTime(); | ||
542 | QString datetime = QLocale().toString(date.date(), QLocale::LongFormat); | 533 | QString datetime = QLocale().toString(date.date(), QLocale::LongFormat); | ||
543 | datetime += QLatin1Char(' ') + QLocale().toString(date.time(), QLocale::LongFormat); | 534 | datetime += QLatin1Char(' ') + QLocale().toString(date.time(), QLocale::LongFormat); | ||
544 | QString replyStr = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> quote me please.\n\n"))); | 535 | QString replyStr = QString::fromLatin1(QByteArray(QByteArray("On ") + datetime.toLatin1() + QByteArray(" you wrote:\n> quote me please.\n\n"))); | ||
545 | QCOMPARE(reply.msg->contentType()->mimeType(), QByteArrayLiteral("multipart/alternative")); | 536 | QCOMPARE(reply.msg->contentType()->mimeType(), QByteArrayLiteral("multipart/alternative")); | ||
546 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: asking for reply")); | 537 | QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: asking for reply")); | ||
547 | QCOMPARE_OR_DIFF(reply.msg->contents().at(0)->body(), replyStr.toLatin1()); | 538 | QCOMPARE_OR_DIFF(reply.msg->contents().at(0)->body(), replyStr.toLatin1()); | ||
Show All 33 Lines | 557 | QString fwdMsg = QString::fromLatin1( | |||
581 | "From: me@me.me\n" | 572 | "From: me@me.me\n" | ||
582 | "To: you@you.you, you2@you.you\n" | 573 | "To: you@you.you, you2@you.you\n" | ||
583 | "CC: cc@cc.cc, cc2@cc.cc\n" | 574 | "CC: cc@cc.cc, cc2@cc.cc\n" | ||
584 | "\n" | 575 | "\n" | ||
585 | "All happy families are alike; each unhappy family is unhappy in its own way.\n" | 576 | "All happy families are alike; each unhappy family is unhappy in its own way.\n" | ||
586 | "-----------------------------------------"); | 577 | "-----------------------------------------"); | ||
587 | fwdMsg = fwdMsg.arg(datetime).arg(fw->date()->asUnicodeString()); | 578 | fwdMsg = fwdMsg.arg(datetime).arg(fw->date()->asUnicodeString()); | ||
588 | 579 | | |||
589 | // qDebug() << "got:" << fw->encodedContent() << "against" << fwdMsg.toLatin1(); | | |||
590 | QCOMPARE(fw->subject()->asUnicodeString(), QStringLiteral("Fwd: Test Email Subject")); | 580 | QCOMPARE(fw->subject()->asUnicodeString(), QStringLiteral("Fwd: Test Email Subject")); | ||
591 | QCOMPARE_OR_DIFF(fw->encodedContent(), fwdMsg.toLatin1()); | 581 | QCOMPARE_OR_DIFF(fw->encodedContent(), fwdMsg.toLatin1()); | ||
592 | } | 582 | } | ||
593 | 583 | | |||
594 | void MessageFactoryTest::testCreateForwardAsync() | 584 | void MessageFactoryTest::testCreateForwardAsync() | ||
595 | { | 585 | { | ||
596 | KMime::Message::Ptr msg = createPlainTestMessage(); | 586 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
597 | 587 | | |||
Show All 28 Lines | 601 | QString fwdMsg = QString::fromLatin1( | |||
626 | "From: me@me.me\n" | 616 | "From: me@me.me\n" | ||
627 | "To: you@you.you\n" | 617 | "To: you@you.you\n" | ||
628 | "CC: cc@cc.cc\n" | 618 | "CC: cc@cc.cc\n" | ||
629 | "\n" | 619 | "\n" | ||
630 | "All happy families are alike; each unhappy family is unhappy in its own way.\n" | 620 | "All happy families are alike; each unhappy family is unhappy in its own way.\n" | ||
631 | "-----------------------------------------"); | 621 | "-----------------------------------------"); | ||
632 | fwdMsg = fwdMsg.arg(datetime).arg(fw->date()->asUnicodeString()); | 622 | fwdMsg = fwdMsg.arg(datetime).arg(fw->date()->asUnicodeString()); | ||
633 | 623 | | |||
634 | // qDebug() << "got:" << fw->encodedContent() << "against" << fwdMsg.toLatin1(); | | |||
635 | QCOMPARE(fw->subject()->asUnicodeString(), QStringLiteral("Fwd: Test Email Subject")); | 624 | QCOMPARE(fw->subject()->asUnicodeString(), QStringLiteral("Fwd: Test Email Subject")); | ||
636 | QCOMPARE_OR_DIFF(fw->encodedContent(), fwdMsg.toLatin1()); | 625 | QCOMPARE_OR_DIFF(fw->encodedContent(), fwdMsg.toLatin1()); | ||
637 | } | 626 | } | ||
638 | 627 | | |||
639 | void MessageFactoryTest::testCreateRedirectToAndCCAndBCC() | 628 | void MessageFactoryTest::testCreateRedirectToAndCCAndBCC() | ||
640 | { | 629 | { | ||
641 | KMime::Message::Ptr msg = createPlainTestMessage(); | 630 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
642 | 631 | | |||
643 | MessageFactoryNG factory(msg, 0); | 632 | MessageFactoryNG factory(msg, 0); | ||
644 | factory.setIdentityManager(mIdentMan); | 633 | factory.setIdentityManager(mIdentMan); | ||
645 | 634 | | |||
646 | QString redirectTo = QStringLiteral("redir@redir.com"); | 635 | QString redirectTo = QStringLiteral("redir@redir.com"); | ||
647 | QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com"); | 636 | QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com"); | ||
648 | QString redirectBcc = QStringLiteral("redirbcc@redirbcc.com, redirbcc2@redirbcc.com"); | 637 | QString redirectBcc = QStringLiteral("redirbcc@redirbcc.com, redirbcc2@redirbcc.com"); | ||
649 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc, redirectBcc); | 638 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc, redirectBcc); | ||
650 | 639 | | |||
651 | QString datetime = rdir->date()->asUnicodeString(); | 640 | QString datetime = rdir->date()->asUnicodeString(); | ||
652 | 641 | | |||
653 | // qDebug() << rdir->encodedContent(); | | |||
654 | | ||||
655 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | 642 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | ||
656 | rx.indexIn(QString::fromLatin1(rdir->head())); | 643 | rx.indexIn(QString::fromLatin1(rdir->head())); | ||
657 | 644 | | |||
658 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | 645 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | ||
659 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | 646 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | ||
660 | //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")"; | | |||
661 | QString baseline = QString::fromLatin1("From: me@me.me\n" | 647 | QString baseline = QString::fromLatin1("From: me@me.me\n" | ||
662 | "Cc: cc@cc.cc\n" | 648 | "Cc: cc@cc.cc\n" | ||
663 | "Bcc: bcc@bcc.bcc\n" | 649 | "Bcc: bcc@bcc.bcc\n" | ||
664 | "Subject: Test Email Subject\n" | 650 | "Subject: Test Email Subject\n" | ||
665 | "Date: %1\n" | 651 | "Date: %1\n" | ||
666 | "X-KMail-Transport: 0\n" | 652 | "X-KMail-Transport: 0\n" | ||
667 | "Message-ID: %2\n" | 653 | "Message-ID: %2\n" | ||
668 | "Disposition-Notification-To: me@me.me\n" | 654 | "Disposition-Notification-To: me@me.me\n" | ||
669 | "MIME-Version: 1.0\n" | 655 | "MIME-Version: 1.0\n" | ||
670 | "Content-Transfer-Encoding: 7Bit\n" | 656 | "Content-Transfer-Encoding: 7Bit\n" | ||
671 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | 657 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | ||
672 | "Resent-Message-ID: %3\n" | 658 | "Resent-Message-ID: %3\n" | ||
673 | "Resent-Date: %4\n" | 659 | "Resent-Date: %4\n" | ||
674 | "Resent-From: %5\n" | 660 | "Resent-From: %5\n" | ||
675 | "To: you@you.you\n" | 661 | "To: you@you.you\n" | ||
676 | "Resent-To: redir@redir.com\n" | 662 | "Resent-To: redir@redir.com\n" | ||
677 | "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n" | 663 | "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n" | ||
678 | "Resent-Bcc: redirbcc@redirbcc.com, redirbcc2@redirbcc.com\n" | 664 | "Resent-Bcc: redirbcc@redirbcc.com, redirbcc2@redirbcc.com\n" | ||
679 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | 665 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | ||
680 | "\n" | 666 | "\n" | ||
681 | "All happy families are alike; each unhappy family is unhappy in its own way."); | 667 | "All happy families are alike; each unhappy family is unhappy in its own way."); | ||
682 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | 668 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | ||
683 | 669 | | |||
684 | // qDebug() << baseline.toLatin1(); | | |||
685 | // qDebug() << "instead:" << rdir->encodedContent(); | | |||
686 | | ||||
687 | // QString fwdStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n" ); | | |||
688 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | 670 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | ||
689 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | 671 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | ||
690 | } | 672 | } | ||
691 | 673 | | |||
692 | void MessageFactoryTest::testCreateRedirectToAndCC() | 674 | void MessageFactoryTest::testCreateRedirectToAndCC() | ||
693 | { | 675 | { | ||
694 | KMime::Message::Ptr msg = createPlainTestMessage(); | 676 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
695 | 677 | | |||
696 | MessageFactoryNG factory(msg, 0); | 678 | MessageFactoryNG factory(msg, 0); | ||
697 | factory.setIdentityManager(mIdentMan); | 679 | factory.setIdentityManager(mIdentMan); | ||
698 | 680 | | |||
699 | QString redirectTo = QStringLiteral("redir@redir.com"); | 681 | QString redirectTo = QStringLiteral("redir@redir.com"); | ||
700 | QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com"); | 682 | QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com"); | ||
701 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc); | 683 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc); | ||
702 | 684 | | |||
703 | QString datetime = rdir->date()->asUnicodeString(); | 685 | QString datetime = rdir->date()->asUnicodeString(); | ||
704 | 686 | | |||
705 | // qDebug() << rdir->encodedContent(); | | |||
706 | | ||||
707 | QString msgId = MessageCore::StringUtil::generateMessageId(msg->sender()->asUnicodeString(), QString()); | 687 | QString msgId = MessageCore::StringUtil::generateMessageId(msg->sender()->asUnicodeString(), QString()); | ||
708 | 688 | | |||
709 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | 689 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | ||
710 | rx.indexIn(QString::fromLatin1(rdir->head())); | 690 | rx.indexIn(QString::fromLatin1(rdir->head())); | ||
711 | 691 | | |||
712 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | 692 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | ||
713 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | 693 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | ||
714 | //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")"; | 694 | //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")"; | ||
Show All 14 Lines | 695 | QString baseline = QString::fromLatin1("From: me@me.me\n" | |||
729 | "To: you@you.you\n" | 709 | "To: you@you.you\n" | ||
730 | "Resent-To: redir@redir.com\n" | 710 | "Resent-To: redir@redir.com\n" | ||
731 | "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n" | 711 | "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n" | ||
732 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | 712 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | ||
733 | "\n" | 713 | "\n" | ||
734 | "All happy families are alike; each unhappy family is unhappy in its own way."); | 714 | "All happy families are alike; each unhappy family is unhappy in its own way."); | ||
735 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | 715 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | ||
736 | 716 | | |||
737 | // qDebug() << baseline.toLatin1(); | | |||
738 | // qDebug() << "instead:" << rdir->encodedContent(); | | |||
739 | | ||||
740 | // QString fwdStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n" ); | | |||
741 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | 717 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | ||
742 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | 718 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | ||
743 | } | 719 | } | ||
744 | 720 | | |||
745 | void MessageFactoryTest::testCreateRedirect() | 721 | void MessageFactoryTest::testCreateRedirect() | ||
746 | { | 722 | { | ||
747 | KMime::Message::Ptr msg = createPlainTestMessage(); | 723 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
748 | 724 | | |||
749 | MessageFactoryNG factory(msg, 0); | 725 | MessageFactoryNG factory(msg, 0); | ||
750 | factory.setIdentityManager(mIdentMan); | 726 | factory.setIdentityManager(mIdentMan); | ||
751 | 727 | | |||
752 | QString redirectTo = QStringLiteral("redir@redir.com"); | 728 | QString redirectTo = QStringLiteral("redir@redir.com"); | ||
753 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo); | 729 | KMime::Message::Ptr rdir = factory.createRedirect(redirectTo); | ||
754 | 730 | | |||
755 | QString datetime = rdir->date()->asUnicodeString(); | 731 | QString datetime = rdir->date()->asUnicodeString(); | ||
756 | 732 | | |||
757 | // qDebug() << rdir->encodedContent(); | | |||
758 | | ||||
759 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | 733 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | ||
760 | rx.indexIn(QString::fromLatin1(rdir->head())); | 734 | rx.indexIn(QString::fromLatin1(rdir->head())); | ||
761 | 735 | | |||
762 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | 736 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | ||
763 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | 737 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | ||
764 | //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")"; | | |||
765 | QString baseline = QString::fromLatin1("From: me@me.me\n" | 738 | QString baseline = QString::fromLatin1("From: me@me.me\n" | ||
766 | "Cc: cc@cc.cc\n" | 739 | "Cc: cc@cc.cc\n" | ||
767 | "Bcc: bcc@bcc.bcc\n" | 740 | "Bcc: bcc@bcc.bcc\n" | ||
768 | "Subject: Test Email Subject\n" | 741 | "Subject: Test Email Subject\n" | ||
769 | "Date: %1\n" | 742 | "Date: %1\n" | ||
770 | "X-KMail-Transport: 0\n" | 743 | "X-KMail-Transport: 0\n" | ||
771 | "Message-ID: %2\n" | 744 | "Message-ID: %2\n" | ||
772 | "Disposition-Notification-To: me@me.me\n" | 745 | "Disposition-Notification-To: me@me.me\n" | ||
773 | "MIME-Version: 1.0\n" | 746 | "MIME-Version: 1.0\n" | ||
774 | "Content-Transfer-Encoding: 7Bit\n" | 747 | "Content-Transfer-Encoding: 7Bit\n" | ||
775 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | 748 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | ||
776 | "Resent-Message-ID: %3\n" | 749 | "Resent-Message-ID: %3\n" | ||
777 | "Resent-Date: %4\n" | 750 | "Resent-Date: %4\n" | ||
778 | "Resent-From: %5\n" | 751 | "Resent-From: %5\n" | ||
779 | "To: you@you.you\n" | 752 | "To: you@you.you\n" | ||
780 | "Resent-To: redir@redir.com\n" | 753 | "Resent-To: redir@redir.com\n" | ||
781 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | 754 | "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n" | ||
782 | "\n" | 755 | "\n" | ||
783 | "All happy families are alike; each unhappy family is unhappy in its own way."); | 756 | "All happy families are alike; each unhappy family is unhappy in its own way."); | ||
784 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | 757 | baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>")); | ||
785 | 758 | | |||
786 | // qDebug() << baseline.toLatin1(); | | |||
787 | // qDebug() << "instead:" << rdir->encodedContent(); | | |||
788 | | ||||
789 | // QString fwdStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n" ); | | |||
790 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | 759 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | ||
791 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | 760 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | ||
792 | } | 761 | } | ||
793 | 762 | | |||
794 | void MessageFactoryTest::testCreateResend() | 763 | void MessageFactoryTest::testCreateResend() | ||
795 | { | 764 | { | ||
796 | KMime::Message::Ptr msg = createPlainTestMessage(); | 765 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
797 | 766 | | |||
798 | MessageFactoryNG factory(msg, 0); | 767 | MessageFactoryNG factory(msg, 0); | ||
799 | factory.setIdentityManager(mIdentMan); | 768 | factory.setIdentityManager(mIdentMan); | ||
800 | 769 | | |||
801 | KMime::Message::Ptr rdir = factory.createResend(); | 770 | KMime::Message::Ptr rdir = factory.createResend(); | ||
802 | 771 | | |||
803 | QString datetime = rdir->date()->asUnicodeString(); | 772 | QString datetime = rdir->date()->asUnicodeString(); | ||
804 | 773 | | |||
805 | // qDebug() << msg->encodedContent(); | | |||
806 | | ||||
807 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | 774 | QRegExp rx(QLatin1String("Resent-Message-ID: ([^\n]*)")); | ||
808 | rx.indexIn(QString::fromLatin1(rdir->head())); | 775 | rx.indexIn(QString::fromLatin1(rdir->head())); | ||
809 | 776 | | |||
810 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | 777 | QRegExp rxmessageid(QLatin1String("Message-ID: ([^\n]+)")); | ||
811 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | 778 | rxmessageid.indexIn(QString::fromLatin1(rdir->head())); | ||
812 | 779 | | |||
813 | QString baseline = QString::fromLatin1("From: me@me.me\n" | 780 | QString baseline = QString::fromLatin1("From: me@me.me\n" | ||
814 | "To: %1\n" | 781 | "To: %1\n" | ||
815 | "Cc: cc@cc.cc\n" | 782 | "Cc: cc@cc.cc\n" | ||
816 | "Bcc: bcc@bcc.bcc\n" | 783 | "Bcc: bcc@bcc.bcc\n" | ||
817 | "Subject: Test Email Subject\n" | 784 | "Subject: Test Email Subject\n" | ||
818 | "Date: %2\n" | 785 | "Date: %2\n" | ||
819 | "X-KMail-Transport: 0\n" | 786 | "X-KMail-Transport: 0\n" | ||
820 | "Message-ID: %3\n" | 787 | "Message-ID: %3\n" | ||
821 | "Disposition-Notification-To: me@me.me\n" | 788 | "Disposition-Notification-To: me@me.me\n" | ||
822 | "MIME-Version: 1.0\n" | 789 | "MIME-Version: 1.0\n" | ||
823 | "Content-Transfer-Encoding: 7Bit\n" | 790 | "Content-Transfer-Encoding: 7Bit\n" | ||
824 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | 791 | "Content-Type: text/plain; charset=\"us-ascii\"\n" | ||
825 | "\n" | 792 | "\n" | ||
826 | "All happy families are alike; each unhappy family is unhappy in its own way."); | 793 | "All happy families are alike; each unhappy family is unhappy in its own way."); | ||
827 | baseline = baseline.arg(msg->to()->asUnicodeString()).arg(datetime).arg(rxmessageid.cap(1)); | 794 | baseline = baseline.arg(msg->to()->asUnicodeString()).arg(datetime).arg(rxmessageid.cap(1)); | ||
828 | 795 | | |||
829 | //qDebug() << baseline.toLatin1(); | | |||
830 | //qDebug() << "instead:" << rdir->encodedContent(); | | |||
831 | | ||||
832 | // QString fwdStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> All happy families are alike; each unhappy family is unhappy in its own way.\n" ); | | |||
833 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | 796 | QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject")); | ||
834 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | 797 | QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1()); | ||
835 | } | 798 | } | ||
836 | 799 | | |||
837 | void MessageFactoryTest::testCreateMDN() | 800 | void MessageFactoryTest::testCreateMDN() | ||
838 | { | 801 | { | ||
839 | KMime::Message::Ptr msg = createPlainTestMessage(); | 802 | KMime::Message::Ptr msg = createPlainTestMessage(); | ||
840 | 803 | | |||
841 | MessageFactoryNG factory(msg, 0); | 804 | MessageFactoryNG factory(msg, 0); | ||
842 | 805 | | |||
843 | factory.setIdentityManager(mIdentMan); | 806 | factory.setIdentityManager(mIdentMan); | ||
844 | 807 | | |||
845 | KMime::Message::Ptr mdn = factory.createMDN(KMime::MDN::AutomaticAction, KMime::MDN::Displayed, KMime::MDN::SentAutomatically); | 808 | KMime::Message::Ptr mdn = factory.createMDN(KMime::MDN::AutomaticAction, KMime::MDN::Displayed, KMime::MDN::SentAutomatically); | ||
846 | 809 | | |||
847 | QVERIFY(mdn.data()); | 810 | QVERIFY(mdn.data()); | ||
848 | //qDebug() << "mdn" << mdn->encodedContent(); | | |||
849 | 811 | | |||
850 | QString mdnContent = QString::fromLatin1("The message sent on %1 to %2 with subject \"%3\" has been displayed. " | 812 | QString mdnContent = QString::fromLatin1("The message sent on %1 to %2 with subject \"%3\" has been displayed. " | ||
851 | "This is no guarantee that the message has been read or understood."); | 813 | "This is no guarantee that the message has been read or understood."); | ||
852 | mdnContent = mdnContent.arg(KMime::DateFormatter::formatDate(KMime::DateFormatter::Localized, msg->date()->dateTime().toSecsSinceEpoch())) | 814 | mdnContent = mdnContent.arg(KMime::DateFormatter::formatDate(KMime::DateFormatter::Localized, msg->date()->dateTime().toSecsSinceEpoch())) | ||
853 | .arg(msg->to()->asUnicodeString()).arg(msg->subject()->asUnicodeString()); | 815 | .arg(msg->to()->asUnicodeString()).arg(msg->subject()->asUnicodeString()); | ||
854 | 816 | | |||
855 | //qDebug() << "comparing with:" << mdnContent; | | |||
856 | | ||||
857 | QCOMPARE_OR_DIFF(Util::findTypeInMessage(mdn.data(), "multipart", "report")->contents().at(0)->body(), | 817 | QCOMPARE_OR_DIFF(Util::findTypeInMessage(mdn.data(), "multipart", "report")->contents().at(0)->body(), | ||
858 | mdnContent.toLatin1()); | 818 | mdnContent.toLatin1()); | ||
859 | } | 819 | } | ||
860 | 820 | | |||
861 | KMime::Message::Ptr MessageFactoryTest::createPlainTestMessage() | 821 | KMime::Message::Ptr MessageFactoryTest::createPlainTestMessage() | ||
862 | { | 822 | { | ||
863 | Composer *composer = new Composer; | 823 | Composer *composer = new Composer; | ||
864 | composer->globalPart()->setFallbackCharsetEnabled(true); | 824 | composer->globalPart()->setFallbackCharsetEnabled(true); | ||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |