File indexing completed on 2024-04-14 03:50:37
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2006-2007 Allen Winter <winter@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "testmemorycalendar.h" 0010 #include "filestorage.h" 0011 #include "memorycalendar.h" 0012 0013 #include <QDebug> 0014 0015 #include <QTest> 0016 #include <QTimeZone> 0017 QTEST_MAIN(MemoryCalendarTest) 0018 0019 using namespace KCalendarCore; 0020 0021 void MemoryCalendarTest::testValidity() 0022 { 0023 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0024 cal->setProductId(QStringLiteral("fredware calendar")); 0025 QVERIFY(cal->productId() == QLatin1String("fredware calendar")); 0026 QVERIFY(cal->timeZoneId() == QByteArrayLiteral("UTC")); 0027 QVERIFY(cal->timeZone() == QTimeZone::utc()); 0028 } 0029 0030 void MemoryCalendarTest::testInvalidTimeZone() 0031 { 0032 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone())); 0033 // On invalid time zone, fallback to system time zone. 0034 QVERIFY(cal->timeZone() == QTimeZone::systemTimeZone()); 0035 } 0036 0037 void MemoryCalendarTest::testEvents() 0038 { 0039 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0040 cal->setProductId(QStringLiteral("fredware calendar")); 0041 QDate dt = QDate::currentDate(); 0042 0043 Event::Ptr event1 = Event::Ptr(new Event()); 0044 event1->setUid(QStringLiteral("1")); 0045 event1->setDtStart(QDateTime(dt, {})); 0046 event1->setDtEnd(QDateTime(dt, {}).addDays(1)); 0047 event1->setAllDay(true); 0048 event1->setSummary(QStringLiteral("Event1 Summary")); 0049 event1->setDescription(QStringLiteral("This is a description of the first event")); 0050 event1->setLocation(QStringLiteral("the place")); 0051 0052 Event::Ptr event2 = Event::Ptr(new Event()); 0053 event2->setUid(QStringLiteral("2")); 0054 event2->setDtStart(QDateTime(dt, {}).addDays(1)); 0055 event2->setDtEnd(QDateTime(dt, {}).addDays(2)); 0056 event2->setAllDay(true); 0057 event2->setSummary(QStringLiteral("Event2 Summary")); 0058 event2->setDescription(QStringLiteral("This is a description of the second event")); 0059 event2->setLocation(QStringLiteral("the other place")); 0060 0061 QVERIFY(cal->addEvent(event1)); 0062 QVERIFY(cal->addEvent(event2)); 0063 0064 FileStorage store(cal, QStringLiteral("foo.ics")); 0065 QVERIFY(store.save()); 0066 QFile::remove(QStringLiteral("foo.ics")); 0067 } 0068 0069 void MemoryCalendarTest::testIncidences() 0070 { 0071 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0072 cal->setProductId(QStringLiteral("fredware calendar")); 0073 QDate dt = QDate::currentDate(); 0074 0075 Event::Ptr event1 = Event::Ptr(new Event()); 0076 event1->setUid(QStringLiteral("1")); 0077 event1->setDtStart(QDateTime(dt, {})); 0078 event1->setDtEnd(QDateTime(dt, {}).addDays(1)); 0079 event1->setAllDay(true); 0080 event1->setSummary(QStringLiteral("Event1 Summary")); 0081 event1->setDescription(QStringLiteral("This is a description of the first event")); 0082 event1->setLocation(QStringLiteral("the place")); 0083 0084 Event::Ptr event2 = Event::Ptr(new Event()); 0085 event2->setUid(QStringLiteral("2")); 0086 event2->setDtStart(QDateTime(dt, {}).addDays(1)); 0087 event2->setDtEnd(QDateTime(dt, {}).addDays(2)); 0088 event2->setAllDay(true); 0089 event2->setSummary(QStringLiteral("Event2 Summary")); 0090 event2->setDescription(QStringLiteral("This is a description of the second event")); 0091 event2->setLocation(QStringLiteral("the other place")); 0092 0093 QVERIFY(cal->addEvent(event1)); 0094 QVERIFY(cal->addEvent(event2)); 0095 0096 Todo::Ptr todo1 = Todo::Ptr(new Todo()); 0097 todo1->setUid(QStringLiteral("3")); 0098 todo1->setDtStart(QDateTime(dt, {}).addDays(1)); 0099 todo1->setDtDue(QDateTime(dt, {}).addDays(2)); 0100 todo1->setAllDay(true); 0101 todo1->setSummary(QStringLiteral("Todo1 Summary")); 0102 todo1->setDescription(QStringLiteral("This is a description of a todo")); 0103 todo1->setLocation(QStringLiteral("this place")); 0104 0105 Todo::Ptr todo2 = Todo::Ptr(new Todo()); 0106 todo2->setUid(QStringLiteral("4")); 0107 todo2->setDtStart(QDateTime(dt, {}).addDays(1)); 0108 todo2->setAllDay(true); 0109 todo2->setSummary(QStringLiteral("<qt><h1>Todo2 Summary</h1></qt>"), true); 0110 todo2->setDescription(QStringLiteral("This is a description of a todo")); 0111 todo2->setLocation(QStringLiteral("<html><a href=\"http://www.fred.com\">this place</a></html>"), true); 0112 0113 QVERIFY(cal->addTodo(todo1)); 0114 QVERIFY(cal->addTodo(todo2)); 0115 0116 FileStorage store(cal, QStringLiteral("foo.ics")); 0117 QVERIFY(store.save()); 0118 0119 QVERIFY(store.load()); 0120 Todo::Ptr todo = cal->incidence(QStringLiteral("4")).staticCast<Todo>(); 0121 QVERIFY(todo->uid() == QLatin1Char('4')); 0122 QVERIFY(todo->summaryIsRich()); 0123 QVERIFY(todo->locationIsRich()); 0124 QFile::remove(QStringLiteral("foo.ics")); 0125 } 0126 0127 void MemoryCalendarTest::testRelationsCrash() 0128 { 0129 // Before, there was a crash that occurred only when reloading a calendar in which 0130 // the incidences had special relations. 0131 // This test tests that scenario, and will crash if it fails. 0132 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0133 FileStorage store1(cal, QLatin1String(ICALTESTDATADIR) + QLatin1String("test_relations.ics")); 0134 QVERIFY(store1.load()); 0135 const Todo::List oldTodos = cal->todos(); 0136 qDebug() << "Loaded " << oldTodos.count() << " todos into oldTodos."; 0137 0138 FileStorage store2(cal, QLatin1String(ICALTESTDATADIR) + QLatin1String("test_relations.ics")); 0139 QVERIFY(store2.load()); 0140 const Todo::List newTodos = cal->todos(); 0141 qDebug() << "Loaded " << newTodos.count() << " into newTodos."; 0142 0143 // We can saftely access the old deleted todos here, since they are not really deleted 0144 // and are still kept in a map of deleted items somewhere. 0145 // 0146 // Here we make sure that non of the old items have connections to the new items, and 0147 // the other way around. 0148 0149 // This doesn't makes sense so i commented it. when you load a calendar the second time 0150 // it reuses what it can, so oldTodo == newTodo 0151 0152 /* foreach (const Todo::Ptr &oldTodo, oldTodos ) { 0153 foreach (const Todo::Ptr &newTodo, newTodos ) { 0154 QVERIFY( oldTodo != newTodo ); 0155 0156 // Make sure that none of the new todos point to an old, deleted todo 0157 QVERIFY( newTodo->relatedTo() != oldTodo ); 0158 QVERIFY( !newTodo->relations().contains( oldTodo ) ); 0159 0160 // Make sure that none of the old todos point to a new todo 0161 QVERIFY( oldTodo->relatedTo() != newTodo ); 0162 QVERIFY( !oldTodo->relations().contains( newTodo ) ); 0163 } 0164 } 0165 */ 0166 } 0167 0168 void MemoryCalendarTest::testRecurrenceExceptions() 0169 { 0170 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0171 cal->setProductId(QStringLiteral("fredware calendar")); 0172 QDate dt = QDate::currentDate(); 0173 QDateTime start(dt, {}); 0174 0175 Event::Ptr event1 = Event::Ptr(new Event()); 0176 event1->setUid(QStringLiteral("1")); 0177 event1->setDtStart(start); 0178 event1->setDtEnd(start.addDays(1)); 0179 event1->setSummary(QStringLiteral("Event1 Summary")); 0180 event1->recurrence()->setDaily(1); 0181 event1->recurrence()->setDuration(3); 0182 QVERIFY(cal->addEvent(event1)); 0183 0184 const QDateTime recurrenceId = event1->dtStart().addDays(1); 0185 Event::Ptr exception1 = cal->createException(event1, recurrenceId).staticCast<Event>(); 0186 QCOMPARE(exception1->recurrenceId(), recurrenceId); 0187 QCOMPARE(exception1->uid(), event1->uid()); 0188 exception1->setSummary(QStringLiteral("exception")); 0189 0190 QVERIFY(exception1); 0191 QVERIFY(cal->addEvent(exception1)); 0192 0193 QCOMPARE(cal->event(event1->uid()), event1); 0194 QCOMPARE(cal->event(event1->uid(), recurrenceId), exception1); 0195 0196 const Event::List incidences = cal->rawEvents(start.date(), start.addDays(3).date(), start.timeZone()); 0197 // Contains incidence and exception 0198 QCOMPARE(incidences.size(), 2); 0199 0200 // Returns only exceptions for an event 0201 const Event::List exceptions = cal->eventInstances(event1); 0202 QCOMPARE(exceptions.size(), 1); 0203 QCOMPARE(exceptions.first()->uid(), event1->uid()); 0204 QCOMPARE(exceptions.first()->summary(), exception1->summary()); 0205 } 0206 0207 void MemoryCalendarTest::testChangeRecurId() 0208 { 0209 // When we change the recurring id, internal hashtables should be updated. 0210 0211 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0212 QDateTime start(QDate::currentDate(), {}); 0213 0214 // Add main event 0215 Event::Ptr event1 = Event::Ptr(new Event()); 0216 const QString uid = QStringLiteral("1"); 0217 event1->setUid(uid); 0218 event1->setDtStart(start); 0219 event1->setDtEnd(start.addDays(1)); 0220 event1->setAllDay(true); 0221 event1->setSummary(QStringLiteral("Event1 Summary")); 0222 event1->recurrence()->setDaily(1); 0223 event1->recurrence()->setDuration(3); 0224 QVERIFY(cal->addEvent(event1)); 0225 0226 // Add exception event: 0227 const QDateTime recurrenceId = event1->dtStart().addDays(1); 0228 Event::Ptr exception1 = cal->createException(event1, recurrenceId).staticCast<Event>(); 0229 QCOMPARE(exception1->recurrenceId(), recurrenceId); 0230 QCOMPARE(exception1->uid(), event1->uid()); 0231 exception1->setSummary(QStringLiteral("exception")); 0232 QVERIFY(exception1); 0233 QVERIFY(cal->addEvent(exception1)); 0234 0235 const QString oldIdentifier = exception1->instanceIdentifier(); 0236 Incidence::Ptr foo = cal->instance(oldIdentifier); 0237 QVERIFY(foo && foo->hasRecurrenceId()); 0238 // Now change the recurring id! 0239 exception1->setRecurrenceId(start.addDays(2)); 0240 const QString newIdentifier = exception1->instanceIdentifier(); 0241 QVERIFY(oldIdentifier != newIdentifier); 0242 0243 foo = cal->instance(oldIdentifier); 0244 QVERIFY(!foo); 0245 0246 foo = cal->instance(newIdentifier); 0247 QVERIFY(foo); 0248 0249 // Test hashing 0250 Incidence::List incidences = cal->incidences(); 0251 QVERIFY(incidences.count() == 2); 0252 0253 QDateTime newRecId = start.addDays(2); 0254 Incidence::Ptr main = cal->incidence(uid); 0255 Incidence::Ptr exception = cal->incidence(uid, newRecId); 0256 Incidence::Ptr noException = cal->incidence(uid, recurrenceId); 0257 QVERIFY(!noException); 0258 QVERIFY(main); 0259 QVERIFY(exception); 0260 QVERIFY(exception->recurrenceId() == newRecId); 0261 QVERIFY(exception->summary() == QLatin1String("exception")); 0262 QVERIFY(main->summary() == event1->summary()); 0263 } 0264 0265 void MemoryCalendarTest::testRawEventsForDate() 0266 { 0267 // We're checking that events at a date in a given time zone 0268 // are properly returned for the day after / before if 0269 // the calendar is for another time zone. 0270 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0271 0272 Event::Ptr event = Event::Ptr(new Event()); 0273 event->setDtStart(QDateTime(QDate(2019, 10, 29), QTime(1, 30), QTimeZone("Asia/Ho_Chi_Minh"))); 0274 0275 QVERIFY(cal->addEvent(event)); 0276 0277 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 28)).count(), 1); 0278 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 29), QTimeZone("Asia/Ho_Chi_Minh")).count(), 1); 0279 0280 cal->setTimeZoneId("Asia/Ho_Chi_Minh"); 0281 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 29)).count(), 1); 0282 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 28), QTimeZone::utc()).count(), 1); 0283 0284 event->setDtStart(QDateTime(QDate(2019, 10, 30), QTime(23, 00), QTimeZone::utc())); 0285 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 31)).count(), 1); 0286 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 30), QTimeZone::utc()).count(), 1); 0287 0288 QVERIFY(cal->deleteIncidence(event)); 0289 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 31)).count(), 0); 0290 0291 // Multi-days events are treated differently. 0292 event->setDtEnd(QDateTime(QDate(2019, 10, 31), QTime(23, 00), QTimeZone::utc())); 0293 QVERIFY(cal->addEvent(event)); 0294 QCOMPARE(cal->rawEventsForDate(QDate(2019, 10, 31)).count(), 1); 0295 QCOMPARE(cal->rawEventsForDate(QDate(2019, 11, 1)).count(), 1); 0296 } 0297 0298 class TestCalendarObserver: public Calendar::CalendarObserver 0299 { 0300 public: 0301 TestCalendarObserver(const Calendar::Ptr &cal) 0302 : mCalendar(cal) 0303 { 0304 cal->registerObserver(this); 0305 } 0306 ~TestCalendarObserver() 0307 { 0308 mCalendar->unregisterObserver(this); 0309 } 0310 void calendarIncidenceChanged(const Incidence::Ptr &incidence) override 0311 { 0312 mUpdated.append(incidence); 0313 } 0314 bool hasIncidenceChanged(const Incidence::Ptr &incidence) const 0315 { 0316 return std::find_if(mUpdated.constBegin(), mUpdated.constEnd(), 0317 [incidence] (const Incidence::Ptr &it) { 0318 return (it->uid() == incidence->uid() 0319 && it->recurrenceId() == incidence->recurrenceId()); 0320 }) != mUpdated.constEnd(); 0321 } 0322 Incidence::List mUpdated; 0323 private: 0324 Calendar::Ptr mCalendar; 0325 }; 0326 0327 void MemoryCalendarTest::testRawEvents() 0328 { 0329 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0330 0331 Event::Ptr event = Event::Ptr(new Event()); 0332 // This event span in 20201011T2330Z - 20201012T2330Z 0333 event->setDtStart(QDateTime(QDate(2020, 10, 12), QTime(1, 30), QTimeZone("Europe/Paris"))); 0334 event->setDtEnd(QDateTime(QDate(2020, 10, 13), QTime(1, 30), QTimeZone("Europe/Paris"))); 0335 0336 QVERIFY(cal->addEvent(event)); 0337 0338 // Not full-event inclusive by default, UTC timezone. 0339 QCOMPARE(cal->rawEvents(QDate(2020, 10, 1), QDate(2020, 10, 10)).count(), 0); 0340 QCOMPARE(cal->rawEvents(QDate(2020, 10, 11), QDate(2020, 10, 11)).count(), 1); 0341 QCOMPARE(cal->rawEvents(QDate(2020, 10, 12), QDate(2020, 10, 12)).count(), 1); 0342 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate(2020, 10, 31)).count(), 0); 0343 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 10)).count(), 0); 0344 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 11)).count(), 1); 0345 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate()).count(), 0); 0346 QCOMPARE(cal->rawEvents(QDate(2020, 10, 12), QDate()).count(), 1); 0347 0348 // Changing the time zone we are considering the dates in. 0349 QCOMPARE(cal->rawEvents(QDate(2020, 10, 1), QDate(2020, 10, 11), QTimeZone("Europe/Paris")).count(), 0); 0350 QCOMPARE(cal->rawEvents(QDate(2020, 10, 12), QDate(2020, 10, 12), QTimeZone("Europe/Paris")).count(), 1); 0351 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate(2020, 10, 13), QTimeZone("Europe/Paris")).count(), 1); 0352 QCOMPARE(cal->rawEvents(QDate(2020, 10, 14), QDate(2020, 10, 31), QTimeZone("Europe/Paris")).count(), 0); 0353 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 11), QTimeZone("Europe/Paris")).count(), 0); 0354 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 12), QTimeZone("Europe/Paris")).count(), 1); 0355 QCOMPARE(cal->rawEvents(QDate(2020, 10, 14), QDate(), QTimeZone("Europe/Paris")).count(), 0); 0356 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate(), QTimeZone("Europe/Paris")).count(), 1); 0357 0358 // Full event must be in the span. 0359 QCOMPARE(cal->rawEvents(QDate(2020, 10, 1), QDate(2020, 10, 10), QTimeZone(), true).count(), 0); 0360 QCOMPARE(cal->rawEvents(QDate(2020, 10, 11), QDate(2020, 10, 11), QTimeZone(), true).count(), 0); 0361 QCOMPARE(cal->rawEvents(QDate(2020, 10, 12), QDate(2020, 10, 12), QTimeZone(), true).count(), 0); 0362 QCOMPARE(cal->rawEvents(QDate(2020, 10, 11), QDate(2020, 10, 12), QTimeZone(), true).count(), 1); 0363 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate(2020, 10, 31), QTimeZone(), true).count(), 0); 0364 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 10), QTimeZone(), true).count(), 0); 0365 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 11), QTimeZone(), true).count(), 0); 0366 QCOMPARE(cal->rawEvents(QDate(), QDate(2020, 10, 12), QTimeZone(), true).count(), 1); 0367 QCOMPARE(cal->rawEvents(QDate(2020, 10, 13), QDate(), QTimeZone(), true).count(), 0); 0368 QCOMPARE(cal->rawEvents(QDate(2020, 10, 12), QDate(), QTimeZone(), true).count(), 0); 0369 QCOMPARE(cal->rawEvents(QDate(2020, 10, 11), QDate(), QTimeZone(), true).count(), 1); 0370 } 0371 0372 void MemoryCalendarTest::testDeleteIncidence() 0373 { 0374 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0375 0376 Event::Ptr event = Event::Ptr(new Event()); 0377 event->setDtStart(QDateTime(QDate(2021, 1, 4), QTime(10, 13), QTimeZone("Europe/Paris"))); 0378 0379 QVERIFY(cal->addEvent(event)); 0380 QVERIFY(cal->instance(event->instanceIdentifier())); 0381 0382 QVERIFY(cal->deleteIncidence(event)); 0383 QVERIFY(cal->instance(event->instanceIdentifier()).isNull()); 0384 0385 event->recurrence()->setDaily(1); 0386 event->recurrence()->setDuration(3); 0387 QVERIFY(cal->addEvent(event)); 0388 QVERIFY(cal->instance(event->instanceIdentifier())); 0389 0390 Event::Ptr exception = Event::Ptr(event->clone()); 0391 exception->recurrence()->clear(); 0392 exception->setRecurrenceId(event->dtStart().addDays(1)); 0393 exception->setDtStart(event->dtStart().addDays(1).addSecs(3600)); 0394 QVERIFY(cal->addEvent(exception)); 0395 QVERIFY(cal->instance(exception->instanceIdentifier())); 0396 0397 Event::Ptr exception2 = Event::Ptr(event->clone()); 0398 exception2->recurrence()->clear(); 0399 exception2->setRecurrenceId(event->dtStart().addDays(2)); 0400 exception2->setDtStart(event->dtStart().addDays(2).addSecs(-3600)); 0401 QVERIFY(cal->addEvent(exception2)); 0402 QVERIFY(cal->instance(exception2->instanceIdentifier())); 0403 0404 QVERIFY(cal->deleteIncidence(exception)); 0405 QVERIFY(cal->incidence(event->uid(), exception->recurrenceId()).isNull()); 0406 QVERIFY(!cal->deleteIncidence(exception)); 0407 QVERIFY(cal->incidence(event->uid(), exception2->recurrenceId())); 0408 QVERIFY(cal->incidence(event->uid())); 0409 0410 QVERIFY(cal->deleteIncidence(event)); 0411 QVERIFY(cal->incidence(event->uid(), exception2->recurrenceId()).isNull()); 0412 QVERIFY(cal->incidence(event->uid()).isNull()); 0413 } 0414 0415 void MemoryCalendarTest::testUpdateIncidence() 0416 { 0417 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0418 0419 const QDateTime dt(QDate(2021, 02, 25), QTime(14, 0), QTimeZone::UTC); 0420 Event::Ptr event(new Event()); 0421 event->setCreated(dt); 0422 event->setLastModified(dt); 0423 event->setDtStart(dt); 0424 event->setDtEnd(dt.addSecs(3600)); 0425 0426 // Adding event to cal, makes cal an observer of event. 0427 QVERIFY(cal->addIncidence(event)); 0428 QCOMPARE(cal->rawEventsForDate(dt.date(), dt.timeZone()).count(), 1); 0429 0430 QVERIFY(cal->updateLastModifiedOnChange()); 0431 0432 const QDateTime now = QDateTime::currentDateTimeUtc(); 0433 0434 // Any single modification is updating the lastModified field. 0435 event->setSummary(QString::fromLatin1("test")); 0436 QVERIFY(event->lastModified().secsTo(now) < 5); 0437 0438 // Reset lastModified field. 0439 event->setLastModified(dt); 0440 QCOMPARE(event->lastModified(), dt); 0441 0442 // Any modification within a startUpdates()/endUpdates() should not touch 0443 // lastModified field, before the changes are completed. 0444 event->startUpdates(); 0445 QVERIFY(cal->rawEventsForDate(dt.date(), dt.timeZone()).isEmpty()); 0446 event->setSummary(QString::fromLatin1("test again")); 0447 QCOMPARE(event->lastModified(), dt); 0448 event->endUpdates(); 0449 QVERIFY(event->lastModified().secsTo(now) < 5); 0450 QCOMPARE(cal->rawEventsForDate(dt.date(), dt.timeZone()).count(), 1); 0451 0452 // Reset lastModified field. 0453 event->setLastModified(dt); 0454 QCOMPARE(event->lastModified(), dt); 0455 0456 // Don't update lastModified on change. 0457 cal->setUpdateLastModifiedOnChange(false); 0458 event->setSummary(QString::fromLatin1("last test")); 0459 QCOMPARE(event->lastModified(), dt); 0460 } 0461 0462 #include "moc_testmemorycalendar.cpp"