Changeset View
Changeset View
Standalone View
Standalone View
tests/testlib/akonadistoragetestbase.cpp
Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Line(s) | 310 | { | |||
---|---|---|---|---|---|
325 | auto storage = createStorage(); | 325 | auto storage = createStorage(); | ||
326 | auto job = storage->createCollection(collection); | 326 | auto job = storage->createCollection(collection); | ||
327 | AKVERIFYEXEC(job); | 327 | AKVERIFYEXEC(job); | ||
328 | monitorSpy.waitForStableState(); | 328 | monitorSpy.waitForStableState(); | ||
329 | QTRY_VERIFY(!spy.isEmpty()); | 329 | QTRY_VERIFY(!spy.isEmpty()); | ||
330 | 330 | | |||
331 | // THEN | 331 | // THEN | ||
332 | QCOMPARE(spy.size(), 1); | 332 | QCOMPARE(spy.size(), 1); | ||
333 | auto notifiedCollection = spy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 333 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
334 | QCOMPARE(notifiedCollection.name(), collection.name()); | 334 | QCOMPARE(notifiedCollection.name(), collection.name()); | ||
335 | 335 | | |||
336 | auto parent = notifiedCollection.parentCollection(); | 336 | auto parent = notifiedCollection.parentCollection(); | ||
337 | while (parent != Akonadi::Collection::root()) { | 337 | while (parent != Akonadi::Collection::root()) { | ||
338 | QVERIFY(parent.isValid()); | 338 | QVERIFY(parent.isValid()); | ||
339 | parent = parent.parentCollection(); | 339 | parent = parent.parentCollection(); | ||
340 | } | 340 | } | ||
341 | } | 341 | } | ||
Show All 15 Lines | 344 | { | |||
357 | auto storage = createStorage(); | 357 | auto storage = createStorage(); | ||
358 | auto job = storage->removeCollection(collection); | 358 | auto job = storage->removeCollection(collection); | ||
359 | AKVERIFYEXEC(job); | 359 | AKVERIFYEXEC(job); | ||
360 | monitorSpy.waitForStableState(); | 360 | monitorSpy.waitForStableState(); | ||
361 | QTRY_VERIFY(!spy.isEmpty()); | 361 | QTRY_VERIFY(!spy.isEmpty()); | ||
362 | 362 | | |||
363 | // THEN | 363 | // THEN | ||
364 | QCOMPARE(spy.size(), 1); | 364 | QCOMPARE(spy.size(), 1); | ||
365 | auto notifiedCollection= spy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 365 | auto notifiedCollection= spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
366 | QCOMPARE(notifiedCollection.id(), collection.id()); | 366 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
367 | } | 367 | } | ||
368 | 368 | | |||
369 | void AkonadiStorageTestBase::shouldNotifyCollectionChanged() | 369 | void AkonadiStorageTestBase::shouldNotifyCollectionChanged() | ||
370 | { | 370 | { | ||
371 | // GIVEN | 371 | // GIVEN | ||
372 | 372 | | |||
373 | // A spied monitor | 373 | // A spied monitor | ||
Show All 10 Lines | |||||
384 | auto storage = createStorage(); | 384 | auto storage = createStorage(); | ||
385 | auto job = storage->updateCollection(collection); | 385 | auto job = storage->updateCollection(collection); | ||
386 | AKVERIFYEXEC(job); | 386 | AKVERIFYEXEC(job); | ||
387 | monitorSpy.waitForStableState(); | 387 | monitorSpy.waitForStableState(); | ||
388 | QTRY_VERIFY(!spy.isEmpty()); | 388 | QTRY_VERIFY(!spy.isEmpty()); | ||
389 | 389 | | |||
390 | // THEN | 390 | // THEN | ||
391 | QCOMPARE(spy.size(), 1); | 391 | QCOMPARE(spy.size(), 1); | ||
392 | auto notifiedCollection = spy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 392 | auto notifiedCollection = spy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
393 | QCOMPARE(notifiedCollection.id(), collection.id()); | 393 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
394 | QCOMPARE(notifiedCollection.name(), collection.name()); | 394 | QCOMPARE(notifiedCollection.name(), collection.name()); | ||
395 | 395 | | |||
396 | auto parent = notifiedCollection.parentCollection(); | 396 | auto parent = notifiedCollection.parentCollection(); | ||
397 | while (parent != Akonadi::Collection::root()) { | 397 | while (parent != Akonadi::Collection::root()) { | ||
398 | QVERIFY(parent.isValid()); | 398 | QVERIFY(parent.isValid()); | ||
399 | parent = parent.parentCollection(); | 399 | parent = parent.parentCollection(); | ||
400 | } | 400 | } | ||
Show All 26 Lines | 404 | { | |||
427 | auto storage = createStorage(); | 427 | auto storage = createStorage(); | ||
428 | auto job = storage->createItem(item, calendar2()); | 428 | auto job = storage->createItem(item, calendar2()); | ||
429 | AKVERIFYEXEC(job); | 429 | AKVERIFYEXEC(job); | ||
430 | monitorSpy.waitForStableState(); | 430 | monitorSpy.waitForStableState(); | ||
431 | QTRY_VERIFY(!spy.isEmpty()); | 431 | QTRY_VERIFY(!spy.isEmpty()); | ||
432 | 432 | | |||
433 | // THEN | 433 | // THEN | ||
434 | QCOMPARE(spy.size(), 1); | 434 | QCOMPARE(spy.size(), 1); | ||
435 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 435 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
436 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | 436 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | ||
437 | QVERIFY(notifiedItem.hasAttribute<Akonadi::EntityDisplayAttribute>()); | 437 | QVERIFY(notifiedItem.hasAttribute<Akonadi::EntityDisplayAttribute>()); | ||
438 | 438 | | |||
439 | auto parent = notifiedItem.parentCollection(); | 439 | auto parent = notifiedItem.parentCollection(); | ||
440 | while (parent != Akonadi::Collection::root()) { | 440 | while (parent != Akonadi::Collection::root()) { | ||
441 | QVERIFY(parent.isValid()); | 441 | QVERIFY(parent.isValid()); | ||
442 | parent = parent.parentCollection(); | 442 | parent = parent.parentCollection(); | ||
443 | } | 443 | } | ||
Show All 16 Lines | 447 | { | |||
460 | auto storage = createStorage(); | 460 | auto storage = createStorage(); | ||
461 | auto job = storage->removeItem(item); | 461 | auto job = storage->removeItem(item); | ||
462 | AKVERIFYEXEC(job); | 462 | AKVERIFYEXEC(job); | ||
463 | monitorSpy.waitForStableState(); | 463 | monitorSpy.waitForStableState(); | ||
464 | QTRY_VERIFY(!spy.isEmpty()); | 464 | QTRY_VERIFY(!spy.isEmpty()); | ||
465 | 465 | | |||
466 | // THEN | 466 | // THEN | ||
467 | QCOMPARE(spy.size(), 1); | 467 | QCOMPARE(spy.size(), 1); | ||
468 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 468 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
469 | QCOMPARE(notifiedItem.id(), item.id()); | 469 | QCOMPARE(notifiedItem.id(), item.id()); | ||
470 | 470 | | |||
471 | auto parent = notifiedItem.parentCollection(); | 471 | auto parent = notifiedItem.parentCollection(); | ||
472 | while (parent != Akonadi::Collection::root()) { | 472 | while (parent != Akonadi::Collection::root()) { | ||
473 | QVERIFY(parent.isValid()); | 473 | QVERIFY(parent.isValid()); | ||
474 | parent = parent.parentCollection(); | 474 | parent = parent.parentCollection(); | ||
475 | } | 475 | } | ||
476 | } | 476 | } | ||
Show All 26 Lines | 479 | { | |||
503 | auto storage = createStorage(); | 503 | auto storage = createStorage(); | ||
504 | auto job = storage->updateItem(item); | 504 | auto job = storage->updateItem(item); | ||
505 | AKVERIFYEXEC(job); | 505 | AKVERIFYEXEC(job); | ||
506 | monitorSpy.waitForStableState(); | 506 | monitorSpy.waitForStableState(); | ||
507 | QTRY_VERIFY(!spy.isEmpty()); | 507 | QTRY_VERIFY(!spy.isEmpty()); | ||
508 | 508 | | |||
509 | // THEN | 509 | // THEN | ||
510 | QCOMPARE(spy.size(), 1); | 510 | QCOMPARE(spy.size(), 1); | ||
511 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 511 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
512 | QCOMPARE(notifiedItem.id(), item.id()); | 512 | QCOMPARE(notifiedItem.id(), item.id()); | ||
513 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | 513 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | ||
514 | QVERIFY(notifiedItem.hasAttribute<Akonadi::EntityDisplayAttribute>()); | 514 | QVERIFY(notifiedItem.hasAttribute<Akonadi::EntityDisplayAttribute>()); | ||
515 | 515 | | |||
516 | auto parent = notifiedItem.parentCollection(); | 516 | auto parent = notifiedItem.parentCollection(); | ||
517 | while (parent != Akonadi::Collection::root()) { | 517 | while (parent != Akonadi::Collection::root()) { | ||
518 | QVERIFY(parent.isValid()); | 518 | QVERIFY(parent.isValid()); | ||
519 | parent = parent.parentCollection(); | 519 | parent = parent.parentCollection(); | ||
Show All 22 Lines | 524 | { | |||
542 | auto storage = createStorage(); | 542 | auto storage = createStorage(); | ||
543 | auto job = storage->updateItem(item); | 543 | auto job = storage->updateItem(item); | ||
544 | AKVERIFYEXEC(job); | 544 | AKVERIFYEXEC(job); | ||
545 | monitorSpy.waitForStableState(); | 545 | monitorSpy.waitForStableState(); | ||
546 | QTRY_VERIFY(!spy.isEmpty()); | 546 | QTRY_VERIFY(!spy.isEmpty()); | ||
547 | 547 | | |||
548 | // THEN | 548 | // THEN | ||
549 | QCOMPARE(spy.size(), 1); | 549 | QCOMPARE(spy.size(), 1); | ||
550 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 550 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
551 | QCOMPARE(notifiedItem.id(), item.id()); | 551 | QCOMPARE(notifiedItem.id(), item.id()); | ||
552 | QVERIFY(notifiedItem.hasPayload<KCalCore::Todo::Ptr>()); | 552 | QVERIFY(notifiedItem.hasPayload<KCalCore::Todo::Ptr>()); | ||
553 | 553 | | |||
554 | Akonadi::Tag::List notifiedTags = notifiedItem.tags(); | 554 | Akonadi::Tag::List notifiedTags = notifiedItem.tags(); | ||
555 | 555 | | |||
556 | QVERIFY(notifiedTags.contains(tag)); | 556 | QVERIFY(notifiedTags.contains(tag)); | ||
557 | for (const auto &tag : notifiedTags) { | 557 | for (const auto &tag : notifiedTags) { | ||
558 | QVERIFY(tag.isValid()); | 558 | QVERIFY(tag.isValid()); | ||
Show All 12 Lines | |||||
571 | { | 571 | { | ||
572 | // GIVEN | 572 | // GIVEN | ||
573 | auto storage = createStorage(); | 573 | auto storage = createStorage(); | ||
574 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("philosophy-tag")); | 574 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("philosophy-tag")); | ||
575 | const QString expectedRemoteIds = {QStringLiteral("{7824df00-2fd6-47a4-8319-52659dc82006}")}; | 575 | const QString expectedRemoteIds = {QStringLiteral("{7824df00-2fd6-47a4-8319-52659dc82006}")}; | ||
576 | auto job = storage->fetchTagItems(tag); | 576 | auto job = storage->fetchTagItems(tag); | ||
577 | AKVERIFYEXEC(job->kjob()); | 577 | AKVERIFYEXEC(job->kjob()); | ||
578 | 578 | | |||
579 | auto item = job->items().first(); | 579 | auto item = job->items().at(0); | ||
580 | QCOMPARE(item.remoteId(), expectedRemoteIds); | 580 | QCOMPARE(item.remoteId(), expectedRemoteIds); | ||
581 | 581 | | |||
582 | QVERIFY(item.loadedPayloadParts().contains(Akonadi::Item::FullPayload)); | 582 | QVERIFY(item.loadedPayloadParts().contains(Akonadi::Item::FullPayload)); | ||
583 | QVERIFY(!item.attributes().isEmpty()); | 583 | QVERIFY(!item.attributes().isEmpty()); | ||
584 | QVERIFY(item.modificationTime().isValid()); | 584 | QVERIFY(item.modificationTime().isValid()); | ||
585 | QVERIFY(!item.flags().isEmpty()); | 585 | QVERIFY(!item.flags().isEmpty()); | ||
586 | QVERIFY(!item.tags().isEmpty()); | 586 | QVERIFY(!item.tags().isEmpty()); | ||
587 | 587 | | |||
588 | // A spied monitor | 588 | // A spied monitor | ||
589 | auto monitor = createMonitor(); | 589 | auto monitor = createMonitor(); | ||
590 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::itemChanged); | 590 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::itemChanged); | ||
591 | MonitorSpy monitorSpy(monitor.data()); | 591 | MonitorSpy monitorSpy(monitor.data()); | ||
592 | 592 | | |||
593 | // WHEN | 593 | // WHEN | ||
594 | item.clearTag(tag); | 594 | item.clearTag(tag); | ||
595 | auto jobUpdate = storage->updateItem(item); | 595 | auto jobUpdate = storage->updateItem(item); | ||
596 | AKVERIFYEXEC(jobUpdate); | 596 | AKVERIFYEXEC(jobUpdate); | ||
597 | monitorSpy.waitForStableState(); | 597 | monitorSpy.waitForStableState(); | ||
598 | QTRY_VERIFY(!spy.isEmpty()); | 598 | QTRY_VERIFY(!spy.isEmpty()); | ||
599 | 599 | | |||
600 | // THEN | 600 | // THEN | ||
601 | QCOMPARE(spy.size(), 1); | 601 | QCOMPARE(spy.size(), 1); | ||
602 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 602 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
603 | QCOMPARE(notifiedItem.id(), item.id()); | 603 | QCOMPARE(notifiedItem.id(), item.id()); | ||
604 | QVERIFY(!notifiedItem.tags().contains(tag)); | 604 | QVERIFY(!notifiedItem.tags().contains(tag)); | ||
605 | } | 605 | } | ||
606 | 606 | | |||
607 | void AkonadiStorageTestBase::shouldNotifyTagAdded() | 607 | void AkonadiStorageTestBase::shouldNotifyTagAdded() | ||
608 | { | 608 | { | ||
609 | // GIVEN | 609 | // GIVEN | ||
610 | 610 | | |||
Show All 12 Lines | |||||
623 | auto storage = createStorage(); | 623 | auto storage = createStorage(); | ||
624 | auto job = storage->createTag(tag); | 624 | auto job = storage->createTag(tag); | ||
625 | AKVERIFYEXEC(job); | 625 | AKVERIFYEXEC(job); | ||
626 | monitorSpy.waitForStableState(); | 626 | monitorSpy.waitForStableState(); | ||
627 | QTRY_VERIFY(!spy.isEmpty()); | 627 | QTRY_VERIFY(!spy.isEmpty()); | ||
628 | 628 | | |||
629 | // THEN | 629 | // THEN | ||
630 | QCOMPARE(spy.size(), 1); | 630 | QCOMPARE(spy.size(), 1); | ||
631 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 631 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
632 | QCOMPARE(notifiedTag.gid(), tag.gid()); | 632 | QCOMPARE(notifiedTag.gid(), tag.gid()); | ||
633 | QCOMPARE(notifiedTag.name(), tag.name()); | 633 | QCOMPARE(notifiedTag.name(), tag.name()); | ||
634 | QCOMPARE(notifiedTag.type(), tag.type()); | 634 | QCOMPARE(notifiedTag.type(), tag.type()); | ||
635 | } | 635 | } | ||
636 | 636 | | |||
637 | void AkonadiStorageTestBase::shouldNotifyTagRemoved() | 637 | void AkonadiStorageTestBase::shouldNotifyTagRemoved() | ||
638 | { | 638 | { | ||
639 | // GIVEN | 639 | // GIVEN | ||
640 | 640 | | |||
641 | // An existing tag (if we trust the test data) connected to an existing item tagged to it | 641 | // An existing tag (if we trust the test data) connected to an existing item tagged to it | ||
642 | auto storage = createStorage(); | 642 | auto storage = createStorage(); | ||
643 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("delete-me")); | 643 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("delete-me")); | ||
644 | // NOTE : this item was linked to the delete-me tag during test time | 644 | // NOTE : this item was linked to the delete-me tag during test time | ||
645 | const QString expectedRemoteIds = {QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff5}")}; | 645 | const QString expectedRemoteIds = {QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff5}")}; | ||
646 | auto job = storage->fetchTagItems(tag); | 646 | auto job = storage->fetchTagItems(tag); | ||
647 | AKVERIFYEXEC(job->kjob()); | 647 | AKVERIFYEXEC(job->kjob()); | ||
648 | 648 | | |||
649 | QCOMPARE(job->items().size(), 1); | 649 | QCOMPARE(job->items().size(), 1); | ||
650 | auto itemTagged = job->items().first(); | 650 | auto itemTagged = job->items().at(0); | ||
651 | QCOMPARE(itemTagged.remoteId(), expectedRemoteIds); | 651 | QCOMPARE(itemTagged.remoteId(), expectedRemoteIds); | ||
652 | 652 | | |||
653 | // A spied monitor | 653 | // A spied monitor | ||
654 | auto monitor = createMonitor(); | 654 | auto monitor = createMonitor(); | ||
655 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::tagRemoved); | 655 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::tagRemoved); | ||
656 | QSignalSpy spyItemChanged(monitor.data(), &Akonadi::MonitorInterface::itemChanged); | 656 | QSignalSpy spyItemChanged(monitor.data(), &Akonadi::MonitorInterface::itemChanged); | ||
657 | MonitorSpy monitorSpy(monitor.data()); | 657 | MonitorSpy monitorSpy(monitor.data()); | ||
658 | 658 | | |||
659 | // WHEN | 659 | // WHEN | ||
660 | auto jobDelete = storage->removeTag(tag); | 660 | auto jobDelete = storage->removeTag(tag); | ||
661 | AKVERIFYEXEC(jobDelete); | 661 | AKVERIFYEXEC(jobDelete); | ||
662 | monitorSpy.waitForStableState(); | 662 | monitorSpy.waitForStableState(); | ||
663 | QTRY_VERIFY(!spy.isEmpty()); | 663 | QTRY_VERIFY(!spy.isEmpty()); | ||
664 | QTRY_VERIFY(!spyItemChanged.isEmpty()); | 664 | QTRY_VERIFY(!spyItemChanged.isEmpty()); | ||
665 | 665 | | |||
666 | // THEN | 666 | // THEN | ||
667 | QCOMPARE(spy.size(), 1); | 667 | QCOMPARE(spy.size(), 1); | ||
668 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 668 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
669 | QCOMPARE(notifiedTag.id(), tag.id()); | 669 | QCOMPARE(notifiedTag.id(), tag.id()); | ||
670 | 670 | | |||
671 | QCOMPARE(spyItemChanged.size(), 1); | 671 | QCOMPARE(spyItemChanged.size(), 1); | ||
672 | auto notifiedItem = spyItemChanged.takeFirst().takeFirst().value<Akonadi::Item>(); | 672 | auto notifiedItem = spyItemChanged.takeFirst().at(0).value<Akonadi::Item>(); | ||
673 | QCOMPARE(notifiedItem.id(), itemTagged.id()); | 673 | QCOMPARE(notifiedItem.id(), itemTagged.id()); | ||
674 | } | 674 | } | ||
675 | 675 | | |||
676 | void AkonadiStorageTestBase::shouldNotifyTagChanged() | 676 | void AkonadiStorageTestBase::shouldNotifyTagChanged() | ||
677 | { | 677 | { | ||
678 | // GIVEN | 678 | // GIVEN | ||
679 | 679 | | |||
680 | // A spied monitor | 680 | // A spied monitor | ||
Show All 9 Lines | |||||
690 | auto storage = createStorage(); | 690 | auto storage = createStorage(); | ||
691 | auto job = storage->updateTag(tag); | 691 | auto job = storage->updateTag(tag); | ||
692 | AKVERIFYEXEC(job); | 692 | AKVERIFYEXEC(job); | ||
693 | monitorSpy.waitForStableState(); | 693 | monitorSpy.waitForStableState(); | ||
694 | QTRY_VERIFY(!spy.isEmpty()); | 694 | QTRY_VERIFY(!spy.isEmpty()); | ||
695 | 695 | | |||
696 | // THEN | 696 | // THEN | ||
697 | QCOMPARE(spy.size(), 1); | 697 | QCOMPARE(spy.size(), 1); | ||
698 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 698 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
699 | QCOMPARE(notifiedTag.id(), tag.id()); | 699 | QCOMPARE(notifiedTag.id(), tag.id()); | ||
700 | QCOMPARE(notifiedTag.name(), tag.name()); | 700 | QCOMPARE(notifiedTag.name(), tag.name()); | ||
701 | } | 701 | } | ||
702 | 702 | | |||
703 | void AkonadiStorageTestBase::shouldReadDefaultNoteCollectionFromSettings() | 703 | void AkonadiStorageTestBase::shouldReadDefaultNoteCollectionFromSettings() | ||
704 | { | 704 | { | ||
705 | // GIVEN | 705 | // GIVEN | ||
706 | 706 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 732 | { | |||
753 | // WHEN | 753 | // WHEN | ||
754 | auto job = storage->updateItem(item); | 754 | auto job = storage->updateItem(item); | ||
755 | AKVERIFYEXEC(job); | 755 | AKVERIFYEXEC(job); | ||
756 | monitorSpy.waitForStableState(); | 756 | monitorSpy.waitForStableState(); | ||
757 | QTRY_VERIFY(!spy.isEmpty()); | 757 | QTRY_VERIFY(!spy.isEmpty()); | ||
758 | 758 | | |||
759 | // THEN | 759 | // THEN | ||
760 | QCOMPARE(spy.size(), 1); | 760 | QCOMPARE(spy.size(), 1); | ||
761 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 761 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
762 | QCOMPARE(notifiedItem.id(), item.id()); | 762 | QCOMPARE(notifiedItem.id(), item.id()); | ||
763 | 763 | | |||
764 | // KCalCore 4.83 fixes this bug | 764 | // KCalCore 4.83 fixes this bug | ||
765 | #if KCALCORE_VERSION < 0x045300 | 765 | #if KCALCORE_VERSION < 0x045300 | ||
766 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->uid(), todo->uid()); | 766 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->uid(), todo->uid()); | ||
767 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->summary(), todo->summary()); | 767 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->summary(), todo->summary()); | ||
768 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->description(), todo->description()); | 768 | QCOMPARE(notifiedItem.payload<KCalCore::Todo::Ptr>()->description(), todo->description()); | ||
769 | QEXPECT_FAIL("", "Bug introduced by 76c686bc1de3a5d16956a627744ce352bc28d12a in KCalCore", Continue); | 769 | QEXPECT_FAIL("", "Bug introduced by 76c686bc1de3a5d16956a627744ce352bc28d12a in KCalCore", Continue); | ||
Show All 37 Lines | 779 | { | |||
807 | QVERIFY(!transaction->exec()); | 807 | QVERIFY(!transaction->exec()); | ||
808 | monitorSpy.waitForStableState(); | 808 | monitorSpy.waitForStableState(); | ||
809 | 809 | | |||
810 | // THEN | 810 | // THEN | ||
811 | QCOMPARE(spyUpdated.size(), 0); | 811 | QCOMPARE(spyUpdated.size(), 0); | ||
812 | auto job = storage->fetchItem(item1); | 812 | auto job = storage->fetchItem(item1); | ||
813 | AKVERIFYEXEC(job->kjob()); | 813 | AKVERIFYEXEC(job->kjob()); | ||
814 | QCOMPARE(job->items().size(), 1); | 814 | QCOMPARE(job->items().size(), 1); | ||
815 | item1 = job->items()[0]; | 815 | item1 = job->items().at(0); | ||
816 | 816 | | |||
817 | job = storage->fetchItem(item2); | 817 | job = storage->fetchItem(item2); | ||
818 | AKVERIFYEXEC(job->kjob()); | 818 | AKVERIFYEXEC(job->kjob()); | ||
819 | QCOMPARE(job->items().size(), 1); | 819 | QCOMPARE(job->items().size(), 1); | ||
820 | item2 = job->items()[0]; | 820 | item2 = job->items().at(0); | ||
821 | 821 | | |||
822 | QCOMPARE(item1.payload<KCalCore::Todo::Ptr>()->summary(), QStringLiteral("Buy kiwis")); | 822 | QCOMPARE(item1.payload<KCalCore::Todo::Ptr>()->summary(), QStringLiteral("Buy kiwis")); | ||
823 | QCOMPARE(item2.payload<KCalCore::Todo::Ptr>()->summary(), QStringLiteral("Buy cheese")); | 823 | QCOMPARE(item2.payload<KCalCore::Todo::Ptr>()->summary(), QStringLiteral("Buy cheese")); | ||
824 | } | 824 | } | ||
825 | 825 | | |||
826 | void AkonadiStorageTestBase::shouldCreateItem() | 826 | void AkonadiStorageTestBase::shouldCreateItem() | ||
827 | { | 827 | { | ||
828 | // GIVEN | 828 | // GIVEN | ||
Show All 22 Lines | |||||
851 | // WHEN | 851 | // WHEN | ||
852 | auto job = storage->createItem(item, calendar2()); | 852 | auto job = storage->createItem(item, calendar2()); | ||
853 | AKVERIFYEXEC(job); | 853 | AKVERIFYEXEC(job); | ||
854 | monitorSpy.waitForStableState(); | 854 | monitorSpy.waitForStableState(); | ||
855 | QTRY_VERIFY(!spy.isEmpty()); | 855 | QTRY_VERIFY(!spy.isEmpty()); | ||
856 | 856 | | |||
857 | // THEN | 857 | // THEN | ||
858 | QCOMPARE(spy.size(), 1); | 858 | QCOMPARE(spy.size(), 1); | ||
859 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 859 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
860 | QCOMPARE(notifiedItem.parentCollection(), calendar2()); | 860 | QCOMPARE(notifiedItem.parentCollection(), calendar2()); | ||
861 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | 861 | QCOMPARE(*notifiedItem.payload<KCalCore::Todo::Ptr>(), *todo); | ||
862 | } | 862 | } | ||
863 | 863 | | |||
864 | void AkonadiStorageTestBase::shouldRetrieveItem() | 864 | void AkonadiStorageTestBase::shouldRetrieveItem() | ||
865 | { | 865 | { | ||
866 | // GIVEN | 866 | // GIVEN | ||
867 | auto storage = createStorage(); | 867 | auto storage = createStorage(); | ||
Show All 37 Lines | 895 | { | |||
905 | MonitorSpy monitorSpy(monitor.data()); | 905 | MonitorSpy monitorSpy(monitor.data()); | ||
906 | 906 | | |||
907 | auto job = storage->moveItem(item, calendar1()); | 907 | auto job = storage->moveItem(item, calendar1()); | ||
908 | AKVERIFYEXEC(job); | 908 | AKVERIFYEXEC(job); | ||
909 | monitorSpy.waitForStableState(); | 909 | monitorSpy.waitForStableState(); | ||
910 | QTRY_VERIFY(!spyMoved.isEmpty()); | 910 | QTRY_VERIFY(!spyMoved.isEmpty()); | ||
911 | 911 | | |||
912 | QCOMPARE(spyMoved.size(), 1); | 912 | QCOMPARE(spyMoved.size(), 1); | ||
913 | auto movedItem = spyMoved.takeFirst().takeFirst().value<Akonadi::Item>(); | 913 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | ||
914 | QCOMPARE(movedItem.id(), item.id()); | 914 | QCOMPARE(movedItem.id(), item.id()); | ||
915 | } | 915 | } | ||
916 | 916 | | |||
917 | void AkonadiStorageTestBase::shouldMoveItems() | 917 | void AkonadiStorageTestBase::shouldMoveItems() | ||
918 | { | 918 | { | ||
919 | // GIVEN | 919 | // GIVEN | ||
920 | auto storage = createStorage(); | 920 | auto storage = createStorage(); | ||
921 | 921 | | |||
922 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | 922 | Akonadi::Item item = fetchItemByRID(QStringLiteral("{1d33862f-f274-4c67-ab6c-362d56521ff4}"), calendar2()); | ||
923 | QVERIFY(item.isValid()); | 923 | QVERIFY(item.isValid()); | ||
924 | Akonadi::Item::List list; | 924 | Akonadi::Item::List list; | ||
925 | list << item; | 925 | list << item; | ||
926 | 926 | | |||
927 | // A spied monitor | 927 | // A spied monitor | ||
928 | auto monitor = createMonitor(); | 928 | auto monitor = createMonitor(); | ||
929 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | 929 | QSignalSpy spyMoved(monitor.data(), &Akonadi::MonitorInterface::itemMoved); | ||
930 | MonitorSpy monitorSpy(monitor.data()); | 930 | MonitorSpy monitorSpy(monitor.data()); | ||
931 | 931 | | |||
932 | auto job = storage->moveItems(list, calendar1()); | 932 | auto job = storage->moveItems(list, calendar1()); | ||
933 | AKVERIFYEXEC(job); | 933 | AKVERIFYEXEC(job); | ||
934 | monitorSpy.waitForStableState(); | 934 | monitorSpy.waitForStableState(); | ||
935 | QTRY_VERIFY(!spyMoved.isEmpty()); | 935 | QTRY_VERIFY(!spyMoved.isEmpty()); | ||
936 | 936 | | |||
937 | QCOMPARE(spyMoved.size(), 1); | 937 | QCOMPARE(spyMoved.size(), 1); | ||
938 | auto movedItem = spyMoved.takeFirst().takeFirst().value<Akonadi::Item>(); | 938 | auto movedItem = spyMoved.takeFirst().at(0).value<Akonadi::Item>(); | ||
939 | QCOMPARE(movedItem.id(), item.id()); | 939 | QCOMPARE(movedItem.id(), item.id()); | ||
940 | } | 940 | } | ||
941 | 941 | | |||
942 | void AkonadiStorageTestBase::shouldDeleteItem() | 942 | void AkonadiStorageTestBase::shouldDeleteItem() | ||
943 | { | 943 | { | ||
944 | //GIVEN | 944 | //GIVEN | ||
945 | auto storage = createStorage(); | 945 | auto storage = createStorage(); | ||
946 | 946 | | |||
Show All 9 Lines | |||||
956 | //When | 956 | //When | ||
957 | auto job = storage->removeItem(item); | 957 | auto job = storage->removeItem(item); | ||
958 | AKVERIFYEXEC(job); | 958 | AKVERIFYEXEC(job); | ||
959 | monitorSpy.waitForStableState(); | 959 | monitorSpy.waitForStableState(); | ||
960 | QTRY_VERIFY(!spy.isEmpty()); | 960 | QTRY_VERIFY(!spy.isEmpty()); | ||
961 | 961 | | |||
962 | // THEN | 962 | // THEN | ||
963 | QCOMPARE(spy.size(), 1); | 963 | QCOMPARE(spy.size(), 1); | ||
964 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 964 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
965 | QCOMPARE(notifiedItem.id(), item.id()); | 965 | QCOMPARE(notifiedItem.id(), item.id()); | ||
966 | } | 966 | } | ||
967 | 967 | | |||
968 | void AkonadiStorageTestBase::shouldDeleteItems() | 968 | void AkonadiStorageTestBase::shouldDeleteItems() | ||
969 | { | 969 | { | ||
970 | //GIVEN | 970 | //GIVEN | ||
971 | auto storage = createStorage(); | 971 | auto storage = createStorage(); | ||
972 | 972 | | |||
Show All 14 Lines | |||||
987 | //When | 987 | //When | ||
988 | auto job = storage->removeItems(list); | 988 | auto job = storage->removeItems(list); | ||
989 | AKVERIFYEXEC(job); | 989 | AKVERIFYEXEC(job); | ||
990 | monitorSpy.waitForStableState(); | 990 | monitorSpy.waitForStableState(); | ||
991 | QTRY_VERIFY(!spy.isEmpty()); | 991 | QTRY_VERIFY(!spy.isEmpty()); | ||
992 | 992 | | |||
993 | // THEN | 993 | // THEN | ||
994 | QCOMPARE(spy.size(), 2); | 994 | QCOMPARE(spy.size(), 2); | ||
995 | auto notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 995 | auto notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
996 | QCOMPARE(notifiedItem.id(), item.id()); | 996 | QCOMPARE(notifiedItem.id(), item.id()); | ||
997 | notifiedItem = spy.takeFirst().takeFirst().value<Akonadi::Item>(); | 997 | notifiedItem = spy.takeFirst().at(0).value<Akonadi::Item>(); | ||
998 | QCOMPARE(notifiedItem.id(), item2.id()); | 998 | QCOMPARE(notifiedItem.id(), item2.id()); | ||
999 | } | 999 | } | ||
1000 | 1000 | | |||
1001 | void AkonadiStorageTestBase::shouldCreateTag() | 1001 | void AkonadiStorageTestBase::shouldCreateTag() | ||
1002 | { | 1002 | { | ||
1003 | // GIVEN | 1003 | // GIVEN | ||
1004 | 1004 | | |||
1005 | // A storage implementation | 1005 | // A storage implementation | ||
Show All 16 Lines | |||||
1022 | // WHEN | 1022 | // WHEN | ||
1023 | auto job = storage->createTag(tag); | 1023 | auto job = storage->createTag(tag); | ||
1024 | AKVERIFYEXEC(job); | 1024 | AKVERIFYEXEC(job); | ||
1025 | monitorSpy.waitForStableState(); | 1025 | monitorSpy.waitForStableState(); | ||
1026 | QTRY_VERIFY(!spy.isEmpty()); | 1026 | QTRY_VERIFY(!spy.isEmpty()); | ||
1027 | 1027 | | |||
1028 | // THEN | 1028 | // THEN | ||
1029 | QCOMPARE(spy.size(), 1); | 1029 | QCOMPARE(spy.size(), 1); | ||
1030 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 1030 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
1031 | QCOMPARE(notifiedTag.name(), name); | 1031 | QCOMPARE(notifiedTag.name(), name); | ||
1032 | QCOMPARE(notifiedTag.type(), type); | 1032 | QCOMPARE(notifiedTag.type(), type); | ||
1033 | QCOMPARE(notifiedTag.gid(), gid); | 1033 | QCOMPARE(notifiedTag.gid(), gid); | ||
1034 | } | 1034 | } | ||
1035 | 1035 | | |||
1036 | void AkonadiStorageTestBase::shouldRemoveTag() | 1036 | void AkonadiStorageTestBase::shouldRemoveTag() | ||
1037 | { | 1037 | { | ||
1038 | 1038 | | |||
Show All 11 Lines | |||||
1050 | // WHEN | 1050 | // WHEN | ||
1051 | auto job = storage->removeTag(tag); | 1051 | auto job = storage->removeTag(tag); | ||
1052 | AKVERIFYEXEC(job); | 1052 | AKVERIFYEXEC(job); | ||
1053 | monitorSpy.waitForStableState(); | 1053 | monitorSpy.waitForStableState(); | ||
1054 | QTRY_VERIFY(!spy.isEmpty()); | 1054 | QTRY_VERIFY(!spy.isEmpty()); | ||
1055 | 1055 | | |||
1056 | // THEN | 1056 | // THEN | ||
1057 | QCOMPARE(spy.size(), 1); | 1057 | QCOMPARE(spy.size(), 1); | ||
1058 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 1058 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
1059 | QCOMPARE(notifiedTag.id(), tag.id()); | 1059 | QCOMPARE(notifiedTag.id(), tag.id()); | ||
1060 | } | 1060 | } | ||
1061 | 1061 | | |||
1062 | void AkonadiStorageTestBase::shouldUpdateTag() | 1062 | void AkonadiStorageTestBase::shouldUpdateTag() | ||
1063 | { | 1063 | { | ||
1064 | // GIVEN | 1064 | // GIVEN | ||
1065 | auto storage = createStorage(); | 1065 | auto storage = createStorage(); | ||
1066 | 1066 | | |||
1067 | // A spied monitor | 1067 | // A spied monitor | ||
1068 | auto monitor = createMonitor(); | 1068 | auto monitor = createMonitor(); | ||
1069 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::tagChanged); | 1069 | QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::tagChanged); | ||
1070 | MonitorSpy monitorSpy(monitor.data()); | 1070 | MonitorSpy monitorSpy(monitor.data()); | ||
1071 | 1071 | | |||
1072 | // An existing tag | 1072 | // An existing tag | ||
1073 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("change-me")); | 1073 | Akonadi::Tag tag = fetchTagByGID(QStringLiteral("change-me")); | ||
1074 | 1074 | | |||
1075 | // WHEN | 1075 | // WHEN | ||
1076 | auto job = storage->updateTag(tag); | 1076 | auto job = storage->updateTag(tag); | ||
1077 | AKVERIFYEXEC(job); | 1077 | AKVERIFYEXEC(job); | ||
1078 | monitorSpy.waitForStableState(); | 1078 | monitorSpy.waitForStableState(); | ||
1079 | QTRY_VERIFY(!spy.isEmpty()); | 1079 | QTRY_VERIFY(!spy.isEmpty()); | ||
1080 | 1080 | | |||
1081 | // THEN | 1081 | // THEN | ||
1082 | QCOMPARE(spy.size(), 1); | 1082 | QCOMPARE(spy.size(), 1); | ||
1083 | auto notifiedTag = spy.takeFirst().takeFirst().value<Akonadi::Tag>(); | 1083 | auto notifiedTag = spy.takeFirst().at(0).value<Akonadi::Tag>(); | ||
1084 | QCOMPARE(notifiedTag.id(), tag.id()); | 1084 | QCOMPARE(notifiedTag.id(), tag.id()); | ||
1085 | } | 1085 | } | ||
1086 | 1086 | | |||
1087 | void AkonadiStorageTestBase::shouldUpdateCollection() | 1087 | void AkonadiStorageTestBase::shouldUpdateCollection() | ||
1088 | { | 1088 | { | ||
1089 | // GIVEN | 1089 | // GIVEN | ||
1090 | 1090 | | |||
1091 | // A storage implementation | 1091 | // A storage implementation | ||
Show All 15 Lines | |||||
1107 | auto job = storage->updateCollection(collection); | 1107 | auto job = storage->updateCollection(collection); | ||
1108 | AKVERIFYEXEC(job); | 1108 | AKVERIFYEXEC(job); | ||
1109 | monitorSpy.waitForStableState(); | 1109 | monitorSpy.waitForStableState(); | ||
1110 | QTRY_VERIFY(!changeSpy.isEmpty()); | 1110 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
1111 | 1111 | | |||
1112 | // THEN | 1112 | // THEN | ||
1113 | QCOMPARE(changeSpy.size(), 1); | 1113 | QCOMPARE(changeSpy.size(), 1); | ||
1114 | QCOMPARE(selectionSpy.size(), 0); | 1114 | QCOMPARE(selectionSpy.size(), 0); | ||
1115 | auto notifiedCollection = changeSpy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 1115 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
1116 | QCOMPARE(notifiedCollection.id(), collection.id()); | 1116 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
1117 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::EntityDisplayAttribute>()); | 1117 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::EntityDisplayAttribute>()); | ||
1118 | QCOMPARE(notifiedCollection.attribute<Akonadi::EntityDisplayAttribute>()->displayName(), attr->displayName()); | 1118 | QCOMPARE(notifiedCollection.attribute<Akonadi::EntityDisplayAttribute>()->displayName(), attr->displayName()); | ||
1119 | } | 1119 | } | ||
1120 | 1120 | | |||
1121 | void AkonadiStorageTestBase::shouldNotifyCollectionTimestampChanges() | 1121 | void AkonadiStorageTestBase::shouldNotifyCollectionTimestampChanges() | ||
1122 | { | 1122 | { | ||
1123 | // GIVEN | 1123 | // GIVEN | ||
Show All 14 Lines | |||||
1138 | auto job = storage->updateCollection(collection); | 1138 | auto job = storage->updateCollection(collection); | ||
1139 | AKVERIFYEXEC(job); | 1139 | AKVERIFYEXEC(job); | ||
1140 | monitorSpy.waitForStableState(); | 1140 | monitorSpy.waitForStableState(); | ||
1141 | QTRY_VERIFY(!changeSpy.isEmpty()); | 1141 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
1142 | 1142 | | |||
1143 | // THEN | 1143 | // THEN | ||
1144 | QCOMPARE(changeSpy.size(), 1); | 1144 | QCOMPARE(changeSpy.size(), 1); | ||
1145 | 1145 | | |||
1146 | auto notifiedCollection = changeSpy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 1146 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
1147 | QCOMPARE(notifiedCollection.id(), collection.id()); | 1147 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
1148 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::TimestampAttribute>()); | 1148 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::TimestampAttribute>()); | ||
1149 | } | 1149 | } | ||
1150 | 1150 | | |||
1151 | void AkonadiStorageTestBase::shouldNotifyCollectionSelectionChanges() | 1151 | void AkonadiStorageTestBase::shouldNotifyCollectionSelectionChanges() | ||
1152 | { | 1152 | { | ||
1153 | // GIVEN | 1153 | // GIVEN | ||
1154 | 1154 | | |||
Show All 17 Lines | |||||
1172 | AKVERIFYEXEC(job); | 1172 | AKVERIFYEXEC(job); | ||
1173 | monitorSpy.waitForStableState(); | 1173 | monitorSpy.waitForStableState(); | ||
1174 | QTRY_VERIFY(!changeSpy.isEmpty()); | 1174 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
1175 | 1175 | | |||
1176 | // THEN | 1176 | // THEN | ||
1177 | QCOMPARE(changeSpy.size(), 1); | 1177 | QCOMPARE(changeSpy.size(), 1); | ||
1178 | QCOMPARE(selectionSpy.size(), 1); | 1178 | QCOMPARE(selectionSpy.size(), 1); | ||
1179 | 1179 | | |||
1180 | auto notifiedCollection = changeSpy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 1180 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
1181 | QCOMPARE(notifiedCollection.id(), collection.id()); | 1181 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
1182 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::ApplicationSelectedAttribute>()); | 1182 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::ApplicationSelectedAttribute>()); | ||
1183 | QVERIFY(!notifiedCollection.attribute<Akonadi::ApplicationSelectedAttribute>()->isSelected()); | 1183 | QVERIFY(!notifiedCollection.attribute<Akonadi::ApplicationSelectedAttribute>()->isSelected()); | ||
1184 | 1184 | | |||
1185 | notifiedCollection = selectionSpy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 1185 | notifiedCollection = selectionSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
1186 | QCOMPARE(notifiedCollection.id(), collection.id()); | 1186 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
1187 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::ApplicationSelectedAttribute>()); | 1187 | QVERIFY(notifiedCollection.hasAttribute<Akonadi::ApplicationSelectedAttribute>()); | ||
1188 | QVERIFY(!notifiedCollection.attribute<Akonadi::ApplicationSelectedAttribute>()->isSelected()); | 1188 | QVERIFY(!notifiedCollection.attribute<Akonadi::ApplicationSelectedAttribute>()->isSelected()); | ||
1189 | } | 1189 | } | ||
1190 | 1190 | | |||
1191 | void AkonadiStorageTestBase::shouldNotNotifyCollectionSelectionChangesForIrrelevantCollections() | 1191 | void AkonadiStorageTestBase::shouldNotNotifyCollectionSelectionChangesForIrrelevantCollections() | ||
1192 | { | 1192 | { | ||
1193 | // GIVEN | 1193 | // GIVEN | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 1235 | { | |||
1257 | auto job = storage->updateCollection(collection); | 1257 | auto job = storage->updateCollection(collection); | ||
1258 | AKVERIFYEXEC(job); | 1258 | AKVERIFYEXEC(job); | ||
1259 | monitorSpy.waitForStableState(); | 1259 | monitorSpy.waitForStableState(); | ||
1260 | QTRY_VERIFY(!changeSpy.isEmpty()); | 1260 | QTRY_VERIFY(!changeSpy.isEmpty()); | ||
1261 | 1261 | | |||
1262 | // THEN | 1262 | // THEN | ||
1263 | QCOMPARE(changeSpy.size(), 1); | 1263 | QCOMPARE(changeSpy.size(), 1); | ||
1264 | 1264 | | |||
1265 | auto notifiedCollection = changeSpy.takeFirst().takeFirst().value<Akonadi::Collection>(); | 1265 | auto notifiedCollection = changeSpy.takeFirst().at(0).value<Akonadi::Collection>(); | ||
1266 | QCOMPARE(notifiedCollection.id(), collection.id()); | 1266 | QCOMPARE(notifiedCollection.id(), collection.id()); | ||
1267 | QCOMPARE(notifiedCollection.enabled(), isEnabled); | 1267 | QCOMPARE(notifiedCollection.enabled(), isEnabled); | ||
1268 | QCOMPARE(notifiedCollection.referenced(), isReferenced); | 1268 | QCOMPARE(notifiedCollection.referenced(), isReferenced); | ||
1269 | } | 1269 | } | ||
1270 | 1270 | | |||
1271 | void AkonadiStorageTestBase::shouldFindCollectionsByName_data() | 1271 | void AkonadiStorageTestBase::shouldFindCollectionsByName_data() | ||
1272 | { | 1272 | { | ||
1273 | QTest::addColumn<QString>("name"); | 1273 | QTest::addColumn<QString>("name"); | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 1397 | if (!job->kjob()->exec()) { | |||
1399 | return Akonadi::Item(); | 1399 | return Akonadi::Item(); | ||
1400 | } | 1400 | } | ||
1401 | 1401 | | |||
1402 | if (job->items().count() != 1) { | 1402 | if (job->items().count() != 1) { | ||
1403 | qWarning() << "Received unexpected amount of items: " << job->items().count(); | 1403 | qWarning() << "Received unexpected amount of items: " << job->items().count(); | ||
1404 | return Akonadi::Item(); | 1404 | return Akonadi::Item(); | ||
1405 | } | 1405 | } | ||
1406 | 1406 | | |||
1407 | return job->items().first(); | 1407 | return job->items().at(0); | ||
1408 | } | 1408 | } | ||
1409 | 1409 | | |||
1410 | Akonadi::Collection AkonadiStorageTestBase::fetchCollectionByRID(const QString &remoteId) | 1410 | Akonadi::Collection AkonadiStorageTestBase::fetchCollectionByRID(const QString &remoteId) | ||
1411 | { | 1411 | { | ||
1412 | Akonadi::Collection collection; | 1412 | Akonadi::Collection collection; | ||
1413 | collection.setRemoteId(remoteId); | 1413 | collection.setRemoteId(remoteId); | ||
1414 | 1414 | | |||
1415 | auto job = createStorage()->fetchCollections(collection, Akonadi::StorageInterface::Base, Akonadi::StorageInterface::AllContent); | 1415 | auto job = createStorage()->fetchCollections(collection, Akonadi::StorageInterface::Base, Akonadi::StorageInterface::AllContent); | ||
1416 | job->setResource(QStringLiteral("akonadi_knut_resource_0")); | 1416 | job->setResource(QStringLiteral("akonadi_knut_resource_0")); | ||
1417 | job->setFiltered(false); | 1417 | job->setFiltered(false); | ||
1418 | if (!job->kjob()->exec()) { | 1418 | if (!job->kjob()->exec()) { | ||
1419 | qWarning() << job->kjob()->errorString() << remoteId; | 1419 | qWarning() << job->kjob()->errorString() << remoteId; | ||
1420 | return Akonadi::Collection(); | 1420 | return Akonadi::Collection(); | ||
1421 | } | 1421 | } | ||
1422 | 1422 | | |||
1423 | if (job->collections().count() != 1) { | 1423 | if (job->collections().count() != 1) { | ||
1424 | qWarning() << "Received unexpected amount of collections: " << job->collections().count(); | 1424 | qWarning() << "Received unexpected amount of collections: " << job->collections().count(); | ||
1425 | return Akonadi::Collection(); | 1425 | return Akonadi::Collection(); | ||
1426 | } | 1426 | } | ||
1427 | 1427 | | |||
1428 | return job->collections().first(); | 1428 | return job->collections().at(0); | ||
1429 | } | 1429 | } | ||
1430 | 1430 | | |||
1431 | Akonadi::Tag AkonadiStorageTestBase::fetchTagByGID(const QString &gid) | 1431 | Akonadi::Tag AkonadiStorageTestBase::fetchTagByGID(const QString &gid) | ||
1432 | { | 1432 | { | ||
1433 | auto job = createStorage()->fetchTags(); | 1433 | auto job = createStorage()->fetchTags(); | ||
1434 | if (!job->kjob()->exec()) { | 1434 | if (!job->kjob()->exec()) { | ||
1435 | qWarning() << job->kjob()->errorString(); | 1435 | qWarning() << job->kjob()->errorString(); | ||
1436 | return Akonadi::Tag(); | 1436 | return Akonadi::Tag(); | ||
Show All 26 Lines |