summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <[email protected]>2016-03-14 11:22:23 +0100
committerSandro Knauß <[email protected]>2016-03-21 11:53:30 +0100
commita87632f1094c10735ca3ebb904c7df2e8d1d7291 (patch)
tree0e2b8472741c8418064c3021f4d9022907101724
parent25e14d068e3a56b5781286fb54fd44685641a179 (diff)
Replace EmptySource with Test::TestObjectTreeSource
-rw-r--r--mimetreeparser/autotests/attachmenttest.cpp8
-rw-r--r--mimetreeparser/autotests/objecttreeparsertest.cpp7
-rw-r--r--mimetreeparser/autotests/setupenv.h54
-rw-r--r--mimetreeparser/autotests/unencryptedmessagetest.cpp24
4 files changed, 69 insertions, 24 deletions
diff --git a/mimetreeparser/autotests/attachmenttest.cpp b/mimetreeparser/autotests/attachmenttest.cpp
index dd525d2..02e9885 100644
--- a/mimetreeparser/autotests/attachmenttest.cpp
+++ b/mimetreeparser/autotests/attachmenttest.cpp
@@ -19,8 +19,6 @@
#include "viewer/objecttreeparser.h"
#include "util.h"
-#include "viewer/objecttreeemptysource.h"
-
#include "setupenv.h"
#include <qtest.h>
@@ -57,9 +55,9 @@ void AttachmentTest::testEncryptedAttachment()
QFETCH(QString, mbox);
auto msg = readAndParseMail(mbox);
NodeHelper nodeHelper;
- EmptySource emptySource;
- emptySource.setAllowDecryption(true);
- ObjectTreeParser otp(&emptySource, &nodeHelper);
+ Test::TestObjectTreeSource testSource(Q_NULLPTR, Q_NULLPTR);
+ testSource.setAllowDecryption(true);
+ ObjectTreeParser otp(&testSource, &nodeHelper);
otp.parseObjectTree(msg.data());
auto attachments = msg->attachments();
diff --git a/mimetreeparser/autotests/objecttreeparsertest.cpp b/mimetreeparser/autotests/objecttreeparsertest.cpp
index 3c0ea67..246b174 100644
--- a/mimetreeparser/autotests/objecttreeparsertest.cpp
+++ b/mimetreeparser/autotests/objecttreeparsertest.cpp
@@ -20,7 +20,6 @@
#include "util.h"
#include "viewer/objecttreeparser.h"
-#include "viewer/objecttreeemptysource.h"
#include "interfaces/htmlwriter.h"
#include "viewer/csshelperbase.h"
@@ -56,7 +55,7 @@ void ObjectTreeParserTester::test_parsePlainMessage()
QCOMPARE(msg->contents().size(), 0);
// Parse the message
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
ObjectTreeParser otp(&emptySource);
otp.parseObjectTree(msg.data());
@@ -190,7 +189,7 @@ void ObjectTreeParserTester::test_HTML()
QCOMPARE(msg->subject()->as7BitString(false).constData(), "HTML test");
QCOMPARE(msg->contents().size(), 2);
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
ObjectTreeParser otp(&emptySource);
otp.parseObjectTree(msg.data());
@@ -227,7 +226,7 @@ void ObjectTreeParserTester::test_HTMLOnly()
QCOMPARE(msg->subject()->as7BitString(false).constData(), "HTML test");
QCOMPARE(msg->contents().size(), 0);
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
ObjectTreeParser otp(&emptySource);
otp.parseObjectTree(msg.data());
diff --git a/mimetreeparser/autotests/setupenv.h b/mimetreeparser/autotests/setupenv.h
index b8701da..d61bd40 100644
--- a/mimetreeparser/autotests/setupenv.h
+++ b/mimetreeparser/autotests/setupenv.h
@@ -22,8 +22,9 @@
#define MESSAGECORE_TESTS_UTIL_H
#include <gpgme++/key.h>
-#include <viewer/objecttreeemptysource.h>
+#include "objecttreesourceif.h"
#include <viewer/attachmentstrategy.h>
+#include "viewer/bodypartformatterbasefactory.h"
namespace MessageViewer
{
@@ -40,7 +41,7 @@ void setupEnv();
// We can't use EmptySource, since we need to control some emelnets of the source for tests to also test
// loadExternal and htmlMail.
-class TestObjectTreeSource : public MessageViewer::EmptySource
+class TestObjectTreeSource : public MessageViewer::ObjectTreeSourceIf
{
public:
TestObjectTreeSource(MessageViewer::HtmlWriter *writer,
@@ -50,6 +51,7 @@ public:
, mAttachmentStrategy(QStringLiteral("smart"))
, mHtmlLoadExternal(false)
, mHtmlMail(true)
+ , mDecryptMessage(false)
{
}
@@ -104,12 +106,60 @@ public:
return false;
}
+ const BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE
+ {
+ return &mBodyPartFormatterBaseFactory;
+ }
+
+ bool decryptMessage() const Q_DECL_OVERRIDE
+ {
+ return mDecryptMessage;
+ }
+
+ void setAllowDecryption(bool allowDecryption)
+ {
+ mDecryptMessage = allowDecryption;
+ }
+
+ bool showSignatureDetails() const Q_DECL_OVERRIDE
+ {
+ return false;
+ }
+
+ void setHtmlMode(MessageViewer::Util::HtmlMode mode) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(mode);
+ }
+
+ int levelQuote() const Q_DECL_OVERRIDE
+ {
+ return 1;
+ }
+
+ const QTextCodec *overrideCodec() Q_DECL_OVERRIDE
+ {
+ return Q_NULLPTR;
+ }
+
+ QString createMessageHeader(KMime::Message *message) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(message);
+ return QString(); //do nothing
+ }
+
+ QObject *sourceObject() Q_DECL_OVERRIDE
+ {
+ return Q_NULLPTR;
+ }
+
private:
MessageViewer::HtmlWriter *mWriter;
MessageViewer::CSSHelperBase *mCSSHelper;
QString mAttachmentStrategy;
+ BodyPartFormatterBaseFactory mBodyPartFormatterBaseFactory;
bool mHtmlLoadExternal;
bool mHtmlMail;
+ bool mDecryptMessage;
};
}
diff --git a/mimetreeparser/autotests/unencryptedmessagetest.cpp b/mimetreeparser/autotests/unencryptedmessagetest.cpp
index 2e73b56..3105550 100644
--- a/mimetreeparser/autotests/unencryptedmessagetest.cpp
+++ b/mimetreeparser/autotests/unencryptedmessagetest.cpp
@@ -19,8 +19,6 @@
#include "viewer/objecttreeparser.h"
#include "util.h"
-#include "viewer/objecttreeemptysource.h"
-
#include <setupenv.h>
#include <qtest.h>
@@ -50,14 +48,14 @@ QTEST_MAIN(UnencryptedMessageTest)
void UnencryptedMessageTest::initTestCase()
{
- MessageViewer::Test::setupEnv();
+ Test::setupEnv();
}
void UnencryptedMessageTest::testMailWithoutEncryption()
{
KMime::Message::Ptr originalMessage = readAndParseMail(QStringLiteral("encapsulated-with-attachment.mbox"));
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
QVERIFY(!nodeHelper.unencryptedMessage(originalMessage));
@@ -70,7 +68,7 @@ void UnencryptedMessageTest::testSignedForwardedOpenPGPSignedEncrypted()
NodeHelper nodeHelper;
TestHtmlWriter testWriter;
TestCSSHelper testCSSHelper;
- MessageViewer::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
+ Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -89,7 +87,7 @@ void UnencryptedMessageTest::testForwardedOpenPGPSignedEncrypted()
NodeHelper nodeHelper;
TestHtmlWriter testWriter;
TestCSSHelper testCSSHelper;
- MessageViewer::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
+ Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
emptySource.setAllowDecryption(true);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -125,7 +123,7 @@ void UnencryptedMessageTest::testSMIMESignedEncrypted()
KMime::Message::Ptr originalMessage = readAndParseMail(QStringLiteral("smime-signed-encrypted.mbox"));
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
emptySource.setAllowDecryption(true);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -154,7 +152,7 @@ void UnencryptedMessageTest::testOpenPGPSignedEncrypted()
KMime::Message::Ptr originalMessage = readAndParseMail(QStringLiteral("openpgp-signed-encrypted.mbox"));
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
emptySource.setAllowDecryption(true);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -183,7 +181,7 @@ void UnencryptedMessageTest::testOpenPGPEncrypted()
KMime::Message::Ptr originalMessage = readAndParseMail(QStringLiteral("openpgp-encrypted.mbox"));
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
emptySource.setAllowDecryption(true);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -203,7 +201,7 @@ void UnencryptedMessageTest::testOpenPGPEncryptedNotDecrypted()
KMime::Message::Ptr originalMessage = readAndParseMail(QStringLiteral("openpgp-encrypted.mbox"));
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
emptySource.setAllowDecryption(false);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -233,7 +231,7 @@ void UnencryptedMessageTest::testAsync()
KMime::Message::Ptr originalMessage = readAndParseMail(mailFileName);
NodeHelper nodeHelper;
- EmptySource emptySource;
+ Test::TestObjectTreeSource emptySource(Q_NULLPTR, Q_NULLPTR);
emptySource.setAllowDecryption(true);
{
QEventLoop loop;
@@ -276,7 +274,7 @@ void UnencryptedMessageTest::testNotDecrypted()
NodeHelper nodeHelper;
TestHtmlWriter testWriter;
TestCSSHelper testCSSHelper;
- MessageViewer::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
+ Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
emptySource.setAllowDecryption(false);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());
@@ -299,7 +297,7 @@ void UnencryptedMessageTest::testSMimeAutoCertImport()
NodeHelper nodeHelper;
TestHtmlWriter testWriter;
TestCSSHelper testCSSHelper;
- MessageViewer::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
+ Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
ObjectTreeParser otp(&emptySource, &nodeHelper);
otp.parseObjectTree(originalMessage.data());