summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-23 19:01:23 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-23 19:01:23 (GMT)
commitbd0daec51ca02f28f5d22f76db1e2c5b65142d0d (patch)
tree971685bc5a8222718bab7cfdfcf643b01185e789
parent4fc620d8cd91f7c8f0f4df9ce87e3cbe422bedb3 (diff)
Add more autotests
-rw-r--r--messagecomposer/autotests/messagefactorytest.cpp56
-rw-r--r--messagecomposer/autotests/messagefactorytest.h2
2 files changed, 58 insertions, 0 deletions
diff --git a/messagecomposer/autotests/messagefactorytest.cpp b/messagecomposer/autotests/messagefactorytest.cpp
index cae2983..49bd94f 100644
--- a/messagecomposer/autotests/messagefactorytest.cpp
+++ b/messagecomposer/autotests/messagefactorytest.cpp
@@ -133,6 +133,62 @@ void MessageFactoryTest::initTestCase()
QStandardPaths::setTestModeEnabled(true);
}
+void MessageFactoryTest::testCreateReplyToAuthor()
+{
+ /*
+ KMime::Message::Ptr msg = createPlainTestMessage();
+ KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
+ KIdentityManagement::Identity ident = identMan->newFromScratch(QStringLiteral("foo"));
+ ident.setPrimaryEmailAddress(QStringLiteral("foo@foo.foo"));
+ identMan->commit();
+
+ MessageFactory factory(msg, 0);
+ 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 = 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")));
+ QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject"));
+ QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1());
+ delete identMan;
+ QDir dir(QDir::homePath() + QStringLiteral("/.qttest/"));
+ dir.removeRecursively();
+ */
+}
+
+void MessageFactoryTest::testCreateReplyAllWithMultiEmails()
+{
+ KMime::Message::Ptr msg = createPlainTestMessageWithMultiEmails();
+ KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
+ KIdentityManagement::Identity ident = identMan->newFromScratch(QStringLiteral("foo"));
+ ident.setPrimaryEmailAddress(QStringLiteral("foo@foo.foo"));
+ identMan->commit();
+
+ MessageFactory factory(msg, 0);
+ 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 = 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")));
+ QCOMPARE(reply.msg->subject()->asUnicodeString(), QLatin1String("Re: Test Email Subject"));
+ //QCOMPARE_OR_DIFF(reply.msg->body(), replyStr.toLatin1());
+ //QByteArray ba;
+ //QCOMPARE_OR_DIFF(reply.msg->encodedContent(), ba);
+ delete identMan;
+ QDir dir(QDir::homePath() + QStringLiteral("/.qttest/"));
+ dir.removeRecursively();
+}
+
void MessageFactoryTest::testCreateReplyAll()
{
KMime::Message::Ptr msg = createPlainTestMessage();
diff --git a/messagecomposer/autotests/messagefactorytest.h b/messagecomposer/autotests/messagefactorytest.h
index c1fe253..e1da630 100644
--- a/messagecomposer/autotests/messagefactorytest.h
+++ b/messagecomposer/autotests/messagefactorytest.h
@@ -46,6 +46,8 @@ private Q_SLOTS:
void test_multipartAlternative();
void testCreateForwardMultiEmails();
+ void testCreateReplyToAuthor();
+ void testCreateReplyAllWithMultiEmails();
private:
KMime::Message::Ptr createPlainTestMessage();
KMime::Message::Ptr loadMessageFromFile(QString filename);