summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-23 14:00:49 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-23 14:00:49 (GMT)
commita0cd09de11895e41922b39cc8db2a8184a63bf4d (patch)
treee058f2400bcc444212446348c88d4d863e37e1aa
parent430da7db55bc91591d097f8755173163b4d5aa8d (diff)
Add more autotest about resend method
-rw-r--r--messagecomposer/autotests/messagefactorytest.cpp129
-rw-r--r--messagecomposer/autotests/messagefactorytest.h3
2 files changed, 132 insertions, 0 deletions
diff --git a/messagecomposer/autotests/messagefactorytest.cpp b/messagecomposer/autotests/messagefactorytest.cpp
index 23d676b..a312c7e 100644
--- a/messagecomposer/autotests/messagefactorytest.cpp
+++ b/messagecomposer/autotests/messagefactorytest.cpp
@@ -274,6 +274,135 @@ void MessageFactoryTest::testCreateForward()
delete identMan;
}
+void MessageFactoryTest::testCreateRedirectToAndCCAndBCC()
+{
+ KMime::Message::Ptr msg = createPlainTestMessage();
+ KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
+ KIdentityManagement::Identity &ident = identMan->modifyIdentityForUoid(identMan->identityForUoidOrDefault(0).uoid());
+ ident.setFullName(QStringLiteral("another"));
+ ident.setPrimaryEmailAddress(QStringLiteral("another@another.com"));
+ identMan->commit();
+
+ MessageFactory factory(msg, 0);
+ factory.setIdentityManager(identMan);
+
+ QString redirectTo = QStringLiteral("redir@redir.com");
+ QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com");
+ QString redirectBcc = QStringLiteral("redirbcc@redirbcc.com, redirbcc2@redirbcc.com");
+ KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc, redirectBcc);
+
+ QDateTime date = rdir->date()->dateTime();
+ QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat);
+ datetime = rdir->date()->asUnicodeString();
+
+// qDebug() << rdir->encodedContent();
+
+ QString msgId = MessageCore::StringUtil::generateMessageId(msg->sender()->asUnicodeString(), QString());
+
+ QRegExp rx(QString::fromLatin1("Resent-Message-ID: ([^\n]*)"));
+ rx.indexIn(QString::fromLatin1(rdir->head()));
+
+ QRegExp rxmessageid(QString::fromLatin1("Message-ID: ([^\n]+)"));
+ rxmessageid.indexIn(QString::fromLatin1(rdir->head()));
+ //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")";
+ QString baseline = QString::fromLatin1("From: me@me.me\n"
+ "Cc: cc@cc.cc\n"
+ "Bcc: bcc@bcc.bcc\n"
+ "Subject: Test Email Subject\n"
+ "Date: %1\n"
+ "X-KMail-Transport: 0\n"
+ "Message-ID: %2\n"
+ "Disposition-Notification-To: me@me.me\n"
+ "MIME-Version: 1.0\n"
+ "Content-Transfer-Encoding: 7Bit\n"
+ "Content-Type: text/plain; charset=\"us-ascii\"\n"
+ "Resent-Message-ID: %3\n"
+ "Resent-Date: %4\n"
+ "Resent-From: %5\n"
+ "To: you@you.you\n"
+ "Resent-To: redir@redir.com\n"
+ "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n"
+ "Resent-Bcc: redirbcc@redirbcc.com, redirbcc2@redirbcc.com\n"
+ "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n"
+ "\n"
+ "All happy families are alike; each unhappy family is unhappy in its own way.");
+ baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>"));
+
+// qDebug() << baseline.toLatin1();
+// qDebug() << "instead:" << rdir->encodedContent();
+
+// 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" );
+ QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject"));
+ QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1());
+ delete identMan;
+ //QDir dir(QDir::homePath() + QStringLiteral("/.qttest/"));
+ //dir.removeRecursively();
+}
+
+void MessageFactoryTest::testCreateRedirectToAndCC()
+{
+ KMime::Message::Ptr msg = createPlainTestMessage();
+ KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
+ KIdentityManagement::Identity &ident = identMan->modifyIdentityForUoid(identMan->identityForUoidOrDefault(0).uoid());
+ ident.setFullName(QStringLiteral("another"));
+ ident.setPrimaryEmailAddress(QStringLiteral("another@another.com"));
+ identMan->commit();
+
+ MessageFactory factory(msg, 0);
+ factory.setIdentityManager(identMan);
+
+ QString redirectTo = QStringLiteral("redir@redir.com");
+ QString redirectCc = QStringLiteral("redircc@redircc.com, redircc2@redircc.com");
+ KMime::Message::Ptr rdir = factory.createRedirect(redirectTo, redirectCc);
+
+ QDateTime date = rdir->date()->dateTime();
+ QString datetime = QLocale::system().toString(date.date(), QLocale::LongFormat);
+ datetime = rdir->date()->asUnicodeString();
+
+// qDebug() << rdir->encodedContent();
+
+ QString msgId = MessageCore::StringUtil::generateMessageId(msg->sender()->asUnicodeString(), QString());
+
+ QRegExp rx(QString::fromLatin1("Resent-Message-ID: ([^\n]*)"));
+ rx.indexIn(QString::fromLatin1(rdir->head()));
+
+ QRegExp rxmessageid(QString::fromLatin1("Message-ID: ([^\n]+)"));
+ rxmessageid.indexIn(QString::fromLatin1(rdir->head()));
+ //qWarning() << "messageid:" << rxmessageid.cap(1) << "(" << rdir->head() << ")";
+ QString baseline = QString::fromLatin1("From: me@me.me\n"
+ "Cc: cc@cc.cc\n"
+ "Bcc: bcc@bcc.bcc\n"
+ "Subject: Test Email Subject\n"
+ "Date: %1\n"
+ "X-KMail-Transport: 0\n"
+ "Message-ID: %2\n"
+ "Disposition-Notification-To: me@me.me\n"
+ "MIME-Version: 1.0\n"
+ "Content-Transfer-Encoding: 7Bit\n"
+ "Content-Type: text/plain; charset=\"us-ascii\"\n"
+ "Resent-Message-ID: %3\n"
+ "Resent-Date: %4\n"
+ "Resent-From: %5\n"
+ "To: you@you.you\n"
+ "Resent-To: redir@redir.com\n"
+ "Resent-Cc: redircc@redircc.com, redircc2@redircc.com\n"
+ "X-KMail-Redirect-From: me@me.me (by way of another <another@another.com>)\n"
+ "\n"
+ "All happy families are alike; each unhappy family is unhappy in its own way.");
+ baseline = baseline.arg(datetime).arg(rxmessageid.cap(1)).arg(rx.cap(1)).arg(datetime).arg(QStringLiteral("another <another@another.com>"));
+
+// qDebug() << baseline.toLatin1();
+// qDebug() << "instead:" << rdir->encodedContent();
+
+// 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" );
+ QCOMPARE(rdir->subject()->asUnicodeString(), QStringLiteral("Test Email Subject"));
+ QCOMPARE_OR_DIFF(rdir->encodedContent(), baseline.toLatin1());
+ delete identMan;
+ //QDir dir(QDir::homePath() + QStringLiteral("/.qttest/"));
+ //dir.removeRecursively();
+}
+
+
void MessageFactoryTest::testCreateRedirect()
{
KMime::Message::Ptr msg = createPlainTestMessage();
diff --git a/messagecomposer/autotests/messagefactorytest.h b/messagecomposer/autotests/messagefactorytest.h
index 3aaf832..fa3e0b3 100644
--- a/messagecomposer/autotests/messagefactorytest.h
+++ b/messagecomposer/autotests/messagefactorytest.h
@@ -37,6 +37,9 @@ private Q_SLOTS:
void testCreateRedirect();
void testCreateResend();
void testCreateMDN();
+ void testCreateRedirectToAndCC();
+ void testCreateRedirectToAndCCAndBCC();
+
//MultiPart
void test_multipartAlternative_data();