summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-08-31 05:16:28 (GMT)
committerMontel Laurent <montel@kde.org>2016-08-31 05:16:28 (GMT)
commit20a43b9a69402b8efb3c0c7444ab22ae76a83c8f (patch)
tree4832bbb5613b59178ddaf869fde81607f96a0524
parenta101d9fbab9c231417cce886503d5370a5c4bf43 (diff)
improve autotests
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp39
-rw-r--r--messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h2
2 files changed, 27 insertions, 14 deletions
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
index d8de69b..4558115 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.cpp
@@ -118,26 +118,37 @@ void RichTextComposerNgTest::shouldNotChangeSignatureWhenOriginalAndNewSignature
const bool replaceSignature = richtextComposerNg.composerSignature()->replaceSignature(oldSignature, oldSignature);
QVERIFY(!replaceSignature);
}
+Q_DECLARE_METATYPE(KIdentityManagement::Signature::Placement)
+Q_DECLARE_METATYPE(KIdentityManagement::Signature::AddedTextFlag)
+
+void RichTextComposerNgTest::shouldAddSignature_data()
+{
+ QTest::addColumn<QString>("original");
+ QTest::addColumn<QString>("expected");
+ QTest::addColumn<KIdentityManagement::Signature::Placement>("signatureplacement");
+ QTest::addColumn<KIdentityManagement::Signature::AddedTextFlag>("signatureaddtext");
+ QTest::newRow("startandaddseparator") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("-- \nSignaturefoo bla, bli\nbb")
+ << 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;
+
+ QTest::newRow("startandnothing") << QStringLiteral("foo bla, bli\nbb") << QStringLiteral("Signaturefoo bla, bli\nbb")
+ << KIdentityManagement::Signature::Start << KIdentityManagement::Signature::AddNothing;
+}
void RichTextComposerNgTest::shouldAddSignature()
{
+ QFETCH(QString, original);
+ QFETCH(QString, expected);
+ QFETCH(KIdentityManagement::Signature::Placement, signatureplacement);
+ QFETCH(KIdentityManagement::Signature::AddedTextFlag, signatureaddtext);
MessageComposer::RichTextComposerNg richtextComposerNg;
- richtextComposerNg.setPlainText(QStringLiteral("foo bla, bli\nbb"));
+ richtextComposerNg.setPlainText(original);
+
KIdentityManagement::Signature newSignature(QStringLiteral("Signature"));
newSignature.setEnabledSignature(true);
- richtextComposerNg.insertSignature(newSignature, KIdentityManagement::Signature::Start, KIdentityManagement::Signature::AddSeparator);
- QString expected = QStringLiteral("-- \nSignaturefoo bla, bli\nbb");
- QCOMPARE(richtextComposerNg.toPlainText(), expected);
-
-
- richtextComposerNg.setPlainText(QStringLiteral("foo bla, bli\nbb"));
- richtextComposerNg.insertSignature(newSignature, KIdentityManagement::Signature::Start, KIdentityManagement::Signature::AddNewLines);
- expected = QStringLiteral("\n\nSignature\nfoo bla, bli\nbb");
- QCOMPARE(richtextComposerNg.toPlainText(), expected);
-
- richtextComposerNg.setPlainText(QStringLiteral("foo bla, bli\nbb"));
- richtextComposerNg.insertSignature(newSignature, KIdentityManagement::Signature::Start, KIdentityManagement::Signature::AddNothing);
- expected = QStringLiteral("Signaturefoo bla, bli\nbb");
+ richtextComposerNg.insertSignature(newSignature, signatureplacement, signatureaddtext);
QCOMPARE(richtextComposerNg.toPlainText(), expected);
}
diff --git a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
index 3ebfd30..e2c6994 100644
--- a/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
+++ b/messagecomposer/src/composer-ng/autotests/richtextcomposerngtest.h
@@ -39,6 +39,8 @@ private Q_SLOTS:
void shouldNotChangeSignatureWhenOriginalAndNewSignatureAreSame();
+
+ void shouldAddSignature_data();
void shouldAddSignature();
};