148
151
QString datetime = KGlobal::locale()->formatDate( date.date(), KLocale::LongDate );
149
152
datetime += QLatin1String( " " ) + KGlobal::locale()->formatTime( date.time(), true );
150
153
QString replyStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> encoded?\n" );
151
QVERIFY( reply.msg->contentType()->mimeType() == "text/plain" );
154
QVERIFY( reply.msg->contentType()->mimeType() == "multipart/alternative" );
152
155
QVERIFY( reply.msg->subject()->asUnicodeString() == QLatin1String( "Re: reply to please" ) );
153
QCOMPARE_OR_DIFF( reply.msg->body(), replyStr.toLatin1() );
156
QCOMPARE_OR_DIFF( reply.msg->contents().at(0)->body(), replyStr.toLatin1() );
172
175
QString datetime = KGlobal::locale()->formatDate( date.date(), KLocale::LongDate );
173
176
datetime += QLatin1String( " " ) + KGlobal::locale()->formatTime( date.time(), true );
174
177
QString replyStr = QString::fromLatin1( "On " + datetime.toLatin1() + " you wrote:\n> quote me please.\n" );
175
QVERIFY( reply.msg->contentType()->mimeType() == "text/plain" );
178
QVERIFY( reply.msg->contentType()->mimeType() == "multipart/alternative" );
176
179
QVERIFY( reply.msg->subject()->asUnicodeString() == QLatin1String( "Re: asking for reply" ) );
177
QCOMPARE_OR_DIFF( reply.msg->body(), replyStr.toLatin1() );
180
QCOMPARE_OR_DIFF( reply.msg->contents().at(0)->body(), replyStr.toLatin1() );
202
205
TestCSSHelper testCSSHelper;
203
206
MessageCore::Test::TestObjectTreeSource testSource( &testWriter, &testCSSHelper );
204
207
MessageViewer::NodeHelper* nh = new MessageViewer::NodeHelper;
205
MessageViewer::ObjectTreeParser otp( &testSource, nh, 0, false, false, true, 0 );
208
MessageViewer::ObjectTreeParser otp( &testSource, nh, 0, false, true, 0 );
206
209
otp.parseObjectTree( reply.msg.get() );
207
210
QVERIFY( otp.textualContent().contains( replyStr ) );*/
212
214
void MessageFactoryTest::testCreateForward()
214
216
KMime::Message::Ptr msg = createPlainTestMessage();
389
389
TestCSSHelper testCSSHelper;
390
390
TestObjectTreeSource testSource( &testWriter, &testCSSHelper );
391
391
MessageViewer::NodeHelper* nh = new MessageViewer::NodeHelper;
392
MessageViewer::ObjectTreeParser otp( &testSource, nh, 0, false, false, true, 0 );
392
MessageViewer::ObjectTreeParser otp( &testSource, nh, 0, false, true, 0 );
393
393
MessageViewer::ProcessResult pResult( nh ); */
395
395
// kDebug() << MessageCore::NodeHelper::firstChild( mdn->mainBodyPart() )->encodedContent();
439
438
msg->setContent( data );
443
void MessageFactoryTest::test_multipartAlternative_data()
445
QTest::addColumn<QString>( "mailFileName" );
446
QTest::addColumn<int>( "contentAt" );
447
QTest::addColumn<QString>( "selection" );
448
QTest::addColumn<QString>( "expected" );
450
QDir dir( QLatin1String( MAIL_DATA_DIR ) );
451
foreach ( const QString &file, dir.entryList( QStringList( QLatin1String("plain_message.mbox") ), QDir::Files | QDir::Readable | QDir::NoSymLinks ) ) {
452
QTest::newRow( file.toLatin1() ) << QString( dir.path() + QLatin1Char( '/' ) + file ) << 0 << "" <<
453
"> This *is* the *message* text *from* Sudhendu Kumar<dontspamme@yoohoo.com>\n"
456
"> Thanks & Regards\n"
458
QTest::newRow( file.toLatin1() ) << QString( dir.path() + QLatin1Char( '/' ) + file ) << 1 << "" << "<html><head></head><body>"
459
"<blockquote>This <i>is</i> the <b>message</b> text <u>from</u> Sudhendu Kumar<dontspamme@yoohoo.com><br>"
460
"<br>-- <br>Thanks & Regards<br>Sudhendu Kumar<br></blockquote><br/></body></html>";
464
void MessageFactoryTest::test_multipartAlternative()
466
QFETCH( QString, mailFileName );
467
QFETCH( int, contentAt );
468
QFETCH( QString, selection );
469
QFETCH( QString, expected );
471
QFile mailFile( mailFileName );
472
QVERIFY( mailFile.open( QIODevice::ReadOnly ) );
473
const QByteArray mailData = KMime::CRLFtoLF( mailFile.readAll() );
474
QVERIFY( !mailData.isEmpty() );
475
KMime::Message::Ptr origMsg( new KMime::Message );
476
origMsg->setContent( mailData );
479
KPIMIdentities::IdentityManager* identMan = new KPIMIdentities::IdentityManager;
481
MessageFactory factory( origMsg, 0 );
482
factory.setIdentityManager( identMan );
483
factory.setSelection( selection );
484
factory.setQuote( true );
485
factory.setReplyStrategy( ReplyAll );
486
TemplateParser::GlobalSettings::self()->setTemplateReplyAll( QLatin1String( "%QUOTE" ) );
489
str = TemplateParser::GlobalSettings::self()->templateReplyAll();
490
factory.setTemplate( str );
492
MessageFactory::MessageReply reply = factory.createReply();
493
QVERIFY( reply.replyAll = true );
494
QVERIFY( reply.msg->contentType()->mimeType() == "multipart/alternative" );
495
QVERIFY( reply.msg->subject()->asUnicodeString() == QLatin1String( "Re: Plain Message Test" ) );
496
QCOMPARE( reply.msg->contents().at( contentAt )->encodedBody().data(), expected.toLatin1().data() );
445
499
#include "messagefactorytest.moc"