SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / messageviewer / autotests / htmlquotecolorertest.cpp
blob9fc4146400cdc4bf0f456083ebc06163cba2bc70
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"
23 #include "qtest.h"
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"));
39 QString header;
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 &gt;text.</body></html>"
51 << "Some unquoted &gt;text.";
52 QTest::newRow("") << "<html><body>Some unquoted \n&gt;text.</body></html>"
53 << "Some unquoted \n&gt;text.";
54 QTest::newRow("") << "<html><body>Some unquoted <b>&gt;</b>text.</body></html>"
55 << "Some unquoted <b>&gt;</b>text.";
56 QTest::newRow("") << "<html><body>&gt;Some quoted text.</body></html>"
57 << "<font color=\"#ff0000\">&gt;Some quoted text.</font>";
58 QTest::newRow("") << "<html><body><b>&gt;Some quoted</b> text.</body></html>"
59 << "<b><font color=\"#ff0000\">&gt;Some quoted</font></b><font color=\"#ff0000\"> text.</font>";
60 QTest::newRow("") << "<html><body>&gt;Some quoted &gt;text.</body></html>"
61 << "<font color=\"#ff0000\">&gt;Some quoted &gt;text.</font>";
62 QTest::newRow("") << "<html><body>&gt;Some <b>quoted</b> text.</body></html>"
63 << "<font color=\"#ff0000\">&gt;Some </font><b><font color=\"#ff0000\">quoted</font></b><font color=\"#ff0000\"> text.</font>";
64 QTest::newRow("") << "<html><body>"
65 "&gt; &gt; &gt; Level 3 Quote<br>"
66 "No Quote<br>"
67 "&gt; &gt; Level 2 Quote<br>"
68 "&gt; Level 1 Quote<br>"
69 "No Quote<br>"
70 "</body></html>"
71 << "<font color=\"#0000ff\">&gt; &gt; &gt; Level 3 Quote</font><br>"
72 "No Quote<br>"
73 "<font color=\"#00ff00\">&gt; &gt; Level 2 Quote</font><br>"
74 "<font color=\"#ff0000\">&gt; Level 1 Quote</font><br>"
75 "No Quote<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;\">&gt; &gt; &gt; 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\">&gt; &gt; &gt; Sdf sdfqsdf fqs dfq sfsdfsqfqs</font></p>";