diff --git a/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.enterprise.html b/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.enterprise.html
new file mode 100644
index 00000000..ba444830
--- /dev/null
+++ b/plugins/messageviewerheaderplugins/autotests/data/allheaders.mbox.enterprise.html
@@ -0,0 +1,72 @@
+
+
+
+
+ NBSP_ENTITY_PLACEHOLDER
+ NBSP_ENTITY_PLACEHOLDER
+
+ 21 May 2018 16:52:43
+
+
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+
+
+ |
+ |
+
+
+ |
+
+
+ |
+ |
+
+
+ |
+
+
+
+ |
+ |
+
+
+
+
diff --git a/plugins/messageviewerheaderplugins/autotests/data/empty.enterprise.html b/plugins/messageviewerheaderplugins/autotests/data/empty.enterprise.html
new file mode 100644
index 00000000..2b28f6e1
--- /dev/null
+++ b/plugins/messageviewerheaderplugins/autotests/data/empty.enterprise.html
@@ -0,0 +1,58 @@
+
+
+
+
+ NBSP_ENTITY_PLACEHOLDER
+ NBSP_ENTITY_PLACEHOLDER
+
+ Unknown
+
+
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+
+
+
+ |
+ No Subject |
+
+
+ From: |
+ |
+
+
+ To: |
+ |
+
+
+ |
+ |
+
+
+ |
+
+
+ |
+ |
+
+
+ |
+
+
+
+ |
+ |
+
+
+
+
diff --git a/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.enterprise.html b/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.enterprise.html
new file mode 100644
index 00000000..f7791116
--- /dev/null
+++ b/plugins/messageviewerheaderplugins/autotests/data/headertest.mbox.enterprise.html
@@ -0,0 +1,66 @@
+
+
+
+
+ NBSP_ENTITY_PLACEHOLDER
+ NBSP_ENTITY_PLACEHOLDER
+
+ 21 May 2018 16:52:43
+
+
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+
+
+
+ |
+ 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> |
+
+
+ To: |
+ 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 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> |
+
+
+ |
+ |
+
+
+ |
+
+
+ |
+ |
+
+
+ |
+
+
+
+ |
+ |
+
+
+
+
diff --git a/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.cpp b/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.cpp
index ad7b0a28..1a4783df 100644
--- a/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.cpp
+++ b/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.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 "enterpriseheaderstyleplugintest.h"
+#include "utils.h"
#include "../enterpriseheaderstyleplugin/enterpriseheaderstyleplugin.h"
#include "../enterpriseheaderstyleplugin/enterpriseheaderstyleinterface.h"
+
+#include
+
#include
#include
#include
#include
EnterpriseHeaderStylePluginTest::EnterpriseHeaderStylePluginTest(QObject *parent)
: QObject(parent)
{
}
EnterpriseHeaderStylePluginTest::~EnterpriseHeaderStylePluginTest()
{
}
void EnterpriseHeaderStylePluginTest::shouldHaveDefaultValue()
{
MessageViewer::EnterpriseHeaderStylePlugin plugin;
QVERIFY(plugin.headerStyle());
QVERIFY(plugin.headerStrategy());
}
void EnterpriseHeaderStylePluginTest::shouldCreateInterface()
{
MessageViewer::EnterpriseHeaderStylePlugin 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 EnterpriseHeaderStylePluginTest::testFormatEmpty()
+{
+ MessageViewer::EnterpriseHeaderStylePlugin 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.enterprise"));
+}
+
+void EnterpriseHeaderStylePluginTest::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 EnterpriseHeaderStylePluginTest::testFormat()
+{
+ QFETCH(QString, mailbox);
+
+ MessageViewer::EnterpriseHeaderStylePlugin 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(".enterprise"));
+}
+
QTEST_MAIN(EnterpriseHeaderStylePluginTest)
diff --git a/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.h b/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.h
index c19e9428..6dafea4d 100644
--- a/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.h
+++ b/plugins/messageviewerheaderplugins/autotests/enterpriseheaderstyleplugintest.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 ENTERPRISEHEADERSTYLEPLUGINTEST_H
#define ENTERPRISEHEADERSTYLEPLUGINTEST_H
#include
class EnterpriseHeaderStylePluginTest : public QObject
{
Q_OBJECT
public:
explicit EnterpriseHeaderStylePluginTest(QObject *parent = nullptr);
~EnterpriseHeaderStylePluginTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCreateInterface();
+ void testFormatEmpty();
+ void testFormat_data();
+ void testFormat();
};
#endif // ENTERPRISEHEADERSTYLEPLUGINTEST_H