Commit ea8b4163 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add more autotests

parent 0ccba34f
macro(add_composerng_autocorrect_unittest _source)
ecm_add_test(${_source}
NAME_PREFIX "messagecomposer-composerng-"
LINK_LIBRARIES Qt5::Test KF5::MessageComposer
LINK_LIBRARIES Qt5::Test KF5::MessageComposer KF5::XmlGui
)
endmacro()
......
......@@ -22,6 +22,9 @@
#include "../richtextcomposerng.h"
#include "../richtextcomposersignatures.h"
#include <KPIMTextEdit/RichTextComposerControler>
#include <KActionCollection>
#include <PimCommon/AutoCorrection>
#include <QTest>
......@@ -41,6 +44,8 @@ void RichTextComposerNgTest::shouldHaveDefaultValue()
MessageComposer::RichTextComposerNg richtextComposerNg;
QVERIFY(richtextComposerNg.composerSignature());
QVERIFY(!richtextComposerNg.autocorrection());
QVERIFY(richtextComposerNg.composerControler());
QVERIFY(richtextComposerNg.composerControler()->composerImages());
}
......@@ -131,19 +136,19 @@ void RichTextComposerNgTest::shouldAddSignature_data()
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddSeparator;
QTest::newRow("startandnewline") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("\n\nSignature\nfoo bla, bli\nbb")
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddNewLines;
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddNewLines;
QTest::newRow("startandnothing") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("Signaturefoo bla, bli\nbb")
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddNothing;
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddNothing;
QTest::newRow("endandaddseparator") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("foo bla, bli\nbb-- \nSignature")
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddSeparator;
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddSeparator;
QTest::newRow("endandnewline") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("foo bla, bli\nbb\nSignature")
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddNewLines;
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddNewLines;
QTest::newRow("endandnothing") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("foo bla, bli\nbbSignature")
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddNothing;
<< KIdentityManagement::Signature::End << KIdentityManagement::Signature::AddNothing;
//TODO test "Add Cursor"
}
......@@ -163,4 +168,44 @@ void RichTextComposerNgTest::shouldAddSignature()
QCOMPARE(richtextComposerNg.toPlainText(), expected);
}
void RichTextComposerNgTest::shouldAddSpecificSignature_data()
{
QTest::addColumn<QString>("original");
QTest::addColumn<QString>("expected");
QTest::addColumn<KIdentityManagement::Signature::Placement>("signatureplacement");
QTest::addColumn<KIdentityManagement::Signature::AddedTextFlag>("signatureaddtext");
QTest::addColumn<bool>("enablesignature");
QTest::addColumn<bool>("signaturehtml");
QTest::newRow("startandaddseparatordisablenonhtml") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("foo bla, bli\nbb")
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddSeparator
<< false << false;
QTest::newRow("startandaddseparatordisablehtml") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("foo bla, bli\nbb")
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddSeparator
<< false << true;
QTest::newRow("startandaddseparatorenablehtml") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("-- \nSignaturefoo bla, bli\nbb")
<< KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddSeparator
<< true << true;
}
void RichTextComposerNgTest::shouldAddSpecificSignature()
{
QFETCH(QString, original);
QFETCH(QString, expected);
QFETCH(KIdentityManagement::Signature::Placement, signatureplacement);
QFETCH(KIdentityManagement::Signature::AddedTextFlag, signatureaddtext);
QFETCH(bool, enablesignature);
QFETCH(bool, signaturehtml);
MessageComposer::RichTextComposerNg richtextComposerNg;
richtextComposerNg.createActions(new KActionCollection(this));
richtextComposerNg.setPlainText(original);
KIdentityManagement::Signature newSignature(QStringLiteral("Signature"));
newSignature.setEnabledSignature(enablesignature);
newSignature.setInlinedHtml(signaturehtml);
richtextComposerNg.insertSignature(newSignature, signatureplacement, signatureaddtext);
QCOMPARE(richtextComposerNg.toPlainText(), expected);
}
QTEST_MAIN(RichTextComposerNgTest)
......@@ -42,6 +42,10 @@ private Q_SLOTS:
void shouldAddSignature_data();
void shouldAddSignature();
void shouldAddSpecificSignature_data();
void shouldAddSpecificSignature();
};
#endif // RICHTEXTCOMPOSERNGTEST_H
Supports Markdown
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