From: ABHISHEK JAIN Date: Mon, 11 May 2020 09:26:18 +0000 (+0530) Subject: [ITC][contacts-service2][ACR-1542][Added New TCs for get count APIs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a54d9aeb91fe0d6c0709060f59d5ede1864f7779;p=test%2Ftct%2Fnative%2Fapi.git [ITC][contacts-service2][ACR-1542][Added New TCs for get count APIs] Change-Id: I744d5ef0b44776d72987afa5990943997a9f8ba8 Signed-off-by: ABHISHEK JAIN (cherry picked from commit 2a0f36609242c4fc3ea0568778f3ee6879ede54a) --- diff --git a/src/itc/contacts-service2/ITs-contacts-service2-database.c b/src/itc/contacts-service2/ITs-contacts-service2-database.c index 820f508bb..ed0212bd1 100755 --- a/src/itc/contacts-service2/ITs-contacts-service2-database.c +++ b/src/itc/contacts-service2/ITs-contacts-service2-database.c @@ -1453,5 +1453,173 @@ int ITc_contacts_db_search_records_with_query_for_snippet_p(void) } +//& purpose: Gets the number of found records based on a given keyword. +//& type: auto +/** +* @testcase ITc_contacts_db_get_count_for_search_records_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the number of found records based on a given keyword. +* @scenario Connect to contacts service\n +* inserts multiple records in the database\n +* deletes multiple records from the database\n +* Disconnect the contacts service +* @apicovered contacts_db_get_count_for_search_records +* @passcase When contacts_db_get_count_for_search_records and pre-conditions are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition NA +* @postcondition None +*/ +int ITc_contacts_db_get_count_for_search_records_p(void) +{ + START_TEST; + + unsigned int nGetRecordCnt = 0; + int nRet; + + // Target API + nRet = contacts_db_get_count_for_search_records(_contacts_person._uri, "010", &nGetRecordCnt); + + if(!g_bIsContactFeatureSupported) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records API call returned mismatch %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 1; + } + else + { + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records API call correctly returned %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 0; + } + } + + PRINT_RESULT(CONTACTS_ERROR_NONE, nRet, "contacts_db_get_count_for_search_records", ContactsServiceGetError(nRet)); + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records, record count is = %d\\n", __LINE__, API_NAMESPACE, nGetRecordCnt); + + return 0; +} + +//& purpose: Gets the number of found records based on a given keyword and query. +//& type: auto + +/** +* @testcase ITc_contacts_db_get_count_for_search_records_with_query_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the number of found records based on a given keyword and query. +* @scenario Connect to contacts service\n +* inserts multiple records in the database\n +* deletes multiple records from the database\n +* Disconnect the contacts service +* @apicovered contacts_db_get_count_for_search_records_with_query +* @passcase When contacts_db_get_count_for_search_records_with_query and pre-conditions are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition NA +* @postcondition None +*/ +int ITc_contacts_db_get_count_for_search_records_with_query_p(void) +{ + START_TEST; + + contacts_query_h hContactQuery = NULL; + contacts_filter_h hContactFilter = NULL; + + int nRet; + unsigned int nGetRecordCnt = 0; + + nRet = contacts_query_create(_contacts_person._uri, &hContactQuery); + PRINT_RESULT(CONTACTS_ERROR_NONE, nRet, "contacts_query_create", ContactsServiceGetError(nRet)); + + if(!g_bIsContactFeatureSupported) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line : %d][%s] contacts_query_create API call returned mismatch %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 1; + } + else + { + FPRINTF("[Line : %d][%s] contacts_query_create API call correctly returned %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 0; + } + } + + nRet = contacts_filter_create(_contacts_person._uri, &hContactFilter); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_filter_create", ContactsServiceGetError(nRet), contacts_query_destroy(hContactQuery)); + + nRet = contacts_filter_add_int(hContactFilter, _contacts_person.id, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, g_nFirstPersonId); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_filter_add_int", ContactsServiceGetError(nRet), contacts_query_destroy(hContactQuery); contacts_filter_destroy(hContactFilter)); + + nRet = contacts_query_set_filter(hContactQuery, hContactFilter); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_query_set_filter", ContactsServiceGetError(nRet), contacts_query_destroy(hContactQuery); contacts_filter_destroy(hContactFilter)); + + // Target API + nRet = contacts_db_get_count_for_search_records_with_query(hContactQuery, "010", &nGetRecordCnt); + PRINT_RESULT_CLEANUP(CONTACTS_ERROR_NONE, nRet, "contacts_db_get_count_for_search_records_with_query", ContactsServiceGetError(nRet), contacts_query_destroy(hContactQuery); contacts_filter_destroy(hContactFilter)); + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records_with_query, record count is = %d\\n", __LINE__, API_NAMESPACE, nGetRecordCnt); + + nRet = contacts_filter_destroy(hContactFilter); + PRINT_RESULT_NORETURN(CONTACTS_ERROR_NONE, nRet, "contacts_filter_destroy", ContactsServiceGetError(nRet)); + + nRet = contacts_query_destroy(hContactQuery); + PRINT_RESULT_NORETURN(CONTACTS_ERROR_NONE, nRet, "contacts_query_destroy", ContactsServiceGetError(nRet)); + + return 0; +} + +//& purpose: Gets the number of found records based on a given keyword and range. +//& type: auto +/** +* @testcase ITc_contacts_db_get_count_for_search_records_with_range_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the number of found records based on a given keyword and range. +* @scenario Connect to contacts service\n +* inserts multiple records in the database\n +* deletes multiple records from the database\n +* Disconnect the contacts service +* @apicovered contacts_db_get_count_for_search_records_with_range +* @passcase When contacts_db_get_count_for_search_records_with_range and pre-conditions are successful. +* @failcase If target API fails or any precondition API fails. +* @precondition NA +* @postcondition None +*/ +int ITc_contacts_db_get_count_for_search_records_with_range_p(void) +{ + START_TEST; + + int nRet; + unsigned int nGetRecordCnt = 0; + + // Target API + nRet = contacts_db_get_count_for_search_records_with_range(_contacts_person._uri, "010", CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_NUMBER, &nGetRecordCnt); + + if(!g_bIsContactFeatureSupported) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records_with_range API call returned mismatch %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 1; + } + else + { + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records_with_range API call correctly returned %s error for unsupported contact feature\\n", __LINE__, API_NAMESPACE, ContactsServiceGetError(nRet)); + return 0; + } + } + + PRINT_RESULT(CONTACTS_ERROR_NONE, nRet, "contacts_db_get_count_for_search_records_with_range", ContactsServiceGetError(nRet)); + FPRINTF("[Line : %d][%s] contacts_db_get_count_for_search_records_with_range, record count is = %d\\n", __LINE__, API_NAMESPACE, nGetRecordCnt); + + 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 91b0ec502..2e724fc6e 100755 --- a/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h +++ b/src/itc/contacts-service2/tct-contacts-service2-native_mobile.h @@ -132,6 +132,9 @@ extern int ITc_contacts_activity_delete_by_contact_id_p(void); extern int ITc_contacts_record_create_destroy_sip_p(void); extern int ITc_contacts_record_set_get_str_sip_p(void); extern int ITc_contacts_record_set_get_int_sip_p(void); +extern int ITc_contacts_db_get_count_for_search_records_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_range_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_query_p(void); testcase tc_array[] = { {"ITc_contacts_connect_disconnect_p",ITc_contacts_connect_disconnect_p,ITs_contacts_service2_database_startup,ITs_contacts_service2_database_cleanup}, @@ -220,6 +223,9 @@ testcase tc_array[] = { {"ITc_contacts_record_create_destroy_sip_p",ITc_contacts_record_create_destroy_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_str_sip_p",ITc_contacts_record_set_get_str_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_int_sip_p",ITc_contacts_record_set_get_int_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_p", ITc_contacts_db_get_count_for_search_records_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_range_p", ITc_contacts_db_get_count_for_search_records_with_range_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_query_p", ITc_contacts_db_get_count_for_search_records_with_query_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, {NULL, NULL} }; diff --git a/src/itc/contacts-service2/tct-contacts-service2-native_tizeniot.h b/src/itc/contacts-service2/tct-contacts-service2-native_tizeniot.h index 91b0ec502..2e724fc6e 100755 --- a/src/itc/contacts-service2/tct-contacts-service2-native_tizeniot.h +++ b/src/itc/contacts-service2/tct-contacts-service2-native_tizeniot.h @@ -132,6 +132,9 @@ extern int ITc_contacts_activity_delete_by_contact_id_p(void); extern int ITc_contacts_record_create_destroy_sip_p(void); extern int ITc_contacts_record_set_get_str_sip_p(void); extern int ITc_contacts_record_set_get_int_sip_p(void); +extern int ITc_contacts_db_get_count_for_search_records_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_range_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_query_p(void); testcase tc_array[] = { {"ITc_contacts_connect_disconnect_p",ITc_contacts_connect_disconnect_p,ITs_contacts_service2_database_startup,ITs_contacts_service2_database_cleanup}, @@ -220,6 +223,9 @@ testcase tc_array[] = { {"ITc_contacts_record_create_destroy_sip_p",ITc_contacts_record_create_destroy_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_str_sip_p",ITc_contacts_record_set_get_str_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_int_sip_p",ITc_contacts_record_set_get_int_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_p", ITc_contacts_db_get_count_for_search_records_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_range_p", ITc_contacts_db_get_count_for_search_records_with_range_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_query_p", ITc_contacts_db_get_count_for_search_records_with_query_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 91b0ec502..2e724fc6e 100755 --- a/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h +++ b/src/itc/contacts-service2/tct-contacts-service2-native_wearable.h @@ -132,6 +132,9 @@ extern int ITc_contacts_activity_delete_by_contact_id_p(void); extern int ITc_contacts_record_create_destroy_sip_p(void); extern int ITc_contacts_record_set_get_str_sip_p(void); extern int ITc_contacts_record_set_get_int_sip_p(void); +extern int ITc_contacts_db_get_count_for_search_records_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_range_p(void); +extern int ITc_contacts_db_get_count_for_search_records_with_query_p(void); testcase tc_array[] = { {"ITc_contacts_connect_disconnect_p",ITc_contacts_connect_disconnect_p,ITs_contacts_service2_database_startup,ITs_contacts_service2_database_cleanup}, @@ -220,6 +223,9 @@ testcase tc_array[] = { {"ITc_contacts_record_create_destroy_sip_p",ITc_contacts_record_create_destroy_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_str_sip_p",ITc_contacts_record_set_get_str_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, {"ITc_contacts_record_set_get_int_sip_p",ITc_contacts_record_set_get_int_sip_p,ITs_contacts_service2_sip_startup,ITs_contacts_service2_sip_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_p", ITc_contacts_db_get_count_for_search_records_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_range_p", ITc_contacts_db_get_count_for_search_records_with_range_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, + {"ITc_contacts_db_get_count_for_search_records_with_query_p", ITc_contacts_db_get_count_for_search_records_with_query_p, ITs_contacts_service2_database_startup, ITs_contacts_service2_database_cleanup}, {NULL, NULL} };