summaryrefslogtreecommitdiffstats
path: root/framework/domain/mimetreeparser/tests
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/mimetreeparser/tests')
-rw-r--r--framework/domain/mimetreeparser/tests/CMakeLists.txt10
-rw-r--r--framework/domain/mimetreeparser/tests/data/alternative.mbox34
-rw-r--r--framework/domain/mimetreeparser/tests/data/html.mbox31
-rw-r--r--framework/domain/mimetreeparser/tests/data/htmlonly.mbox21
-rw-r--r--framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox21
-rw-r--r--framework/domain/mimetreeparser/tests/data/plaintext.mbox17
-rw-r--r--framework/domain/mimetreeparser/tests/interfacetest.cpp47
7 files changed, 181 insertions, 0 deletions
diff --git a/framework/domain/mimetreeparser/tests/CMakeLists.txt b/framework/domain/mimetreeparser/tests/CMakeLists.txt
new file mode 100644
index 00000000..d3549215
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/CMakeLists.txt
@@ -0,0 +1,10 @@
1add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
2include_directories(
3 ${CMAKE_CURRENT_BINARY_DIR}
4 ${CMAKE_CURRENT_SOURCE_DIR}/..
5 )
6
7add_executable(mimetreeparsertest interfacetest.cpp)
8add_test(mimetreeparsertest mimetreeparsertest)
9qt5_use_modules(mimetreeparsertest Core Test)
10target_link_libraries(mimetreeparsertest mimetreeparser) \ No newline at end of file
diff --git a/framework/domain/mimetreeparser/tests/data/alternative.mbox b/framework/domain/mimetreeparser/tests/data/alternative.mbox
new file mode 100644
index 00000000..a2c58591
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/data/alternative.mbox
@@ -0,0 +1,34 @@
1Return-Path: <konqi@example.org>
2Date: Wed, 8 Jun 2016 20:34:44 -0700
3From: Konqi <konqi@example.org>
4To: konqi@kde.org
5Subject: A random subject with alternative contenttype
6MIME-Version: 1.0
7Content-Type: multipart/alternative;
8 boundary="----=_Part_12345678_12345678"
9
10
11------=_Part_12345678_12345678
12Content-Type: text/plain; charset=utf-8
13Content-Transfer-Encoding: quoted-printable
14
15If you can see this text it means that your email client couldn't display o=
16ur newsletter properly.
17Please visit this link to view the newsletter on our website: http://www.go=
18g.com/newsletter/
19
20=2D GOG.com Team
21
22
23------=_Part_12345678_12345678
24Content-Transfer-Encoding: 7Bit
25Content-Type: text/html; charset="windows-1252"
26
27<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
28<html><head><meta name="qrichtext" content="1" /><style type="text/css">
29p, li { white-space: pre-wrap; }
30</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
31<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;">Some <span style=" font-weight:600;">HTML</span> text</p></body></html>
32
33
34------=_Part_12345678_12345678--
diff --git a/framework/domain/mimetreeparser/tests/data/html.mbox b/framework/domain/mimetreeparser/tests/data/html.mbox
new file mode 100644
index 00000000..eebd4283
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/data/html.mbox
@@ -0,0 +1,31 @@
1From foo@example.com Thu, 26 May 2011 01:16:54 +0100
2From: Thomas McGuire <foo@example.com>
3Subject: HTML test
4Date: Thu, 26 May 2011 01:16:54 +0100
5Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost>
6X-KMail-Transport: GMX
7X-KMail-Fcc: 28
8X-KMail-Drafts: 7
9X-KMail-Templates: 9
10User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19)
11MIME-Version: 1.0
12Content-Type: multipart/alternative; boundary="nextPart8606278.tpV19BTJKu"
13Content-Transfer-Encoding: 7Bit
14
15
16--nextPart8606278.tpV19BTJKu
17Content-Transfer-Encoding: 7Bit
18Content-Type: text/plain; charset="windows-1252"
19
20Some HTML text
21--nextPart8606278.tpV19BTJKu
22Content-Transfer-Encoding: 7Bit
23Content-Type: text/html; charset="windows-1252"
24
25<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
26<html><head><meta name="qrichtext" content="1" /><style type="text/css">
27p, li { white-space: pre-wrap; }
28</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
29<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;">Some <span style=" font-weight:600;">HTML</span> text</p></body></html>
30--nextPart8606278.tpV19BTJKu--
31
diff --git a/framework/domain/mimetreeparser/tests/data/htmlonly.mbox b/framework/domain/mimetreeparser/tests/data/htmlonly.mbox
new file mode 100644
index 00000000..e45b1c4d
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/data/htmlonly.mbox
@@ -0,0 +1,21 @@
1From foo@example.com Thu, 26 May 2011 01:16:54 +0100
2From: Thomas McGuire <foo@example.com>
3Subject: HTML test
4Date: Thu, 26 May 2011 01:16:54 +0100
5Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost>
6X-KMail-Transport: GMX
7X-KMail-Fcc: 28
8X-KMail-Drafts: 7
9X-KMail-Templates: 9
10User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19)
11MIME-Version: 1.0
12Content-Type: text/html
13Content-Transfer-Encoding: 7Bit
14
15<html>
16<head>
17</head>
18<body>
19<b>SOME</b> HTML text.
20</body>
21</html>
diff --git a/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox b/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox
new file mode 100644
index 00000000..4eb3e2c3
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox
@@ -0,0 +1,21 @@
1From foo@example.com Thu, 26 May 2011 01:16:54 +0100
2From: Thomas McGuire <foo@example.com>
3Subject: HTML test
4Date: Thu, 26 May 2011 01:16:54 +0100
5Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost>
6X-KMail-Transport: GMX
7X-KMail-Fcc: 28
8X-KMail-Drafts: 7
9X-KMail-Templates: 9
10User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19)
11MIME-Version: 1.0
12Content-Type: text/html
13Content-Transfer-Encoding: 7Bit
14
15<html>
16<head>
17</head>
18<body>
19<b>SOME</b> HTML text. <img src="http://example.org/test.img" >
20</body>
21</html>
diff --git a/framework/domain/mimetreeparser/tests/data/plaintext.mbox b/framework/domain/mimetreeparser/tests/data/plaintext.mbox
new file mode 100644
index 00000000..c2e00a35
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/data/plaintext.mbox
@@ -0,0 +1,17 @@
1Return-Path: <konqi@example.org>
2Date: Wed, 8 Jun 2016 20:34:44 -0700
3From: Konqi <konqi@example.org>
4To: konqi@kde.org
5Subject: A random subject with alternative contenttype
6MIME-Version: 1.0
7Content-Type: text/plain; charset=utf-8
8Content-Transfer-Encoding: quoted-printable
9
10If you can see this text it means that your email client couldn't display o=
11ur newsletter properly.
12Please visit this link to view the newsletter on our website: http://www.go=
13g.com/newsletter/
14
15=2D GOG.com Team
16
17
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp
new file mode 100644
index 00000000..1e8c5302
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp
@@ -0,0 +1,47 @@
1/*
2 Copyright (c) 2016 Sandro Knauß <knauss@kolabsystems.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "interface.h"
21
22#include <QTest>
23
24QByteArray readMailFromFile(const QString &mailFile)
25{
26 QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + mailFile);
27 file.open(QIODevice::ReadOnly);
28 Q_ASSERT(file.isOpen());
29 return file.readAll();
30}
31
32
33class InterfaceTest : public QObject
34{
35 Q_OBJECT
36private slots:
37
38 void testTextMail()
39 {
40 Parser parser(readMailFromFile("plaintext.mbox"));
41 auto contentPart = parser.collectContentPart();
42 //QVERIFY((bool)contentPart);
43 }
44};
45
46QTEST_GUILESS_MAIN(InterfaceTest)
47#include "interfacetest.moc" \ No newline at end of file