{
START_TEST;
- int nRetVal = -1, nURICount = 0;
+ int nRetVal = -1, nURICount = 1;//set to 1 for _calendar_event._uri
calendar_list_h list = NULL;
int nOffset = 0;
int nLimit = 2;
-
char szURI[MAX_ROW][MAX_COL];
GetViewURIforDB(szURI);
- int nTotalURICount = URI_COUNT_FOR_DB;
-
- for ( nURICount = 0; nURICount<nTotalURICount; nURICount++ )
+ int nEventId = 0;
+ calendar_record_h record = NULL;
+
+ // Preconditions
+ if ( CreateCalendarRecordInsertInDb(&record, &nEventId) == FAIL )
{
- // Target APIs
- nRetVal = calendar_db_get_all_records(szURI[nURICount], nOffset, nLimit, &list);
- PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_all_records", CalendarServiceGetError(nRetVal));
+ return 1;
+ }
- CHECK_HANDLE(list, "calendar_db_get_all_records");
+ // Target APIs
+ nRetVal = calendar_db_get_all_records(szURI[nURICount], nOffset, nLimit, &list);
+ PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_all_records", CalendarServiceGetError(nRetVal));
- //Postcondition
- nRetVal = calendar_list_destroy(list, true);
- PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_list_destroy", CalendarServiceGetError(nRetVal));
- list = NULL;
- }
+ CHECK_HANDLE(list, "calendar_db_get_all_records");
+
+ nRetVal = calendar_record_destroy(record, true);
+ PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_destroy", CalendarServiceGetError(nRetVal));
+
+ // delete record from database
+ nRetVal = calendar_db_delete_record(_calendar_event._uri,nEventId);
+ PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_delete_record", CalendarServiceGetError(nRetVal));
+
+ //Postcondition
+ nRetVal = calendar_list_destroy(list, true);
+ PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_list_destroy", CalendarServiceGetError(nRetVal));
+ list = NULL;
+
return 0;
}
{
START_TEST;
- int nURICount = 0;
+ int nURICount = 1;
calendar_list_h list = NULL;
- int nGivenVersion = -1;
+ int nGivenVersion = 1;
int nCurrentVersion = -1;
char szURI[MAX_ROW][MAX_COL];
GetViewURIforDBByVersion(szURI);
- int nTotalURICount = URI_COUNT_FOR_DB_BY_VERSION;
+ int nEventID =0;
+
+ // Target APIs
+ int nRetVal = calendar_db_get_changes_by_version(_calendar_event._uri, nEventID, nGivenVersion, &list, &nCurrentVersion);
+ PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_changes_by_version", CalendarServiceGetError(nRetVal));
- //Precondition
- int nRetVal = calendar_db_get_current_version(&nGivenVersion);
- PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_current_version", CalendarServiceGetError(nRetVal));
- if ( nGivenVersion == -1 )
+ CHECK_HANDLE(list, "calendar_db_get_changes_by_version");
+ if ( nCurrentVersion == -1 )
{
- FPRINTF("[Line : %d][%s] calendar_db_get_current_version failed, error returned = Invalid output parameter\\n", __LINE__, API_NAMESPACE);
+ FPRINTF("[Line : %d][%s] calendar_db_get_changes_by_version failed, error returned = Invalid output parameter\\n", __LINE__, API_NAMESPACE);
+ calendar_list_destroy(list, true);
return 1;
}
-
- for ( nURICount = 0; nURICount<nTotalURICount; nURICount++ )
- {
- // Target APIs
- nRetVal = calendar_db_get_changes_by_version(szURI[nURICount], DEFAULT_EVENT_CALENDAR_BOOK_ID, nGivenVersion, &list, &nCurrentVersion);
- PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_changes_by_version", CalendarServiceGetError(nRetVal));
-
- CHECK_HANDLE(list, "calendar_db_get_changes_by_version");
- if ( nCurrentVersion == -1 )
- {
- FPRINTF("[Line : %d][%s] calendar_db_get_changes_by_version failed, error returned = Invalid output parameter\\n", __LINE__, API_NAMESPACE);
- calendar_list_destroy(list, true);
- return 1;
- }
- }
+
//Postconditions
nRetVal = calendar_list_destroy(list, true);
PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_list_destroy", CalendarServiceGetError(nRetVal));
START_TEST;
calendar_list_h list = NULL;
- calendar_record_h record = NULL;
- int nGivenVersion = -1;
- int nRecordId = 0;
-
- //Precondition
- //get current db version
- int nRetVal = calendar_db_get_current_version(&nGivenVersion);
- PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_current_version", CalendarServiceGetError(nRetVal));
- if ( nGivenVersion == -1 )
- {
- FPRINTF("[Line : %d][%s] calendar_db_get_current_version failed, error returned = Invalid output parameter\\n", __LINE__, API_NAMESPACE);
- return 1;
- }
+ int nGivenVersion = 1;
+ int nEventId = 1;
+ int nCurrentVersion = 0;
+ int nEventID_F = 0;
+
+ int nClone_ID = 0;
+ calendar_record_h hGet_event = NULL;
+ calendar_record_h hClone = NULL;
+ calendar_record_h event = NULL;
+
+ int nRetVal = calendar_record_create(_calendar_event._uri, &event);
+ PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_create", CalendarServiceGetError(nRetVal));
+ CHECK_HANDLE(event, "calendar_record_create");
+
+ char buf[256] = {0};
+ snprintf(buf, sizeof(buf), "Test %ld", time(NULL));
+ nRetVal = calendar_record_set_str(event, _calendar_event.summary, buf);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_str", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
+ calendar_time_s st = {0};
+ st.type = CALENDAR_TIME_UTIME;
+ st.time.utime = get_utime(2010, 1, 5, 0, 0, 0);
+
+ nRetVal = calendar_record_set_caltime(event, _calendar_event.start_time, st);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_caltime", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
- // create and insert record
- if ( CreateCalendarRecordInsertInDb(&record, &nRecordId) == FAIL )
- {
- return 1;
- }
+ calendar_time_s et = {0};
+ et.type = CALENDAR_TIME_UTIME;
+ et.time.utime = st.time.utime + 3600;
+ nRetVal = calendar_record_set_caltime(event, _calendar_event.end_time, et);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_caltime", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
- // Target API
- nRetVal = calendar_db_get_changes_exception_by_version(_calendar_event._uri, nRecordId, nGivenVersion, &list);
- PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_changes_by_version", CalendarServiceGetError(nRetVal), calendar_record_destroy(record, true);calendar_db_delete_record(_calendar_event._uri,nRecordId));
- CHECK_HANDLE_CLEANUP(list, "calendar_db_get_changes_by_version", calendar_record_destroy(record, true);calendar_db_delete_record(_calendar_event._uri,nRecordId));
+ nRetVal = calendar_record_set_int(event, _calendar_event.freq, CALENDAR_RECURRENCE_DAILY);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_int", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
+ nRetVal = calendar_record_set_int(event, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_int", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
+ nRetVal = calendar_record_set_int(event, _calendar_event.count, 10);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_int", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
+ nRetVal = calendar_db_insert_record(event, &nEventID_F);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_insert_record", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+
+
+ nRetVal = calendar_db_get_record(_calendar_event._uri, nEventID_F, &hGet_event);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_insert_record", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true));
+ CHECK_HANDLE(hGet_event, "calendar_db_get_record");
+
- //Postconditions
- // destroy records
- nRetVal = calendar_record_destroy(record, true);
- PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_destroy", CalendarServiceGetError(nRetVal));
+ nRetVal = calendar_record_clone(hGet_event, &hClone);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_clone", CalendarServiceGetError(nRetVal),calendar_record_destroy(event, true);calendar_record_destroy(hGet_event, true));
+
+ nRetVal = calendar_record_destroy(hGet_event, true);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_destroy", CalendarServiceGetError(nRetVal),calendar_record_destroy(hClone, true));
+ nRetVal = calendar_record_set_str(hClone, _calendar_event.summary, "exception");
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_str", CalendarServiceGetError(nRetVal),calendar_record_destroy(hClone, true));
+
+ nRetVal = calendar_record_set_int(hClone, _calendar_event.original_event_id, nEventID_F);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_int", CalendarServiceGetError(nRetVal),calendar_record_destroy(hClone, true));
+
+ nRetVal = calendar_record_set_str(hClone, _calendar_event.recurrence_id, "20100106000000Z");
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_set_str", CalendarServiceGetError(nRetVal),calendar_record_destroy(hClone, true));
+
+ nRetVal = calendar_db_insert_record(hClone, &nClone_ID);
+ PRINT_RESULT_CLEANUP(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_insert_record", CalendarServiceGetError(nRetVal),calendar_record_destroy(hClone, true));
+
+ nRetVal = calendar_record_destroy(hClone, true);
+ PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_record_destroy", CalendarServiceGetError(nRetVal));
+
+ // Target API
+ nRetVal = calendar_db_get_changes_exception_by_version(_calendar_event._uri, nEventID_F, nCurrentVersion, &list);
+ PRINT_RESULT(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_get_changes_exception_by_version", CalendarServiceGetError(nRetVal));
+ CHECK_HANDLE(list, "calendar_db_get_changes_exception_by_version");
+
// destroy list
nRetVal = calendar_list_destroy(list, true);
PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_list_destroy", CalendarServiceGetError(nRetVal));
- // delete record from database
- nRetVal = calendar_db_delete_record(_calendar_event._uri,nRecordId);
- PRINT_RESULT_NORETURN(CALENDAR_ERROR_NONE, nRetVal, "calendar_db_delete_record", CalendarServiceGetError(nRetVal));
-
return 0;
}