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% 9 / 0 / 9
Functions: 100.0% 8 / 0 / 8
Branches: 75.0% 3 / 0 / 4

presentation/AccountConnectionTest.h
Line Branch Exec Source
1 #pragma once
2
3 #include <QObject>
4 #include <QPointer>
5 #include <QString>
6 #include <QVariantMap>
7
8 #include <functional>
9
10 class ImapService;
11 struct ImapConfig;
12
13 // Q07: the account form's connection test. Owns a dedicated IMAP probe
14 // (never the session's live transport) and reports idle/testing/success/
15 // failed with a readable message. Ports the SetupWizard TestPage contract:
16 // success is the Authenticated state, failure is the service error or a
17 // bounded timeout; the result never changes after the run completed.
18 class AccountConnectionTest final : public QObject {
19 26 Q_OBJECT
20 Q_PROPERTY(QString state READ state NOTIFY stateChanged)
21 Q_PROPERTY(QString message READ message NOTIFY stateChanged)
22 public:
23 // Returns an unstarted probe; the tester connects its signals and starts
24 // the connection itself.
25 using ProbeFactory =
26 std::function<ImapService *(const ImapConfig &)>;
27 // SMTP probe seam (tests): receives host/port/security, returns a
28 // ready-to-start probe object whose started()/failed(QString) signals
29 // drive the same completion path as the production socket probe.
30 using SmtpProbeFactory =
31 std::function<QObject *(const QString &host, quint16 port,
32 const QString &security)>;
33 // Reads the stored IMAP secret for a saved account (empty password in
34 // the form means "use the keyring").
35 using SecretReader =
36 std::function<void(QObject *owner, const QString &accountId,
37 std::function<void(bool, const QByteArray &)> callback)>;
38
39 explicit AccountConnectionTest(QObject *parent = nullptr);
40 ~AccountConnectionTest() override;
41
42 // fields: the account form map (id, imapHost, imapPort, imapSecurity,
43 // imapUsername, imapPassword). Validation failures surface as a failed
44 // run without touching any socket.
45 Q_INVOKABLE void start(const QVariantMap &fields);
46 Q_INVOKABLE void cancel();
47
48 93 QString state() const { return m_state; }
49 17 QString message() const { return m_message; }
50
51 11 void setProbeFactory(ProbeFactory factory) { m_probeFactory = std::move(factory); }
52 2 void setSmtpProbeFactory(SmtpProbeFactory factory) { m_smtpProbeFactory = std::move(factory); }
53 797 void setSecretReader(SecretReader reader) { m_secretReader = std::move(reader); }
54 10 void setTimeoutMs(int ms) { m_timeoutMs = ms; }
55
56 signals:
57 void stateChanged();
58
59 private:
60 void finish(const QString &state, const QString &message);
61 28 bool runCurrent(quint64 generation) const {
62
3/4
✓ Branch 3 → 4 taken 27 times.
✓ Branch 3 → 6 taken 1 time.
✓ Branch 4 → 5 taken 27 times.
✗ Branch 4 → 6 not taken.
28 return m_run && m_generation == generation;
63 }
64
65 QString m_state = QStringLiteral("idle");
66 QString m_message;
67 QPointer<QObject> m_run;
68 quint64 m_generation = 0;
69 int m_timeoutMs = 10000;
70 ProbeFactory m_probeFactory;
71 SmtpProbeFactory m_smtpProbeFactory;
72 SecretReader m_secretReader;
73 };
74