Changeset View
Changeset View
Standalone View
Standalone View
tests/testlib/akonadistoragetestbase.cpp
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Line(s) | 187 | { | |||
---|---|---|---|---|---|
195 | // A collection | 195 | // A collection | ||
196 | Akonadi::Collection collection; | 196 | Akonadi::Collection collection; | ||
197 | collection.setParentCollection(calendar2()); | 197 | collection.setParentCollection(calendar2()); | ||
198 | collection.setName(QStringLiteral("Foo!")); | 198 | collection.setName(QStringLiteral("Foo!")); | ||
199 | collection.setContentMimeTypes(QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | 199 | collection.setContentMimeTypes(QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | ||
200 | 200 | | |||
201 | // WHEN | 201 | // WHEN | ||
202 | auto storage = createStorage(); | 202 | auto storage = createStorage(); | ||
203 | auto job = storage->createCollection(collection); | 203 | auto job = storage->createCollection(collection, nullptr); | ||
204 | AKVERIFYEXEC(job); | 204 | AKVERIFYEXEC(job); | ||
205 | monitorSpy.waitForStableState(); | 205 | monitorSpy.waitForStableState(); | ||
206 | QTRY_VERIFY(!spy.isEmpty()); | 206 | QTRY_VERIFY(!spy.isEmpty()); | ||
207 | 207 | | |||
208 | // THEN | 208 | // THEN | ||
209 | QCOMPARE(spy.size(), 1); | 209 | QCOMPARE(spy.size(), 1); | ||
210 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | 210 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
211 | QCOMPARE(notifiedCollection.name(), collection.name()); | 211 | QCOMPARE(notifiedCollection.name(), collection.name()); | ||
Show All 15 Lines | 221 | { | |||
227 | MonitorSpy monitorSpy(monitor.data()); | 227 | MonitorSpy monitorSpy(monitor.data()); | ||
228 | 228 | | |||
229 | // An existing item (if we trust the test data) | 229 | // An existing item (if we trust the test data) | ||
230 | Akonadi::Collection collection = fetchCollectionByRID(QStringLiteral("{1f78b360-a01b-4785-9187-75450190342c}")); | 230 | Akonadi::Collection collection = fetchCollectionByRID(QStringLiteral("{1f78b360-a01b-4785-9187-75450190342c}")); | ||
231 | QVERIFY(collection.isValid()); | 231 | QVERIFY(collection.isValid()); | ||
232 | 232 | | |||
233 | // WHEN | 233 | // WHEN | ||
234 | auto storage = createStorage(); | 234 | auto storage = createStorage(); | ||
235 | auto job = storage->removeCollection(collection); | 235 | auto job = storage->removeCollection(collection, nullptr); | ||
236 | AKVERIFYEXEC(job); | 236 | AKVERIFYEXEC(job); | ||
237 | monitorSpy.waitForStableState(); | 237 | monitorSpy.waitForStableState(); | ||
238 | QTRY_VERIFY(!spy.isEmpty()); | 238 | QTRY_VERIFY(!spy.isEmpty()); | ||
239 | 239 | | |||
240 | // THEN | 240 | // THEN | ||
241 | QCOMPARE(spy.size(), 1); | 241 | QCOMPARE(spy.size(), 1); | ||
242 | auto notifiedCollection= spy.takeFirst().at(0).value<Akonadi::Collection>(); | 242 | auto notifiedCollection= spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
243 | QCOMPARE(notifiedCollection.id(), collection.id()); | 243 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
Show All 10 Lines | 247 | { | |||
254 | 254 | | |||
255 | // A collection with an existing id (if we trust the test data) | 255 | // A collection with an existing id (if we trust the test data) | ||
256 | Akonadi::Collection collection = fetchCollectionByRID(QStringLiteral("{28ef9f03-4ebc-4e33-970f-f379775894f9}")); | 256 | Akonadi::Collection collection = fetchCollectionByRID(QStringLiteral("{28ef9f03-4ebc-4e33-970f-f379775894f9}")); | ||
257 | QVERIFY(collection.isValid()); | 257 | QVERIFY(collection.isValid()); | ||
258 | collection.setName(QStringLiteral("Bar!")); | 258 | collection.setName(QStringLiteral("Bar!")); | ||
259 | 259 | | |||
260 | // WHEN | 260 | // WHEN | ||
261 | auto storage = createStorage(); | 261 | auto storage = createStorage(); | ||
262 | auto job = storage->updateCollection(collection); | 262 | auto job = storage->updateCollection(collection, nullptr); | ||
263 | AKVERIFYEXEC(job); | 263 | AKVERIFYEXEC(job); | ||
264 | monitorSpy.waitForStableState(); | 264 | monitorSpy.waitForStableState(); | ||
265 | QTRY_VERIFY(!spy.isEmpty()); | 265 | QTRY_VERIFY(!spy.isEmpty()); | ||
266 | 266 | | |||
267 | // THEN | 267 | // THEN | ||
268 | QCOMPARE(spy.size(), 1); | 268 | QCOMPARE(spy.size(), 1); | ||
269 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | 269 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
270 | QCOMPARE(notifiedCollection.id(), collection.id()); | 270 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 355 | { | |||
372 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff6}"), calendar2()); | 372 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff6}"), calendar2()); | ||
373 | QVERIFY(item.isValid()); | 373 | QVERIFY(item.isValid()); | ||
374 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | 374 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | ||
375 | item.setPayload<KCalCore::Todo::Ptr>(todo); | 375 | item.setPayload<KCalCore::Todo::Ptr>(todo); | ||
376 | item.addAttribute(new Akonadi::EntityDisplayAttribute); | 376 | item.addAttribute(new Akonadi::EntityDisplayAttribute); | ||
377 | 377 | | |||
378 | // WHEN | 378 | // WHEN | ||
379 | auto storage = createStorage(); | 379 | auto storage = createStorage(); | ||
380 | auto job = storage->updateItem(item); | 380 | auto job = storage->updateItem(item, nullptr); | ||
381 | AKVERIFYEXEC(job); | 381 | AKVERIFYEXEC(job); | ||
382 | monitorSpy.waitForStableState(); | 382 | monitorSpy.waitForStableState(); | ||
383 | QTRY_VERIFY(!spy.isEmpty()); | 383 | QTRY_VERIFY(!spy.isEmpty()); | ||
384 | 384 | | |||
385 | // THEN | 385 | // THEN | ||
386 | QCOMPARE(spy.size(), 1); | 386 | QCOMPARE(spy.size(), 1); | ||
387 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | 387 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
388 | QCOMPARE(notifiedItem.id(), item.id()); | 388 | QCOMPARE(notifiedItem.id(), item.id()); | ||
Show All 39 Lines | 414 | { | |||
428 | todo->setDescription(QStringLiteral("new content")); | 428 | todo->setDescription(QStringLiteral("new content")); | ||
429 | 429 | | |||
430 | // ... as payload of an existing item (if we trust the test data)... | 430 | // ... as payload of an existing item (if we trust the test data)... | ||
431 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | 431 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | ||
432 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | 432 | item.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); | ||
433 | item.setPayload<KCalCore::Todo::Ptr>(todo); | 433 | item.setPayload<KCalCore::Todo::Ptr>(todo); | ||
434 | 434 | | |||
435 | // WHEN | 435 | // WHEN | ||
436 | auto job = storage->updateItem(item); | 436 | auto job = storage->updateItem(item, nullptr); | ||
437 | AKVERIFYEXEC(job); | 437 | AKVERIFYEXEC(job); | ||
438 | monitorSpy.waitForStableState(); | 438 | monitorSpy.waitForStableState(); | ||
439 | QTRY_VERIFY(!spy.isEmpty()); | 439 | QTRY_VERIFY(!spy.isEmpty()); | ||
440 | 440 | | |||
441 | // THEN | 441 | // THEN | ||
442 | QCOMPARE(spy.size(), 1); | 442 | QCOMPARE(spy.size(), 1); | ||
443 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | 443 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
444 | QCOMPARE(notifiedItem.id(), item.id()); | 444 | QCOMPARE(notifiedItem.id(), item.id()); | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 566 | { | |||
570 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{7824df00-2fd6-47a4-8319-52659dc82005}"), calendar2()); | 570 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{7824df00-2fd6-47a4-8319-52659dc82005}"), calendar2()); | ||
571 | QVERIFY(item.isValid()); | 571 | QVERIFY(item.isValid()); | ||
572 | 572 | | |||
573 | // A spied monitor | 573 | // A spied monitor | ||
574 | auto monitor = createMonitor(); | 574 | auto monitor = createMonitor(); | ||
575 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | 575 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | ||
576 | MonitorSpy monitorSpy(monitor.data()); | 576 | MonitorSpy monitorSpy(monitor.data()); | ||
577 | 577 | | |||
578 | auto job = storage->moveItem(item, calendar1()); | 578 | auto job = storage->moveItem(item, calendar1(), nullptr); | ||
579 | AKVERIFYEXEC(job); | 579 | AKVERIFYEXEC(job); | ||
580 | monitorSpy.waitForStableState(); | 580 | monitorSpy.waitForStableState(); | ||
581 | QTRY_VERIFY(!spyMoved.isEmpty()); | 581 | QTRY_VERIFY(!spyMoved.isEmpty()); | ||
582 | 582 | | |||
583 | QCOMPARE(spyMoved.size(), 1); | 583 | QCOMPARE(spyMoved.size(), 1); | ||
584 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | 584 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | ||
585 | QCOMPARE(movedItem.id(), item.id()); | 585 | QCOMPARE(movedItem.id(), item.id()); | ||
586 | } | 586 | } | ||
587 | 587 | | |||
588 | void AkonadiStorageTestBase::shouldMoveItems() | 588 | void AkonadiStorageTestBase::shouldMoveItems() | ||
589 | { | 589 | { | ||
590 | // GIVEN | 590 | // GIVEN | ||
591 | auto storage = createStorage(); | 591 | auto storage = createStorage(); | ||
592 | 592 | | |||
593 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | 593 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | ||
594 | QVERIFY(item.isValid()); | 594 | QVERIFY(item.isValid()); | ||
595 | Akonadi::Item::List list; | 595 | Akonadi::Item::List list; | ||
596 | list << item; | 596 | list << item; | ||
597 | 597 | | |||
598 | // A spied monitor | 598 | // A spied monitor | ||
599 | auto monitor = createMonitor(); | 599 | auto monitor = createMonitor(); | ||
600 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | 600 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | ||
601 | MonitorSpy monitorSpy(monitor.data()); | 601 | MonitorSpy monitorSpy(monitor.data()); | ||
602 | 602 | | |||
603 | auto job = storage->moveItems(list, calendar1()); | 603 | auto job = storage->moveItems(list, calendar1(), nullptr); | ||
604 | AKVERIFYEXEC(job); | 604 | AKVERIFYEXEC(job); | ||
605 | monitorSpy.waitForStableState(); | 605 | monitorSpy.waitForStableState(); | ||
606 | QTRY_VERIFY(!spyMoved.isEmpty()); | 606 | QTRY_VERIFY(!spyMoved.isEmpty()); | ||
607 | 607 | | |||
608 | QCOMPARE(spyMoved.size(), 1); | 608 | QCOMPARE(spyMoved.size(), 1); | ||
609 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | 609 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | ||
610 | QCOMPARE(movedItem.id(), item.id()); | 610 | QCOMPARE(movedItem.id(), item.id()); | ||
611 | } | 611 | } | ||
Show All 39 Lines | 640 | { | |||
651 | QVERIFY(item.isValid()); | 651 | QVERIFY(item.isValid()); | ||
652 | Akonadi::Item item2 = fetchItemByRID(QStringLiteral("{83cf0b15-8d61-436b-97ae-4bd88fb2fef9}"), calendar1()); | 652 | Akonadi::Item item2 = fetchItemByRID(QStringLiteral("{83cf0b15-8d61-436b-97ae-4bd88fb2fef9}"), calendar1()); | ||
653 | QVERIFY(item2.isValid()); | 653 | QVERIFY(item2.isValid()); | ||
654 | 654 | | |||
655 | Akonadi::Item::List list; | 655 | Akonadi::Item::List list; | ||
656 | list << item << item2; | 656 | list << item << item2; | ||
657 | 657 | | |||
658 | //When | 658 | //When | ||
659 | auto job = storage->removeItems(list); | 659 | auto job = storage->removeItems(list, nullptr); | ||
660 | AKVERIFYEXEC(job); | 660 | AKVERIFYEXEC(job); | ||
661 | monitorSpy.waitForStableState(); | 661 | monitorSpy.waitForStableState(); | ||
662 | QTRY_VERIFY(!spy.isEmpty()); | 662 | QTRY_VERIFY(!spy.isEmpty()); | ||
663 | 663 | | |||
664 | // THEN | 664 | // THEN | ||
665 | QCOMPARE(spy.size(), 2); | 665 | QCOMPARE(spy.size(), 2); | ||
666 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | 666 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
667 | QCOMPARE(notifiedItem.id(), item.id()); | 667 | QCOMPARE(notifiedItem.id(), item.id()); | ||
Show All 16 Lines | 673 | { | |||
684 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | 684 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | ||
685 | QSignalSpy selectionSpy(monitor.data(), &Akonadi::MonitorInterface::collectionSelectionChanged); | 685 | QSignalSpy selectionSpy(monitor.data(), &Akonadi::MonitorInterface::collectionSelectionChanged); | ||
686 | MonitorSpy monitorSpy(monitor.data()); | 686 | MonitorSpy monitorSpy(monitor.data()); | ||
687 | 687 | | |||
688 | // WHEN | 688 | // WHEN | ||
689 | auto attr = new Akonadi::EntityDisplayAttribute; | 689 | auto attr = new Akonadi::EntityDisplayAttribute; | ||
690 | attr->setDisplayName(QStringLiteral("Foo")); | 690 | attr->setDisplayName(QStringLiteral("Foo")); | ||
691 | collection.addAttribute(attr); | 691 | collection.addAttribute(attr); | ||
692 | auto job = storage->updateCollection(collection); | 692 | auto job = storage->updateCollection(collection, nullptr); | ||
693 | AKVERIFYEXEC(job); | 693 | AKVERIFYEXEC(job); | ||
694 | monitorSpy.waitForStableState(); | 694 | monitorSpy.waitForStableState(); | ||
695 | QTRY_VERIFY(!changeSpy.isEmpty()); | 695 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
696 | 696 | | |||
697 | // THEN | 697 | // THEN | ||
698 | QCOMPARE(changeSpy.size(), 1); | 698 | QCOMPARE(changeSpy.size(), 1); | ||
699 | QCOMPARE(selectionSpy.size(), 0); | 699 | QCOMPARE(selectionSpy.size(), 0); | ||
700 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | 700 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
Show All 14 Lines | 707 | { | |||
715 | 715 | | |||
716 | // A spied monitor | 716 | // A spied monitor | ||
717 | auto monitor = createMonitor(); | 717 | auto monitor = createMonitor(); | ||
718 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | 718 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | ||
719 | MonitorSpy monitorSpy(monitor.data()); | 719 | MonitorSpy monitorSpy(monitor.data()); | ||
720 | 720 | | |||
721 | // WHEN | 721 | // WHEN | ||
722 | collection.attribute<Akonadi::TimestampAttribute>(Akonadi::Collection::AddIfMissing)->refreshTimestamp(); | 722 | collection.attribute<Akonadi::TimestampAttribute>(Akonadi::Collection::AddIfMissing)->refreshTimestamp(); | ||
723 | auto job = storage->updateCollection(collection); | 723 | auto job = storage->updateCollection(collection, nullptr); | ||
724 | AKVERIFYEXEC(job); | 724 | AKVERIFYEXEC(job); | ||
725 | monitorSpy.waitForStableState(); | 725 | monitorSpy.waitForStableState(); | ||
726 | QTRY_VERIFY(!changeSpy.isEmpty()); | 726 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
727 | 727 | | |||
728 | // THEN | 728 | // THEN | ||
729 | QCOMPARE(changeSpy.size(), 1); | 729 | QCOMPARE(changeSpy.size(), 1); | ||
730 | 730 | | |||
731 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | 731 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
Show All 16 Lines | 737 | { | |||
748 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | 748 | QSignalSpy changeSpy(monitor.data(), &Akonadi::MonitorInterface::collectionChanged); | ||
749 | QSignalSpy selectionSpy(monitor.data(), &Akonadi::MonitorInterface::collectionSelectionChanged); | 749 | QSignalSpy selectionSpy(monitor.data(), &Akonadi::MonitorInterface::collectionSelectionChanged); | ||
750 | MonitorSpy monitorSpy(monitor.data()); | 750 | MonitorSpy monitorSpy(monitor.data()); | ||
751 | 751 | | |||
752 | // WHEN | 752 | // WHEN | ||
753 | auto attr = new Akonadi::ApplicationSelectedAttribute; | 753 | auto attr = new Akonadi::ApplicationSelectedAttribute; | ||
754 | attr->setSelected(false); | 754 | attr->setSelected(false); | ||
755 | collection.addAttribute(attr); | 755 | collection.addAttribute(attr); | ||
756 | auto job = storage->updateCollection(collection); | 756 | auto job = storage->updateCollection(collection, nullptr); | ||
757 | AKVERIFYEXEC(job); | 757 | AKVERIFYEXEC(job); | ||
758 | monitorSpy.waitForStableState(); | 758 | monitorSpy.waitForStableState(); | ||
759 | QTRY_VERIFY(!changeSpy.isEmpty()); | 759 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
760 | 760 | | |||
761 | // THEN | 761 | // THEN | ||
762 | QCOMPARE(changeSpy.size(), 1); | 762 | QCOMPARE(changeSpy.size(), 1); | ||
763 | QCOMPARE(selectionSpy.size(), 1); | 763 | QCOMPARE(selectionSpy.size(), 1); | ||
764 | 764 | | |||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |