Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34134251
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
6 KB
Subscribers
None
View Options
diff --git a/src/core/autotests/attachmentmodeltest.cpp b/src/core/autotests/attachmentmodeltest.cpp
index 2a6f352..0bf55e6 100644
--- a/src/core/autotests/attachmentmodeltest.cpp
+++ b/src/core/autotests/attachmentmodeltest.cpp
@@ -1,71 +1,71 @@
// SPDX-FileCopyrightText: 2023 g10 Code GmbH
// SPDX-FileContributor: Carl Schwan <carl.schwan@gnupg.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include <QTest>
#include "attachmentmodel.h"
#include "messageparser.h"
#include <QAbstractItemModelTester>
#include <QTemporaryFile>
KMime::Message::Ptr readMailFromFile(const QString &mailFile)
{
QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + mailFile);
file.open(QIODevice::ReadOnly);
Q_ASSERT(file.isOpen());
auto mailData = KMime::CRLFtoLF(file.readAll());
KMime::Message::Ptr message(new KMime::Message);
message->setContent(mailData);
message->parse();
return message;
}
class AttachmentModelTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void openMailWithOneAttachementTest()
{
MessageParser messageParser;
messageParser.setMessage(readMailFromFile(QLatin1String("attachment.mbox")));
auto attachmentModel = messageParser.attachments();
- auto tester = new QAbstractItemModelTester(attachmentModel);
+ new QAbstractItemModelTester(attachmentModel);
QCOMPARE(attachmentModel->rowCount(), 1);
QCOMPARE(attachmentModel->data(attachmentModel->index(0, 0), AttachmentModel::TypeRole).toString(), QStringLiteral("image/jpeg"));
QCOMPARE(attachmentModel->data(attachmentModel->index(0, 0), AttachmentModel::NameRole).toString(), QStringLiteral("aqnaozisxya.jpeg"));
QCOMPARE(attachmentModel->data(attachmentModel->index(0, 0), AttachmentModel::SizeRole).toString(), QStringLiteral("100.22 KB"));
QCOMPARE(attachmentModel->data(attachmentModel->index(0, 0), AttachmentModel::IsEncryptedRole).toBool(), false);
QCOMPARE(attachmentModel->data(attachmentModel->index(0, 0), AttachmentModel::IsSignedRole).toBool(), false);
QCOMPARE(attachmentModel->data(attachmentModel->index(0, AttachmentModel::IsEncryptedColumn), Qt::CheckStateRole).value<Qt::CheckState>(),
Qt::Unchecked);
QCOMPARE(attachmentModel->data(attachmentModel->index(0, AttachmentModel::IsSignedColumn), Qt::CheckStateRole).value<Qt::CheckState>(), Qt::Unchecked);
QCOMPARE(attachmentModel->data(attachmentModel->index(0, AttachmentModel::SizeColumn), Qt::DisplayRole).toString(), QStringLiteral("100.22 KB"));
}
void saveTest()
{
MessageParser messageParser;
messageParser.setMessage(readMailFromFile(QLatin1String("attachment.mbox")));
auto attachmentModel = messageParser.attachments();
QTemporaryFile file;
QVERIFY(file.open());
const auto fileName = attachmentModel->saveAttachmentToPath(0, file.fileName());
QCOMPARE(file.readAll(), "");
QFile file2(fileName);
QVERIFY(file2.open(QIODevice::ReadOnly | QIODevice::Text));
QVERIFY(!file2.readAll().isEmpty());
}
};
QTEST_MAIN(AttachmentModelTest)
#include "attachmentmodeltest.moc"
diff --git a/src/core/autotests/partmodeltest.cpp b/src/core/autotests/partmodeltest.cpp
index f19fb3e..a3f8b15 100644
--- a/src/core/autotests/partmodeltest.cpp
+++ b/src/core/autotests/partmodeltest.cpp
@@ -1,77 +1,77 @@
// SPDX-FileCopyrightText: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include <KMime/Message>
#include <QAbstractItemModelTester>
#include <QDebug>
#include <QTest>
#include <QTextDocument>
#include "messageparser.h"
#include "partmodel.h"
KMime::Message::Ptr readMailFromFile(const QString &mailFile)
{
QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + mailFile);
file.open(QIODevice::ReadOnly);
Q_ASSERT(file.isOpen());
auto mailData = KMime::CRLFtoLF(file.readAll());
KMime::Message::Ptr message(new KMime::Message);
message->setContent(mailData);
message->parse();
return message;
}
class PartModelTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void testTrim()
{
auto result = PartModel::trim(QLatin1String("<p>This is some funky test.</p>\n<p>-- <br>\nChristian Mollekopf<br>\nSenior Software"));
QCOMPARE(result.second, true);
QCOMPARE(result.first, QLatin1String("<p>This is some funky test.</p>\n"));
}
void testTrimFromPlain()
{
// Qt::convertFromPlainText inserts non-breaking spaces
auto result = PartModel::trim(Qt::convertFromPlainText(QLatin1String("This is some funky text.\n\n-- \nChristian Mollekopf\nSenior Software")));
QCOMPARE(result.second, true);
//\u00A0 is a on-breaking space
const auto expected = QStringLiteral("<p>This is some funky text.</p>\n").replace(QLatin1Char(' '), QChar(0x00a0));
QCOMPARE(result.first, expected);
}
void testModel()
{
MessageParser messageParser;
messageParser.setMessage(readMailFromFile(QLatin1String("html.mbox")));
QFont font{};
font.setFamily(QStringLiteral("Noto Sans"));
qGuiApp->setFont(font);
auto partModel = messageParser.parts();
- auto tester = new QAbstractItemModelTester(partModel);
+ new QAbstractItemModelTester(partModel);
QCOMPARE(partModel->rowCount(), 1);
QCOMPARE(partModel->data(partModel->index(0, 0), PartModel::TypeRole).value<PartModel::Types>(), PartModel::Types::Plain);
QCOMPARE(partModel->data(partModel->index(0, 0), PartModel::IsEmbeddedRole).toBool(), false);
QCOMPARE(partModel->data(partModel->index(0, 0), PartModel::IsErrorRole).toBool(), false);
QCOMPARE(
partModel->data(partModel->index(0, 0), PartModel::ContentRole).toString(),
QStringLiteral("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
"\"http://www.w3.org/TR/html4/loose.dtd\">\n<html><head><title></title><style>\nbody {\n overflow:hidden;\n font-family: \"Noto "
"Sans\" ! important;\n color: #31363b ! important;\n background-color: #fcfcfc ! important\n}\nblockquote { \n border-left: 2px "
"solid #bdc3c7 ! important;\n}\n</style></head>\n<body>\n<html><body><p><span>HTML</span> text</p></body></html></body></html>"));
}
};
QTEST_MAIN(PartModelTest)
#include "partmodeltest.moc"
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Dec 8, 6:47 AM (10 h, 38 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
71/66/1f90a06feec975aeffa80f020e7d
Attached To
rMTP MIME Tree Parser
Event Timeline
Log In to Comment