summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-25 06:44:23 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-25 06:44:23 (GMT)
commit144a531e56273d2dcb1165b289aca3ebb76471ad (patch)
tree8a229ac557a6daf3a94a6f3524cfcef6bbe2313d
parente1927f87c690168d9a190b439819e7949a772e67 (diff)
Improve autotest
-rw-r--r--messagecomposer/autotests/data/replyall_with_identity_message.mbox1
-rw-r--r--messagecomposer/autotests/messagefactorytest.cpp45
2 files changed, 44 insertions, 2 deletions
diff --git a/messagecomposer/autotests/data/replyall_with_identity_message.mbox b/messagecomposer/autotests/data/replyall_with_identity_message.mbox
index 2e936ae..20e0552 100644
--- a/messagecomposer/autotests/data/replyall_with_identity_message.mbox
+++ b/messagecomposer/autotests/data/replyall_with_identity_message.mbox
@@ -3,7 +3,6 @@ To: blo <blo@blo.org>, bli <bli@bli.org>
Cc: blu <blu@blu.org>, bly <bly@bly.org>
Sender: Bla1 <identity2@bla.com>
Subject: Plain Message Test
-List-Post: <mailto:list@list.org>
Date: Tue, 16 Aug 2011 17:03:52 +0530
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="nextPart7970347.4U2bZv7Mgu"
diff --git a/messagecomposer/autotests/messagefactorytest.cpp b/messagecomposer/autotests/messagefactorytest.cpp
index 57fccde..783be33 100644
--- a/messagecomposer/autotests/messagefactorytest.cpp
+++ b/messagecomposer/autotests/messagefactorytest.cpp
@@ -151,7 +151,50 @@ KMime::Message::Ptr MessageFactoryTest::loadMessage(const QString &filename)
void MessageFactoryTest::testCreateReplyToAllWithUseSender()
{
- //TODO
+ const QString filename(QStringLiteral(MAIL_DATA_DIR) + QStringLiteral("/replyall_with_identity_message.mbox"));
+ KMime::Message::Ptr msg = loadMessage(filename);
+ KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
+ KIdentityManagement::Identity ident = identMan->newFromScratch(QStringLiteral("foo"));
+ ident.setPrimaryEmailAddress(QStringLiteral("identity1@bla.com"));
+ ident = identMan->newFromScratch(QStringLiteral("foo1"));
+ identMan->setAsDefault(ident.uoid());
+ ident.setPrimaryEmailAddress(QStringLiteral("identity2@bla.com"));
+ identMan->commit();
+
+ MessageFactory factory(msg, 0);
+ factory.setReplyStrategy(ReplyAll);
+ factory.setIdentityManager(identMan);
+
+ MessageFactory::MessageReply reply = factory.createReply();
+ reply.replyAll = true;
+ //qDebug() << reply.msg->body();
+
+ QDateTime date = msg->date()->dateTime();
+ QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat);
+ datetime += QLatin1String(" ") + QLocale::system().toString(date.time(), QLocale::LongFormat);
+ QString replyStr = QStringLiteral("> This is a mail for testing replyall and sender");
+ QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Plain Message Test"));
+ QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1());
+
+ QString userAgent = reply.msg->userAgent()->asUnicodeString();
+ QString dateStr = reply.msg->date()->asUnicodeString();
+ QString ba = QString::fromLatin1("Date: %1\n"
+ "User-Agent: %2\n"
+ "Cc: blo <blo@blo.org>, bli <bli@bli.org>, blu <blu@blu.org>, bly <bly@bly.org>\n"
+ "To: Bla <identity1@bla.com>\n"
+ "Subject: Re: Plain Message Test\n"
+ "Content-Type: text/plain; charset=\"US-ASCII\"\n"
+ "Content-Transfer-Encoding: 8Bit\nMIME-Version: 1.0\n"
+ "X-KMail-Link-Message: 0\n"
+ "X-KMail-Link-Type: reply\n\n"
+ "%3")
+ .arg(dateStr).arg(userAgent).arg(replyStr);
+ QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba.toLatin1());
+
+
+ delete identMan;
+ QDir dir(QDir::homePath() + QStringLiteral("/.qttest/"));
+ dir.removeRecursively();
}
void MessageFactoryTest::testCreateReplyToList()