diff options
Diffstat (limited to 'framework/domain/mimetreeparser/tests')
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 @@ | |||
1 | add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) | ||
2 | include_directories( | ||
3 | ${CMAKE_CURRENT_BINARY_DIR} | ||
4 | ${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
5 | ) | ||
6 | |||
7 | add_executable(mimetreeparsertest interfacetest.cpp) | ||
8 | add_test(mimetreeparsertest mimetreeparsertest) | ||
9 | qt5_use_modules(mimetreeparsertest Core Test) | ||
10 | target_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 @@ | |||
1 | Return-Path: <konqi@example.org> | ||
2 | Date: Wed, 8 Jun 2016 20:34:44 -0700 | ||
3 | From: Konqi <konqi@example.org> | ||
4 | To: konqi@kde.org | ||
5 | Subject: A random subject with alternative contenttype | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: multipart/alternative; | ||
8 | boundary="----=_Part_12345678_12345678" | ||
9 | |||
10 | |||
11 | ------=_Part_12345678_12345678 | ||
12 | Content-Type: text/plain; charset=utf-8 | ||
13 | Content-Transfer-Encoding: quoted-printable | ||
14 | |||
15 | If you can see this text it means that your email client couldn't display o= | ||
16 | ur newsletter properly. | ||
17 | Please visit this link to view the newsletter on our website: http://www.go= | ||
18 | g.com/newsletter/ | ||
19 | |||
20 | =2D GOG.com Team | ||
21 | |||
22 | |||
23 | ------=_Part_12345678_12345678 | ||
24 | Content-Transfer-Encoding: 7Bit | ||
25 | Content-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"> | ||
29 | p, 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 @@ | |||
1 | From foo@example.com Thu, 26 May 2011 01:16:54 +0100 | ||
2 | From: Thomas McGuire <foo@example.com> | ||
3 | Subject: HTML test | ||
4 | Date: Thu, 26 May 2011 01:16:54 +0100 | ||
5 | Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> | ||
6 | X-KMail-Transport: GMX | ||
7 | X-KMail-Fcc: 28 | ||
8 | X-KMail-Drafts: 7 | ||
9 | X-KMail-Templates: 9 | ||
10 | User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) | ||
11 | MIME-Version: 1.0 | ||
12 | Content-Type: multipart/alternative; boundary="nextPart8606278.tpV19BTJKu" | ||
13 | Content-Transfer-Encoding: 7Bit | ||
14 | |||
15 | |||
16 | --nextPart8606278.tpV19BTJKu | ||
17 | Content-Transfer-Encoding: 7Bit | ||
18 | Content-Type: text/plain; charset="windows-1252" | ||
19 | |||
20 | Some HTML text | ||
21 | --nextPart8606278.tpV19BTJKu | ||
22 | Content-Transfer-Encoding: 7Bit | ||
23 | Content-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"> | ||
27 | p, 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 @@ | |||
1 | From foo@example.com Thu, 26 May 2011 01:16:54 +0100 | ||
2 | From: Thomas McGuire <foo@example.com> | ||
3 | Subject: HTML test | ||
4 | Date: Thu, 26 May 2011 01:16:54 +0100 | ||
5 | Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> | ||
6 | X-KMail-Transport: GMX | ||
7 | X-KMail-Fcc: 28 | ||
8 | X-KMail-Drafts: 7 | ||
9 | X-KMail-Templates: 9 | ||
10 | User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) | ||
11 | MIME-Version: 1.0 | ||
12 | Content-Type: text/html | ||
13 | Content-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 @@ | |||
1 | From foo@example.com Thu, 26 May 2011 01:16:54 +0100 | ||
2 | From: Thomas McGuire <foo@example.com> | ||
3 | Subject: HTML test | ||
4 | Date: Thu, 26 May 2011 01:16:54 +0100 | ||
5 | Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> | ||
6 | X-KMail-Transport: GMX | ||
7 | X-KMail-Fcc: 28 | ||
8 | X-KMail-Drafts: 7 | ||
9 | X-KMail-Templates: 9 | ||
10 | User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) | ||
11 | MIME-Version: 1.0 | ||
12 | Content-Type: text/html | ||
13 | Content-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 @@ | |||
1 | Return-Path: <konqi@example.org> | ||
2 | Date: Wed, 8 Jun 2016 20:34:44 -0700 | ||
3 | From: Konqi <konqi@example.org> | ||
4 | To: konqi@kde.org | ||
5 | Subject: A random subject with alternative contenttype | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=utf-8 | ||
8 | Content-Transfer-Encoding: quoted-printable | ||
9 | |||
10 | If you can see this text it means that your email client couldn't display o= | ||
11 | ur newsletter properly. | ||
12 | Please visit this link to view the newsletter on our website: http://www.go= | ||
13 | g.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 | |||
24 | QByteArray 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 | |||
33 | class InterfaceTest : public QObject | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | private slots: | ||
37 | |||
38 | void testTextMail() | ||
39 | { | ||
40 | Parser parser(readMailFromFile("plaintext.mbox")); | ||
41 | auto contentPart = parser.collectContentPart(); | ||
42 | //QVERIFY((bool)contentPart); | ||
43 | } | ||
44 | }; | ||
45 | |||
46 | QTEST_GUILESS_MAIN(InterfaceTest) | ||
47 | #include "interfacetest.moc" \ No newline at end of file | ||