Changeset View
Changeset View
Standalone View
Standalone View
tests/units/akonadi/akonadiserializertest.cpp
Show First 20 Lines • Show All 898 Lines • ▼ Show 20 Line(s) | 896 | { | |||
---|---|---|---|---|---|
899 | // Data... | 899 | // Data... | ||
900 | const QDate today(QDate::currentDate()); | 900 | const QDate today(QDate::currentDate()); | ||
901 | const QDate doneDate(2013, 11, 20); | 901 | const QDate doneDate(2013, 11, 20); | ||
902 | const QDate startDate(2013, 11, 10); | 902 | const QDate startDate(2013, 11, 10); | ||
903 | 903 | | |||
904 | // ... stored in a todo... | 904 | // ... stored in a todo... | ||
905 | KCalCore::Todo::Ptr todo(new KCalCore::Todo); | 905 | KCalCore::Todo::Ptr todo(new KCalCore::Todo); | ||
906 | todo->setSummary(QStringLiteral("summary")); | 906 | todo->setSummary(QStringLiteral("summary")); | ||
907 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | | |||
908 | todo->setDtStart(QDateTime(startDate)); | 907 | todo->setDtStart(QDateTime(startDate)); | ||
909 | #else | | |||
910 | todo->setDtStart(KDateTime(startDate, KDateTime::UTC)); | | |||
911 | #endif | | |||
912 | todo->recurrence()->setMonthly(1); | 908 | todo->recurrence()->setMonthly(1); | ||
913 | 909 | | |||
914 | // ... as payload of an item... | 910 | // ... as payload of an item... | ||
915 | Akonadi::Item item; | 911 | Akonadi::Item item; | ||
916 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | 912 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | ||
917 | item.setPayload<KCalCore::Todo::Ptr>(todo); | 913 | item.setPayload<KCalCore::Todo::Ptr>(todo); | ||
918 | 914 | | |||
919 | // ... deserialized as a task | 915 | // ... deserialized as a task | ||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 1175 | { | |||
1234 | if (parentCollectionId > 0) { | 1230 | if (parentCollectionId > 0) { | ||
1235 | QCOMPARE(item.parentCollection().id(), parentCollectionId); | 1231 | QCOMPARE(item.parentCollection().id(), parentCollectionId); | ||
1236 | } | 1232 | } | ||
1237 | 1233 | | |||
1238 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | 1234 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | ||
1239 | QCOMPARE(todo->summary(), summary); | 1235 | QCOMPARE(todo->summary(), summary); | ||
1240 | QCOMPARE(todo->description(), content); | 1236 | QCOMPARE(todo->description(), content); | ||
1241 | QCOMPARE(todo->isCompleted(), isDone); | 1237 | QCOMPARE(todo->isCompleted(), isDone); | ||
1242 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | | |||
1243 | QCOMPARE(todo->completed().toLocalTime().date(), doneDate); | 1238 | QCOMPARE(todo->completed().toLocalTime().date(), doneDate); | ||
1244 | QCOMPARE(todo->dtStart().toLocalTime().date(), startDate); | 1239 | QCOMPARE(todo->dtStart().toLocalTime().date(), startDate); | ||
1245 | QCOMPARE(todo->dtDue().toLocalTime().date(), dueDate); | 1240 | QCOMPARE(todo->dtDue().toLocalTime().date(), dueDate); | ||
1246 | if (todo->dtStart().isValid()) { | 1241 | if (todo->dtStart().isValid()) { | ||
1247 | QCOMPARE(int(todo->dtStart().timeSpec()), int(Qt::LocalTime)); | 1242 | QCOMPARE(int(todo->dtStart().timeSpec()), int(Qt::LocalTime)); | ||
1248 | } | 1243 | } | ||
1249 | QVERIFY(todo->allDay()); // this is always true currently... | 1244 | QVERIFY(todo->allDay()); // this is always true currently... | ||
1250 | #else | | |||
1251 | QCOMPARE(todo->completed().dateTime().date(), doneDate); | | |||
1252 | QCOMPARE(todo->dtStart().dateTime().date(), startDate); | | |||
1253 | QCOMPARE(todo->dtDue().dateTime().date(), dueDate); | | |||
1254 | if (todo->dtStart().isValid()) { | | |||
1255 | QCOMPARE(int(todo->dtStart().timeType()), int(KDateTime::LocalTime)); | | |||
1256 | } | | |||
1257 | QCOMPARE(todo->dtStart().isDateOnly(), todo->allDay()); | | |||
1258 | | ||||
1259 | #endif | | |||
1260 | const ushort expectedRecurrence = recurrence == Domain::Task::NoRecurrence ? KCalCore::Recurrence::rNone | 1245 | const ushort expectedRecurrence = recurrence == Domain::Task::NoRecurrence ? KCalCore::Recurrence::rNone | ||
1261 | : recurrence == Domain::Task::RecursDaily ? KCalCore::Recurrence::rDaily | 1246 | : recurrence == Domain::Task::RecursDaily ? KCalCore::Recurrence::rDaily | ||
1262 | : recurrence == Domain::Task::RecursWeekly ? KCalCore::Recurrence::rWeekly | 1247 | : recurrence == Domain::Task::RecursWeekly ? KCalCore::Recurrence::rWeekly | ||
1263 | : recurrence == Domain::Task::RecursMonthly ? KCalCore::Recurrence::rMonthlyDay | 1248 | : recurrence == Domain::Task::RecursMonthly ? KCalCore::Recurrence::rMonthlyDay | ||
1264 | : KCalCore::Recurrence::rNone; // Shouldn't happen though | 1249 | : KCalCore::Recurrence::rNone; // Shouldn't happen though | ||
1265 | QCOMPARE(todo->recurrence()->recurrenceType(), expectedRecurrence); | 1250 | QCOMPARE(todo->recurrence()->recurrenceType(), expectedRecurrence); | ||
1266 | if (recurrence != Domain::Task::NoRecurrence) | 1251 | if (recurrence != Domain::Task::NoRecurrence) | ||
1267 | QCOMPARE(todo->recurrence()->frequency(), 1); | 1252 | QCOMPARE(todo->recurrence()->frequency(), 1); | ||
▲ Show 20 Lines • Show All 1415 Lines • Show Last 20 Lines |