Changeset View
Changeset View
Standalone View
Standalone View
tests/units/akonadi/akonadiserializertest.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 77 | { | |||
---|---|---|---|---|---|
94 | 94 | | |||
95 | // WHEN | 95 | // WHEN | ||
96 | object->setProperty("itemId", 43); | 96 | object->setProperty("itemId", 43); | ||
97 | 97 | | |||
98 | // THEN | 98 | // THEN | ||
99 | QVERIFY(!serializer.representsItem(object, item)); | 99 | QVERIFY(!serializer.representsItem(object, item)); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | void shouldKnowWhenAnAkonadiTagRepresentsATag() | | |||
103 | { | | |||
104 | // GIVEN | | |||
105 | Akonadi::Serializer serializer; | | |||
106 | Akonadi::Tag akondiTag(42); | | |||
107 | auto tag = Domain::Tag::Ptr::create(); | | |||
108 | | ||||
109 | // WHEN | | |||
110 | // Nothing yet | | |||
111 | // THEN | | |||
112 | QVERIFY(!serializer.representsAkonadiTag(tag, akondiTag)); | | |||
113 | | ||||
114 | // WHEN | | |||
115 | tag->setProperty("tagId", 42); | | |||
116 | | ||||
117 | // THEN | | |||
118 | QVERIFY(serializer.representsAkonadiTag(tag, akondiTag)); | | |||
119 | | ||||
120 | // WHEN | | |||
121 | tag->setProperty("tagId", 43); | | |||
122 | | ||||
123 | // THEN | | |||
124 | QVERIFY(!serializer.representsAkonadiTag(tag, akondiTag)); | | |||
125 | } | | |||
126 | | ||||
127 | void shouldKnowTaskItemUid_data() | 102 | void shouldKnowTaskItemUid_data() | ||
128 | { | 103 | { | ||
129 | QTest::addColumn<Akonadi::Item>("item"); | 104 | QTest::addColumn<Akonadi::Item>("item"); | ||
130 | QTest::addColumn<QString>("expectedUid"); | 105 | QTest::addColumn<QString>("expectedUid"); | ||
131 | 106 | | |||
132 | Akonadi::Item item1; | 107 | Akonadi::Item item1; | ||
133 | KCalCore::Todo::Ptr todo1(new KCalCore::Todo); | 108 | KCalCore::Todo::Ptr todo1(new KCalCore::Todo); | ||
134 | todo1->setUid(QString()); | 109 | todo1->setUid(QString()); | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 170 | { | |||
198 | // Data... | 173 | // Data... | ||
199 | QFETCH(QString, name); | 174 | QFETCH(QString, name); | ||
200 | QFETCH(QString, iconName); | 175 | QFETCH(QString, iconName); | ||
201 | QFETCH(QStringList, mimeTypes); | 176 | QFETCH(QStringList, mimeTypes); | ||
202 | QFETCH(bool, hasSelectedAttribute); | 177 | QFETCH(bool, hasSelectedAttribute); | ||
203 | QFETCH(bool, isSelected); | 178 | QFETCH(bool, isSelected); | ||
204 | 179 | | |||
205 | Domain::DataSource::ContentTypes expectedContentTypes; | 180 | Domain::DataSource::ContentTypes expectedContentTypes; | ||
206 | if (mimeTypes.contains(QStringLiteral("text/x-vnd.akonadi.note"))) { | | |||
207 | expectedContentTypes |= Domain::DataSource::Notes; | | |||
208 | } | | |||
209 | if (mimeTypes.contains(QStringLiteral("application/x-vnd.akonadi.calendar.todo"))) { | 181 | if (mimeTypes.contains(QStringLiteral("application/x-vnd.akonadi.calendar.todo"))) { | ||
210 | expectedContentTypes |= Domain::DataSource::Tasks; | 182 | expectedContentTypes |= Domain::DataSource::Tasks; | ||
211 | } | 183 | } | ||
212 | 184 | | |||
213 | // ... stored in a collection | 185 | // ... stored in a collection | ||
214 | Akonadi::Collection collection(42); | 186 | Akonadi::Collection collection(42); | ||
215 | collection.setContentMimeTypes(mimeTypes); | 187 | collection.setContentMimeTypes(mimeTypes); | ||
216 | collection.setName(name); | 188 | collection.setName(name); | ||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Line(s) | |||||
407 | 379 | | |||
408 | void shouldVerifyIfCollectionIsSelected_data() | 380 | void shouldVerifyIfCollectionIsSelected_data() | ||
409 | { | 381 | { | ||
410 | QTest::addColumn<QStringList>("mimeTypes"); | 382 | QTest::addColumn<QStringList>("mimeTypes"); | ||
411 | QTest::addColumn<bool>("hasSelectedAttribute"); | 383 | QTest::addColumn<bool>("hasSelectedAttribute"); | ||
412 | QTest::addColumn<bool>("isSelected"); | 384 | QTest::addColumn<bool>("isSelected"); | ||
413 | QTest::addColumn<bool>("expectedSelected"); | 385 | QTest::addColumn<bool>("expectedSelected"); | ||
414 | 386 | | |||
415 | const auto noteMimeTypes = QStringList() << QStringLiteral("text/x-vnd.akonadi.note"); | | |||
416 | const auto taskMimeTypes = QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.todo"); | 387 | const auto taskMimeTypes = QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.todo"); | ||
417 | const auto bogusMimeTypes = QStringList() << QStringLiteral("foo/bar"); | 388 | const auto bogusMimeTypes = QStringList() << QStringLiteral("foo/bar"); | ||
418 | const auto allMimeTypes = noteMimeTypes + taskMimeTypes + bogusMimeTypes; | 389 | const auto allMimeTypes = taskMimeTypes + bogusMimeTypes; | ||
419 | 390 | | |||
420 | QTest::newRow("nominal case") << allMimeTypes << true << false << false; | 391 | QTest::newRow("nominal case") << allMimeTypes << true << false << false; | ||
421 | 392 | | |||
422 | QTest::newRow("only notes") << noteMimeTypes << true << false << false; | | |||
423 | QTest::newRow("only tasks") << taskMimeTypes << true << false << false; | 393 | QTest::newRow("only tasks") << taskMimeTypes << true << false << false; | ||
424 | QTest::newRow("only bogus") << bogusMimeTypes << true << false << false; | 394 | QTest::newRow("only bogus") << bogusMimeTypes << true << false << false; | ||
425 | 395 | | |||
426 | QTest::newRow("selected, only notes") << noteMimeTypes << true << true << true; | | |||
427 | QTest::newRow("selected, only tasks") << taskMimeTypes << true << true << true; | 396 | QTest::newRow("selected, only tasks") << taskMimeTypes << true << true << true; | ||
428 | QTest::newRow("selected, only bogus") << bogusMimeTypes << true << true << false; | 397 | QTest::newRow("selected, only bogus") << bogusMimeTypes << true << true << false; | ||
429 | 398 | | |||
430 | QTest::newRow("no selected attribute") << allMimeTypes << false << false << true; | 399 | QTest::newRow("no selected attribute") << allMimeTypes << false << false << true; | ||
431 | QTest::newRow("selected attribute (false)") << allMimeTypes << true << false << false; | 400 | QTest::newRow("selected attribute (false)") << allMimeTypes << true << false << false; | ||
432 | QTest::newRow("selected attribute (true)") << allMimeTypes << true << true << true; | 401 | QTest::newRow("selected attribute (true)") << allMimeTypes << true << true << true; | ||
433 | 402 | | |||
434 | QTest::newRow("empty case") << QStringList() << false << false << false; | 403 | QTest::newRow("empty case") << QStringList() << false << false << false; | ||
Show All 29 Lines | 407 | { | |||
464 | // THEN | 433 | // THEN | ||
465 | QFETCH(bool, expectedSelected); | 434 | QFETCH(bool, expectedSelected); | ||
466 | QCOMPARE(serializer.isSelectedCollection(collection), expectedSelected); | 435 | QCOMPARE(serializer.isSelectedCollection(collection), expectedSelected); | ||
467 | } | 436 | } | ||
468 | 437 | | |||
469 | void shouldVerifyCollectionContents_data() | 438 | void shouldVerifyCollectionContents_data() | ||
470 | { | 439 | { | ||
471 | QTest::addColumn<QString>("mimeType"); | 440 | QTest::addColumn<QString>("mimeType"); | ||
472 | QTest::addColumn<bool>("expectedNotes"); | | |||
473 | QTest::addColumn<bool>("expectedTasks"); | 441 | QTest::addColumn<bool>("expectedTasks"); | ||
474 | 442 | | |||
475 | QTest::newRow("task collection") << "application/x-vnd.akonadi.calendar.todo" << false << true; | 443 | QTest::newRow("task collection") << "application/x-vnd.akonadi.calendar.todo" << true; | ||
476 | QTest::newRow("note collection") << "text/x-vnd.akonadi.note" << true << false; | 444 | QTest::newRow("note collection") << "text/x-vnd.akonadi.note" << false; | ||
477 | } | 445 | } | ||
478 | 446 | | |||
479 | void shouldVerifyCollectionContents() | 447 | void shouldVerifyCollectionContents() | ||
480 | { | 448 | { | ||
481 | // GIVEN | 449 | // GIVEN | ||
482 | 450 | | |||
483 | // Data... | 451 | // Data... | ||
484 | QFETCH(QString, mimeType); | 452 | QFETCH(QString, mimeType); | ||
485 | 453 | | |||
486 | // ... stored in a collection | 454 | // ... stored in a collection | ||
487 | Akonadi::Collection collection(42); | 455 | Akonadi::Collection collection(42); | ||
488 | collection.setContentMimeTypes(QStringList() << mimeType); | 456 | collection.setContentMimeTypes(QStringList() << mimeType); | ||
489 | 457 | | |||
490 | // WHEN | 458 | // WHEN | ||
491 | Akonadi::Serializer serializer; | 459 | Akonadi::Serializer serializer; | ||
492 | QFETCH(bool, expectedNotes); | | |||
493 | QFETCH(bool, expectedTasks); | 460 | QFETCH(bool, expectedTasks); | ||
494 | 461 | | |||
495 | // THEN | 462 | // THEN | ||
496 | QCOMPARE(serializer.isNoteCollection(collection), expectedNotes); | | |||
497 | QCOMPARE(serializer.isTaskCollection(collection), expectedTasks); | 463 | QCOMPARE(serializer.isTaskCollection(collection), expectedTasks); | ||
498 | } | 464 | } | ||
499 | 465 | | |||
500 | void shouldCreateTaskFromItem_data() | 466 | void shouldCreateTaskFromItem_data() | ||
501 | { | 467 | { | ||
502 | QTest::addColumn<QString>("summary"); | 468 | QTest::addColumn<QString>("summary"); | ||
503 | QTest::addColumn<QString>("content"); | 469 | QTest::addColumn<QString>("content"); | ||
504 | QTest::addColumn<bool>("isDone"); | 470 | QTest::addColumn<bool>("isDone"); | ||
▲ Show 20 Lines • Show All 793 Lines • ▼ Show 20 Line(s) | 1259 | { | |||
1298 | KCalCore::Todo::Ptr todo1(new KCalCore::Todo); | 1264 | KCalCore::Todo::Ptr todo1(new KCalCore::Todo); | ||
1299 | item1.setPayload<KCalCore::Todo::Ptr>(todo1); | 1265 | item1.setPayload<KCalCore::Todo::Ptr>(todo1); | ||
1300 | 1266 | | |||
1301 | Akonadi::Item item2; | 1267 | Akonadi::Item item2; | ||
1302 | KCalCore::Todo::Ptr todo2(new KCalCore::Todo); | 1268 | KCalCore::Todo::Ptr todo2(new KCalCore::Todo); | ||
1303 | todo2->setRelatedTo(QStringLiteral("1")); | 1269 | todo2->setRelatedTo(QStringLiteral("1")); | ||
1304 | item2.setPayload<KCalCore::Todo::Ptr>(todo2); | 1270 | item2.setPayload<KCalCore::Todo::Ptr>(todo2); | ||
1305 | 1271 | | |||
1306 | Akonadi::Item item3; | | |||
1307 | KMime::Message::Ptr message1(new KMime::Message); | | |||
1308 | message1->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); | | |||
1309 | message1->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); | | |||
1310 | item3.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1311 | item3.setPayload<KMime::Message::Ptr>(message1); | | |||
1312 | | ||||
1313 | Akonadi::Item item4; | | |||
1314 | KMime::Message::Ptr message2(new KMime::Message); | | |||
1315 | message2->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); | | |||
1316 | message2->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); | | |||
1317 | auto relatedHeader1 = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1318 | relatedHeader1->from7BitString("1"); | | |||
1319 | message2->appendHeader(relatedHeader1); | | |||
1320 | item4.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1321 | item4.setPayload<KMime::Message::Ptr>(message2); | | |||
1322 | | ||||
1323 | Akonadi::Item item5; | | |||
1324 | KMime::Message::Ptr message3(new KMime::Message); | | |||
1325 | message3->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); | | |||
1326 | message3->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); | | |||
1327 | auto relatedHeader2 = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1328 | message3->appendHeader(relatedHeader2); | | |||
1329 | item5.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1330 | item5.setPayload<KMime::Message::Ptr>(message3); | | |||
1331 | | ||||
1332 | QTest::newRow("task without related") << item1 << QString(); | 1272 | QTest::newRow("task without related") << item1 << QString(); | ||
1333 | QTest::newRow("task with related") << item2 << "1"; | 1273 | QTest::newRow("task with related") << item2 << "1"; | ||
1334 | QTest::newRow("note without related") << item3 << QString(); | | |||
1335 | QTest::newRow("note with related") << item4 << "1"; | | |||
1336 | QTest::newRow("note with empty related") << item5 << QString(); | | |||
1337 | } | 1274 | } | ||
1338 | 1275 | | |||
1339 | void shouldRetrieveRelatedUidFromItem() | 1276 | void shouldRetrieveRelatedUidFromItem() | ||
1340 | { | 1277 | { | ||
1341 | // GIVEN | 1278 | // GIVEN | ||
1342 | QFETCH(Akonadi::Item, item); | 1279 | QFETCH(Akonadi::Item, item); | ||
1343 | QFETCH(QString, expectedUid); | 1280 | QFETCH(QString, expectedUid); | ||
1344 | 1281 | | |||
Show All 12 Lines | 1291 | { | |||
1357 | QTest::addColumn<QString>("relatedUid"); | 1294 | QTest::addColumn<QString>("relatedUid"); | ||
1358 | 1295 | | |||
1359 | QTest::newRow("nominal case (no related)") << "A note title" << "A note content.\nWith two lines." << QString(); | 1296 | QTest::newRow("nominal case (no related)") << "A note title" << "A note content.\nWith two lines." << QString(); | ||
1360 | QTest::newRow("nominal case (with related)") << "A note title" << "A note content.\nWith two lines." << "parent-uid"; | 1297 | QTest::newRow("nominal case (with related)") << "A note title" << "A note content.\nWith two lines." << "parent-uid"; | ||
1361 | QTest::newRow("trailing new lines") << "A note title" << "Empty lines at the end.\n\n\n" << QString(); | 1298 | QTest::newRow("trailing new lines") << "A note title" << "Empty lines at the end.\n\n\n" << QString(); | ||
1362 | QTest::newRow("empty case") << QString() << QString() << QString(); | 1299 | QTest::newRow("empty case") << QString() << QString() << QString(); | ||
1363 | } | 1300 | } | ||
1364 | 1301 | | |||
1365 | void shouldCreateNoteFromItem() | | |||
1366 | { | | |||
1367 | // GIVEN | | |||
1368 | | ||||
1369 | // Data... | | |||
1370 | QFETCH(QString, title); | | |||
1371 | QFETCH(QString, text); | | |||
1372 | QFETCH(QString, relatedUid); | | |||
1373 | | ||||
1374 | // ... stored in a message... | | |||
1375 | KMime::Message::Ptr message(new KMime::Message); | | |||
1376 | message->subject(true)->fromUnicodeString(title, "utf-8"); | | |||
1377 | message->mainBodyPart()->fromUnicodeString(text); | | |||
1378 | | ||||
1379 | if (!relatedUid.isEmpty()) { | | |||
1380 | auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1381 | relatedHeader->from7BitString(relatedUid.toUtf8()); | | |||
1382 | message->appendHeader(relatedHeader); | | |||
1383 | } | | |||
1384 | | ||||
1385 | // ... as payload of an item. | | |||
1386 | Akonadi::Item item; | | |||
1387 | item.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1388 | item.setPayload<KMime::Message::Ptr>(message); | | |||
1389 | | ||||
1390 | // WHEN | | |||
1391 | Akonadi::Serializer serializer; | | |||
1392 | Domain::Note::Ptr note = serializer.createNoteFromItem(item); | | |||
1393 | auto artifact = serializer.createArtifactFromItem(item).dynamicCast<Domain::Note>(); | | |||
1394 | | ||||
1395 | // THEN | | |||
1396 | const auto expectedText = text.endsWith('\n') ? (text.chop(1), text) : text; | | |||
1397 | | ||||
1398 | QCOMPARE(note->title(), title); | | |||
1399 | QCOMPARE(note->text(), expectedText); | | |||
1400 | QCOMPARE(note->property("itemId").toLongLong(), item.id()); | | |||
1401 | QCOMPARE(note->property("relatedUid").toString(), relatedUid); | | |||
1402 | | ||||
1403 | QVERIFY(!artifact.isNull()); | | |||
1404 | QCOMPARE(artifact->title(), title); | | |||
1405 | QCOMPARE(artifact->text(), expectedText); | | |||
1406 | QCOMPARE(artifact->property("itemId").toLongLong(), item.id()); | | |||
1407 | QCOMPARE(artifact->property("relatedUid").toString(), relatedUid); | | |||
1408 | } | | |||
1409 | | ||||
1410 | void shouldCreateNullNoteFromInvalidItem() | | |||
1411 | { | | |||
1412 | // GIVEN | | |||
1413 | Akonadi::Item item; | | |||
1414 | | ||||
1415 | // WHEN | | |||
1416 | Akonadi::Serializer serializer; | | |||
1417 | Domain::Note::Ptr note = serializer.createNoteFromItem(item); | | |||
1418 | auto artifact = serializer.createArtifactFromItem(item); | | |||
1419 | | ||||
1420 | // THEN | | |||
1421 | QVERIFY(note.isNull()); | | |||
1422 | QVERIFY(artifact.isNull()); | | |||
1423 | } | | |||
1424 | | ||||
1425 | void shouldUpdateNoteFromItem_data() | | |||
1426 | { | | |||
1427 | QTest::addColumn<QString>("updatedTitle"); | | |||
1428 | QTest::addColumn<QString>("updatedText"); | | |||
1429 | QTest::addColumn<QString>("updatedRelatedUid"); | | |||
1430 | | ||||
1431 | QTest::newRow("no change") << "title" << "content" << "parent-uid"; | | |||
1432 | QTest::newRow("data changed (with related)") << "A new title" << "A new content" << "new-parent-uid"; | | |||
1433 | QTest::newRow("data changed (with no related)") << "A new title" << "A new content" << QString(); | | |||
1434 | } | | |||
1435 | | ||||
1436 | void shouldUpdateNoteFromItem() | | |||
1437 | { | | |||
1438 | // GIVEN | | |||
1439 | | ||||
1440 | // A message... | | |||
1441 | KMime::Message::Ptr message(new KMime::Message); | | |||
1442 | message->subject(true)->fromUnicodeString(QStringLiteral("title"), "utf-8"); | | |||
1443 | message->mainBodyPart()->fromUnicodeString(QStringLiteral("text")); | | |||
1444 | auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1445 | relatedHeader->from7BitString("parent-uid"); | | |||
1446 | message->appendHeader(relatedHeader); | | |||
1447 | | ||||
1448 | //... as the payload of an item... | | |||
1449 | Akonadi::Item item; | | |||
1450 | item.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1451 | item.setPayload<KMime::Message::Ptr>(message); | | |||
1452 | | ||||
1453 | //... deserialized as a note | | |||
1454 | Akonadi::Serializer serializer; | | |||
1455 | auto note = serializer.createNoteFromItem(item); | | |||
1456 | auto artifact = serializer.createNoteFromItem(item); | | |||
1457 | | ||||
1458 | // WHEN | | |||
1459 | | ||||
1460 | // Data... | | |||
1461 | QFETCH(QString, updatedTitle); | | |||
1462 | QFETCH(QString, updatedText); | | |||
1463 | QFETCH(QString, updatedRelatedUid); | | |||
1464 | | ||||
1465 | //... stored in a new message... | | |||
1466 | KMime::Message::Ptr updatedMessage(new KMime::Message); | | |||
1467 | updatedMessage->subject(true)->fromUnicodeString(updatedTitle, "utf-8"); | | |||
1468 | updatedMessage->mainBodyPart()->fromUnicodeString(updatedText); | | |||
1469 | | ||||
1470 | if (!updatedRelatedUid.isEmpty()) { | | |||
1471 | relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1472 | relatedHeader->from7BitString(updatedRelatedUid.toUtf8()); | | |||
1473 | updatedMessage->appendHeader(relatedHeader); | | |||
1474 | } | | |||
1475 | | ||||
1476 | //... as the payload of a new item... | | |||
1477 | Akonadi::Item updatedItem; | | |||
1478 | updatedItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1479 | updatedItem.setPayload<KMime::Message::Ptr>(updatedMessage); | | |||
1480 | | ||||
1481 | serializer.updateNoteFromItem(note, updatedItem); | | |||
1482 | serializer.updateArtifactFromItem(artifact, updatedItem); | | |||
1483 | | ||||
1484 | // THEN | | |||
1485 | QCOMPARE(note->title(), updatedTitle); | | |||
1486 | QCOMPARE(note->text(), updatedText); | | |||
1487 | QCOMPARE(note->property("itemId").toLongLong(), updatedItem.id()); | | |||
1488 | QCOMPARE(note->property("relatedUid").toString(), updatedRelatedUid); | | |||
1489 | | ||||
1490 | note = artifact.dynamicCast<Domain::Note>(); | | |||
1491 | QCOMPARE(note->title(), updatedTitle); | | |||
1492 | QCOMPARE(note->text(), updatedText); | | |||
1493 | QCOMPARE(note->property("itemId").toLongLong(), updatedItem.id()); | | |||
1494 | QCOMPARE(note->property("relatedUid").toString(), updatedRelatedUid); | | |||
1495 | } | | |||
1496 | | ||||
1497 | void shouldNotUpdateNoteFromInvalidItem() | | |||
1498 | { | | |||
1499 | // GIVEN | | |||
1500 | | ||||
1501 | // Data... | | |||
1502 | QString title = QStringLiteral("A title"); | | |||
1503 | QString text = QStringLiteral("A note content"); | | |||
1504 | | ||||
1505 | // ... stored in a message... | | |||
1506 | KMime::Message::Ptr message(new KMime::Message); | | |||
1507 | message->subject(true)->fromUnicodeString(title, "utf-8"); | | |||
1508 | message->mainBodyPart()->fromUnicodeString(text); | | |||
1509 | | ||||
1510 | //... as the payload of an item... | | |||
1511 | Akonadi::Item item; | | |||
1512 | item.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1513 | item.setPayload<KMime::Message::Ptr>(message); | | |||
1514 | | ||||
1515 | //... deserialized as a note | | |||
1516 | Akonadi::Serializer serializer; | | |||
1517 | auto note = serializer.createNoteFromItem(item); | | |||
1518 | auto artifact = serializer.createArtifactFromItem(item); | | |||
1519 | | ||||
1520 | // WHEN | | |||
1521 | Akonadi::Item invalidItem; | | |||
1522 | | ||||
1523 | serializer.updateNoteFromItem(note, invalidItem); | | |||
1524 | serializer.updateArtifactFromItem(artifact, invalidItem); | | |||
1525 | | ||||
1526 | //THEN | | |||
1527 | QCOMPARE(note->title(), title); | | |||
1528 | QCOMPARE(note->text(), text); | | |||
1529 | QCOMPARE(note->property("itemId").toLongLong(), item.id()); | | |||
1530 | | ||||
1531 | note = artifact.dynamicCast<Domain::Note>(); | | |||
1532 | QCOMPARE(note->title(), title); | | |||
1533 | QCOMPARE(note->text(), text); | | |||
1534 | QCOMPARE(note->property("itemId").toLongLong(), item.id()); | | |||
1535 | } | | |||
1536 | | ||||
1537 | void shouldCreateItemFromNote_data() | | |||
1538 | { | | |||
1539 | QTest::addColumn<QString>("title"); | | |||
1540 | QTest::addColumn<QString>("content"); | | |||
1541 | QTest::addColumn<QString>("expectedTitle"); | | |||
1542 | QTest::addColumn<QString>("expectedContent"); | | |||
1543 | QTest::addColumn<qint64>("itemId"); | | |||
1544 | QTest::addColumn<QString>("relatedUid"); | | |||
1545 | | ||||
1546 | QTest::newRow("nominal case (no id)") << "title" << "content" << "title" << "content" << qint64(-1) << QString(); | | |||
1547 | QTest::newRow("empty case (no id)") << QString() << QString() << "New Note" << QString() << qint64(-1) << QString(); | | |||
1548 | | ||||
1549 | QTest::newRow("nominal case (with id)") << "title" << "content" << "title" << "content" << qint64(42) << "parent-uid"; | | |||
1550 | QTest::newRow("empty case (with id)") << QString() << QString() << "New Note" << QString() << qint64(42) << "parent-uid"; | | |||
1551 | | ||||
1552 | QTest::newRow("empty line at the end") << "title" << "content\n\n\n" << "title" << "content\n\n\n" << qint64(-1) << QString(); | | |||
1553 | } | | |||
1554 | | ||||
1555 | void shouldCreateItemFromNote() | | |||
1556 | { | | |||
1557 | // GIVEN | | |||
1558 | | ||||
1559 | // Data... | | |||
1560 | QFETCH(QString, title); | | |||
1561 | QFETCH(QString, content); | | |||
1562 | QFETCH(qint64, itemId); | | |||
1563 | QFETCH(QString, relatedUid); | | |||
1564 | | ||||
1565 | // ... stored in a note | | |||
1566 | auto note = Domain::Note::Ptr::create(); | | |||
1567 | note->setTitle(title); | | |||
1568 | note->setText(content); | | |||
1569 | | ||||
1570 | if (itemId > 0) | | |||
1571 | note->setProperty("itemId", itemId); | | |||
1572 | | ||||
1573 | if (!relatedUid.isEmpty()) | | |||
1574 | note->setProperty("relatedUid", relatedUid); | | |||
1575 | | ||||
1576 | // WHEN | | |||
1577 | Akonadi::Serializer serializer; | | |||
1578 | auto item = serializer.createItemFromNote(note); | | |||
1579 | | ||||
1580 | // THEN | | |||
1581 | QCOMPARE(item.mimeType(), Akonadi::NoteUtils::noteMimeType()); | | |||
1582 | | ||||
1583 | QCOMPARE(item.isValid(), itemId > 0); | | |||
1584 | if (itemId > 0) { | | |||
1585 | QCOMPARE(item.id(), itemId); | | |||
1586 | } | | |||
1587 | | ||||
1588 | QFETCH(QString, expectedTitle); | | |||
1589 | QFETCH(QString, expectedContent); | | |||
1590 | auto message = item.payload<KMime::Message::Ptr>(); | | |||
1591 | QCOMPARE(message->subject(false)->asUnicodeString(), expectedTitle); | | |||
1592 | QCOMPARE(message->mainBodyPart()->decodedText(), expectedContent); | | |||
1593 | | ||||
1594 | if (relatedUid.isEmpty()) { | | |||
1595 | QVERIFY(!message->headerByType("X-Zanshin-RelatedProjectUid")); | | |||
1596 | } else { | | |||
1597 | QVERIFY(message->headerByType("X-Zanshin-RelatedProjectUid")); | | |||
1598 | QCOMPARE(message->headerByType("X-Zanshin-RelatedProjectUid")->asUnicodeString(), relatedUid); | | |||
1599 | } | | |||
1600 | } | | |||
1601 | | ||||
1602 | void shouldCreateProjectFromItem_data() | 1302 | void shouldCreateProjectFromItem_data() | ||
1603 | { | 1303 | { | ||
1604 | QTest::addColumn<QString>("summary"); | 1304 | QTest::addColumn<QString>("summary"); | ||
1605 | 1305 | | |||
1606 | QTest::newRow("nominal case") << "summary"; | 1306 | QTest::newRow("nominal case") << "summary"; | ||
1607 | QTest::newRow("empty case") << QString(); | 1307 | QTest::newRow("empty case") << QString(); | ||
1608 | } | 1308 | } | ||
1609 | 1309 | | |||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Line(s) | 1559 | { | |||
1880 | childTodo->setSummary(QStringLiteral("summary")); | 1580 | childTodo->setSummary(QStringLiteral("summary")); | ||
1881 | childTodo->setRelatedTo(QStringLiteral("1")); | 1581 | childTodo->setRelatedTo(QStringLiteral("1")); | ||
1882 | Akonadi::Item childTodoItem; | 1582 | Akonadi::Item childTodoItem; | ||
1883 | childTodoItem.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | 1583 | childTodoItem.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | ||
1884 | childTodoItem.setPayload<KCalCore::Todo::Ptr>(childTodo); | 1584 | childTodoItem.setPayload<KCalCore::Todo::Ptr>(childTodo); | ||
1885 | 1585 | | |||
1886 | QTest::newRow("child todo") << project << childTodoItem << true; | 1586 | QTest::newRow("child todo") << project << childTodoItem << true; | ||
1887 | 1587 | | |||
1888 | // Create unrelated note | | |||
1889 | KMime::Message::Ptr unrelatedNote(new KMime::Message); | | |||
1890 | unrelatedNote->subject(true)->fromUnicodeString(QStringLiteral("subject"), "utf-8"); | | |||
1891 | Akonadi::Item unrelatedNoteItem; | | |||
1892 | unrelatedNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1893 | unrelatedNoteItem.setPayload<KMime::Message::Ptr>(unrelatedNote); | | |||
1894 | | ||||
1895 | QTest::newRow("unrelated note") << project << unrelatedNoteItem << false; | | |||
1896 | | ||||
1897 | // Create child note | | |||
1898 | KMime::Message::Ptr childNote(new KMime::Message); | | |||
1899 | childNote->subject(true)->fromUnicodeString(QStringLiteral("subject"), "utf-8"); | | |||
1900 | auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); | | |||
1901 | relatedHeader->from7BitString("1"); | | |||
1902 | childNote->appendHeader(relatedHeader); | | |||
1903 | Akonadi::Item childNoteItem; | | |||
1904 | childNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); | | |||
1905 | childNoteItem.setPayload<KMime::Message::Ptr>(childNote); | | |||
1906 | | ||||
1907 | QTest::newRow("child todo") << project << childNoteItem << true; | | |||
1908 | | ||||
1909 | auto invalidProject = Domain::Project::Ptr::create(); | 1588 | auto invalidProject = Domain::Project::Ptr::create(); | ||
1910 | QTest::newRow("invalid project") << invalidProject << unrelatedNoteItem << false; | 1589 | QTest::newRow("invalid project") << invalidProject << unrelatedTodoItem << false; | ||
1911 | 1590 | | |||
1912 | Akonadi::Item invalidItem; | 1591 | Akonadi::Item invalidItem; | ||
1913 | QTest::newRow("invalid item") << project << invalidItem << false; | 1592 | QTest::newRow("invalid item") << project << invalidItem << false; | ||
1914 | 1593 | | |||
1915 | } | 1594 | } | ||
1916 | 1595 | | |||
1917 | void shouldVerifyIfAnItemIsAProjectChild() | 1596 | void shouldVerifyIfAnItemIsAProjectChild() | ||
1918 | { | 1597 | { | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 1653 | { | |||
1983 | auto parent = Domain::Project::Ptr::create(); | 1662 | auto parent = Domain::Project::Ptr::create(); | ||
1984 | parent->setProperty("todoUid", "1"); | 1663 | parent->setProperty("todoUid", "1"); | ||
1985 | 1664 | | |||
1986 | QTest::newRow("nominal todo case") << todoItem << parent << "1"; | 1665 | QTest::newRow("nominal todo case") << todoItem << parent << "1"; | ||
1987 | 1666 | | |||
1988 | auto invalidParent = Domain::Project::Ptr::create(); | 1667 | auto invalidParent = Domain::Project::Ptr::create(); | ||
1989 | QTest::newRow("update todo item with a empty parent uid") << todoItem << invalidParent << QString(); | 1668 | QTest::newRow("update todo item with a empty parent uid") << todoItem << invalidParent << QString(); | ||
1990 | 1669 | | |||
1991 | Akonadi::Item noteItem; | | |||
1992 | KMime::Message::Ptr note(new KMime::Message); | | |||
1993 | noteItem.setPayload<KMime::Message::Ptr>(note); | | |||
1994 | | ||||
1995 | QTest::newRow("nominal note case") << noteItem << parent << "1"; | | |||
1996 | QTest::newRow("update note item with a empty parent uid") << noteItem << invalidParent << QString(); | | |||
1997 | | ||||
1998 | Akonadi::Item invalidItem; | 1670 | Akonadi::Item invalidItem; | ||
1999 | QTest::newRow("update item without payload") << invalidItem << parent << QString(); | 1671 | QTest::newRow("update item without payload") << invalidItem << parent << QString(); | ||
2000 | } | 1672 | } | ||
2001 | 1673 | | |||
2002 | void shouldUpdateItemProject() | 1674 | void shouldUpdateItemProject() | ||
2003 | { | 1675 | { | ||
2004 | // GIVEN | 1676 | // GIVEN | ||
2005 | QFETCH(Akonadi::Item, item); | 1677 | QFETCH(Akonadi::Item, item); | ||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | 1989 | { | |||
2323 | // WHEN | 1995 | // WHEN | ||
2324 | Akonadi::Serializer serializer; | 1996 | Akonadi::Serializer serializer; | ||
2325 | bool value = serializer.isContextChild(context, item); | 1997 | bool value = serializer.isContextChild(context, item); | ||
2326 | 1998 | | |||
2327 | // THEN | 1999 | // THEN | ||
2328 | QCOMPARE(value, isChild); | 2000 | QCOMPARE(value, isChild); | ||
2329 | } | 2001 | } | ||
2330 | 2002 | | |||
2331 | void shouldCheckIfAnItemHasContextsOrTags_data() | 2003 | void shouldCheckIfAnItemHasContexts_data() | ||
2332 | { | 2004 | { | ||
2333 | QTest::addColumn<Akonadi::Item>("item"); | 2005 | QTest::addColumn<Akonadi::Item>("item"); | ||
2334 | QTest::addColumn<bool>("contextsExpected"); | 2006 | QTest::addColumn<bool>("contextsExpected"); | ||
2335 | QTest::addColumn<bool>("tagsExpected"); | | |||
2336 | 2007 | | |||
2337 | Akonadi::Tag unrelatedTag(QStringLiteral("Foo")); | 2008 | Akonadi::Tag unrelatedTag(QStringLiteral("Foo")); | ||
2338 | unrelatedTag.setType("unrelated"); | 2009 | unrelatedTag.setType("unrelated"); | ||
2339 | Akonadi::Tag contextTag(QStringLiteral("Bar")); | 2010 | Akonadi::Tag contextTag(QStringLiteral("Bar")); | ||
2340 | contextTag.setType(Akonadi::Serializer::contextTagType()); | 2011 | contextTag.setType(Akonadi::Serializer::contextTagType()); | ||
2341 | Akonadi::Tag akonadiTag(QStringLiteral("Baz")); | 2012 | Akonadi::Tag akonadiTag(QStringLiteral("Baz")); | ||
2342 | akonadiTag.setType(Akonadi::Tag::PLAIN); | 2013 | akonadiTag.setType(Akonadi::Tag::PLAIN); | ||
2343 | 2014 | | |||
2344 | Akonadi::Item item; | 2015 | Akonadi::Item item; | ||
2345 | QTest::newRow("no tags") << item << false << false; | 2016 | QTest::newRow("no tags") << item << false; | ||
2346 | 2017 | | |||
2347 | item.setTags({ unrelatedTag }); | 2018 | item.setTags({ unrelatedTag }); | ||
2348 | QTest::newRow("unrelated tags") << item << false << false; | 2019 | QTest::newRow("unrelated tags") << item << false; | ||
2349 | 2020 | | |||
2350 | item.setTags({ unrelatedTag, contextTag }); | 2021 | item.setTags({ unrelatedTag, contextTag }); | ||
2351 | QTest::newRow("has contexts") << item << true << false; | 2022 | QTest::newRow("has contexts") << item << true; | ||
2352 | 2023 | | |||
2353 | item.setTags({ unrelatedTag, akonadiTag }); | 2024 | item.setTags({ unrelatedTag, akonadiTag }); | ||
2354 | QTest::newRow("has tags") << item << false << true; | 2025 | QTest::newRow("has tags") << item << false; | ||
2355 | 2026 | | |||
2356 | item.setTags({ unrelatedTag, contextTag, akonadiTag }); | 2027 | item.setTags({ unrelatedTag, contextTag, akonadiTag }); | ||
2357 | QTest::newRow("has both") << item << true << true; | 2028 | QTest::newRow("has both") << item << true; | ||
2358 | } | 2029 | } | ||
2359 | 2030 | | |||
2360 | void shouldCheckIfAnItemHasContextsOrTags() | 2031 | void shouldCheckIfAnItemHasContexts() | ||
2361 | { | 2032 | { | ||
2362 | // GIVEN | 2033 | // GIVEN | ||
2363 | QFETCH(Akonadi::Item, item); | 2034 | QFETCH(Akonadi::Item, item); | ||
2364 | QFETCH(bool, contextsExpected); | 2035 | QFETCH(bool, contextsExpected); | ||
2365 | QFETCH(bool, tagsExpected); | | |||
2366 | 2036 | | |||
2367 | Akonadi::Serializer serializer; | 2037 | Akonadi::Serializer serializer; | ||
2368 | 2038 | | |||
2369 | // WHEN | 2039 | // WHEN | ||
2370 | const bool hasContexts = serializer.hasContextTags(item); | 2040 | const bool hasContexts = serializer.hasContextTags(item); | ||
2371 | const bool hasTags = serializer.hasAkonadiTags(item); | | |||
2372 | 2041 | | |||
2373 | // THEN | 2042 | // THEN | ||
2374 | QCOMPARE(hasContexts, contextsExpected); | 2043 | QCOMPARE(hasContexts, contextsExpected); | ||
2375 | QCOMPARE(hasTags, tagsExpected); | | |||
2376 | } | 2044 | } | ||
2377 | 2045 | | |||
2378 | void shouldCreateTagFromContext_data() | 2046 | void shouldCreateTagFromContext_data() | ||
2379 | { | 2047 | { | ||
2380 | QTest::addColumn<QString>("name"); | 2048 | QTest::addColumn<QString>("name"); | ||
2381 | QTest::addColumn<qint64>("tagId"); | 2049 | QTest::addColumn<qint64>("tagId"); | ||
2382 | QTest::addColumn<QByteArray>("tagGid"); | 2050 | QTest::addColumn<QByteArray>("tagGid"); | ||
2383 | 2051 | | |||
Show All 26 Lines | 2061 | { | |||
2410 | 2078 | | |||
2411 | if (tagId > 0) { | 2079 | if (tagId > 0) { | ||
2412 | QCOMPARE(tag.id(), tagId); | 2080 | QCOMPARE(tag.id(), tagId); | ||
2413 | QCOMPARE(tag.gid(), tagGid); | 2081 | QCOMPARE(tag.gid(), tagGid); | ||
2414 | QCOMPARE(tag.type(), Akonadi::SerializerInterface::contextTagType()); | 2082 | QCOMPARE(tag.type(), Akonadi::SerializerInterface::contextTagType()); | ||
2415 | } | 2083 | } | ||
2416 | } | 2084 | } | ||
2417 | 2085 | | |||
2418 | void shouldCreateTagFromAkonadiTag_data() | | |||
2419 | { | | |||
2420 | QTest::addColumn<QString>("name"); | | |||
2421 | QTest::addColumn<qint64>("tagId"); | | |||
2422 | QTest::addColumn<QByteArray>("type"); | | |||
2423 | | ||||
2424 | QString tagName = QStringLiteral("Optional"); | | |||
2425 | QByteArray plainType = Akonadi::Tag::PLAIN; | | |||
2426 | | ||||
2427 | QTest::newRow("nominal case") << tagName << qint64(42) << plainType; | | |||
2428 | QTest::newRow("null name case") << QString() << qint64(42) << plainType; | | |||
2429 | QTest::newRow("null tagId case") << tagName << qint64(-1) << plainType; | | |||
2430 | QTest::newRow("totally null tag case") << QString() << qint64(-1) << plainType; | | |||
2431 | } | | |||
2432 | | ||||
2433 | void shouldCreateTagFromAkonadiTag() | | |||
2434 | { | | |||
2435 | // GIVEN | | |||
2436 | QFETCH(QString, name); | | |||
2437 | QFETCH(qint64, tagId); | | |||
2438 | QFETCH(QByteArray, type); | | |||
2439 | | ||||
2440 | auto akonadiTag = Akonadi::Tag(); | | |||
2441 | akonadiTag.setName(name); | | |||
2442 | akonadiTag.setId(tagId); | | |||
2443 | akonadiTag.setType(type); | | |||
2444 | | ||||
2445 | // WHEN | | |||
2446 | Akonadi::Serializer serializer; | | |||
2447 | Domain::Tag::Ptr resultTag = serializer.createTagFromAkonadiTag(akonadiTag); | | |||
2448 | | ||||
2449 | // THEN | | |||
2450 | QCOMPARE(resultTag->name(), akonadiTag.name()); | | |||
2451 | QCOMPARE(resultTag->property("tagId").toLongLong(), akonadiTag.id()); | | |||
2452 | } | | |||
2453 | | ||||
2454 | void shouldUpdateTagFromAkonadiTag_data() | | |||
2455 | { | | |||
2456 | shouldCreateTagFromAkonadiTag_data(); | | |||
2457 | } | | |||
2458 | | ||||
2459 | void shouldUpdateTagFromAkonadiTag() | | |||
2460 | { | | |||
2461 | // GIVEN | | |||
2462 | QFETCH(QString, name); | | |||
2463 | QFETCH(qint64, tagId); | | |||
2464 | QFETCH(QByteArray, type); | | |||
2465 | | ||||
2466 | // ... stored as an Akonadi Tag | | |||
2467 | Akonadi::Tag akonadiTag(name); | | |||
2468 | akonadiTag.setId(tagId); | | |||
2469 | akonadiTag.setType(type); | | |||
2470 | | ||||
2471 | // WHEN | | |||
2472 | Akonadi::Serializer serializer; | | |||
2473 | auto tag = Domain::Tag::Ptr::create(); | | |||
2474 | tag->setName(QStringLiteral("tag42")); | | |||
2475 | | ||||
2476 | serializer.updateTagFromAkonadiTag(tag, akonadiTag); | | |||
2477 | | ||||
2478 | // THEN | | |||
2479 | QCOMPARE(tag->name(), akonadiTag.name()); | | |||
2480 | QCOMPARE(tag->property("tagId").toLongLong(), akonadiTag.id()); | | |||
2481 | } | | |||
2482 | | ||||
2483 | void shouldCreateAkonadiTagFromTag_data() | | |||
2484 | { | | |||
2485 | // GIVEN | | |||
2486 | QTest::addColumn<QString>("name"); | | |||
2487 | QTest::addColumn<qint64>("tagId"); | | |||
2488 | QTest::addColumn<QByteArray>("tagGid"); | | |||
2489 | | ||||
2490 | const QByteArray namePhilo = "Philosophy"; | | |||
2491 | | ||||
2492 | QTest::newRow("nominal case") << QString(namePhilo) << qint64(42) << namePhilo; | | |||
2493 | QTest::newRow("null name case") << QString() << qint64(42) << QByteArray(); | | |||
2494 | QTest::newRow("null tagId case") << QString(namePhilo) << qint64(-1) << namePhilo; | | |||
2495 | QTest::newRow("totally null tag case") << QString() << qint64(-1) << QByteArray(); | | |||
2496 | } | | |||
2497 | | ||||
2498 | void shouldCreateAkonadiTagFromTag() | | |||
2499 | { | | |||
2500 | // GIVEN | | |||
2501 | QFETCH(QString, name); | | |||
2502 | QFETCH(qint64, tagId); | | |||
2503 | QFETCH(QByteArray, tagGid); | | |||
2504 | | ||||
2505 | // WHEN | | |||
2506 | auto tag = Domain::Tag::Ptr::create(); | | |||
2507 | tag->setProperty("tagId", tagId); | | |||
2508 | tag->setName(name); | | |||
2509 | | ||||
2510 | Akonadi::Serializer serializer; | | |||
2511 | Akonadi::Tag akonadiTag = serializer.createAkonadiTagFromTag(tag); | | |||
2512 | | ||||
2513 | // THEN | | |||
2514 | QCOMPARE(akonadiTag.name(), name); | | |||
2515 | QCOMPARE(akonadiTag.isValid(), tagId > 0); | | |||
2516 | | ||||
2517 | if (tagId > 0) { | | |||
2518 | QCOMPARE(akonadiTag.id(), tagId); | | |||
2519 | QCOMPARE(akonadiTag.gid(), tagGid); | | |||
2520 | QCOMPARE(akonadiTag.type(), QByteArray(Akonadi::Tag::PLAIN)); | | |||
2521 | } | | |||
2522 | } | | |||
2523 | | ||||
2524 | void shouldVerifyIfAnItemIsATagChild_data() | | |||
2525 | { | | |||
2526 | QTest::addColumn<Domain::Tag::Ptr>("tag"); | | |||
2527 | QTest::addColumn<Akonadi::Item>("item"); | | |||
2528 | QTest::addColumn<bool>("isChild"); | | |||
2529 | | ||||
2530 | // Create a Tag | | |||
2531 | auto tag = Domain::Tag::Ptr::create(); | | |||
2532 | tag->setProperty("tagId", qint64(43)); | | |||
2533 | Akonadi::Tag akonadiTag(Akonadi::Tag::Id(43)); | | |||
2534 | | ||||
2535 | Akonadi::Item unrelatedItem; | | |||
2536 | QTest::newRow("Unrelated item") << tag << unrelatedItem << false; | | |||
2537 | | ||||
2538 | Akonadi::Item relatedItem; | | |||
2539 | relatedItem.setTag(akonadiTag); | | |||
2540 | QTest::newRow("Related item") << tag << relatedItem << true; | | |||
2541 | | ||||
2542 | auto invalidTag = Domain::Tag::Ptr::create(); | | |||
2543 | QTest::newRow("Invalid Tag") << invalidTag << relatedItem << false; | | |||
2544 | | ||||
2545 | Akonadi::Item invalidItem; | | |||
2546 | QTest::newRow("Invalid Item") << tag << invalidItem << false; | | |||
2547 | | ||||
2548 | QTest::newRow("both invalid") << invalidTag << invalidItem << false; | | |||
2549 | } | | |||
2550 | | ||||
2551 | void shouldVerifyIfAnItemIsATagChild() | | |||
2552 | { | | |||
2553 | // GIVEN | | |||
2554 | QFETCH(Domain::Tag::Ptr, tag); | | |||
2555 | QFETCH(Akonadi::Item, item); | | |||
2556 | QFETCH(bool, isChild); | | |||
2557 | | ||||
2558 | // WHEN | | |||
2559 | Akonadi::Serializer serializer; | | |||
2560 | bool value = serializer.isTagChild(tag, item); | | |||
2561 | | ||||
2562 | // THEN | | |||
2563 | QCOMPARE(value, isChild); | | |||
2564 | } | | |||
2565 | | ||||
2566 | // Investigation into how to differentiate all-day events from events with time, | 2086 | // Investigation into how to differentiate all-day events from events with time, | ||
2567 | // using QDateTime only. Doesn't seem to be possible. | 2087 | // using QDateTime only. Doesn't seem to be possible. | ||
2568 | void noWayToHaveQDateTimeWithoutTime() | 2088 | void noWayToHaveQDateTimeWithoutTime() | ||
2569 | { | 2089 | { | ||
2570 | // GIVEN a QDateTime without time information | 2090 | // GIVEN a QDateTime without time information | ||
2571 | QDateTime dateOnly(QDate(2016, 6, 12), QTime(-1, -1, -1)); | 2091 | QDateTime dateOnly(QDate(2016, 6, 12), QTime(-1, -1, -1)); | ||
2572 | // THEN we can't detect that there was no time information, i.e. all day event | 2092 | // THEN we can't detect that there was no time information, i.e. all day event | ||
2573 | QVERIFY(dateOnly.time().isValid()); // I wish this was "!" | 2093 | QVERIFY(dateOnly.time().isValid()); // I wish this was "!" | ||
Show All 24 Lines |