From 9ee20c3608bf008c2a0a1bec87d3ca6768904c7e Mon Sep 17 00:00:00 2001 From: perforce Date: Wed, 8 Jun 2016 17:51:34 +0900 Subject: [PATCH] [ITC][contacts-service2][ACR-549][Added testcases for new apis] Change-Id: I31b6149ba7f74ee722a4b29102f05789bf7296b8 Signed-off-by: perforce --- .../ITs-contacts-service2-database.c | 138 +++++++++++++++++++++ .../tct-contacts-service2-native_mobile.h | 6 + .../tct-contacts-service2-native_wearable.h | 6 + 3 files changed, 150 insertions(+) diff --git a/src/itc/contacts-service2/ITs-contacts-service2-database.c b/src/itc/contacts-service2/ITs-contacts-service2-database.c index 6c8dcab..ca60455 100755 --- a/src/itc/contacts-service2/ITs-contacts-service2-database.c +++ b/src/itc/contacts-service2/ITs-contacts-service2-database.c @@ -1141,5 +1141,143 @@ int ITc_contacts_db_get_all_records_p(void) return 0; } +//& purpose: Finds records based on a given keyword for snippet. +//& type: auto +/** +* @testcase ITc_contacts_db_search_records_for_snippet_p +* @since_tizen 3.0 +* @author SRID(sameer.g1) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Finds records based on a given keyword. +* @scenario Connect to contacts service\n +* To find record for a given keyword\n +* Disconnect to contacts service +* @apicovered contacts_db_search_records_for_snippet() +* @passcase When contacts_db_search_records_for_snippet are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition contacts_connect() should be called to open a connection to the contacts service +* @postcondition None +*/ +int ITc_contacts_db_search_records_for_snippet_p(void) +{ + START_TEST; + + const char* pszKeyword = "test"; + int nOffset = 0; + int nLimit = 0; + contacts_list_h stList; + + // Target API + int nRet = contacts_db_search_records_for_snippet(_contacts_person._uri, pszKeyword, nOffset, nLimit, NULL, NULL, -1, &stList); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_db_search_records_for_snippet", ContactsServiceGetError(nRet),contacts_list_destroy(stList, true)); + if ( stList == NULL ) + { + FPRINTF("[Line : %d][%s] contacts_db_search_records_for_snippet failed, returned NULL value \\n", __LINE__, API_NAMESPACE); + contacts_list_destroy(stList, true); + return 1; + } + + nRet = contacts_list_destroy(stList, true); + PRINT_RESULT_NORETURN(CONTACTS_ERROR_NONE, nRet, "contacts_list_destroy", ContactsServiceGetError(nRet)); + + return 0; +} + +//& purpose: To Finds records based on a keyword and range for snippet. +//& type: auto +/** +* @testcase ITc_contacts_db_search_records_with_range_for_snippet_p +* @since_tizen 3.0 +* @author SRID(sameer.g1) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To find records based on a keyword and range. +* @scenario connect to contacts service\n +* set the range and accordingly find record based on keyword\n +* disconnect to contacts service +* @apicovered contacts_db_search_records_with_range_for_snippet() +* @passcase When contacts_db_search_records_with_range_for_snippet are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition contacts_connect() should be called to open a connection to the contacts service +* @postcondition None +*/ +int ITc_contacts_db_search_records_with_range_for_snippet_p(void) +{ + START_TEST; + + const char* pszKeyword = "test"; + int nOffset = 0; + int nLimit = 0; + int nRange = 1; + contacts_list_h stList; + + // Target API + int nRet = contacts_db_search_records_with_range_for_snippet(_contacts_person._uri, pszKeyword, nOffset, nLimit, nRange,NULL, NULL, -1, &stList); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_db_search_records_with_range_for_snippet", ContactsServiceGetError(nRet),contacts_list_destroy(stList, true)); + if ( stList == NULL ) + { + FPRINTF("[Line : %d][%s] contacts_db_search_records_with_range_for_snippet failed, returned NULL value \\n", __LINE__, API_NAMESPACE); + contacts_list_destroy(stList, true); + return 1; + } + + nRet = contacts_list_destroy(stList, true); + PRINT_RESULT_NORETURN(CONTACTS_ERROR_NONE, nRet, "contacts_list_destroy", ContactsServiceGetError(nRet)); + + return 0; +} + +//& purpose: To find records based on given query and keyword. +//& type: auto +/** +* @testcase ITc_contacts_db_search_records_with_query_for_snippet_p +* @since_tizen 3.0 +* @author SRID(sameer.g1) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To find records based on given query and keyword. +* @scenario connect to contacts service\n +* Use query on keyword to find record\n +* Disconnect to contacts service +* @apicovered contacts_db_search_records_with_query_for_snippet +* @passcase When contacts_db_search_records_with_query_for_snippet are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition contacts_connect() should be called to open a connection to the contacts service +* @postcondition None +*/ +int ITc_contacts_db_search_records_with_query_for_snippet_p(void) +{ + START_TEST; + + const char* pszKeyword = "test"; + int nOffset = 0; + int nLimit = 0; + contacts_list_h stList; + contacts_query_h query = NULL; + + int nRet = contacts_query_create(_contacts_person._uri, &query); + PRINT_RESULT(CONTACTS_ERROR_NONE, nRet, "contacts_query_create", ContactsServiceGetError(nRet)); + + // Target API + nRet = contacts_db_search_records_with_query_for_snippet(query, pszKeyword, nOffset, nLimit,NULL, NULL, -1, &stList); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_db_search_records_with_query_for_snippet", ContactsServiceGetError(nRet),contacts_list_destroy(stList, true);contacts_query_destroy(query)); + if ( stList == NULL ) + { + FPRINTF("[Line : %d][%s] contacts_db_search_records_with_query_for_snippet failed, returned NULL value \\n", __LINE__, API_NAMESPACE); + contacts_list_destroy(stList, true); + return 1; + } + + + nRet = contacts_list_destroy(stList, true); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_list_destroy", ContactsServiceGetError(nRet),contacts_query_destroy(query)); + + nRet = contacts_query_destroy(query); + PRINT_RESULT_NORETURN(CONTACTS_ERROR_NONE, nRet, "contacts_query_destroy", ContactsServiceGetError(nRet)); + return 0; + +} + /** @} */ /** @} */ diff --git a/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h b/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h index fd1749f..a3edbfd 100755 --- a/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h +++ b/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h @@ -129,6 +129,9 @@ extern int ITc_contacts_vcard_make_from_person_p(void); extern int ITc_contacts_vcard_parse_to_contact_foreach_p(void); extern int ITc_contacts_vcard_parse_to_contacts_p(void); extern int ITc_contacts_vcard_set_get_limit_size_of_photo_p(void); +extern int ITc_contacts_db_search_records_with_query_for_snippet_p(void); +extern int ITc_contacts_db_search_records_with_range_for_snippet_p(void); +extern int ITc_contacts_db_search_records_for_snippet_p(void); testcase tc_array[] = { {"ITc_contacts_activity_delete_by_account_id_p", ITc_contacts_activity_delete_by_account_id_p, ITs_contacts_service2_activity_startup, ITs_contacts_service2_activity_cleanup}, @@ -214,6 +217,9 @@ testcase tc_array[] = { {"ITc_contacts_vcard_parse_to_contact_foreach_p", ITc_contacts_vcard_parse_to_contact_foreach_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, {"ITc_contacts_vcard_parse_to_contacts_p", ITc_contacts_vcard_parse_to_contacts_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, {"ITc_contacts_vcard_set_get_limit_size_of_photo_p", ITc_contacts_vcard_set_get_limit_size_of_photo_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, + {"ITc_contacts_db_search_records_with_query_for_snippet_p", ITc_contacts_db_search_records_with_query_for_snippet_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_search_records_with_range_for_snippet_p", ITc_contacts_db_search_records_with_range_for_snippet_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_search_records_for_snippet_p", ITc_contacts_db_search_records_for_snippet_p, ITs_contacts_service2_database_startup,ITs_contacts_service2_database_cleanup}, {NULL, NULL} }; diff --git a/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h b/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h index fd1749f..a3edbfd 100755 --- a/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h +++ b/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h @@ -129,6 +129,9 @@ extern int ITc_contacts_vcard_make_from_person_p(void); extern int ITc_contacts_vcard_parse_to_contact_foreach_p(void); extern int ITc_contacts_vcard_parse_to_contacts_p(void); extern int ITc_contacts_vcard_set_get_limit_size_of_photo_p(void); +extern int ITc_contacts_db_search_records_with_query_for_snippet_p(void); +extern int ITc_contacts_db_search_records_with_range_for_snippet_p(void); +extern int ITc_contacts_db_search_records_for_snippet_p(void); testcase tc_array[] = { {"ITc_contacts_activity_delete_by_account_id_p", ITc_contacts_activity_delete_by_account_id_p, ITs_contacts_service2_activity_startup, ITs_contacts_service2_activity_cleanup}, @@ -214,6 +217,9 @@ testcase tc_array[] = { {"ITc_contacts_vcard_parse_to_contact_foreach_p", ITc_contacts_vcard_parse_to_contact_foreach_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, {"ITc_contacts_vcard_parse_to_contacts_p", ITc_contacts_vcard_parse_to_contacts_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, {"ITc_contacts_vcard_set_get_limit_size_of_photo_p", ITc_contacts_vcard_set_get_limit_size_of_photo_p, ITs_contacts_service2_vcard_startup, ITs_contacts_service2_vcard_cleanup}, + {"ITc_contacts_db_search_records_with_query_for_snippet_p", ITc_contacts_db_search_records_with_query_for_snippet_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_search_records_with_range_for_snippet_p", ITc_contacts_db_search_records_with_range_for_snippet_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_search_records_for_snippet_p", ITc_contacts_db_search_records_for_snippet_p, ITs_contacts_service2_database_startup,ITs_contacts_service2_database_cleanup}, {NULL, NULL} }; -- 2.7.4