diff options
Diffstat (limited to 'TC/testcase/utc_social_calendar_todo.c')
-rwxr-xr-x | TC/testcase/utc_social_calendar_todo.c | 1385 |
1 files changed, 1385 insertions, 0 deletions
diff --git a/TC/testcase/utc_social_calendar_todo.c b/TC/testcase/utc_social_calendar_todo.c new file mode 100755 index 0000000..f77eb10 --- /dev/null +++ b/TC/testcase/utc_social_calendar_todo.c @@ -0,0 +1,1385 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <tet_api.h> +#include <social/calendar.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define API_NAME_CALENDAR_TODO_CREATE "calendar_todo_create" +#define API_NAME_CALENDAR_TODO_GET_DB_ID "calendar_todo_get_db_id" +#define API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID "calendar_todo_get_calendar_book_db_id" +#define API_NAME_CALENDAR_TODO_GET_SUBJECT "calendar_todo_get_subject" +#define API_NAME_CALENDAR_TODO_GET_DESCRIPTION "calendar_todo_get_description" +#define API_NAME_CALENDAR_TODO_GET_LOCATION "calendar_todo_get_location" +#define API_NAME_CALENDAR_TODO_GET_TIMEZONE "calendar_todo_get_timezone" +#define API_NAME_CALENDAR_TODO_GET_PRIORITY "calendar_todo_get_priority" +#define API_NAME_CALENDAR_TODO_GET_STATUS "calendar_todo_get_status" +#define API_NAME_CALENDAR_TODO_GET_VISIBILITY "calendar_todo_get_visibility" +#define API_NAME_CALENDAR_TODO_GET_START_TIME "calendar_todo_get_start_time" +#define API_NAME_CALENDAR_TODO_GET_DUE_TIME "calendar_todo_get_due_time" +#define API_NAME_CALENDAR_FOREACH_TODO_FROM_DB "calendar_foreach_todo_from_db" +#define API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR "calendar_query_todo_by_calendar" +#define API_NAME_CALENDAR_TODO_INSERT_TO_DB "calendar_todo_insert_to_db" +#define API_NAME_CALENDAR_TODO_GET_FROM_DB "calendar_todo_get_from_db" +#define API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME "calendar_todo_get_last_modified_time" +#define API_NAME_CALENDAR_TODO_UPDATE_TO_DB "calendar_todo_update_to_db" +#define API_NAME_CALENDAR_TODO_DELETE_FROM_DB "calendar_todo_delete_from_db" + +#define API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES "calendar_todo_get_set_categories" +#define API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB "calendar_todo_get_total_count_from_db" +#define API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE "CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE" +#define API_NAME_CALENDAR_TODO_FREE_ARRAY "calendar_todo_free_array" +#define API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE "calendar_todo_free_modified_todo_array_free" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK "calendar_todo_search_todo_by_calendar_book" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE "CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION "calendar_todo_search_todo_by_version" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_social_calendar_calendar_todo_create_destroy_p(void); +static void utc_social_calendar_calendar_todo_create_destroy_n(void); +static void utc_social_calendar_calendar_todo_get_db_id_p(void); +static void utc_social_calendar_calendar_todo_get_db_id_n(void); +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_p(void); +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_n(void); +static void utc_social_calendar_calendar_todo_get_set_subject_p(void); +static void utc_social_calendar_calendar_todo_get_set_subject_n(void); +static void utc_social_calendar_calendar_todo_get_set_description_p(void); +static void utc_social_calendar_calendar_todo_get_set_description_n(void); +static void utc_social_calendar_calendar_todo_get_set_location_p(void); +static void utc_social_calendar_calendar_todo_get_set_location_n(void); +static void utc_social_calendar_calendar_todo_get_set_timezone_p(void); +static void utc_social_calendar_calendar_todo_get_set_timezone_n(void); +static void utc_social_calendar_calendar_todo_get_set_priority_p(void); +static void utc_social_calendar_calendar_todo_get_set_priority_n(void); +static void utc_social_calendar_calendar_todo_get_set_status_p(void); +static void utc_social_calendar_calendar_todo_get_set_status_n(void); +static void utc_social_calendar_calendar_todo_get_set_visibility_p(void); +static void utc_social_calendar_calendar_todo_get_set_visibility_n(void); +static void utc_social_calendar_calendar_todo_get_set_start_time_p(void); +static void utc_social_calendar_calendar_todo_get_set_start_time_n(void); +static void utc_social_calendar_calendar_todo_get_set_due_time_p(void); +static void utc_social_calendar_calendar_todo_get_set_due_time_n(void); +//static void utc_social_calendar_calendar_foreach_todo_from_db_p(void); +//static void utc_social_calendar_calendar_foreach_todo_from_db_n(void); +//static void utc_social_calendar_calendar_query_todo_by_calendar_p(void); +//static void utc_social_calendar_calendar_query_todo_by_calendar_n(void); +static void utc_social_calendar_calendar_todo_insert_to_db_p(void); +static void utc_social_calendar_calendar_todo_insert_to_db_n(void); +static void utc_social_calendar_calendar_todo_get_from_db_p(void); +static void utc_social_calendar_calendar_todo_get_from_db_n(void); +static void utc_social_calendar_calendar_todo_get_last_modified_time_p(void); +static void utc_social_calendar_calendar_todo_get_last_modified_time_n(void); +static void utc_social_calendar_calendar_todo_update_to_db_p(void); +static void utc_social_calendar_calendar_todo_update_to_db_n(void); +static void utc_social_calendar_calendar_todo_delete_from_db_p(void); +static void utc_social_calendar_calendar_todo_delete_from_db_n(void); + +static void utc_social_calendar_todo_get_set_categories_p(void); +static void utc_social_calendar_todo_get_set_categories_n(void); +static void utc_social_calendar_todo_get_total_count_from_db_p(void); +static void utc_social_calendar_todo_get_total_count_from_db_n(void); +static void utc_social_calendar_todo_get_total_count_by_duedate_range_p(void); +static void utc_social_calendar_todo_get_total_count_by_duedate_range_n(void); +static void utc_social_calendar_todo_free_array_p(void); +static void utc_social_calendar_todo_free_array_n(void); +static void utc_social_calendar_todo_free_modified_todo_array_free_p(void); +static void utc_social_calendar_todo_free_modified_todo_array_free_n(void); +static void utc_social_calendar_todo_search_todo_by_calendar_book_p(void); +static void utc_social_calendar_todo_search_todo_by_calendar_book_n(void); +static void utc_social_calendar_todo_search_todo_by_duedate_range_p(void); +static void utc_social_calendar_todo_search_todo_by_duedate_range_n(void); +static void utc_social_calendar_todo_search_todo_by_version_p(void); +static void utc_social_calendar_todo_search_todo_by_version_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_social_calendar_calendar_todo_create_destroy_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_create_destroy_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_calendar_book_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_calendar_book_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_subject_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_subject_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_description_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_description_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_location_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_location_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_timezone_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_timezone_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_priority_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_priority_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_status_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_status_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_visibility_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_visibility_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_start_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_start_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_due_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_due_time_n, NEGATIVE_TC_IDX }, +// { utc_social_calendar_calendar_foreach_todo_from_db_p, POSITIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_foreach_todo_from_db_n, NEGATIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_query_todo_by_calendar_p, POSITIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_query_todo_by_calendar_n, NEGATIVE_TC_IDX }, // TOREM + { utc_social_calendar_calendar_todo_insert_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_insert_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_last_modified_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_last_modified_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_update_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_update_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_delete_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_delete_from_db_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_todo_get_set_categories_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_set_categories_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_by_duedate_range_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_by_duedate_range_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_free_array_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_free_array_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_free_modified_todo_array_free_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_free_modified_todo_array_free_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_calendar_book_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_calendar_book_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_duedate_range_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_duedate_range_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_version_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_version_n, NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +calendar_todo_h _dts_todo = NULL; +int _dts_todo_db_id = -1; + +static void startup(void) +{ + /* start of TC */ + calendar_connect(); + calendar_todo_create(&_dts_todo); +} + +static void cleanup(void) +{ + /* end of TC */ + calendar_disconnect(); + calendar_todo_destroy(_dts_todo); +} + +static void utc_social_calendar_calendar_todo_create_destroy_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + calendar_todo_h todo = NULL; + + if((ret = calendar_todo_create(&todo)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_destroy(todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_create_destroy_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + if((ret = calendar_todo_create(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_destroy(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DB_ID; + + bool success = false; + + int todo_db_id = 0; + + if((ret = calendar_todo_get_db_id(_dts_todo, &todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DB_ID; + + bool success = false; + + if((ret = calendar_todo_get_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID; + + bool success = false; + + int calendar_db_id = 0; + + if((ret = calendar_todo_get_calendar_book_db_id(&_dts_todo, &calendar_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID; + + bool success = false; + + if((ret = calendar_todo_get_calendar_book_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_subject_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_SUBJECT; + + bool success = false; + + char* subject = NULL; + + if((ret = calendar_todo_set_subject(_dts_todo, "todo subject")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_subject(_dts_todo, &subject)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(subject != NULL) { + free(subject); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_subject_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + if((ret = calendar_todo_set_subject(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_subject(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_description_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DESCRIPTION; + + bool success = false; + + char* description = NULL; + + if((ret = calendar_todo_set_description(_dts_todo, "todo description")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_description(_dts_todo, &description)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(description != NULL) { + free(description); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_description_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DESCRIPTION; + + bool success = false; + + if((ret = calendar_todo_set_description(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_description(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_location_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LOCATION; + + bool success = false; + + char* location = NULL; + + if((ret = calendar_todo_set_location(_dts_todo, "todo location")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_location(_dts_todo, &location)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(location != NULL) { + free(location); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_location_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LOCATION; + + bool success = false; + + if((ret = calendar_todo_set_location(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_location(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_timezone_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_TIMEZONE; + + bool success = false; + + char* timezone = NULL; + + if((ret = calendar_todo_set_timezone(_dts_todo, "Seoul")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_timezone(_dts_todo, &timezone)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(timezone != NULL) { + free(timezone); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_timezone_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_TIMEZONE; + + bool success = false; + + if((ret = calendar_todo_set_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_priority_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_PRIORITY; + + bool success = false; + + calendar_todo_priority_e value = 0; + + if((ret = calendar_todo_set_priority(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_priority(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_priority_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_PRIORITY; + + bool success = false; + + if((ret = calendar_todo_set_priority(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_priority(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_status_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_STATUS; + + bool success = false; + + calendar_todo_status_e value = 0; + + if((ret = calendar_todo_set_status(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_status(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_status_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_STATUS; + + bool success = false; + + if((ret = calendar_todo_set_status(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_status(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_visibility_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_VISIBILITY; + + bool success = false; + + calendar_visibility_e value = 0; + + if((ret = calendar_todo_set_visibility(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_visibility(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_visibility_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_VISIBILITY; + + bool success = false; + + if((ret = calendar_todo_set_visibility(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_visibility(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_start_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_START_TIME; + + bool success = false; + + long long int value = {0}; + + if((ret = calendar_todo_set_start_time(_dts_todo, value)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_start_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_start_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_START_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_start_time(NULL, value)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_start_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_due_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DUE_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_due_time(_dts_todo, value)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_due_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_due_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DUE_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_due_time(NULL, value)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_due_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +bool dts_calendar_foreach_query_todo_cb(calendar_todo_h todo, void *user_data) +{ + return false; +} + +//static void utc_social_calendar_calendar_foreach_todo_from_db_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TODO_FROM_DB; +// bool success = false; +// +// if((ret = calendar_foreach_todo_from_db(dts_calendar_foreach_query_todo_cb, NULL)) == CALENDAR_ERROR_NONE) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_foreach_todo_from_db_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TODO_FROM_DB; +// bool success = false; +// +// if((ret = calendar_foreach_todo_from_db(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_query_todo_by_calendar_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR; +// bool success = false; +// +// if((ret = calendar_query_todo_by_calendar(dts_calendar_foreach_query_todo_cb, 1, NULL)) == CALENDAR_ERROR_NONE) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_query_todo_by_calendar_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR; +// bool success = false; +// +// if((ret = calendar_query_todo_by_calendar(NULL, 1, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} + +static void utc_social_calendar_calendar_todo_insert_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_INSERT_TO_DB; + + bool success = false; + + if((ret = calendar_todo_insert_to_db(_dts_todo, 1, &_dts_todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_insert_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_INSERT_TO_DB; + + bool success = false; + + if((ret = calendar_todo_insert_to_db(NULL, 1, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_FROM_DB; + + bool success = false; + calendar_todo_h todo = NULL; + + if((ret = calendar_todo_get_from_db(_dts_todo_db_id, &todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + calendar_todo_destroy(todo); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_get_from_db(0, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_last_modified_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME; + + bool success = false; + long long int value = 0; + + if((ret = calendar_todo_get_last_modified_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_last_modified_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME; + + bool success = false; + + if((ret = calendar_todo_get_last_modified_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_update_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_UPDATE_TO_DB; + + bool success = false; + + if((ret = calendar_todo_update_to_db(_dts_todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_update_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_UPDATE_TO_DB; + + bool success = false; + + if((ret = calendar_todo_update_to_db(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_delete_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_DELETE_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_delete_from_db(_dts_todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_delete_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_DELETE_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_delete_from_db(-1)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_todo_get_set_categories_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + char* categories = NULL; + + calendar_event_h event = NULL; + if ((ret = calendar_todo_create(&event)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_todo_set_categories(event, "category1,category2,category3")) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_todo_get_categories(event, &categories)) == CALENDAR_ERROR_NONE) { + pass = true; + if (categories != NULL) { + free(categories); + } + } + } + calendar_todo_destroy(event); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } +} + +static void utc_social_calendar_todo_get_set_categories_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + if ((ret = calendar_todo_set_categories(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_get_categories(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } + dts_fail(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); +} + +static void utc_social_calendar_todo_get_total_count_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + int count; + + if ((ret = calendar_todo_get_total_count_from_db(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &count)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } +} + +static void utc_social_calendar_todo_get_total_count_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_get_total_count_from_db(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER ) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } +} + +static int _create_sample_todo(const char subject[], long long int due) +{ + calendar_todo_h todo; + if (calendar_todo_create(&todo) != CALENDAR_ERROR_NONE) return 1; + if (calendar_todo_set_subject(todo, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_todo_set_due_time(todo, due) != CALENDAR_ERROR_NONE) return 3; + if (calendar_todo_set_priority(todo, CALENDAR_TODO_PRIORITY_NORMAL) != CALENDAR_ERROR_NONE) return 4; + if (calendar_todo_set_status(todo, CALENDAR_TODO_STATUS_IN_PROCESS) != CALENDAR_ERROR_NONE) return 5; + int todo_id; + if (calendar_todo_insert_to_db(todo, DEFAULT_CALENDAR_BOOK_DB_ID, &todo_id) != CALENDAR_ERROR_NONE) + return 6; + if (calendar_todo_destroy(todo) != CALENDAR_ERROR_NONE) return 7; + return 0; +} + +static void utc_social_calendar_todo_get_total_count_by_duedate_range_p(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE; + + calendar_connect(); + + int error; + if ((error = _create_sample_todo("", 100))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 200))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 300))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 400))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 500))) + dts_message(api_name, "Error while building precondition(%d)", error); + + int count; + if ((error = calendar_todo_get_total_count_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_PRIORITY_NORMAL, + CALENDAR_TODO_STATUS_IN_PROCESS, + &count)) + != CALENDAR_ERROR_NONE) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + calendar_disconnect(); + + if (count != 3) { + dts_message(api_name, "Count(%d)", count); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_get_total_count_by_duedate_range_n(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE; + int error; + if ((error = calendar_todo_get_total_count_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + dts_pass(api_name); +} + +static void utc_social_calendar_todo_free_array_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_todo_h* todo_array = NULL; + int length; + + calendar_connect(); + + ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, + CALENDAR_TODO_FILTER_PRIORITY_ALL, + CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, &length); + + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Error while test set-up!"); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + return; + } + + if (todo_array[0] == NULL) { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "array is NULL"); + } + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "lendth:%d", length); + + if ((ret = calendar_todo_free_todo_array(todo_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } +} + +static void utc_social_calendar_todo_free_array_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_free_todo_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } +} + +static void utc_social_calendar_todo_free_modified_todo_array_free_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + pcalendar_modified_todo_s* modified_todo_array = NULL; + + if ((ret = calendar_todo_free_modified_todo_array(modified_todo_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + // TODO: more elaborate test-case needed! + pass = true; + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } +} + +static void utc_social_calendar_todo_free_modified_todo_array_free_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_free_modified_todo_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } +} + +static void utc_social_calendar_todo_search_todo_by_calendar_book_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_todo_h* todo_array = NULL; + int length; + + calendar_connect(); + + if ((ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } +} + +static void utc_social_calendar_todo_search_todo_by_calendar_book_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + calendar_todo_h* todo_array; + int length; + + if ((ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } +} + +static void utc_social_calendar_todo_search_todo_by_duedate_range_p(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE; + + calendar_connect(); + + int error; + if ((error = _create_sample_todo("", 100))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 200))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 300))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 400))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 500))) + dts_message(api_name, "Error while building precondition(%d)", error); + + calendar_todo_h *todo_array = NULL; + int length; + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &todo_array, &length)) + != CALENDAR_ERROR_NONE) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + calendar_disconnect(); + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_search_todo_by_duedate_range_n(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE; + int error; + calendar_todo_h *todo_array = NULL; + int length; + + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL, &length)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &todo_array, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_search_todo_by_version_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + int length; + + calendar_connect(); + pcalendar_modified_todo_s* modified_todo_array = NULL; + + if ((ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, &modified_todo_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } +} + +static void utc_social_calendar_todo_search_todo_by_version_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_modified_todo_s* modified_todo_array = NULL; + int length; + + if ((ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, &modified_todo_array, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } +} |