From 2fdddd2f795da4645dc9a48fee4865324143a21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Mon, 18 Jul 2016 15:35:07 +0200 Subject: first tests with mimetreeparser interface --- .../domain/mimetreeparser/tests/CMakeLists.txt | 10 +++++ .../mimetreeparser/tests/data/alternative.mbox | 34 ++++++++++++++++ .../domain/mimetreeparser/tests/data/html.mbox | 31 ++++++++++++++ .../domain/mimetreeparser/tests/data/htmlonly.mbox | 21 ++++++++++ .../tests/data/htmlonlyexternal.mbox | 21 ++++++++++ .../mimetreeparser/tests/data/plaintext.mbox | 17 ++++++++ .../domain/mimetreeparser/tests/interfacetest.cpp | 47 ++++++++++++++++++++++ 7 files changed, 181 insertions(+) create mode 100644 framework/domain/mimetreeparser/tests/CMakeLists.txt create mode 100644 framework/domain/mimetreeparser/tests/data/alternative.mbox create mode 100644 framework/domain/mimetreeparser/tests/data/html.mbox create mode 100644 framework/domain/mimetreeparser/tests/data/htmlonly.mbox create mode 100644 framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox create mode 100644 framework/domain/mimetreeparser/tests/data/plaintext.mbox create mode 100644 framework/domain/mimetreeparser/tests/interfacetest.cpp (limited to 'framework/domain/mimetreeparser/tests') 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 @@ +add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ) + +add_executable(mimetreeparsertest interfacetest.cpp) +add_test(mimetreeparsertest mimetreeparsertest) +qt5_use_modules(mimetreeparsertest Core Test) +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 @@ +Return-Path: +Date: Wed, 8 Jun 2016 20:34:44 -0700 +From: Konqi +To: konqi@kde.org +Subject: A random subject with alternative contenttype +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_12345678_12345678" + + +------=_Part_12345678_12345678 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + +If you can see this text it means that your email client couldn't display o= +ur newsletter properly. +Please visit this link to view the newsletter on our website: http://www.go= +g.com/newsletter/ + +=2D GOG.com Team + + +------=_Part_12345678_12345678 +Content-Transfer-Encoding: 7Bit +Content-Type: text/html; charset="windows-1252" + + + +

Some HTML text

+ + +------=_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 @@ +From foo@example.com Thu, 26 May 2011 01:16:54 +0100 +From: Thomas McGuire +Subject: HTML test +Date: Thu, 26 May 2011 01:16:54 +0100 +Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> +X-KMail-Transport: GMX +X-KMail-Fcc: 28 +X-KMail-Drafts: 7 +X-KMail-Templates: 9 +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) +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="nextPart8606278.tpV19BTJKu" +Content-Transfer-Encoding: 7Bit + + +--nextPart8606278.tpV19BTJKu +Content-Transfer-Encoding: 7Bit +Content-Type: text/plain; charset="windows-1252" + +Some HTML text +--nextPart8606278.tpV19BTJKu +Content-Transfer-Encoding: 7Bit +Content-Type: text/html; charset="windows-1252" + + + +

Some HTML text

+--nextPart8606278.tpV19BTJKu-- + 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 @@ +From foo@example.com Thu, 26 May 2011 01:16:54 +0100 +From: Thomas McGuire +Subject: HTML test +Date: Thu, 26 May 2011 01:16:54 +0100 +Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> +X-KMail-Transport: GMX +X-KMail-Fcc: 28 +X-KMail-Drafts: 7 +X-KMail-Templates: 9 +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) +MIME-Version: 1.0 +Content-Type: text/html +Content-Transfer-Encoding: 7Bit + + + + + +SOME HTML text. + + 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 @@ +From foo@example.com Thu, 26 May 2011 01:16:54 +0100 +From: Thomas McGuire +Subject: HTML test +Date: Thu, 26 May 2011 01:16:54 +0100 +Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> +X-KMail-Transport: GMX +X-KMail-Fcc: 28 +X-KMail-Drafts: 7 +X-KMail-Templates: 9 +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) +MIME-Version: 1.0 +Content-Type: text/html +Content-Transfer-Encoding: 7Bit + + + + + +SOME HTML text. + + 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 @@ +Return-Path: +Date: Wed, 8 Jun 2016 20:34:44 -0700 +From: Konqi +To: konqi@kde.org +Subject: A random subject with alternative contenttype +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + +If you can see this text it means that your email client couldn't display o= +ur newsletter properly. +Please visit this link to view the newsletter on our website: http://www.go= +g.com/newsletter/ + +=2D GOG.com Team + + 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 @@ +/* + Copyright (c) 2016 Sandro Knauß + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#include "interface.h" + +#include + +QByteArray readMailFromFile(const QString &mailFile) +{ + QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + mailFile); + file.open(QIODevice::ReadOnly); + Q_ASSERT(file.isOpen()); + return file.readAll(); +} + + +class InterfaceTest : public QObject +{ + Q_OBJECT +private slots: + + void testTextMail() + { + Parser parser(readMailFromFile("plaintext.mbox")); + auto contentPart = parser.collectContentPart(); + //QVERIFY((bool)contentPart); + } +}; + +QTEST_GUILESS_MAIN(InterfaceTest) +#include "interfacetest.moc" \ No newline at end of file -- cgit v1.2.3