[ITC][contacts-service2][ACR-1542][Added New TCs for get count APIs] 44/234144/1
authorABHISHEK JAIN <j.abhishek@samsung.com>
Mon, 11 May 2020 09:26:18 +0000 (14:56 +0530)
committerABHISHEK JAIN <j.abhishek@samsung.com>
Fri, 22 May 2020 07:14:59 +0000 (07:14 +0000)
Change-Id: I744d5ef0b44776d72987afa5990943997a9f8ba8
Signed-off-by: ABHISHEK JAIN <j.abhishek@samsung.com>
(cherry picked from commit 2a0f36609242c4fc3ea0568778f3ee6879ede54a)

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_tizeniot.h
src/itc/contacts-service2/tct-contacts-service2-native_wearable.h

index 820f508bb73432eef7e0892f054111f2870d9c55..ed0212bd16fdc71faf3e3a3bcee8a14d471cb4de 100755 (executable)
@@ -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;
+}
+
 /** @} */ 
 /** @} */
index 91b0ec50256f0a6b291275c14010f4e6a274afbb..2e724fc6e83e0e371bea45feabf2bb04acc54b90 100755 (executable)
@@ -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}
 };
 
index 91b0ec50256f0a6b291275c14010f4e6a274afbb..2e724fc6e83e0e371bea45feabf2bb04acc54b90 100755 (executable)
@@ -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}
 };
 
index 91b0ec50256f0a6b291275c14010f4e6a274afbb..2e724fc6e83e0e371bea45feabf2bb04acc54b90 100755 (executable)
@@ -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}
 };