summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-08-31 20:32:10 (GMT)
committerMontel Laurent <montel@kde.org>2016-08-31 20:32:10 (GMT)
commit406f488a9cef1e33c604e4f78875b7db6fa038d7 (patch)
tree232f1e4016581e031f1e986624e02beb658d7f1d
parentea8b4163cd62787964316d33c67e804d87d0d986 (diff)
improve autotests (fix some bugs about signature)
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp26
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
index 545acf8..39313df 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
@@ -205,7 +205,33 @@ void RichTextComposerNgTest::shouldAddSpecificSignature()
newSignature.setEnabledSignature(enablesignature);
newSignature.setInlinedHtml(signaturehtml);
richtextComposerNg.insertSignature(newSignature, signatureplacement, signatureaddtext);
+ //qDebug() << " clean html "<<richtextComposerNg.toCleanHtml();
QCOMPARE(richtextComposerNg.toPlainText(), expected);
}
+void RichTextComposerNgTest::shouldReplaceSignature()
+{
+ MessageComposer::RichTextComposerNg richtextComposerNg;
+ richtextComposerNg.createActions(new KActionCollection(this));
+ const QString original(QStringLiteral("foo bla, bli\nbb"));
+ richtextComposerNg.setPlainText(original);
+
+ KIdentityManagement::Signature newSignature(QStringLiteral("Signature"));
+ newSignature.setEnabledSignature(true);
+ newSignature.setInlinedHtml(false);
+ QString expected(QStringLiteral("foo bla, bli\nbb-- \nSignature"));
+ richtextComposerNg.insertSignature(newSignature, KIdentityManagement::Signature::End, KIdentityManagement::Signature::AddSeparator);
+ QCOMPARE(richtextComposerNg.toPlainText(), expected);
+
+ KIdentityManagement::Signature emptySignature;
+
+ bool replaceSignature = richtextComposerNg.composerSignature()->replaceSignature(newSignature, emptySignature);
+ QVERIFY(replaceSignature);
+ QCOMPARE(richtextComposerNg.toPlainText(), original);
+
+ replaceSignature = richtextComposerNg.composerSignature()->replaceSignature(emptySignature, newSignature);
+ //When signature is empty we can't replace it.
+ QVERIFY(!replaceSignature);
+}
+
QTEST_MAIN(RichTextComposerNgTest)
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
index 05af94d..0a47951 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
@@ -46,6 +46,9 @@ private Q_SLOTS:
void shouldAddSpecificSignature_data();
void shouldAddSpecificSignature();
+
+ void shouldReplaceSignature();
+
};
#endif // RICHTEXTCOMPOSERNGTEST_H