diff --git a/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.fancy.html b/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.fancy.html new file mode 100644 index 00000000..228501c2 --- /dev/null +++ b/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.fancy.html @@ -0,0 +1,62 @@ + + + + +
+
ssr/vpn超低价促销
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
From: admin <admin@ssrr.link>NBSP_ENTITY_PLACEHOLDER(resent from resent@example.org)NBSP_ENTITY_PLACEHOLDERNBSP_ENTITY_PLACEHOLDER(Universität KDE)
To: + + + spam1 <spam1@example.org>, spam2 <spam2@example.org>, spam3 <spam3@example.org>, spam4 <spam4@example.org> + spam1 <spam1@example.org>, spam2 <spam2@example.org>, spam3 <spam3@example.org>, spam4 <spam4@example.org>, spam5 <spam5@example.org>, spam6 <spam6@example.org> + +
CC: + foo@exampleorg +
BCC: + bcc@example.org +
Date: 21 May 2018 16:52:43
+
Spam Status:NBSP_ENTITY_PLACEHOLDERSpamassassin NBSP_ENTITY_PLACEHOLDER
+
+
+
+
+
+ +
+
+
+ + diff --git a/plugins/messageviewerheaderplugins/autotests/data/empty.fancy.html b/plugins/messageviewerheaderplugins/autotests/data/empty.fancy.html new file mode 100644 index 00000000..c24ea3e6 --- /dev/null +++ b/plugins/messageviewerheaderplugins/autotests/data/empty.fancy.html @@ -0,0 +1,35 @@ + + + + +
+
No Subject
+ + + + + +
+ + + + + + + + + + + + + + + + +
From:
To:
Date: Unknown
+
+
+
+
+ + diff --git a/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.fancy.html b/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.fancy.html new file mode 100644 index 00000000..c15b2b1b --- /dev/null +++ b/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.fancy.html @@ -0,0 +1,49 @@ + + + + +
+
No Subject
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
From: admin <admin@ssrr.link>, from2 <from2@example.org>, from3 <from3@example.org>, from4 <from4@example.org>, from5 <from5@example.org>, from6 <from6@example.org>NBSP_ENTITY_PLACEHOLDER(resent from resent-from@example.org, resent-from2@example.org, resent-from3@example.org, resent-from4@example.org, resent-to5@example.org, resent-to6@example.org)
To: resent-to@example.org, resent-to2@example.org, resent-to3@example.org, resent-to4@example.org, resent-to5@example.org, resent-to6@example.org (receiver was direct recipient1 <tospam1@example.org>, direct recipient2 <tospam2@example.org>, direct recipient3 <tospam3@example.org>, direct recipient4 <tospam4@example.org>direct recipient1 <tospam1@example.org>, direct recipient2 <tospam2@example.org>, direct recipient3 <tospam3@example.org>, direct recipient4 <tospam4@example.org>, direct recipient5 <tospam5@example.org>, direct recipient6 <tospam6@example.org>)
CC: + + + copy recipient1 <ccspam1@example.org>, copy recipient2 <ccspam2@example.org>, copy recipient3 <ccspam3@example.org>, copy recipient4 <ccspam4@example.org> + copy recipient1 <ccspam1@example.org>, copy recipient2 <ccspam2@example.org>, copy recipient3 <ccspam3@example.org>, copy recipient4 <ccspam4@example.org>, copy recipient5 <ccspam5@example.org>, copy recipient6 <ccspam6@example.org> + +
BCC: blind copy recipient1 <bccspam1@example.org>, blind copy recipient2 <bccspam2@example.org>, blind copy recipient3 <bccspam3@example.org>, blind copy recipient4 <bccspam4@example.org>, blind copy recipient5 <bccspam5@example.org>, blind copy recipient6 <bccspam6@example.org>
Date: 21 May 2018 16:52:43
+
+
+
+
+ + diff --git a/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.cpp b/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.cpp index fe5ea2c1..7280671c 100644 --- a/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.cpp +++ b/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.cpp @@ -1,55 +1,94 @@ /* Copyright (C) 2015-2018 Montel Laurent 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) any later version. 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "fancyheaderstyleplugintest.h" +#include "utils.h" #include "../fancyheaderstyleplugin/fancyheaderstyleplugin.h" #include "../fancyheaderstyleplugin/fancyheaderstyleinterface.h" + +#include + #include #include #include #include FancyHeaderStylePluginTest::FancyHeaderStylePluginTest(QObject *parent) : QObject(parent) { } FancyHeaderStylePluginTest::~FancyHeaderStylePluginTest() { } void FancyHeaderStylePluginTest::shouldHaveDefaultValue() { MessageViewer::FancyHeaderStylePlugin plugin; QVERIFY(plugin.headerStyle()); QVERIFY(plugin.headerStrategy()); } void FancyHeaderStylePluginTest::shouldCreateInterface() { MessageViewer::FancyHeaderStylePlugin plugin; KActionMenu *menu = new KActionMenu(this); QActionGroup *act = new QActionGroup(this); MessageViewer::HeaderStyleInterface *interface = plugin.createView(menu, act, new KActionCollection(this)); QVERIFY(interface); QVERIFY(!interface->action().isEmpty()); } +void FancyHeaderStylePluginTest::testFormatEmpty() +{ + MessageViewer::FancyHeaderStylePlugin plugin; + auto style = plugin.headerStyle(); + auto stategy = plugin.headerStrategy(); + style->setHeaderStrategy(stategy); + QCOMPARE(style->headerStrategy(), stategy); + auto aMsg = new KMime::Message(); + testHeaderFile(style->format(aMsg), QStringLiteral("empty.fancy")); +} + +void FancyHeaderStylePluginTest::testFormat_data() +{ + QTest::addColumn("mailbox"); + + QDir dir(QStringLiteral(HEADER_DATA_DIR)); + const auto l = dir.entryList(QStringList(QStringLiteral("*.mbox")), QDir::Files | QDir::Readable | QDir::NoSymLinks); + foreach (const QString &file, l) { + QTest::newRow(file.toLatin1().constData()) << file; + } +} + +void FancyHeaderStylePluginTest::testFormat() +{ + QFETCH(QString, mailbox); + + MessageViewer::FancyHeaderStylePlugin plugin; + auto style = plugin.headerStyle(); + auto stategy = plugin.headerStrategy(); + style->setHeaderStrategy(stategy); + QCOMPARE(style->headerStrategy(), stategy); + auto aMsg = readAndParseMail(mailbox); + testHeaderFile(style->format(aMsg.data()), mailbox+QStringLiteral(".fancy")); +} + QTEST_MAIN(FancyHeaderStylePluginTest) diff --git a/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.h b/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.h index e31b7544..d37f45f4 100644 --- a/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.h +++ b/plugins/messageviewerheaderplugins/autotests/fancyheaderstyleplugintest.h @@ -1,37 +1,40 @@ /* Copyright (C) 2015-2018 Montel Laurent 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) any later version. 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FANCYHEADERSTYLEPLUGINTEST_H #define FANCYHEADERSTYLEPLUGINTEST_H #include class FancyHeaderStylePluginTest : public QObject { Q_OBJECT public: explicit FancyHeaderStylePluginTest(QObject *parent = nullptr); ~FancyHeaderStylePluginTest(); private Q_SLOTS: void shouldHaveDefaultValue(); void shouldCreateInterface(); + void testFormatEmpty(); + void testFormat_data(); + void testFormat(); }; #endif // FANCYHEADERSTYLEPLUGINTEST_H