MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 49 / 0 / 49
Functions: 100.0% 3 / 0 / 3
Branches: 87.2% 75 / 0 / 86

presentation/ComposeQuoteSource.cpp
Line Branch Exec Source
1 #include "ComposeQuoteSource.h"
2
3 #include "data/ComposeHtmlImport.h"
4 #include "data/MailHtmlWriter.h"
5 #include "data/MailTextWriter.h"
6 #include "data/MessageLanguageText.h"
7 #include "service/MimeParser.h"
8
9 #include <QTextCursor>
10 #include <QTextDocument>
11
12 namespace ComposeQuoteSource {
13
14 32 QString cleanHtml(const QString &html) {
15
3/3
✓ Branch 2 → 3 taken 32 times.
✓ Branch 5 → 6 taken 26 times.
✓ Branch 5 → 7 taken 6 times.
32 if (html.trimmed().isEmpty()) return {};
16
1/1
✓ Branch 9 → 10 taken 6 times.
6 const auto imported = ComposeHtmlImport::import(html.toUtf8());
17
1/2
✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 6 times.
6 if (!imported.ok()) return {};
18
1/1
✓ Branch 15 → 16 taken 6 times.
6 QTextDocument document;
19
2/2
✓ Branch 16 → 17 taken 6 times.
✓ Branch 17 → 18 taken 6 times.
6 QTextCursor(&document).insertFragment(imported.fragment);
20
1/1
✓ Branch 20 → 21 taken 6 times.
6 return MailHtmlWriter::writeBody(document).html;
21 18 }
22
23 1 QString textOf(const QString &html) {
24
2/3
✓ Branch 2 → 3 taken 1 time.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 1 time.
1 if (html.trimmed().isEmpty()) return {};
25
1/1
✓ Branch 9 → 10 taken 1 time.
1 const auto imported = ComposeHtmlImport::import(html.toUtf8());
26
1/2
✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 1 time.
1 if (!imported.ok()) return {};
27
1/1
✓ Branch 15 → 16 taken 1 time.
1 QTextDocument document;
28
2/2
✓ Branch 16 → 17 taken 1 time.
✓ Branch 17 → 18 taken 1 time.
1 QTextCursor(&document).insertFragment(imported.fragment);
29
1/1
✓ Branch 19 → 20 taken 1 time.
1 return MailTextWriter::write(document);
30 2 }
31
32 30 void add(QVariantMap &draft, const MailSnapshotReader::ComposeSourceSnapshot &source, bool forward,
33 const QString &messageLanguage) {
34
1/1
✓ Branch 2 → 3 taken 30 times.
30 const MessageLanguageText language(messageLanguage);
35
1/1
✓ Branch 3 → 4 taken 30 times.
30 const auto envelope = MimeParser::messageHeaders(source.envelopePrefix);
36
1/1
✓ Branch 7 → 8 taken 30 times.
60 const QString from = envelope.value(QStringLiteral("from"), source.header.from);
37 // The author's display name for the attribution ("Anna Berg"), else the address.
38 30 QString author = from;
39 30 const qsizetype angle = author.lastIndexOf(QLatin1Char('<'));
40
5/5
✓ Branch 14 → 15 taken 25 times.
✓ Branch 14 → 24 taken 5 times.
✓ Branch 15 → 16 taken 25 times.
✓ Branch 16 → 17 taken 25 times.
✓ Branch 19 → 20 taken 25 times.
30 if (angle > 0) author = author.left(angle).trimmed().remove(QLatin1Char('"'));
41
2/3
✓ Branch 24 → 25 taken 30 times.
✗ Branch 24 → 26 not taken.
✓ Branch 25 → 27 taken 30 times.
30 const QString html = source.bodyPresent ? cleanHtml(source.quoteHtml) : QString();
42
2/3
✓ Branch 27 → 28 taken 30 times.
✗ Branch 27 → 29 not taken.
✓ Branch 34 → 35 taken 30 times.
60 draft.insert(QStringLiteral("quoteText"), source.bodyPresent ? source.quoteText : QString());
43
1/1
✓ Branch 43 → 44 taken 30 times.
60 draft.insert(QStringLiteral("quoteHtml"), html);
44
1/1
✓ Branch 51 → 52 taken 30 times.
60 draft.insert(QStringLiteral("quoteAvailable"), source.bodyPresent);
45
1/1
✓ Branch 60 → 61 taken 30 times.
60 draft.insert(QStringLiteral("originalFormatted"), !html.isEmpty());
46
2/2
✓ Branch 64 → 65 taken 30 times.
✓ Branch 69 → 70 taken 30 times.
60 draft.insert(QStringLiteral("quoteAttribution"), language.attribution(source.header.date, author));
47
2/2
✓ Branch 77 → 78 taken 30 times.
✓ Branch 82 → 83 taken 30 times.
90 draft.insert(QStringLiteral("originalTo"), envelope.value(QStringLiteral("to"), source.header.to));
48
2/2
✓ Branch 93 → 94 taken 30 times.
✓ Branch 98 → 99 taken 30 times.
90 draft.insert(QStringLiteral("originalCc"), envelope.value(QStringLiteral("cc")));
49
2/2
✓ Branch 110 → 111 taken 30 times.
✓ Branch 115 → 116 taken 30 times.
90 draft.insert(QStringLiteral("deliveredTo"), envelope.value(QStringLiteral("delivered-to")));
50
2/2
✓ Branch 127 → 128 taken 30 times.
✓ Branch 132 → 133 taken 30 times.
90 draft.insert(QStringLiteral("xOriginalTo"), envelope.value(QStringLiteral("x-original-to")));
51
2/2
✓ Branch 144 → 145 taken 30 times.
✓ Branch 149 → 150 taken 30 times.
90 draft.insert(QStringLiteral("listPost"), envelope.value(QStringLiteral("list-post")));
52
1/1
✓ Branch 161 → 162 taken 30 times.
60 draft.insert(QStringLiteral("fromHeader"), from);
53
2/2
✓ Branch 165 → 166 taken 27 times.
✓ Branch 165 → 167 taken 3 times.
30 if (!forward) return;
54 3 const QString header = language.forwardHeader(from, source.header.date, source.header.subject,
55
2/2
✓ Branch 170 → 171 taken 3 times.
✓ Branch 171 → 172 taken 3 times.
6 envelope.value(QStringLiteral("to"), source.header.to));
56
3/3
✓ Branch 178 → 179 taken 3 times.
✓ Branch 179 → 180 taken 3 times.
✓ Branch 184 → 185 taken 3 times.
9 draft.insert(QStringLiteral("forwardText"), header + QStringLiteral("\n\n") + source.quoteText);
57 3 QString block;
58
5/5
✓ Branch 195 → 196 taken 3 times.
✓ Branch 196 → 197 taken 3 times.
✓ Branch 197 → 198 taken 3 times.
✓ Branch 219 → 199 taken 15 times.
✓ Branch 219 → 220 taken 3 times.
18 for (const QString &line : header.split(QLatin1Char('\n')))
59
4/4
✓ Branch 203 → 204 taken 15 times.
✓ Branch 207 → 208 taken 15 times.
✓ Branch 208 → 209 taken 15 times.
✓ Branch 209 → 210 taken 15 times.
33 block += QStringLiteral("<p style=\"margin:0\">") + line.toHtmlEscaped() + QStringLiteral("</p>");
60
1/1
✓ Branch 224 → 225 taken 3 times.
3 block += QStringLiteral("<p style=\"margin:0\"><br></p>");
61
1/3
✗ Branch 228 → 229 not taken.
✓ Branch 228 → 230 taken 3 times.
✗ Branch 229 → 267 not taken.
3 if (!html.isEmpty()) block += html;
62 else
63
5/5
✓ Branch 233 → 234 taken 3 times.
✓ Branch 234 → 235 taken 3 times.
✓ Branch 235 → 236 taken 3 times.
✓ Branch 264 → 237 taken 3 times.
✓ Branch 264 → 265 taken 3 times.
6 for (const QString &line : source.quoteText.split(QLatin1Char('\n')))
64 6 block += QStringLiteral("<p style=\"margin:0\">") +
65
6/10
✗ Branch 242 → 243 not taken.
✓ Branch 242 → 246 taken 3 times.
✓ Branch 246 → 247 taken 3 times.
✓ Branch 250 → 251 taken 3 times.
✓ Branch 251 → 252 taken 3 times.
✓ Branch 252 → 253 taken 3 times.
✗ Branch 258 → 259 not taken.
✓ Branch 258 → 260 taken 3 times.
✗ Branch 554 → 555 not taken.
✗ Branch 554 → 556 not taken.
12 (line.isEmpty() ? QStringLiteral("<br>") : line.toHtmlEscaped()) + QStringLiteral("</p>");
66
1/1
✓ Branch 271 → 272 taken 3 times.
6 draft.insert(QStringLiteral("forwardHtml"), block);
67 138 }
68
69 } // namespace ComposeQuoteSource
70