Commit 27f6d544 authored by Damien Caliste's avatar Damien Caliste

Also clear notebook associations when closing a MemoryCalendar.

parent 6ed5fb3a
......@@ -18,6 +18,35 @@ QTEST_MAIN(MemoryCalendarTest)
using namespace KCalendarCore;
void MemoryCalendarTest::testClose()
{
MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc()));
Event::Ptr event1(new Event);
cal->addIncidence(event1);
const QString nbuid = QString::fromLatin1("test-notebook");
QVERIFY(cal->addNotebook(nbuid, true));
Event::Ptr event2(new Event);
cal->addIncidence(event2);
cal->setNotebook(event2, nbuid);
QCOMPARE(cal->incidences().count(), 2);
QVERIFY(cal->instance(event1->instanceIdentifier()));
QVERIFY(cal->instance(event2->instanceIdentifier()));
QVERIFY(cal->event(event1->uid()));
QVERIFY(cal->event(event2->uid()));
QCOMPARE(cal->incidences(nbuid).count(), 1);
cal->close();
QVERIFY(!cal->event(event1->uid()));
QVERIFY(!cal->event(event2->uid()));
QVERIFY(cal->incidences().isEmpty());
QVERIFY(cal->incidences(nbuid).isEmpty());
}
void MemoryCalendarTest::testValidity()
{
MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc()));
......
......@@ -15,6 +15,7 @@ class MemoryCalendarTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testClose();
void testValidity();
void testInvalidTimeZone();
void testEvents();
......
......@@ -196,6 +196,8 @@ void MemoryCalendar::close()
table.clear();
}
clearNotebookAssociations();
setModified(false);
setObserversEnabled(true);
......
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