summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-03 06:42:13 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-03 06:42:13 (GMT)
commit0976cf3112ca6ffbfae78b3fef02474815120b61 (patch)
tree930b46edd108608a2ad9a2fc16be3029b99b7609
parent0e07b10191e454706d63ff17b704e666bd192738 (diff)
Add new autotest
-rw-r--r--messagecomposer/autotests/data/replyall_with_identity_message_and_identity_in_cc.mbox11
-rw-r--r--messagecomposer/autotests/messagefactorytest.cpp44
-rw-r--r--messagecomposer/autotests/messagefactorytest.h1
3 files changed, 56 insertions, 0 deletions
diff --git a/messagecomposer/autotests/data/replyall_with_identity_message_and_identity_in_cc.mbox b/messagecomposer/autotests/data/replyall_with_identity_message_and_identity_in_cc.mbox
new file mode 100644
index 0000000..19c8f8e
--- /dev/null
+++ b/messagecomposer/autotests/data/replyall_with_identity_message_and_identity_in_cc.mbox
@@ -0,0 +1,11 @@
+From: Bla <identity1@bla.com>
+To: blo <blo@blo.org>, bli <bli@bli.org>
+Cc: blu <blu@blu.org>, bly <bly@bly.org>, Bla <identity1@bla.com>
+Sender: Bla1 <identity2@bla.com>
+Subject: Plain Message Test
+Date: Tue, 16 Aug 2011 17:03:52 +0530
+MIME-Version: 1.0
+Content-Type: multipart/alternative; boundary="nextPart7970347.4U2bZv7Mgu"
+Content-Transfer-Encoding: 7Bit
+
+This is a mail for testing replyall and sender
diff --git a/messagecomposer/autotests/messagefactorytest.cpp b/messagecomposer/autotests/messagefactorytest.cpp
index 77b59cd..f57d485 100644
--- a/messagecomposer/autotests/messagefactorytest.cpp
+++ b/messagecomposer/autotests/messagefactorytest.cpp
@@ -168,6 +168,50 @@ KMime::Message::Ptr MessageFactoryTest::loadMessage(const QString &filename)
return origMsg;
}
+void MessageFactoryTest::testCreateReplyToAllWithUseSenderAndIdentityInCC()
+{
+ const QString filename(QStringLiteral(MAIL_DATA_DIR) + QStringLiteral("/replyall_with_identity_message_and_identity_in_cc.mbox"));
+ KMime::Message::Ptr msg = loadMessage(filename);
+ KIdentityManagement::Identity &i1 = mIdentMan->modifyIdentityForName(QStringLiteral("test1"));
+ i1.setFullName(QStringLiteral("foo1"));
+ i1.setPrimaryEmailAddress(QStringLiteral("identity1@bla.com"));
+ KIdentityManagement::Identity &i2 = mIdentMan->modifyIdentityForName(QStringLiteral("test2"));
+ i2.setFullName(QStringLiteral("foo2"));
+ i2.setPrimaryEmailAddress(QStringLiteral("identity2@bla.com"));
+ mIdentMan->commit();
+
+ MessageFactory factory(msg, 0);
+ factory.setReplyStrategy(ReplyAll);
+ factory.setIdentityManager(mIdentMan);
+
+ 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("From: another <another@another.com>\n"
+ "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());
+}
+
void MessageFactoryTest::testCreateReplyToAllWithUseSender()
{
const QString filename(QStringLiteral(MAIL_DATA_DIR) + QStringLiteral("/replyall_with_identity_message.mbox"));
diff --git a/messagecomposer/autotests/messagefactorytest.h b/messagecomposer/autotests/messagefactorytest.h
index a0e455d..bd458b5 100644
--- a/messagecomposer/autotests/messagefactorytest.h
+++ b/messagecomposer/autotests/messagefactorytest.h
@@ -53,6 +53,7 @@ private Q_SLOTS:
void testCreateReplyToList();
void testCreateReplyToAllWithUseSender();
void testCreateReplyToAllWithUseSenderByNoSameIdentities();
+ void testCreateReplyToAllWithUseSenderAndIdentityInCC();
void cleanupTestCase();
private: