File indexing completed on 2024-05-12 05:15:04
0001 /* 0002 Copyright (c) 2017 Sandro Knauß <sknauss@kde.org> 0003 Copyright (c) 2018 Rémi Nicole <minijackson@riseup.net> 0004 0005 This program is free software; you can redistribute it and/or modify 0006 it under the terms of the GNU General Public License as published by 0007 the Free Software Foundation; either version 2 of the License, or 0008 (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "davcollectionfetchjobtest.h" 0021 0022 #include <KDAV2/DavCollectionFetchJob> 0023 0024 #include <QColor> 0025 #include <QTest> 0026 0027 void DavCollectionFetchJobTest::runAddressbookTest() 0028 { 0029 QUrl url(QStringLiteral("https://apps.kolabnow.com/addressbooks/test1%40kolab.org/7511b26d-198c-41b0-8cbf-78923ee1ca8c")); 0030 url.setUserName("test1@kolab.org"); 0031 url.setPassword("Welcome2KolabSystems"); 0032 KDAV2::DavUrl testCollectionUrl(url, KDAV2::CalDav); 0033 KDAV2::DavCollection testCollection; 0034 testCollection.setUrl(testCollectionUrl); 0035 auto collectionFetchJob = new KDAV2::DavCollectionFetchJob(testCollection); 0036 collectionFetchJob->exec(); 0037 0038 QCOMPARE(collectionFetchJob->error(), 0); 0039 0040 QCOMPARE(testCollection.CTag(), QString()); 0041 0042 KDAV2::DavCollection resultCollection = collectionFetchJob->collection(); 0043 0044 QVERIFY(!resultCollection.CTag().isEmpty()); 0045 QCOMPARE(resultCollection.displayName(), QLatin1String("Contacts")); 0046 } 0047 0048 void DavCollectionFetchJobTest::runCalendarTest() 0049 { 0050 QUrl url(QStringLiteral("https://apps.kolabnow.com/calendars/test1%40kolab.org/52abfc74-2441-49b5-80ef-f058d0fa4bd0")); 0051 url.setUserName("test1@kolab.org"); 0052 url.setPassword("Welcome2KolabSystems"); 0053 KDAV2::DavUrl testCollectionUrl(url, KDAV2::CalDav); 0054 KDAV2::DavCollection testCollection; 0055 testCollection.setUrl(testCollectionUrl); 0056 auto collectionFetchJob = new KDAV2::DavCollectionFetchJob(testCollection); 0057 collectionFetchJob->exec(); 0058 0059 QCOMPARE(collectionFetchJob->error(), 0); 0060 0061 QCOMPARE(testCollection.CTag(), QString()); 0062 QCOMPARE(testCollection.color(), QColor()); 0063 0064 KDAV2::DavCollection resultCollection = collectionFetchJob->collection(); 0065 0066 QVERIFY(!resultCollection.CTag().isEmpty()); 0067 QCOMPARE(resultCollection.displayName(), QLatin1String("Calendar")); 0068 QCOMPARE(resultCollection.color().name(), QLatin1String("#cc0000")); 0069 } 0070 0071 QTEST_GUILESS_MAIN(DavCollectionFetchJobTest)