603 { |
605 { |
604 completeTodo(); |
606 completeTodo(); |
605 unCompletedTodo(); |
607 unCompletedTodo(); |
606 } |
608 } |
607 |
609 |
|
610 /* |
|
611 Test the api AgendaUtil::store for exceptional entry. |
|
612 */ |
|
613 void TestAgendaUtil::test_createExceptionalEntryWithSubjectChange() |
|
614 { |
|
615 // Test case setup. |
|
616 |
|
617 // Clean up all the entries. |
|
618 QDateTime startRange(QDate(1900, 01, 1), QTime(0, 0, 0, 0)); |
|
619 QDateTime endRange(QDate(2100, 12, 30), QTime(23, 59, 59, 0)); |
|
620 mAgendaUtil->deleteEntries(startRange,endRange); |
|
621 |
|
622 // Start the timer as the above operation is asynchronous |
|
623 if (!mWait) { |
|
624 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
|
625 if (!mWait->IsStarted()) { |
|
626 mWait->Start(); |
|
627 } |
|
628 } |
|
629 |
|
630 // Create the repeating entry. |
|
631 AgendaEntry entry; |
|
632 entry.setType(AgendaEntry::TypeAppoinment); |
|
633 entry.setSummary("Test case"); |
|
634 QDateTime startTime(QDate(2010,1,1),QTime(8,0,0,0)); |
|
635 QDateTime endTime(QDate(2010,1,1),QTime(9,0,0,0)); |
|
636 |
|
637 entry.setStartAndEndTime( |
|
638 startTime, |
|
639 endTime); |
|
640 |
|
641 AgendaRepeatRule repeatRule; |
|
642 repeatRule.setType(AgendaRepeatRule::DailyRule); |
|
643 repeatRule.setRepeatRuleStart(startTime); |
|
644 QDateTime until(QDate(2010, 2, 3)); |
|
645 repeatRule.setUntil(until); |
|
646 repeatRule.setInterval(1); |
|
647 entry.setRepeatRule(repeatRule); |
|
648 |
|
649 ulong id = mAgendaUtil->store(entry); |
|
650 |
|
651 // Get the instance and create the exceptional entry by changing the subject |
|
652 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
|
653 QList<AgendaEntry> entriesRetrieved = |
|
654 mAgendaUtil->fetchEntriesInRange( |
|
655 QDateTime(QDate(2010, 1, 2), QTime(8, 0, 0, 0)), |
|
656 QDateTime(QDate(2010, 1, 2), QTime(9, 0, 0, 0))); |
|
657 |
|
658 int numOfEntriesRetrieved = entriesRetrieved.count(); |
|
659 AgendaEntry modifiedEntry = entriesRetrieved.first(); |
|
660 // Verify |
|
661 QVERIFY(id == modifiedEntry.id()); |
|
662 |
|
663 modifiedEntry.setSummary("Test case Exceptional"); |
|
664 |
|
665 // Run the test case |
|
666 ulong newId = mAgendaUtil->store( |
|
667 modifiedEntry, AgendaUtil::ThisOnly, modifiedEntry.startTime()); |
|
668 |
|
669 // Verify. |
|
670 QVERIFY(id != newId); |
|
671 |
|
672 entriesRetrieved.clear(); |
|
673 |
|
674 // Get the exceptional entry. |
|
675 AgendaEntry exceptionalEntry = mAgendaUtil->fetchById(newId); |
|
676 |
|
677 // Verify. |
|
678 QCOMPARE(exceptionalEntry.summary(), modifiedEntry.summary()); |
|
679 QVERIFY(exceptionalEntry.recurrenceId() == modifiedEntry.startTime()); |
|
680 } |
|
681 |
|
682 /*! |
|
683 Test the api AgendaUtil::store for exceptional entry. |
|
684 */ |
|
685 void TestAgendaUtil::test_createExceptionalEntryWithStartTimeChange() |
|
686 { |
|
687 // Test case setup. |
|
688 |
|
689 // Clean up all the entries. |
|
690 QDateTime startRange(QDate(1900, 01, 1), QTime(0, 0, 0, 0)); |
|
691 QDateTime endRange(QDate(2100, 12, 30), QTime(23, 59, 59, 0)); |
|
692 mAgendaUtil->deleteEntries(startRange,endRange); |
|
693 |
|
694 // Start the timer as the above operation is asynchronous |
|
695 if (!mWait) { |
|
696 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
|
697 if (!mWait->IsStarted()) { |
|
698 mWait->Start(); |
|
699 } |
|
700 } |
|
701 |
|
702 QList<AgendaEntry> allEntries = mAgendaUtil->fetchAllEntries(); |
|
703 int count = allEntries.count(); |
|
704 |
|
705 // Create the repeating entry. |
|
706 AgendaEntry entry; |
|
707 entry.setType(AgendaEntry::TypeAppoinment); |
|
708 entry.setSummary("Test case"); |
|
709 QDateTime startTime(QDate(2010,2,1),QTime(8,0,0,0)); |
|
710 QDateTime endTime(QDate(2010,2,1),QTime(9,0,0,0)); |
|
711 |
|
712 entry.setStartAndEndTime(startTime, endTime); |
|
713 |
|
714 AgendaRepeatRule repeatRule; |
|
715 repeatRule.setType(AgendaRepeatRule::DailyRule); |
|
716 repeatRule.setRepeatRuleStart(startTime); |
|
717 QDateTime until(QDate(2010, 3, 3)); |
|
718 repeatRule.setUntil(until); |
|
719 repeatRule.setInterval(1); |
|
720 entry.setRepeatRule(repeatRule); |
|
721 |
|
722 ulong id = mAgendaUtil->store(entry); |
|
723 |
|
724 // Get the instance and create the exceptional entry by changing the subject |
|
725 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
|
726 QList<AgendaEntry> entriesRetrieved = |
|
727 mAgendaUtil->fetchEntriesInRange( |
|
728 QDateTime(QDate(2010, 2, 2), QTime(8, 0, 0, 0)), |
|
729 QDateTime(QDate(2010, 2, 2), QTime(9, 0, 0, 0))); |
|
730 |
|
731 int numOfEntriesRetrieved = entriesRetrieved.count(); |
|
732 AgendaEntry modifiedEntry = entriesRetrieved.first(); |
|
733 AgendaEntry originalEntry = modifiedEntry; |
|
734 // Verify |
|
735 QVERIFY(id == modifiedEntry.id()); |
|
736 |
|
737 QDateTime modifiedStartTime(QDate(2010,2,1),QTime(8,0,0,0)); |
|
738 QDateTime modifiedEndTime(QDate(2010,2,1),QTime(9,0,0,0)); |
|
739 modifiedEntry.setStartAndEndTime(modifiedStartTime, modifiedStartTime); |
|
740 |
|
741 // Run the test case |
|
742 ulong newId = mAgendaUtil->store( |
|
743 modifiedEntry, AgendaUtil::ThisOnly, originalEntry.startTime()); |
|
744 |
|
745 // Verify. |
|
746 QVERIFY(id != newId); |
|
747 |
|
748 entriesRetrieved.clear(); |
|
749 |
|
750 // Get the exceptional entry. |
|
751 AgendaEntry exceptionalEntry = mAgendaUtil->fetchById(newId); |
|
752 |
|
753 // Verify. |
|
754 QVERIFY(exceptionalEntry.recurrenceId() == originalEntry.startTime()); |
|
755 } |
|
756 |
608 /*! |
757 /*! |
609 Slot to listen for the completion of deleting the entries asynchronously. |
758 Slot to listen for the completion of deleting the entries asynchronously. |
610 */ |
759 */ |
611 void TestAgendaUtil::handleEntriesDeletion(int error) |
760 void TestAgendaUtil::handleEntriesDeletion(int error) |
612 { |
761 { |