Commit d3870cca authored by Sandro Knauß's avatar Sandro Knauß

Move quoteHTMLTest to messageparttest

parent 88ae138e
......@@ -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")
......
/* Copyright 2009 Thomas McGuire <mcguire@kde.org>
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);
}
/* Copyright 2016 Sandro Knauß <sknauss@kde.org>
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
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment