summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <[email protected]>2016-05-04 00:48:11 +0200
committerSandro Knauß <[email protected]>2016-05-04 16:24:45 +0200
commitd3870ccad713aaebe293f58ff477ef18a86b05f1 (patch)
tree4fb9f0f0608958d6dbd08aeb5fcc2a608004f80a
parent88ae138ea552a313aba0a70d6635700d85bf2da5 (diff)
Move quoteHTMLTest to messageparttest
-rw-r--r--mimetreeparser/autotests/CMakeLists.txt1
-rw-r--r--mimetreeparser/autotests/messageparttest.cpp64
-rw-r--r--mimetreeparser/autotests/messageparttest.h36
-rw-r--r--mimetreeparser/autotests/objecttreeparsertest.cpp25
-rw-r--r--mimetreeparser/autotests/objecttreeparsertest.h5
5 files changed, 102 insertions, 29 deletions
diff --git a/mimetreeparser/autotests/CMakeLists.txt b/mimetreeparser/autotests/CMakeLists.txt
index e4960ad..08bfc97 100644
--- a/mimetreeparser/autotests/CMakeLists.txt
+++ b/mimetreeparser/autotests/CMakeLists.txt
@@ -39,6 +39,7 @@ add_mimetreeparser_crypto_unittest(attachmenttest.cpp)
add_mimetreeparser_crypto_unittest(objecttreeparsertest.cpp)
add_mimetreeparser_crypto_unittest(rendertest.cpp)
add_mimetreeparser_crypto_unittest(unencryptedmessagetest.cpp)
+add_mimetreeparser_unittest(messageparttest.cpp)
add_mimetreeparser_unittest(nodehelpertest.cpp)
add_mimetreeparser_unittest(csshelpertest.cpp)
add_mimetreeparser_class_unittest( cryptohelpertest.cpp "../src/viewer/cryptohelper.cpp")
diff --git a/mimetreeparser/autotests/messageparttest.cpp b/mimetreeparser/autotests/messageparttest.cpp
new file mode 100644
index 0000000..655292b
--- /dev/null
+++ b/mimetreeparser/autotests/messageparttest.cpp
@@ -0,0 +1,64 @@
+/* Copyright 2009 Thomas McGuire <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "messageparttest.h"
+#include "util.h"
+#include "setupenv.h"
+
+#include "viewer/objecttreeparser.h"
+#include "interfaces/htmlwriter.h"
+#include "viewer/csshelperbase.h"
+#include "viewer/messagepart.h"
+
+
+#include <QTest>
+
+
+using namespace MimeTreeParser;
+
+QTEST_GUILESS_MAIN(MessagePartTest)
+
+void MessagePartTest::initTestCase()
+{
+ MimeTreeParser::Test::setupEnv();
+}
+
+void MessagePartTest::testQuoteHtml_data()
+{
+ QTest::addColumn<QString>("data");
+ QTest::addColumn<QString>("result");
+ QTest::newRow("simpletext") << QStringLiteral("http") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">http</div></div>");
+ QTest::newRow("simplequote") << QStringLiteral(">") << QStringLiteral("<blockquote><div class=\"quotelevel1\"><div dir=\"ltr\"><span class=\"quotemarks\">></span></div></div></blockquote>");
+ QTest::newRow("doublequotewithtext") << QStringLiteral(">> sddf") << QStringLiteral("<blockquote><blockquote><div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>> </span><font color=\"#007000\">sddf</font></div></div></blockquote></blockquote>");
+ QTest::newRow("doublequote") << QStringLiteral(">>") << QStringLiteral("<blockquote><blockquote><div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>></span></div></div></blockquote></blockquote>");
+ QTest::newRow("simplespace") << QStringLiteral(" ") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">&nbsp;</div></div>");
+ QTest::newRow("multispace") << QStringLiteral(" Bug ID: 358324") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bug ID: 358324</div></div>");
+}
+
+void MessagePartTest::testQuoteHtml()
+{
+ QFETCH(QString, data);
+ QFETCH(QString, result);
+ TestHtmlWriter testWriter;
+ TestCSSHelper testCSSHelper;
+ MimeTreeParser::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
+ ObjectTreeParser otp(&emptySource);
+ MessagePart part(&otp, data);
+ part.html(false);
+ QCOMPARE(testWriter.html, result);
+}
diff --git a/mimetreeparser/autotests/messageparttest.h b/mimetreeparser/autotests/messageparttest.h
new file mode 100644
index 0000000..398e383
--- /dev/null
+++ b/mimetreeparser/autotests/messageparttest.h
@@ -0,0 +1,36 @@
+/* Copyright 2016 Sandro Knauß <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef MESSAGEPARTTEST_H
+#define MESSAGEPARTTEST_H
+
+#include <QObject>
+
+class MessagePartTest : public QObject
+{
+ Q_OBJECT
+
+public Q_SLOTS:
+ void initTestCase();
+
+private Q_SLOTS:
+ void testQuoteHtml();
+ void testQuoteHtml_data();
+};
+
+#endif
diff --git a/mimetreeparser/autotests/objecttreeparsertest.cpp b/mimetreeparser/autotests/objecttreeparsertest.cpp
index c9b48a5..2ff17ad 100644
--- a/mimetreeparser/autotests/objecttreeparsertest.cpp
+++ b/mimetreeparser/autotests/objecttreeparsertest.cpp
@@ -289,27 +289,4 @@ void ObjectTreeParserTester::test_HTMLExternal()
QVERIFY(testWriter.html.contains(QStringLiteral("<b>SOME</b> HTML text.")));
QVERIFY(!testWriter.html.contains(QStringLiteral("This HTML message may contain external references to images etc. For security/privacy reasons external references are not loaded.")));
}
-}
-
-void ObjectTreeParserTester::text_quoteHtml_data()
-{
- QTest::addColumn<QString>("data");
- QTest::addColumn<QString>("result");
- QTest::newRow("simpletext") << QStringLiteral("http") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">http</div></div>");
- QTest::newRow("simplequote") << QStringLiteral(">") << QStringLiteral("<blockquote><div class=\"quotelevel1\"><div dir=\"ltr\"><span class=\"quotemarks\">></span></div></div></blockquote>");
- QTest::newRow("doublequotewithtext") << QStringLiteral(">> sddf") << QStringLiteral("<blockquote><blockquote><div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>> </span><font color=\"#007000\">sddf</font></div></div></blockquote></blockquote>");
- QTest::newRow("doublequote") << QStringLiteral(">>") << QStringLiteral("<blockquote><blockquote><div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>></span></div></div></blockquote></blockquote>");
- QTest::newRow("simplespace") << QStringLiteral(" ") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">&nbsp;</div></div>");
- QTest::newRow("multispace") << QStringLiteral(" Bug ID: 358324") << QStringLiteral("<div class=\"noquote\"><div dir=\"ltr\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bug ID: 358324</div></div>");
-}
-
-void ObjectTreeParserTester::text_quoteHtml()
-{
- QFETCH(QString, data);
- QFETCH(QString, result);
- TestHtmlWriter testWriter;
- TestCSSHelper testCSSHelper;
- MimeTreeParser::Test::TestObjectTreeSource emptySource(&testWriter, &testCSSHelper);
- ObjectTreeParser otp(&emptySource);
- QCOMPARE(otp.quotedHTML(data, false), result);
-}
+} \ No newline at end of file
diff --git a/mimetreeparser/autotests/objecttreeparsertest.h b/mimetreeparser/autotests/objecttreeparsertest.h
index efe128c..8872737 100644
--- a/mimetreeparser/autotests/objecttreeparsertest.h
+++ b/mimetreeparser/autotests/objecttreeparsertest.h
@@ -19,8 +19,6 @@
#ifndef OBJECTTREEPARSERTEST_H
#define OBJECTTREEPARSERTEST_H
-#include <KMime/Message>
-
#include <QObject>
class ObjectTreeParserTester : public QObject
@@ -41,9 +39,6 @@ private Q_SLOTS:
void test_HTMLOnly();
void test_HTMLOnlyText();
void test_HTMLExternal();
-
- void text_quoteHtml();
- void text_quoteHtml_data();
};
#endif