176 // Test case setup. |
197 // Test case setup. |
177 AgendaEntry entry; |
198 AgendaEntry entry; |
178 entry.setType(AgendaEntry::TypeAppoinment); |
199 entry.setType(AgendaEntry::TypeAppoinment); |
179 entry.setSummary("Test case"); |
200 entry.setSummary("Test case"); |
180 entry.setStartAndEndTime( |
201 entry.setStartAndEndTime( |
181 QDateTime::currentDateTime(), |
202 QDateTime::currentDateTime(), |
182 QDateTime::currentDateTime()); |
203 QDateTime::currentDateTime()); |
183 AgendaRepeatRule repeatRule; |
204 AgendaRepeatRule repeatRule; |
184 repeatRule.setType(AgendaRepeatRule::DailyRule); |
205 repeatRule.setType(AgendaRepeatRule::DailyRule); |
185 QDateTime ruleStartDateTime(QDate(2019, 11, 3)); |
206 QDateTime ruleStartDateTime(QDate(2019, 11, 3)); |
186 repeatRule.setRepeatRuleStart(ruleStartDateTime); |
207 repeatRule.setRepeatRuleStart(ruleStartDateTime); |
187 QDateTime until(QDate(2019, 12, 3)); |
208 QDateTime until(QDate(2019, 12, 3)); |
188 repeatRule.setUntil(until); |
209 repeatRule.setUntil(until); |
189 repeatRule.setInterval(1); |
210 repeatRule.setInterval(1); |
190 entry.setRepeatRule(repeatRule); |
211 entry.setRepeatRule(repeatRule); |
191 |
212 |
192 ulong id = mAgendaUtil->addEntry(entry); |
213 ulong id = mAgendaUtil->addEntry(entry); |
193 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
214 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
194 QVERIFY(!savedEntry.isNull()); |
215 QVERIFY(!savedEntry.isNull()); |
195 QVERIFY(savedEntry.isRepeating()); |
216 QVERIFY(savedEntry.isRepeating()); |
196 |
217 |
197 // Run the case. |
218 // Run the case. |
198 mAgendaUtil->deleteRepeatedEntry(savedEntry, AgendaUtil::ThisAndAll); |
219 mAgendaUtil->deleteRepeatedEntry(savedEntry, AgendaUtil::ThisAndAll); |
199 |
220 |
200 // Verify. |
221 // Verify. |
201 QVERIFY(mAgendaUtil->fetchById(id).isNull()); |
222 QVERIFY(mAgendaUtil->fetchById(id).isNull()); |
202 } |
223 } |
203 |
224 |
204 /*! |
225 /*! |
245 entry.setType(AgendaEntry::TypeAppoinment); |
266 entry.setType(AgendaEntry::TypeAppoinment); |
246 entry.setSummary("Test case"); |
267 entry.setSummary("Test case"); |
247 entry.setDescription("Entry to test the updateEntry API"); |
268 entry.setDescription("Entry to test the updateEntry API"); |
248 entry.setLocation("Nokia"); |
269 entry.setLocation("Nokia"); |
249 entry.setStartAndEndTime( |
270 entry.setStartAndEndTime( |
250 QDateTime::currentDateTime(), |
271 QDateTime::currentDateTime(), |
251 QDateTime::currentDateTime()); |
272 QDateTime::currentDateTime()); |
252 |
273 |
253 // Save the entry |
274 // Save the entry |
254 ulong id = mAgendaUtil->addEntry(entry); |
275 ulong id = mAgendaUtil->addEntry(entry); |
255 |
276 |
256 // Fetch the same entry |
277 // Fetch the same entry |
257 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
278 AgendaEntry savedEntry = mAgendaUtil->fetchById(id); |
258 QVERIFY(!savedEntry.isNull()); |
279 QVERIFY(!savedEntry.isNull()); |
259 savedEntry.setSummary("Fetced Entry"); |
280 savedEntry.setSummary("Fetced Entry"); |
260 savedEntry.setLocation("India"); |
281 savedEntry.setLocation("India"); |
261 savedEntry.setStartAndEndTime( |
282 savedEntry.setStartAndEndTime( |
262 QDateTime::currentDateTime().addDays(1), |
283 QDateTime::currentDateTime().addDays(1), |
263 QDateTime::currentDateTime().addDays(1)); |
284 QDateTime::currentDateTime().addDays(1)); |
264 |
285 |
265 // Update the entry |
286 // Update the entry |
266 bool success = mAgendaUtil->updateEntry(savedEntry); |
287 bool success = mAgendaUtil->updateEntry(savedEntry); |
267 QVERIFY(success); |
288 QVERIFY(success); |
268 |
289 |
269 // Fetch the updated entry again |
290 // Fetch the updated entry again |
270 AgendaEntry updatedEntry = mAgendaUtil->fetchById(id); |
291 AgendaEntry updatedEntry = mAgendaUtil->fetchById(id); |
271 |
292 |
272 // Verify |
293 // Verify |
273 QVERIFY(savedEntry.summary() == updatedEntry.summary()); |
294 QVERIFY(savedEntry.summary() == updatedEntry.summary()); |
274 QVERIFY(savedEntry.type() == updatedEntry.type()); |
295 QVERIFY(savedEntry.type() == updatedEntry.type()); |
275 |
296 |
469 QList<AgendaEntry> entriesRetrieved = |
490 QList<AgendaEntry> entriesRetrieved = |
470 mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
491 mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
471 int numOfEntriesRetrieved = entriesRetrieved.count(); |
492 int numOfEntriesRetrieved = entriesRetrieved.count(); |
472 QList<ulong> checkList = mAgendaUtil->entryIds(); |
493 QList<ulong> checkList = mAgendaUtil->entryIds(); |
473 int checkNum = checkList.count(); |
494 int checkNum = checkList.count(); |
474 |
495 |
475 // Create the required entries. |
496 // Create the required entries. |
476 int numOfEntries = createMultipleEntries(); |
497 int numOfEntries = createMultipleEntries(); |
477 |
498 |
478 entriesRetrieved = mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
499 entriesRetrieved = mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
479 numOfEntriesRetrieved = entriesRetrieved.count(); |
500 numOfEntriesRetrieved = entriesRetrieved.count(); |
480 checkList = mAgendaUtil->entryIds(); |
501 checkList = mAgendaUtil->entryIds(); |
481 checkNum = checkList.count(); |
502 checkNum = checkList.count(); |
482 |
503 |
483 Q_ASSERT(numOfEntries); |
504 Q_ASSERT(numOfEntries); |
484 |
505 |
485 qDebug("Entries have been created"); |
506 qDebug("Entries have been created"); |
486 |
507 |
487 // Execute the case. |
508 // Execute the case. |
488 mAgendaUtil->deleteEntries(startRange, endRange); |
509 mAgendaUtil->deleteEntries(startRange, endRange); |
489 |
510 |
490 qDebug("Request for deletion made."); |
511 qDebug("Request for deletion made."); |
491 |
512 |
492 // Start the timer as the above operation is asynchronous |
513 // Start the timer as the above operation is asynchronous |
493 if (!mWait) { |
514 if (!mWait) { |
494 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
515 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
495 if (!mWait->IsStarted()) { |
516 if (!mWait->IsStarted()) { |
496 mWait->Start(); |
517 mWait->Start(); |
497 } |
518 } |
498 } |
519 } |
499 |
520 |
500 qDebug("Waiting for confirmation."); |
521 qDebug("Waiting for confirmation."); |
501 entriesRetrieved = mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
522 entriesRetrieved = mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
502 numOfEntriesRetrieved = entriesRetrieved.count(); |
523 numOfEntriesRetrieved = entriesRetrieved.count(); |
503 checkList = mAgendaUtil->entryIds(); |
524 checkList = mAgendaUtil->entryIds(); |
504 checkNum = checkList.count(); |
525 checkNum = checkList.count(); |
512 { |
533 { |
513 // Clean up all the entries. |
534 // Clean up all the entries. |
514 QDateTime startRange(QDate(1900, 01, 1), QTime(0, 0, 0, 0)); |
535 QDateTime startRange(QDate(1900, 01, 1), QTime(0, 0, 0, 0)); |
515 QDateTime endRange(QDate(2100, 12, 30), QTime(23, 59, 59, 0)); |
536 QDateTime endRange(QDate(2100, 12, 30), QTime(23, 59, 59, 0)); |
516 mAgendaUtil->deleteEntries(startRange,endRange); |
537 mAgendaUtil->deleteEntries(startRange,endRange); |
517 |
538 |
518 //qDebug("Request for deletion made."); |
539 //qDebug("Request for deletion made."); |
519 |
540 |
520 // Start the timer as the above operation is asynchronous |
541 // Start the timer as the above operation is asynchronous |
521 if (!mWait) { |
542 if (!mWait) { |
522 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
543 QT_TRAP_THROWING(mWait = new (ELeave) CActiveSchedulerWait;); |
523 if (!mWait->IsStarted()) { |
544 if (!mWait->IsStarted()) { |
524 mWait->Start(); |
545 mWait->Start(); |
525 } |
546 } |
526 } |
547 } |
527 |
548 |
528 //qDebug("Waiting for confirmation."); |
549 //qDebug("Waiting for confirmation."); |
529 |
550 |
530 QList<AgendaEntry> entriesRetrieved = |
551 QList<AgendaEntry> entriesRetrieved = |
531 mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
552 mAgendaUtil->fetchEntriesInRange(startRange, endRange); |
532 int numOfEntriesRetrieved = entriesRetrieved.count(); |
553 int numOfEntriesRetrieved = entriesRetrieved.count(); |
533 QList<ulong> checkList = mAgendaUtil->entryIds(); |
554 QList<ulong> checkList = mAgendaUtil->entryIds(); |
534 int checkNum = checkList.count(); |
555 int checkNum = checkList.count(); |
535 |
556 |
536 // Appointment. |
557 // Appointment. |
537 AgendaEntry firstEntry; |
558 AgendaEntry firstEntry; |
538 firstEntry.setType(AgendaEntry::TypeAppoinment); |
559 firstEntry.setType(AgendaEntry::TypeAppoinment); |
539 firstEntry.setSummary("first entry"); |
560 firstEntry.setSummary("first entry"); |
540 QDateTime firstEntryStart( |
561 QDateTime firstEntryStart( |
541 QDate(2020, 05, 01), QTime(9, 0, 0, 0)); |
562 QDate(2020, 05, 01), QTime(9, 0, 0, 0)); |
542 QDateTime firstEntryEnd( |
563 QDateTime firstEntryEnd( |
543 QDate(2020, 05, 01), QTime(10, 0, 0, 0)); |
564 QDate(2020, 05, 01), QTime(10, 0, 0, 0)); |
544 firstEntry.setStartAndEndTime(firstEntryStart, firstEntryEnd); |
565 firstEntry.setStartAndEndTime(firstEntryStart, firstEntryEnd); |
545 ulong id = mAgendaUtil->addEntry(firstEntry); |
566 ulong id = mAgendaUtil->addEntry(firstEntry); |
546 |
567 |
547 // Create the range for which entries are needed |
568 // Create the range for which entries are needed |
548 QDateTime fromRange( |
569 QDateTime fromRange( |
549 QDate(2020, 01, 01), QTime(0, 0, 0, 0)); |
570 QDate(2020, 01, 01), QTime(0, 0, 0, 0)); |
550 QDateTime toRange( |
571 QDateTime toRange( |
551 QDate(2023, 12, 31), QTime(23, 59, 0, 0)); |
572 QDate(2023, 12, 31), QTime(23, 59, 0, 0)); |
552 // Run the test case |
573 // Run the test case |
553 QList<AgendaEntry> entries = mAgendaUtil->fetchEntriesInRange( |
574 QList<AgendaEntry> entries = mAgendaUtil->fetchEntriesInRange( |
554 fromRange, toRange); |
575 fromRange, toRange); |
555 |
576 |
556 // Verify |
577 // Verify |
557 int num = entries.count(); |
578 int num = entries.count(); |
558 QVERIFY( 1 == entries.count()); |
579 QVERIFY( 1 == entries.count()); |
559 |
580 |
560 //cleanup(); |
581 //cleanup(); |
561 |
582 |
562 //User::Exit(0); |
583 //User::Exit(0); |
|
584 } |
|
585 |
|
586 /*! |
|
587 Test the api AgendaUtil::cloneEntry |
|
588 */ |
|
589 void TestAgendaUtil::test_cloneEntry() |
|
590 { |
|
591 cloneNoteToTodo(); |
|
592 cloneNoteToMeeting(); |
|
593 cloneTodoToNote(); |
|
594 cloneTodoToMeeting(); |
|
595 cloneMeetingToNote(); |
|
596 cloneMeetingToTodo(); |
|
597 } |
|
598 |
|
599 /* |
|
600 Test the api AgendaUtil::setCompleted |
|
601 */ |
|
602 void TestAgendaUtil::test_todoCompleted() |
|
603 { |
|
604 completeTodo(); |
|
605 unCompletedTodo(); |
563 } |
606 } |
564 |
607 |
565 /*! |
608 /*! |
566 Slot to listen for the completion of deleting the entries asynchronously. |
609 Slot to listen for the completion of deleting the entries asynchronously. |
567 */ |
610 */ |
619 numOfEntries++; |
674 numOfEntries++; |
620 |
675 |
621 return numOfEntries; |
676 return numOfEntries; |
622 } |
677 } |
623 |
678 |
624 QTEST_MAIN(TestAgendaUtil) |
679 /*! |
|
680 Test Cloning of Note to To-do |
|
681 */ |
|
682 void TestAgendaUtil::cloneNoteToTodo() |
|
683 { |
|
684 // Create an agenda entry(TypeNote) and save it. |
|
685 AgendaEntry noteEntry(AgendaEntry::TypeNote); |
|
686 noteEntry.setDescription(QString("test cloning of note to todo")); |
|
687 |
|
688 // Clone the entry type TypeNote to TypeTodo |
|
689 long notSavedEntryId = mAgendaUtil->cloneEntry( |
|
690 noteEntry, AgendaEntry::TypeTodo); |
|
691 // Shouldn't clone the entry as AgendaEntry is not yet saved. |
|
692 QVERIFY(!notSavedEntryId); |
|
693 |
|
694 long noteId = mAgendaUtil->addEntry(noteEntry); |
|
695 QVERIFY(noteId); |
|
696 |
|
697 // Fetch the saved note entry for cloning |
|
698 AgendaEntry fetchedNoteEntry = mAgendaUtil->fetchById(noteId); |
|
699 |
|
700 // Clone the entry type ENote to ETodo |
|
701 long clonedTodoEntryId = mAgendaUtil->cloneEntry( |
|
702 fetchedNoteEntry, AgendaEntry::TypeTodo); |
|
703 QVERIFY(clonedTodoEntryId); |
|
704 |
|
705 AgendaEntry clonedTodoEntry = mAgendaUtil->fetchById(clonedTodoEntryId); |
|
706 // Compare the attributes. |
|
707 QCOMPARE(AgendaEntry::TypeTodo,clonedTodoEntry.type()); |
|
708 QCOMPARE(fetchedNoteEntry.description(),clonedTodoEntry.description()); |
|
709 } |
|
710 |
|
711 /*! |
|
712 Test Cloning of Note to Meeting |
|
713 */ |
|
714 |
|
715 void TestAgendaUtil::cloneNoteToMeeting() |
|
716 { |
|
717 // Create an agenda entry(TypeNote) and save it. |
|
718 AgendaEntry noteEntry(AgendaEntry::TypeNote); |
|
719 noteEntry.setDescription(QString("test cloning of note to meeting")); |
|
720 |
|
721 long noteId = mAgendaUtil->addEntry(noteEntry); |
|
722 QVERIFY(noteId); |
|
723 |
|
724 // Fetch the saved note entry for cloning |
|
725 AgendaEntry fetchedNoteEntry = mAgendaUtil->fetchById(noteId); |
|
726 |
|
727 // Clone the entry type TypeNote to TypeTodo |
|
728 long clonedMeetingEntryId = mAgendaUtil->cloneEntry( |
|
729 fetchedNoteEntry, AgendaEntry::TypeAppoinment); |
|
730 QVERIFY(clonedMeetingEntryId); |
|
731 |
|
732 AgendaEntry clonedMeetingEntry = mAgendaUtil->fetchById(clonedMeetingEntryId); |
|
733 // Compare the attributes. |
|
734 QCOMPARE(AgendaEntry::TypeAppoinment,clonedMeetingEntry.type()); |
|
735 QCOMPARE(fetchedNoteEntry.description(),clonedMeetingEntry.description()); |
|
736 } |
|
737 |
|
738 /*! |
|
739 Test Cloning of To-do to Note |
|
740 */ |
|
741 void TestAgendaUtil::cloneTodoToNote() |
|
742 { |
|
743 // Create an agenda entry(TypeTodo) and save it. |
|
744 AgendaEntry todoEntry(AgendaEntry::TypeTodo); |
|
745 todoEntry.setDescription(QString("test cloning of todo to note")); |
|
746 QDateTime dueDate(QDate(2011, 06, 01), QTime(10, 0, 0, 0)); |
|
747 todoEntry.setStartAndEndTime(dueDate, dueDate); |
|
748 long todoId = mAgendaUtil->addEntry(todoEntry); |
|
749 QVERIFY(todoId); |
|
750 |
|
751 // Fetch the saved note entry for cloning |
|
752 AgendaEntry fetchedTodoEntry = mAgendaUtil->fetchById(todoId); |
|
753 |
|
754 // Clone the entry type ETodo to EANote |
|
755 ulong clonedNoteId = mAgendaUtil->cloneEntry( |
|
756 fetchedTodoEntry, AgendaEntry::TypeNote); |
|
757 QVERIFY(clonedNoteId); |
|
758 AgendaEntry clonedNoteEntry = |
|
759 mAgendaUtil->fetchById(clonedNoteId); |
|
760 |
|
761 // Compare the attributes. |
|
762 QCOMPARE(AgendaEntry::TypeNote,clonedNoteEntry.type()); |
|
763 QCOMPARE(fetchedTodoEntry.description(),clonedNoteEntry.description()); |
|
764 QCOMPARE(fetchedTodoEntry.favourite(),clonedNoteEntry.favourite()); |
|
765 } |
|
766 |
|
767 /*! |
|
768 Test Cloning of To-do to Meeting |
|
769 */ |
|
770 void TestAgendaUtil::cloneTodoToMeeting() |
|
771 { |
|
772 // Create an agenda entry(TypeTodo) and save it. |
|
773 AgendaEntry todoEntry(AgendaEntry::TypeTodo); |
|
774 todoEntry.setSummary(QString("test cloning of todo to meeting")); |
|
775 QDateTime dueDate(QDate(2011, 06, 01), QTime(10, 0, 0, 0)); |
|
776 todoEntry.setStartAndEndTime(dueDate, dueDate); |
|
777 long todoId = mAgendaUtil->addEntry(todoEntry); |
|
778 QVERIFY(todoId); |
|
779 |
|
780 // Fetch the saved note entry for cloning |
|
781 AgendaEntry fetchedTodoEntry = mAgendaUtil->fetchById(todoId); |
|
782 |
|
783 // Clone the entry type TypeTodo to TypeAppointment |
|
784 ulong clonedAppointmentId = mAgendaUtil->cloneEntry( |
|
785 fetchedTodoEntry, AgendaEntry::TypeAppoinment); |
|
786 QVERIFY(clonedAppointmentId); |
|
787 AgendaEntry clonedAppointmentEntry = |
|
788 mAgendaUtil->fetchById(clonedAppointmentId); |
|
789 |
|
790 // Compare the attributes. |
|
791 QCOMPARE(AgendaEntry::TypeAppoinment,clonedAppointmentEntry.type()); |
|
792 QCOMPARE(fetchedTodoEntry.summary(),clonedAppointmentEntry.summary()); |
|
793 QCOMPARE(fetchedTodoEntry.startTime(),clonedAppointmentEntry.startTime()); |
|
794 QCOMPARE(fetchedTodoEntry.endTime(),clonedAppointmentEntry.endTime()); |
|
795 } |
|
796 |
|
797 /*! |
|
798 Test Cloning of Meeting to Note |
|
799 */ |
|
800 void TestAgendaUtil::cloneMeetingToNote() |
|
801 { |
|
802 // Create an agenda entry(TypeAppointment) and save it. |
|
803 AgendaEntry appointment(AgendaEntry::TypeAppoinment); |
|
804 appointment.setSummary(QString("test cloning of meeting to note")); |
|
805 QDateTime startDate(QDate(2011, 06, 01), QTime(10, 0, 0, 0)); |
|
806 QDateTime endDate(QDate(2011, 06, 01), QTime(12, 0, 0, 0)); |
|
807 appointment.setStartAndEndTime(startDate, endDate); |
|
808 long appointmentId = mAgendaUtil->addEntry(appointment); |
|
809 QVERIFY(appointmentId); |
|
810 |
|
811 // Fetch the saved note entry for cloning |
|
812 AgendaEntry fetchedAppointment = mAgendaUtil->fetchById(appointmentId); |
|
813 |
|
814 // Clone the entry type TypeAppointment to TypeNote |
|
815 ulong clonedNoteId = mAgendaUtil->cloneEntry( |
|
816 fetchedAppointment, AgendaEntry::TypeNote); |
|
817 QVERIFY(clonedNoteId); |
|
818 |
|
819 AgendaEntry clonedNote = mAgendaUtil->fetchById(clonedNoteId); |
|
820 // Compare the attributes. |
|
821 QCOMPARE(AgendaEntry::TypeNote,clonedNote.type()); |
|
822 QCOMPARE(fetchedAppointment.description(),clonedNote.description()); |
|
823 QCOMPARE(fetchedAppointment.favourite(),clonedNote.favourite()); |
|
824 } |
|
825 |
|
826 /*! |
|
827 Test Cloning of Meeting to To-do |
|
828 */ |
|
829 void TestAgendaUtil::cloneMeetingToTodo() |
|
830 { |
|
831 // Create an agenda entry(TypeAppointment) and save it. |
|
832 AgendaEntry appointment(AgendaEntry::TypeAppoinment); |
|
833 appointment.setSummary(QString("test cloning of meeting to todo")); |
|
834 QDateTime startDate(QDate(2011, 06, 01), QTime(10, 0, 0, 0)); |
|
835 QDateTime endDate(QDate(2011, 06, 01), QTime(12, 0, 0, 0)); |
|
836 appointment.setStartAndEndTime(startDate, endDate); |
|
837 long appointmentId = mAgendaUtil->addEntry(appointment); |
|
838 QVERIFY(appointmentId); |
|
839 |
|
840 // Fetch the saved note entry for cloning |
|
841 AgendaEntry fetchedAppointment = mAgendaUtil->fetchById(appointmentId); |
|
842 |
|
843 // Clone the entry type EAppointment to TypeNote |
|
844 ulong clonedTodoId = mAgendaUtil->cloneEntry( |
|
845 fetchedAppointment, AgendaEntry::TypeTodo); |
|
846 QVERIFY(clonedTodoId); |
|
847 |
|
848 AgendaEntry clonedTodo = mAgendaUtil->fetchById(clonedTodoId); |
|
849 // Compare the attributes. |
|
850 QCOMPARE(AgendaEntry::TypeTodo,clonedTodo.type()); |
|
851 QCOMPARE(fetchedAppointment.summary(),clonedTodo.summary()); |
|
852 QCOMPARE(fetchedAppointment.startTime(),clonedTodo.startTime()); |
|
853 QCOMPARE(fetchedAppointment.endTime(),clonedTodo.endTime()); |
|
854 } |
|
855 |
|
856 /*! |
|
857 test making To-do as completed |
|
858 */ |
|
859 void TestAgendaUtil::completeTodo() |
|
860 { |
|
861 // Create and Save a To-do event. |
|
862 AgendaEntry todoEntry(AgendaEntry::TypeTodo); |
|
863 todoEntry.setSummary(QString("Test making To-do event as Completed")); |
|
864 QDateTime dueDate(QDate(2011, 06, 01), QTime(0, 0, 0, 0)); |
|
865 todoEntry.setStartAndEndTime(dueDate, dueDate); |
|
866 |
|
867 ulong todoId = mAgendaUtil->addEntry(todoEntry); |
|
868 QVERIFY(todoId); |
|
869 |
|
870 // Complete the to-do. |
|
871 AgendaEntry fetchedTodoEntry = mAgendaUtil->fetchById(todoId); |
|
872 QDateTime completedTime(QDate(2011, 07, 01),QTime(0, 0, 0, 0)); |
|
873 mAgendaUtil->setCompleted(fetchedTodoEntry, true, completedTime); |
|
874 |
|
875 // Compare the completed time. |
|
876 AgendaEntry completedTodo = mAgendaUtil->fetchById(todoId); |
|
877 QCOMPARE(completedTime,completedTodo.completedDateTime()); |
|
878 } |
|
879 |
|
880 /*! |
|
881 test making To-do as uncompleted |
|
882 */ |
|
883 void TestAgendaUtil::unCompletedTodo() |
|
884 { |
|
885 // Create and Save a To-do event. |
|
886 AgendaEntry todoEntry(AgendaEntry::TypeTodo); |
|
887 todoEntry.setSummary(QString("Test making To-do event as Completed")); |
|
888 QDateTime dueDate(QDate(2011, 06, 01), QTime(0, 0, 0, 0)); |
|
889 todoEntry.setStartAndEndTime(dueDate, dueDate); |
|
890 |
|
891 ulong todoId = mAgendaUtil->addEntry(todoEntry); |
|
892 QVERIFY(todoId); |
|
893 |
|
894 // Complete the to-do. |
|
895 AgendaEntry fetchedTodoEntry = mAgendaUtil->fetchById(todoId); |
|
896 QDateTime completedTime(QDate(2011, 07, 01),QTime(0, 0, 0, 0)); |
|
897 mAgendaUtil->setCompleted(fetchedTodoEntry, true, completedTime); |
|
898 |
|
899 // Compare the completed time. |
|
900 AgendaEntry unCompletedTodo = mAgendaUtil->fetchById(todoId); |
|
901 // make to-do as uncompleted. |
|
902 mAgendaUtil->setCompleted(fetchedTodoEntry, false, completedTime); |
|
903 |
|
904 QCOMPARE(completedTime, unCompletedTodo.completedDateTime()); |
|
905 } |
|
906 |
|
907 int main(int argc, char *argv[]) |
|
908 { |
|
909 QApplication app(argc, argv); |
|
910 TestAgendaUtil tc; |
|
911 |
|
912 char *pass[3]; |
|
913 pass[0] = argv[0]; |
|
914 pass[1] = "-o"; |
|
915 pass[2] = "c:\\data\\TestAgendaUtil.txt"; |
|
916 |
|
917 int res = QTest::qExec(&tc, 3, pass); |
|
918 return res; |
|
919 } |
|
920 |
625 #include "unittest_agendautil.moc" |
921 #include "unittest_agendautil.moc" |
626 |
922 |
627 // End of file --Don't remove this. |
923 // End of file --Don't remove this. |