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 @@
+
+
+
+
+
+
+
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 @@
+
+
+
+
+
+
+
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 @@
+
+
+
+
+
+
+
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