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

Move code to improve autotests

parent db9f2aef
......@@ -100,6 +100,15 @@ void CheckDuplicateEmailsJobTest::shouldReturnEmails_data()
result.insert(QStringLiteral("foo@kde.org"), 3);
result.insert(QStringLiteral("blo@kde.org"), 2);
QTest::newRow("twoduplicateemailswithemailname") << lst << result;
lst.clear();
lst.append(QStringLiteral("foo <foo@kde.org>, foo@kde.org, foo@kde.org"));
lst.append(QStringLiteral("foo@kde.org"));
result.clear();
result.insert(QStringLiteral("foo@kde.org"), 4);
QTest::newRow("emailseparatedbycommat") << lst << result;
}
void CheckDuplicateEmailsJobTest::shouldReturnEmails()
......
......@@ -71,12 +71,10 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
}
if (mCheckDuplicateEmails) {
const QStringList lst{ params.bccAddresses(), params.toAddresses(), params.ccAddresses() };
const QString str = lst.join(QStringLiteral(", "));
const QStringList emails = str.split(QStringLiteral(", "));
if (!emails.isEmpty()) {
if (!lst.isEmpty()) {
CheckDuplicateEmailsJob job;
job.setEmails(emails);
job.setEmails(lst);
job.start();
const QMap<QString, int> results = job.result();
if (!results.isEmpty()) {
......
......@@ -61,7 +61,10 @@ void CheckDuplicateEmailsJob::start()
void CheckDuplicateEmailsJob::setEmails(const QStringList &list)
{
mEmails = list;
const QString str = list.join(QStringLiteral(", "));
const QStringList emails = str.split(QStringLiteral(", "));
mEmails = emails;
}
QMap<QString, int> CheckDuplicateEmailsJob::result() const
......
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