1 /* Copyright 2009 Thomas McGuire <mcguire@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3 or any later version
7 accepted by the membership of KDE e.V. (or its successor approved
8 by the membership of KDE e.V.), which shall act as a proxy
9 defined in Section 14 of version 3 of the license.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "htmlquotecolorertest.h"
21 #include "viewer/htmlquotecolorer.cpp"
25 using namespace MessageViewer
;
27 QTEST_MAIN(HTMLQuoteColorerTester
)
29 void HTMLQuoteColorerTester::test_QuoteColor()
31 QFETCH(QString
, originalCode
);
32 QFETCH(QString
, expectedCode
);
34 HTMLQuoteColorer colorer
;
35 colorer
.setEnableHtmlQuoteColorer(true);
36 colorer
.setQuoteColor(0, QColor("#FF0000"));
37 colorer
.setQuoteColor(1, QColor("#00FF00"));
38 colorer
.setQuoteColor(2, QColor("#0000FF"));
40 QCOMPARE(colorer
.process(originalCode
, header
), expectedCode
);
43 void HTMLQuoteColorerTester::test_QuoteColor_data()
45 QTest::addColumn
<QString
>("originalCode");
46 QTest::addColumn
<QString
>("expectedCode");
48 QTest::newRow("") << "<html><body>Some unquoted text.</body></html>"
49 << "Some unquoted text.";
50 QTest::newRow("") << "<html><body>Some unquoted >text.</body></html>"
51 << "Some unquoted >text.";
52 QTest::newRow("") << "<html><body>Some unquoted \n>text.</body></html>"
53 << "Some unquoted \n>text.";
54 QTest::newRow("") << "<html><body>Some unquoted <b>></b>text.</body></html>"
55 << "Some unquoted <b>></b>text.";
56 QTest::newRow("") << "<html><body>>Some quoted text.</body></html>"
57 << "<font color=\"#ff0000\">>Some quoted text.</font>";
58 QTest::newRow("") << "<html><body><b>>Some quoted</b> text.</body></html>"
59 << "<b><font color=\"#ff0000\">>Some quoted</font></b><font color=\"#ff0000\"> text.</font>";
60 QTest::newRow("") << "<html><body>>Some quoted >text.</body></html>"
61 << "<font color=\"#ff0000\">>Some quoted >text.</font>";
62 QTest::newRow("") << "<html><body>>Some <b>quoted</b> text.</body></html>"
63 << "<font color=\"#ff0000\">>Some </font><b><font color=\"#ff0000\">quoted</font></b><font color=\"#ff0000\"> text.</font>";
64 QTest::newRow("") << "<html><body>"
65 "> > > Level 3 Quote<br>"
67 "> > Level 2 Quote<br>"
68 "> Level 1 Quote<br>"
71 << "<font color=\"#0000ff\">> > > Level 3 Quote</font><br>"
73 "<font color=\"#00ff00\">> > Level 2 Quote</font><br>"
74 "<font color=\"#ff0000\">> Level 1 Quote</font><br>"
77 QTest::newRow("") << "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;\">> > > Sdf sdfqsdf fqs dfq sfsdfsqfqs</p>"
78 << "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;\"><font color=\"#0000ff\">> > > Sdf sdfqsdf fqs dfq sfsdfsqfqs</font></p>";