File indexing completed on 2024-11-24 04:44:08
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 #include "calendaringtest.h" 0008 0009 #include "calendaring/calendaring.h" 0010 #include "calendaring/datetimeutils.h" 0011 #include "calendaring/event.h" 0012 #include <QTest> 0013 #include <iostream> 0014 #include <kolabevent.h> 0015 0016 #include "testhelpers.h" 0017 #include "testutils.h" 0018 0019 void compareEvents(const std::vector<Kolab::Event> &list1, const std::vector<Kolab::Event> &list2) 0020 { 0021 QCOMPARE(list1.size(), list2.size()); 0022 for (std::size_t i = 0; i < list1.size(); i++) { 0023 const Kolab::Event &e1 = list1.at(i); 0024 const Kolab::Event &e2 = list2.at(i); 0025 // qDebug() << i; 0026 // QCOMPARE(e1.uid(), e2.uid()); 0027 QCOMPARE(e1.start(), e2.start()); 0028 QCOMPARE(e1.end(), e2.end()); 0029 } 0030 } 0031 0032 void CalendaringTest::initTestCase() 0033 { 0034 } 0035 0036 void CalendaringTest::testCalendaringEvent() 0037 { 0038 Kolab::Event event; 0039 event.setUid("uid"); 0040 event.setStart(Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true)); 0041 event.setEnd(Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true)); 0042 Kolab::Calendaring::Event calEvent(event); 0043 0044 QCOMPARE(event.start(), calEvent.start()); 0045 QCOMPARE(event.uid(), calEvent.uid()); 0046 0047 Kolab::Calendaring::Event calEvent2; 0048 Kolab::Calendaring::Event calEvent3 = calEvent2; 0049 QVERIFY(!calEvent2.uid().empty()); 0050 QCOMPARE(calEvent2.uid(), calEvent3.uid()); 0051 } 0052 0053 void CalendaringTest::testEventConflict_data() 0054 { 0055 QTest::addColumn<Kolab::Event>("e1"); 0056 QTest::addColumn<Kolab::Event>("e2"); 0057 QTest::addColumn<bool>("result"); 0058 { 0059 Kolab::Event e1; 0060 e1.setStart(Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true)); 0061 e1.setEnd(Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true)); 0062 0063 Kolab::Event e2; 0064 e2.setStart(Kolab::cDateTime(2011, 11, 10, 12, 1, 1, true)); 0065 e2.setEnd(Kolab::cDateTime(2011, 11, 11, 12, 1, 1, true)); 0066 0067 QTest::newRow("after") << e1 << e2 << false; 0068 } 0069 0070 { 0071 Kolab::Event e1; 0072 e1.setStart(Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true)); 0073 e1.setEnd(Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true)); 0074 0075 Kolab::Event e2; 0076 e2.setStart(Kolab::cDateTime(2011, 9, 10, 12, 1, 1, true)); 0077 e2.setEnd(Kolab::cDateTime(2011, 9, 11, 12, 1, 1, true)); 0078 0079 QTest::newRow("before") << e1 << e2 << false; 0080 } 0081 0082 { 0083 Kolab::Event e1; 0084 e1.setStart(Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true)); 0085 e1.setEnd(Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true)); 0086 0087 Kolab::Event e2; 0088 e2.setStart(Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true)); 0089 e2.setEnd(Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true)); 0090 0091 QTest::newRow("conflict") << e1 << e2 << true; 0092 } 0093 0094 { 0095 Kolab::Event e1; 0096 e1.setStart(Kolab::cDateTime("Europe/Zurich", 2011, 10, 10, 6, 1, 1)); 0097 e1.setEnd(Kolab::cDateTime("Europe/Zurich", 2011, 10, 10, 6, 1, 2)); 0098 0099 Kolab::Event e2; 0100 e2.setStart(Kolab::cDateTime("Asia/Dubai", 2011, 10, 10, 6, 1, 1)); 0101 e2.setEnd(Kolab::cDateTime("Asia/Dubai", 2011, 10, 10, 6, 1, 2)); 0102 0103 QTest::newRow("tz non-conflict") << e1 << e2 << false; 0104 } 0105 0106 { 0107 Kolab::Event e1; 0108 e1.setStart(Kolab::cDateTime("Europe/Berlin", 2011, 10, 10, 6, 1, 1)); 0109 e1.setEnd(Kolab::cDateTime("Europe/Berlin", 2011, 10, 10, 6, 1, 2)); 0110 0111 Kolab::Event e2; 0112 e2.setStart(Kolab::cDateTime("Europe/Zurich", 2011, 10, 10, 6, 1, 1)); 0113 e2.setEnd(Kolab::cDateTime("Europe/Zurich", 2011, 10, 10, 6, 1, 2)); 0114 0115 QTest::newRow("tz conflict") << e1 << e2 << true; 0116 } 0117 } 0118 0119 void CalendaringTest::testEventConflict() 0120 { 0121 QFETCH(Kolab::Event, e1); 0122 QFETCH(Kolab::Event, e2); 0123 QFETCH(bool, result); 0124 QCOMPARE(Kolab::Calendaring::conflicts(e1, e2), result); 0125 } 0126 0127 void CalendaringTest::testEventConflictSet() 0128 { 0129 std::vector<Kolab::Event> events; 0130 events.push_back(createEvent(Kolab::cDateTime(2011, 10, 6, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 8, 12, 1, 1, true))); 0131 events.push_back(createEvent(Kolab::cDateTime(2011, 10, 7, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true))); 0132 events.push_back(createEvent(Kolab::cDateTime(2011, 10, 9, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true))); 0133 const std::vector<std::vector<Kolab::Event>> &result = Kolab::Calendaring::getConflictingSets(events); 0134 0135 std::vector<std::vector<Kolab::Event>> expectedResult; 0136 std::vector<Kolab::Event> r1; 0137 r1.push_back(createEvent(Kolab::cDateTime(2011, 10, 6, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 8, 12, 1, 1, true))); 0138 r1.push_back(createEvent(Kolab::cDateTime(2011, 10, 7, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true))); 0139 expectedResult.push_back(r1); 0140 std::vector<Kolab::Event> r2; 0141 r2.push_back(createEvent(Kolab::cDateTime(2011, 10, 7, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 10, 12, 1, 1, true))); 0142 r2.push_back(createEvent(Kolab::cDateTime(2011, 10, 9, 12, 1, 1, true), Kolab::cDateTime(2011, 10, 11, 12, 1, 1, true))); 0143 expectedResult.push_back(r2); 0144 0145 for (std::size_t i = 0; i < result.size(); i++) { 0146 const std::vector<Kolab::Event> &list = result.at(i); 0147 0148 qDebug() << "---------_Set--------------"; 0149 for (const Kolab::Event &event : list) { 0150 qDebug() << QTest::toString(event.start()) << QTest::toString(event.end()); 0151 } 0152 compareEvents(result.at(i), expectedResult.at(i)); 0153 } 0154 } 0155 0156 void CalendaringTest::testTimesInInterval_data() 0157 { 0158 QTest::addColumn<Kolab::Event>("event"); 0159 QTest::addColumn<Kolab::cDateTime>("start"); 0160 QTest::addColumn<Kolab::cDateTime>("end"); 0161 QTest::addColumn<std::vector<Kolab::cDateTime>>("result"); 0162 { 0163 { 0164 Kolab::Event event; 0165 event.setStart(Kolab::cDateTime(2011, 1, 1, 1, 1, 1, true)); 0166 event.setEnd(Kolab::cDateTime(2011, 1, 1, 2, 1, 1, true)); 0167 Kolab::RecurrenceRule rrule; 0168 rrule.setFrequency(Kolab::RecurrenceRule::Daily); 0169 rrule.setInterval(1); 0170 rrule.setCount(5); 0171 event.setRecurrenceRule(rrule); 0172 0173 std::vector<Kolab::cDateTime> result; 0174 result.emplace_back(2011, 1, 1, 1, 1, 1, true); 0175 result.emplace_back(2011, 1, 2, 1, 1, 1, true); 0176 result.emplace_back(2011, 1, 3, 1, 1, 1, true); 0177 result.emplace_back(2011, 1, 4, 1, 1, 1, true); 0178 result.emplace_back(2011, 1, 5, 1, 1, 1, true); 0179 QTest::newRow("simple") << event << Kolab::cDateTime(2011, 1, 1, 1, 1, 1, true) << Kolab::cDateTime(2011, 1, 5, 1, 1, 1, true) << result; 0180 } 0181 } 0182 } 0183 0184 void CalendaringTest::testTimesInInterval() 0185 { 0186 QFETCH(Kolab::Event, event); 0187 QFETCH(Kolab::cDateTime, start); 0188 QFETCH(Kolab::cDateTime, end); 0189 QFETCH(std::vector<Kolab::cDateTime>, result); 0190 QCOMPARE(Kolab::Calendaring::timeInInterval(event, start, end), result); 0191 } 0192 0193 void CalendaringTest::testTimesInIntervalBenchmark() 0194 { 0195 Kolab::Event event; 0196 event.setStart(Kolab::cDateTime(2011, 1, 1, 1, 1, 1)); 0197 event.setEnd(Kolab::cDateTime(2011, 1, 1, 2, 1, 1)); 0198 Kolab::RecurrenceRule rrule; 0199 rrule.setFrequency(Kolab::RecurrenceRule::Daily); 0200 rrule.setInterval(1); 0201 rrule.setCount(500); 0202 event.setRecurrenceRule(rrule); 0203 0204 QBENCHMARK { 0205 Kolab::Calendaring::timeInInterval(event, Kolab::cDateTime(2011, 1, 1, 1, 1, 1), Kolab::cDateTime(2013, 1, 1, 1, 1, 1)); 0206 } 0207 const std::vector<Kolab::cDateTime> &result = 0208 Kolab::Calendaring::timeInInterval(event, Kolab::cDateTime(2011, 1, 1, 1, 1, 1), Kolab::cDateTime(2013, 1, 1, 1, 1, 1)); 0209 QVERIFY(result.size() == 500); 0210 // qDebug() << QTest::toString(result); 0211 } 0212 0213 void CalendaringTest::testCalendar_data() 0214 { 0215 QTest::addColumn<std::vector<Kolab::Event>>("inputevents"); 0216 QTest::addColumn<Kolab::cDateTime>("start"); 0217 QTest::addColumn<Kolab::cDateTime>("end"); 0218 QTest::addColumn<std::vector<Kolab::Event>>("expectedResult"); 0219 0220 { 0221 std::vector<Kolab::Event> inputevents; 0222 for (int day = 1; day < 28; day++) { 0223 for (int hour = 1; hour < 20; hour += 2) { 0224 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, day, hour, 4, 4, true), Kolab::cDateTime(2012, 5, day, hour + 1, 4, 4, true))); 0225 } 0226 } 0227 std::vector<Kolab::Event> expectedResult; 0228 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 3, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 3 + 1, 4, 4, true))); 0229 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 5, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 5 + 1, 4, 4, true))); 0230 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 7, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 7 + 1, 4, 4, true))); 0231 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 9, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 9 + 1, 4, 4, true))); 0232 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 11, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 11 + 1, 4, 4, true))); 0233 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 13, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 13 + 1, 4, 4, true))); 0234 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 15, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 15 + 1, 4, 4, true))); 0235 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 17, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 17 + 1, 4, 4, true))); 0236 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 19, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 19 + 1, 4, 4, true))); 0237 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 6, 1, 4, 4, true), Kolab::cDateTime(2012, 5, 6, 1 + 1, 4, 4, true))); 0238 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 6, 3, 4, 4, true), Kolab::cDateTime(2012, 5, 6, 3 + 1, 4, 4, true))); 0239 QTest::newRow("simple") << inputevents << Kolab::cDateTime(2012, 5, 5, 4, 4, 4, true) << Kolab::cDateTime(2012, 5, 6, 4, 4, 4, true) << expectedResult; 0240 } 0241 0242 { // Start and end time inclusive 0243 std::vector<Kolab::Event> inputevents; 0244 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 1, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 1 + 1, 4, 4, true))); 0245 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 3, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 3 + 1, 4, 4, true))); 0246 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 5, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 5 + 1, 4, 4, true))); 0247 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 7, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 7 + 1, 4, 4, true))); 0248 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 9, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 9 + 1, 4, 4, true))); 0249 0250 std::vector<Kolab::Event> expectedResult; 0251 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 3, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 3 + 1, 4, 4, true))); 0252 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 5, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 5 + 1, 4, 4, true))); 0253 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 7, 4, 4, true), Kolab::cDateTime(2012, 5, 5, 7 + 1, 4, 4, true))); 0254 QTest::newRow("startEndTimeInclusive") << inputevents << Kolab::cDateTime(2012, 5, 5, 3, 4, 4, true) << Kolab::cDateTime(2012, 5, 5, 7, 4, 4, true) 0255 << expectedResult; 0256 } 0257 0258 { // Start and end time inclusive (floating time) 0259 std::vector<Kolab::Event> inputevents; 0260 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 1, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 1 + 1, 4, 4, false))); 0261 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 3, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 3 + 1, 4, 4, false))); 0262 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 5, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 5 + 1, 4, 4, false))); 0263 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 7, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 7 + 1, 4, 4, false))); 0264 inputevents.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 9, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 9 + 1, 4, 4, false))); 0265 0266 std::vector<Kolab::Event> expectedResult; 0267 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 3, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 3 + 1, 4, 4, false))); 0268 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 5, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 5 + 1, 4, 4, false))); 0269 expectedResult.push_back(createEvent(Kolab::cDateTime(2012, 5, 5, 7, 4, 4, false), Kolab::cDateTime(2012, 5, 5, 7 + 1, 4, 4, false))); 0270 QTest::newRow("startEndTimeInclusive") << inputevents << Kolab::cDateTime(2012, 5, 5, 3, 4, 4, false) << Kolab::cDateTime(2012, 5, 5, 7, 4, 4, false) 0271 << expectedResult; 0272 } 0273 0274 { // Start and end time inclusive (timezone) 0275 std::vector<Kolab::Event> inputevents; 0276 inputevents.push_back(createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 1, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 1 + 1, 4, 4))); 0277 inputevents.push_back(createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3 + 1, 4, 4))); 0278 inputevents.push_back(createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 5, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 5 + 1, 4, 4))); 0279 inputevents.push_back(createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 7, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 7 + 1, 4, 4))); 0280 inputevents.push_back(createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 9, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 9 + 1, 4, 4))); 0281 0282 std::vector<Kolab::Event> expectedResult; 0283 expectedResult.push_back( 0284 createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3 + 1, 4, 4))); 0285 expectedResult.push_back( 0286 createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 5, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 5 + 1, 4, 4))); 0287 expectedResult.push_back( 0288 createEvent(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 7, 4, 4), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 7 + 1, 4, 4))); 0289 QTest::newRow("startEndTimeInclusive") << inputevents << Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4) 0290 << Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 7, 4, 4) << expectedResult; 0291 } 0292 } 0293 0294 void CalendaringTest::testCalendar() 0295 { 0296 QFETCH(std::vector<Kolab::Event>, inputevents); 0297 QFETCH(Kolab::cDateTime, start); 0298 QFETCH(Kolab::cDateTime, end); 0299 QFETCH(std::vector<Kolab::Event>, expectedResult); 0300 0301 Kolab::Calendaring::Calendar cal; 0302 for (const Kolab::Event &event : std::as_const(inputevents)) { 0303 cal.addEvent(event); 0304 } 0305 const std::vector<Kolab::Event> result = cal.getEvents(start, end, true); 0306 for (const Kolab::Event &event : result) { 0307 qDebug() << QTest::toString(event.start()) << QTest::toString(event.end()); 0308 } 0309 compareEvents(result, expectedResult); 0310 } 0311 0312 void CalendaringTest::delegationTest() 0313 { 0314 Kolab::Calendaring::Event event; 0315 event.setStart(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0316 0317 Kolab::Attendee att1(Kolab::ContactReference("email1", "name1", "uid1")); 0318 att1.setCutype(Kolab::CutypeIndividual); 0319 Kolab::Attendee att2(Kolab::ContactReference("email2", "name2", "uid2")); 0320 Kolab::Attendee att3(Kolab::ContactReference("email3", "name3", "uid3")); 0321 Kolab::Attendee att4(Kolab::ContactReference("email4", "name4", "uid4")); 0322 0323 std::vector<Kolab::Attendee> attendees; 0324 attendees.push_back(att1); 0325 attendees.push_back(att2); 0326 attendees.push_back(att3); 0327 event.setAttendees(attendees); 0328 0329 std::vector<Kolab::Attendee> delegators; 0330 delegators.push_back(att1); 0331 delegators.push_back(att2); 0332 0333 std::vector<Kolab::Attendee> delegatees; 0334 delegatees.push_back(att3); 0335 delegatees.push_back(att4); 0336 0337 event.delegate(delegators, delegatees); 0338 0339 std::cout << event.write(); 0340 // TODO write an actual test 0341 } 0342 0343 void CalendaringTest::testICal() 0344 { 0345 Kolab::Calendaring::Event event; 0346 event.setStart(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0347 const std::string &result = event.toICal(); 0348 // TODO write an actual test 0349 event.setStart(Kolab::cDateTime(1, 1, 1)); 0350 event.fromICal(result); 0351 QCOMPARE(event.start(), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0352 } 0353 0354 void CalendaringTest::testMime() 0355 { 0356 Kolab::Calendaring::Event event; 0357 event.setStart(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0358 std::cout << event.toMime(); 0359 const std::string &result = event.toMime(); 0360 event.setStart(Kolab::cDateTime(1, 1, 1)); 0361 event.fromMime(result); 0362 QCOMPARE(event.start(), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0363 } 0364 0365 void CalendaringTest::testIMip() 0366 { 0367 Kolab::Calendaring::Event event; 0368 Kolab::Attendee att1(Kolab::ContactReference("email1", "name1", "uid1")); 0369 0370 std::vector<Kolab::Attendee> attendees; 0371 attendees.push_back(att1); 0372 event.setAttendees(attendees); 0373 event.setOrganizer(Kolab::ContactReference("organizer@test.org", "organizer", "uid3")); 0374 event.setSummary("summary"); 0375 event.setStart(Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0376 const std::string &result = event.toIMip(Kolab::Calendaring::Event::iTIPRequest); 0377 event.setStart(Kolab::cDateTime(1, 1, 1)); 0378 event.fromIMip(result); 0379 QEXPECT_FAIL("", "returns UTC instead of local timezone", Continue); 0380 QCOMPARE(event.start(), Kolab::cDateTime("Europe/Zurich", 2012, 5, 5, 3, 4, 4)); 0381 QCOMPARE(event.getSchedulingMethod(), Kolab::Calendaring::Event::iTIPRequest); 0382 } 0383 0384 void CalendaringTest::testRecurrence() 0385 { 0386 Kolab::Calendaring::Event event; 0387 event.setStart(Kolab::cDateTime(2011, 1, 1, 1, 1, 1)); 0388 event.setEnd(Kolab::cDateTime(2011, 1, 1, 2, 1, 1)); 0389 Kolab::RecurrenceRule rrule; 0390 rrule.setFrequency(Kolab::RecurrenceRule::Daily); 0391 rrule.setInterval(1); 0392 rrule.setCount(10); 0393 event.setRecurrenceRule(rrule); 0394 0395 Kolab::cDateTime previousDate = event.start(); 0396 for (int i = 0; i < 9; i++) { 0397 const Kolab::cDateTime nextDate = event.getNextOccurence(previousDate); 0398 // qDebug() << QTest::toString(nextDate); 0399 QCOMPARE(nextDate, 0400 Kolab::cDateTime(previousDate.year(), 0401 previousDate.month(), 0402 previousDate.day() + 1, 0403 previousDate.hour(), 0404 previousDate.minute(), 0405 previousDate.second())); 0406 const Kolab::cDateTime endDate = event.getOccurenceEndDate(nextDate); 0407 // qDebug() << QTest::toString(endDate); 0408 QCOMPARE(endDate, Kolab::cDateTime(nextDate.year(), nextDate.month(), nextDate.day(), event.end().hour(), event.end().minute(), event.end().second())); 0409 previousDate = nextDate; 0410 } 0411 0412 Kolab::cDateTime outOfScopeDate = event.getNextOccurence(previousDate); 0413 QVERIFY(!outOfScopeDate.isValid()); 0414 } 0415 0416 void CalendaringTest::testDateTimeUtils() 0417 { 0418 std::cout << Kolab::DateTimeUtils::getLocalTimezone() << std::endl; 0419 } 0420 0421 QTEST_MAIN(CalendaringTest) 0422 0423 #include "moc_calendaringtest.cpp"