summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-08-31 11:14:27 (GMT)
committerMontel Laurent <montel@kde.org>2016-08-31 11:14:27 (GMT)
commitea8b4163cd62787964316d33c67e804d87d0d986 (patch)
treea1abcdff8068592dd80a4d02336babeacbf120ef
parent0ccba34fa950dbbb453a34f02f6dc989856ff052 (diff)
Add more autotests
-rw-r--r--messagecomposer/src/composer-ng/autotests/CMakeLists.txt2
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp55
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h4
3 files changed, 55 insertions, 6 deletions
diff --git a/messagecomposer/src/composer-ng/autotests/CMakeLists.txt b/messagecomposer/src/composer-ng/autotests/CMakeLists.txt
index 4d15fe1..97ecb5f 100644
--- a/messagecomposer/src/composer-ng/autotests/CMakeLists.txt
+++ b/messagecomposer/src/composer-ng/autotests/CMakeLists.txt
@@ -1,7 +1,7 @@
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()
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
index e267c5c..545acf8 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
@@ -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)
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
index e2c6994..05af94d 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
@@ -42,6 +42,10 @@ private Q_SLOTS:
void shouldAddSignature_data();
void shouldAddSignature();
+
+ void shouldAddSpecificSignature_data();
+ void shouldAddSpecificSignature();
+
};
#endif // RICHTEXTCOMPOSERNGTEST_H