File: mailinglisttest.cpp

package info (click to toggle)
messagelib 4%3A24.12.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 83,448 kB
  • sloc: cpp: 106,765; xml: 375; sh: 25; makefile: 15
file content (105 lines) | stat: -rw-r--r-- 4,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
  SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>

  SPDX-License-Identifier: GPL-2.0-only
*/

#include "mailinglisttest.h"
#include "messagecore_debug.h"
#include "misc/mailinglist.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <QTest>

// TODO add test for static MailingList detect(  const KMime::Message::Ptr &message ); and static QString name( ... );

MailingListTest::MailingListTest(QObject *parent)
    : QObject(parent)
{
}

MailingListTest::~MailingListTest() = default;

void MailingListTest::shouldHaveDefaultValue()
{
    MessageCore::MailingList ml;
    QVERIFY(ml.postUrls().isEmpty());
    QVERIFY(ml.subscribeUrls().isEmpty());
    QVERIFY(ml.unsubscribeUrls().isEmpty());
    QVERIFY(ml.helpUrls().isEmpty());
    QVERIFY(ml.archiveUrls().isEmpty());
    QVERIFY(ml.ownerUrls().isEmpty());
    QVERIFY(ml.archivedAtUrls().isEmpty());
    QVERIFY(ml.id().isEmpty());
    QVERIFY(ml.features() == MessageCore::MailingList::None);
    QVERIFY(ml.handler() == MessageCore::MailingList::KMail);
}

void MailingListTest::shouldRestoreFromSettings()
{
    MessageCore::MailingList ml;
    QList<QUrl> lst;
    lst << QUrl(QStringLiteral("http://www.kde.org")) << QUrl(QStringLiteral("http://www.koffice.org"));
    ml.setPostUrls(lst);
    lst << QUrl(QStringLiteral("mailto://www.kde2.org")) << QUrl(QStringLiteral("http://www.koffice2.org"));
    ml.setSubscribeUrls(lst);
    lst << QUrl(QStringLiteral("mailto://www.kde3.org")) << QUrl(QStringLiteral("http://www.koffice3.org"));
    ml.setUnsubscribeUrls(lst);
    lst << QUrl(QStringLiteral("mailto://www.kde4.org")) << QUrl(QStringLiteral("http://www.koffice4.org"));
    ml.setHelpUrls(lst);
    /* Note: mArchivedAtUrl deliberately not saved here as it refers to a single
     * instance of a message rather than an element of a general mailing list.
     * http://reviewboard.kde.org/r/1768/#review2783
     */
    // normal that we don't save it.
    // ml.setArchivedAtUrls(lst);
    lst << QUrl(QStringLiteral("mailto://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice5.org"));
    ml.setArchiveUrls(lst);
    lst << QUrl(QStringLiteral("mailto://www.kde6.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
    ml.setOwnerUrls(lst);
    ml.setId(QStringLiteral("ID"));
    ml.setHandler(MessageCore::MailingList::Browser);

    KConfigGroup grp(KSharedConfig::openConfig(), QStringLiteral("testsettings"));
    ml.writeConfig(grp);

    MessageCore::MailingList restoreMl;
    restoreMl.readConfig(grp);
    QCOMPARE(ml, restoreMl);
}

void MailingListTest::shouldCopyReminderInfo()
{
    MessageCore::MailingList ml;
    QList<QUrl> lst;
    lst << QUrl(QStringLiteral("http://www.kde.org")) << QUrl(QStringLiteral("http://www.koffice.org"));
    ml.setPostUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde2.org")) << QUrl(QStringLiteral("http://www.koffice2.org"));
    ml.setSubscribeUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde3.org")) << QUrl(QStringLiteral("http://www.koffice3.org"));
    ml.setUnsubscribeUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde4.org")) << QUrl(QStringLiteral("http://www.koffice4.org"));
    ml.setHelpUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice5.org"));
    ml.setArchivedAtUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
    ml.setArchiveUrls(lst);
    lst << QUrl(QStringLiteral("http://www.kde6.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
    ml.setOwnerUrls(lst);
    ml.setPostUrls(lst);
    ml.setSubscribeUrls(lst);
    ml.setUnsubscribeUrls(lst);
    ml.setHelpUrls(lst);
    ml.setArchivedAtUrls(lst);
    ml.setArchiveUrls(lst);
    ml.setOwnerUrls(lst);
    ml.setId(QStringLiteral("ID"));
    ml.setHandler(MessageCore::MailingList::Browser);

    MessageCore::MailingList restoreMl(ml);
    QCOMPARE(ml, restoreMl);
}

QTEST_APPLESS_MAIN(MailingListTest)

#include "moc_mailinglisttest.cpp"