File indexing completed on 2024-04-14 03:50:36
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "event.h" 0010 #include "freebusy.h" 0011 #include "icalformat.h" 0012 0013 #include <QDebug> 0014 #include <QTest> 0015 0016 using namespace KCalendarCore; 0017 0018 class TestFb : public QObject 0019 { 0020 Q_OBJECT 0021 private Q_SLOTS: 0022 void testFbLoad() 0023 { 0024 const QString fbString = QStringLiteral( 0025 "BEGIN:VCALENDAR\n" 0026 "PRODID:-//proko2//freebusy 1.0//EN\n" 0027 "METHOD:PUBLISH\n" 0028 "VERSION:2.0\n" 0029 "BEGIN:VFREEBUSY\n" 0030 "ORGANIZER:MAILTO:test3@kdab.net\n" 0031 "X-KDE-Foo:bla\n" 0032 "DTSTAMP:20071202T152453Z\n" 0033 "URL:http://mail.kdab.net/freebusy/test3%40kdab.net.ifb\n" 0034 "DTSTART:19700101T000000Z\n" 0035 "DTEND:200700101T000000Z\n" 0036 "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n" 0037 "FREEBUSY:19700101T000000Z/19700101T000000Z\n" 0038 "FREEBUSY;X-UID=bGlia2NhbC0xODk4MjgxNTcuMTAxMA==;X-\n" 0039 " SUMMARY=RW1wbG95ZWUgbWVldGluZw==;X-LOCATION=Um9vb\n" 0040 " SAyMTM=:20080131T170000Z/20080131T174500Z\n" 0041 "END:VFREEBUSY\n" 0042 "END:VCALENDAR\n"); 0043 0044 ICalFormat format; 0045 FreeBusy::Ptr fb = format.parseFreeBusy(fbString); 0046 QCOMPARE(fb->fullBusyPeriods().size(), 2); 0047 QCOMPARE(fb->dtStart(), QDateTime({1970, 1, 1}, {0, 0}, QTimeZone::UTC)); 0048 const FreeBusyPeriod::List lst = fb->fullBusyPeriods(); 0049 const auto &freebusy1 = lst.at(0); 0050 QCOMPARE(freebusy1.start(), QDateTime({1970, 1, 1}, {0, 0}, QTimeZone::UTC)); 0051 QCOMPARE(freebusy1.end(), QDateTime({1970, 1, 1}, {0, 0}, QTimeZone::UTC)); 0052 QCOMPARE(freebusy1.summary(), QString()); 0053 QCOMPARE(freebusy1.location(), QString()); 0054 0055 const auto &freebusy2 = lst.at(1); 0056 QCOMPARE(freebusy2.start(), QDateTime({2008, 1, 31}, {17, 0}, QTimeZone::UTC)); 0057 QCOMPARE(freebusy2.end(), QDateTime({2008, 1, 31}, {17, 45}, QTimeZone::UTC)); 0058 QCOMPARE(freebusy2.summary(), QLatin1String("Employee meeting")); 0059 QCOMPARE(freebusy2.location(), QLatin1String("Room 213")); 0060 0061 const QMap<QByteArray, QString> props = fb->customProperties(); 0062 QCOMPARE(props.size(), 1); 0063 QCOMPARE(props.firstKey(), "X-KDE-Foo"); 0064 QCOMPARE(props.first(), QLatin1String("bla")); 0065 } 0066 }; 0067 0068 QTEST_APPLESS_MAIN(TestFb) 0069 0070 #include "testfb.moc"