void tst_storage::tst_rawEvents() { // TODO: Should split tests if making more cases outside storage auto event = KCalCore::Event::Ptr(new KCalCore::Event); // NOTE: no other events should be made happening this day QDate startDate(2010, 12, 1); event->setDtStart(KDateTime(startDate, QTime(12, 0), KDateTime::ClockTime)); event->setDtEnd(KDateTime(startDate, QTime(13, 0), KDateTime::ClockTime)); KCalCore::Recurrence *recurrence = event->recurrence(); recurrence->setDaily(1); recurrence->setStartDateTime(event->dtStart()); m_calendar->addEvent(event, NotebookId); m_storage->save(); QString uid = event->uid(); reloadDb(); auto fetchEvent = m_calendar->event(uid); QVERIFY(fetchEvent); KCalCore::Recurrence *fetchRecurrence = fetchEvent->recurrence(); QVERIFY(fetchRecurrence); // should return occurrence for both days mKCal::ExtendedCalendar::ExpandedIncidenceList events = m_calendar->rawExpandedEvents(startDate, startDate.addDays(1), false, false, KDateTime::Spec(KDateTime::LocalZone)); QCOMPARE(events.size(), 2); }
void tst_storage::tst_allday() { auto event = KCalCore::Event::Ptr(new KCalCore::Event); QFETCH(QDate, startDate); QFETCH(int, days); event->setDtStart(KDateTime(startDate, QTime(), KDateTime::ClockTime)); event->setAllDay(true); if (days) { event->setDtEnd(KDateTime(startDate.addDays(days), QTime(), KDateTime::ClockTime)); } event->setSummary("test event"); QCOMPARE(event->allDay(), true); QCOMPARE(event->dtStart().date(), startDate); if (days) { QCOMPARE(event->dateEnd(), startDate.addDays(days)); QCOMPARE(event->hasEndDate(), true); QVERIFY(event->dateEnd() > event->dtStart().date()); } else { QCOMPARE(event->dateEnd(), startDate); QCOMPARE(event->hasEndDate(), false); } m_calendar->addEvent(event, NotebookId); m_storage->save(); QString uid = event->uid(); reloadDb(); auto fetchedEvent = m_calendar->event(uid); QVERIFY(fetchedEvent.data()); QCOMPARE(fetchedEvent->allDay(), true); QCOMPARE(fetchedEvent->dtStart().date(), startDate); QTime time = fetchedEvent->dtStart().time(); QVERIFY(time == QTime() || time == QTime(0, 0)); QTime localTime = fetchedEvent->dtStart().toLocalZone().time(); QVERIFY(localTime == QTime() || localTime == QTime(0, 0)); if (days) { QCOMPARE(fetchedEvent->dateEnd(), startDate.addDays(days)); QCOMPARE(fetchedEvent->hasEndDate(), true); QVERIFY(event->dateEnd() > event->dtStart().date()); } else { QCOMPARE(fetchedEvent->dateEnd(), startDate); QCOMPARE(fetchedEvent->hasEndDate(), false); } }
static SwdbPrivate::TransactionPtr initTransSecond(SQLite3Ptr conn) { // create the second transaction auto second = std::make_shared< SwdbPrivate::Transaction >(conn); second->setDtBegin(3); second->setDtEnd(4); second->setRpmdbVersionBegin("begin 2"); second->setRpmdbVersionEnd("end 2"); second->setUserId(1001); second->setCmdline("dnf install bar"); auto rpmRpm = std::make_shared< RPMItem >(conn); rpmRpm->setName("rpm"); rpmRpm->setEpoch(0); rpmRpm->setVersion("4.14.0"); rpmRpm->setRelease("2.fc26"); rpmRpm->setArch("x86_64"); rpmRpm->save(); second->addSoftwarePerformedWith(rpmRpm); return second; }
static SwdbPrivate::TransactionPtr initTransFirst(SQLite3Ptr conn) { // create the first transaction auto first = std::make_shared< SwdbPrivate::Transaction >(conn); first->setDtBegin(1); first->setDtEnd(2); first->setRpmdbVersionBegin("begin 1"); first->setRpmdbVersionEnd("end 1"); first->setUserId(1000); first->setCmdline("dnf install foo"); auto dnfRpm = std::make_shared< RPMItem >(conn); dnfRpm->setName("dnf"); dnfRpm->setEpoch(0); dnfRpm->setVersion("3.0.0"); dnfRpm->setRelease("2.fc26"); dnfRpm->setArch("x86_64"); dnfRpm->save(); first->addSoftwarePerformedWith(dnfRpm); return first; }