Commit a2d46a00 authored by Laurent Montel's avatar Laurent Montel 😁

Add autotest

parent 3b0079c5
/*
Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
Copyright (c) 2017 Laurent Montel <montel@kde.org>
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
......@@ -19,13 +20,21 @@
#include "utiltest.h"
#include <QTextDocument>
#include <qtest.h>
#include <QStandardPaths>
#include <MessageComposer/Util>
using namespace MessageComposer;
QTEST_APPLESS_MAIN(UtilTest)
UtilTest::UtilTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void UtilTest::testSelectCharset()
{
// Pick a charset that actually works.
......@@ -64,3 +73,27 @@ void UtilTest::testSelectCharset()
}
void UtilTest::shouldTestHasMissingAttachment_data()
{
QTest::addColumn<QStringList>("attachmentKeywords");
QTest::addColumn<QString>("subject");
QTest::addColumn<QString>("body");
QTest::addColumn<bool>("hasMissingAttachment");
QStringList lstDefaultAttachement{QStringLiteral("attachment"), QStringLiteral("att:")};
QTest::newRow("emptybody") << lstDefaultAttachement << QStringLiteral("foo") << QString() << false;
QTest::newRow("emptybodyandsubject") << lstDefaultAttachement << QString() << QString() << false;
}
void UtilTest::shouldTestHasMissingAttachment()
{
QFETCH(QStringList, attachmentKeywords);
QFETCH(QString, subject);
QFETCH(QString, body);
QFETCH(bool, hasMissingAttachment);
QTextDocument doc(body);
QCOMPARE(Util::hasMissingAttachments(attachmentKeywords, &doc, subject), hasMissingAttachment);
}
/*
Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
Copyright (c) 2017 Laurent Montel <montel@kde.org>
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
......@@ -25,8 +26,12 @@
class UtilTest : public QObject
{
Q_OBJECT
public:
explicit UtilTest(QObject *parent = nullptr);
private Q_SLOTS:
void testSelectCharset();
void shouldTestHasMissingAttachment();
void shouldTestHasMissingAttachment_data();
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment