[ITC][contacts-service2][ACR-549][Added testcases for new apis]
authorperforce <perforce@perforce.(none)>
Wed, 8 Jun 2016 08:51:34 +0000 (17:51 +0900)
committerperforce <perforce@perforce.(none)>
Wed, 8 Jun 2016 08:51:34 +0000 (17:51 +0900)
Change-Id: I31b6149ba7f74ee722a4b29102f05789bf7296b8
Signed-off-by: perforce <perforce@perforce.(none)>
src/itc/contacts-service2/ITs-contacts-service2-database.c
src/itc/contacts-service2/tct-contacts-service2-native_mobile.h
src/itc/contacts-service2/tct-contacts-service2-native_wearable.h

index 6c8dcab..ca60455 100755 (executable)
@@ -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;
+
+}
+
 /** @} */ 
 /** @} */
index fd1749f..a3edbfd 100755 (executable)
@@ -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}
 };
 
index fd1749f..a3edbfd 100755 (executable)
@@ -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}
 };