Commit a768baaa authored by pvuorela's avatar pvuorela

Merge branch 'fixup' into 'master'

Correct unit tests and a minor optimisation

See merge request !83
parents 2537ef47 2b687ee4
......@@ -118,9 +118,13 @@ void CalendarWorker::storageFinished(mKCal::ExtendedStorage *storage, bool error
void CalendarWorker::deleteEvent(const QString &uid, const QDateTime &recurrenceId, const QDateTime &dateTime)
{
KCalendarCore::Event::Ptr event = mCalendar->event(uid, recurrenceId);
if (!event)
if (!event && mStorage->load(uid, recurrenceId)) {
event = mCalendar->event(uid, recurrenceId);
}
if (!event) {
qDebug() << uid << "event already deleted from DB";
return;
}
if (event->recurs() && dateTime.isValid()) {
// We're deleting an occurrence from a recurring event.
......@@ -137,8 +141,11 @@ void CalendarWorker::deleteEvent(const QString &uid, const QDateTime &recurrence
void CalendarWorker::deleteAll(const QString &uid)
{
KCalendarCore::Event::Ptr event = mCalendar->event(uid);
if (!event && mStorage->loadSeries(uid)) {
event = mCalendar->event(uid);
}
if (!event) {
qWarning() << "Failed to delete event, not found" << uid;
qDebug() << uid << "event already deleted from DB";
return;
}
......@@ -813,9 +820,8 @@ void CalendarWorker::loadData(const QList<CalendarData::Range> &ranges,
continue;
}
CalendarData::Event event = createEventStruct(e, notebook);
if (!mSentEvents.contains(event.uniqueId, event.recurrenceId)) {
if (!mSentEvents.contains(e->uid(), e->recurrenceId())) {
CalendarData::Event event = createEventStruct(e, notebook);
mSentEvents.insert(event.uniqueId, event.recurrenceId);
events.insert(event.uniqueId, event);
if (event.allDay)
......
......@@ -80,6 +80,8 @@ void tst_CalendarEvent::initTestCase()
// Ensure a default notebook exists for saving new events
CalendarManager *manager = CalendarManager::instance();
// Need to wait for the notebooks to be loaded from worker;
QTest::qWait(1000);
if (manager->defaultNotebook().isEmpty()) {
manager->setDefaultNotebook(manager->notebooks().value(0).uid);
}
......@@ -458,7 +460,7 @@ void tst_CalendarEvent::testRecurrenceException()
}
QVERIFY(modificationFound);
// ensure all gone
// ensure all gone, this emits two warning for not finding the two occurrences.
calendarApi->removeAll(uid);
mSavedEvents.remove(uid);
occurrence = CalendarManager::instance()->getNextOccurrence(uid, QDateTime(), startTime.addDays(-1));
......@@ -489,6 +491,9 @@ bool tst_CalendarEvent::saveEvent(CalendarEventModification *eventMod, QString *
return false;
}
if (eventMod->calendarUid().isEmpty()) {
eventMod->setCalendarUid(CalendarManager::instance()->defaultNotebook());
}
eventMod->save();
for (int i = 0; i < 30; i++) {
if (agendaModel.count() > count)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment