Fix includes
[kdepim.git] / messagecore / autotests / mailinglisttest.cpp
blob80e229ebcd2d4e5ab745586aebefd90630554a33
1 /*
2 Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "mailinglisttest.h"
19 #include "misc/mailinglist.h"
20 #include <qtest.h>
21 #include <KConfigGroup>
22 #include "messagecore_debug.h"
23 #include <KSharedConfig>
25 //TODO add test for static MailingList detect( const KMime::Message::Ptr &message ); and static QString name( ... );
27 MailingListTest::MailingListTest(QObject *parent)
28 : QObject(parent)
33 MailingListTest::~MailingListTest()
38 void MailingListTest::shouldHaveDefaultValue()
40 MessageCore::MailingList ml;
41 QVERIFY(ml.postUrls().isEmpty());
42 QVERIFY(ml.subscribeUrls().isEmpty());
43 QVERIFY(ml.unsubscribeUrls().isEmpty());
44 QVERIFY(ml.helpUrls().isEmpty());
45 QVERIFY(ml.archiveUrls().isEmpty());
46 QVERIFY(ml.ownerUrls().isEmpty());
47 QVERIFY(ml.archivedAtUrls().isEmpty());
48 QVERIFY(ml.id().isEmpty());
49 QVERIFY(ml.features() == MessageCore::MailingList::None);
50 QVERIFY(ml.handler() == MessageCore::MailingList::KMail);
53 void MailingListTest::shouldRestoreFromSettings()
55 MessageCore::MailingList ml;
56 QList<QUrl> lst;
57 lst << QUrl(QStringLiteral("http://www.kde.org")) << QUrl(QStringLiteral("http://www.koffice.org"));
58 ml.setPostUrls(lst);
59 lst << QUrl(QStringLiteral("mailto://www.kde2.org")) << QUrl(QStringLiteral("http://www.koffice2.org"));
60 ml.setSubscribeUrls(lst);
61 lst << QUrl(QStringLiteral("mailto://www.kde3.org")) << QUrl(QStringLiteral("http://www.koffice3.org"));
62 ml.setUnsubscribeUrls(lst);
63 lst << QUrl(QStringLiteral("mailto://www.kde4.org")) << QUrl(QStringLiteral("http://www.koffice4.org"));
64 ml.setHelpUrls(lst);
65 /* Note: mArchivedAtUrl deliberately not saved here as it refers to a single
66 * instance of a message rather than an element of a general mailing list.
67 * http://reviewboard.kde.org/r/1768/#review2783
69 //normal that we don't save it.
70 //ml.setArchivedAtUrls(lst);
71 lst << QUrl(QStringLiteral("mailto://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice5.org"));
72 ml.setArchiveUrls(lst);
73 lst << QUrl(QStringLiteral("mailto://www.kde6.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
74 ml.setOwnerUrls(lst);
75 ml.setId(QStringLiteral("ID"));
76 ml.setHandler(MessageCore::MailingList::Browser);
78 KConfigGroup grp(KSharedConfig::openConfig(), "testsettings");
79 ml.writeConfig(grp);
81 MessageCore::MailingList restoreMl;
82 restoreMl.readConfig(grp);
83 QCOMPARE(ml, restoreMl);
86 void MailingListTest::shouldCopyReminderInfo()
88 MessageCore::MailingList ml;
89 QList<QUrl> lst;
90 lst << QUrl(QStringLiteral("http://www.kde.org")) << QUrl(QStringLiteral("http://www.koffice.org"));
91 ml.setPostUrls(lst);
92 lst << QUrl(QStringLiteral("http://www.kde2.org")) << QUrl(QStringLiteral("http://www.koffice2.org"));
93 ml.setSubscribeUrls(lst);
94 lst << QUrl(QStringLiteral("http://www.kde3.org")) << QUrl(QStringLiteral("http://www.koffice3.org"));
95 ml.setUnsubscribeUrls(lst);
96 lst << QUrl(QStringLiteral("http://www.kde4.org")) << QUrl(QStringLiteral("http://www.koffice4.org"));
97 ml.setHelpUrls(lst);
98 lst << QUrl(QStringLiteral("http://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice5.org"));
99 ml.setArchivedAtUrls(lst);
100 lst << QUrl(QStringLiteral("http://www.kde5.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
101 ml.setArchiveUrls(lst);
102 lst << QUrl(QStringLiteral("http://www.kde6.org")) << QUrl(QStringLiteral("http://www.koffice6.org"));
103 ml.setOwnerUrls(lst);
104 ml.setPostUrls(lst);
105 ml.setSubscribeUrls(lst);
106 ml.setUnsubscribeUrls(lst);
107 ml.setHelpUrls(lst);
108 ml.setArchivedAtUrls(lst);
109 ml.setArchiveUrls(lst);
110 ml.setOwnerUrls(lst);
111 ml.setId(QStringLiteral("ID"));
112 ml.setHandler(MessageCore::MailingList::Browser);
114 MessageCore::MailingList restoreMl(ml);
115 QCOMPARE(ml, restoreMl);
118 QTEST_MAIN(MailingListTest)