From 55982998b196ab17126c6794ec2c44bbea0d5c23 Mon Sep 17 00:00:00 2001 From: sri Date: Thu, 7 Sep 2017 14:26:32 +0530 Subject: [PATCH] [ITC][phonenumber-utils][ACR-1005][New api to get blocking rules of specific number] Signed-off-by: sri Change-Id: I262b0747954d1c2eb9f89ea1a34d88ea987b3980 --- .../ITs-phonenumber-utils-blocking-rule.c | 120 ++++++++++++++++++++- .../tct-phonenumber-utils-native_mobile.h | 2 + .../tct-phonenumber-utils-native_wearable.h | 2 + 3 files changed, 122 insertions(+), 2 deletions(-) diff --git a/src/itc/phonenumber-utils/ITs-phonenumber-utils-blocking-rule.c b/src/itc/phonenumber-utils/ITs-phonenumber-utils-blocking-rule.c index 9501604..b8af4b6 100755 --- a/src/itc/phonenumber-utils/ITs-phonenumber-utils-blocking-rule.c +++ b/src/itc/phonenumber-utils/ITs-phonenumber-utils-blocking-rule.c @@ -17,7 +17,6 @@ bool g_IsConnected = false; #define TEST_BLOCKING_RULE_COUNT 8 -#define TEST_NUMBER_COUNT 35 typedef struct { char *number; @@ -52,7 +51,8 @@ static int Phone_add_blocking_rules(int length) } PRINT_RESULT(PHONE_NUMBER_ERROR_NONE, nRet, "phone_number_blocking_rule_create", PhoneNumberUtilsGetError(nRet)); - for (idx = 0; idx < length; idx++) { + for (idx = 0; idx < length; idx++) + { nRet = phone_number_blocking_rule_set_number(rule, g_Blocking_rules[idx].number); PRINT_RESULT_CLEANUP(PHONE_NUMBER_ERROR_NONE, nRet, "phone_number_blocking_rule_set_number", PhoneNumberUtilsGetError(nRet), phone_number_blocking_rule_destroy(rule)); @@ -425,5 +425,121 @@ int ITc_phone_number_utils_blocking_rule_set_get_match_type_p(void) return 0; } +//& type: auto +//& purpose: This function retrieves blocking rules that block a specific number +/** + * @testcase ITc_phone_number_utils_get_blocking_rules_related_p + * @since_tizen 4.0 + * @author SRID(sp.pradhan) + * @reviewer SRID(shobhit.v) + * @type auto + * @description Retrieves blocking rules that block a specific number. + * @scenario Retrieves blocking rules that block a specific number. + * @apicovered phone_number_get_blocking_rules_related, phone_number_blocking_rule_destroy, + * phone_number_blocking_rule_get_match_type. + * @passcase if phone_number_get_blocking_rules_related, phone_number_blocking_rule_get_match_type and phone_number_blocking_rule_destroy returns success + * @failcase if phone_number_get_blocking_rules_related, phone_number_blocking_rule_get_match_type and phone_number_blocking_rule_destroy returns failure + * @precondition NA + * @postcondition NA + */ + +int ITc_phone_number_utils_get_blocking_rules_related_p(void) +{ + START_TEST; + if (g_IsConnected == false) + { + return 1; + } + int nRet = PHONE_NUMBER_ERROR_NONE; + const int test_rules_count = TEST_BLOCKING_RULE_COUNT; + phone_number_blocking_rule_h *rule = NULL; + int length = 0; + int ruleArrayIndex = 0; + int index = 0; + + nRet = Phone_add_blocking_rules(test_rules_count); + if (PHONE_NUMBER_ERROR_NONE != nRet) + { + FPRINTF("[Line : %d][%s] phone_number_utils_add_blocking_rule failed \\n", __LINE__, API_NAMESPACE); + return 1; + } + nRet = phone_number_get_blocking_rules_related("070-1500-1500", &rule, &length); + PRINT_RESULT(PHONE_NUMBER_ERROR_NONE, nRet, "phone_number_get_blocking_rules_related", PhoneNumberUtilsGetError(nRet)); + CHECK_HANDLE(rule, "phone_number_get_blocking_rules_related"); + + if (3 != length) // There are 3 rules possible using "070-1500-1500" string at index 3,4 and 7 in array g_Blocking_rules + { + FPRINTF("[Line : %d][%s] Retunred wrong number of blocking rule \\n", __LINE__, API_NAMESPACE); + Phone_remove_blocking_rules(rule, length); + Phone_free_blocking_rules(rule, length); + return 1; + } + ruleArrayIndex = 3; + for (index = 0; index < length; index++) + { + if (ruleArrayIndex == 5) // Setting array index to compare with rule + { + ruleArrayIndex = 7; + } + nRet = Phone_compare_blocking_rules(g_Blocking_rules[ruleArrayIndex++], rule[index]); + if (PHONE_NUMBER_ERROR_NONE != (nRet)) + { + Phone_remove_blocking_rules(rule, length); + Phone_free_blocking_rules(rule, length); + return 1; + } + } + nRet = Phone_remove_blocking_rules(rule, length); + if (PHONE_NUMBER_ERROR_NONE != nRet) + { + Phone_free_blocking_rules(rule, length); + return 1; + } + + nRet = Phone_free_blocking_rules(rule, length); + if (PHONE_NUMBER_ERROR_NONE != nRet) + { + FPRINTF("[Line : %d][%s] Phone_free_blocking_rules failed \\n", __LINE__, API_NAMESPACE); + return 1; + } + + nRet = phone_number_get_blocking_rules_related("1588-0909", &rule, &length); + PRINT_RESULT(PHONE_NUMBER_ERROR_NONE, nRet, "phone_number_get_blocking_rules_related", PhoneNumberUtilsGetError(nRet)); + CHECK_HANDLE(rule, "phone_number_get_blocking_rules_related"); + if (2 != length) // There are 2 rules possible using "1588-0909" string at index 5 and 6 in array g_Blocking_rules + { + FPRINTF("[Line : %d][%s] Retunred wrong number of blocking rule \\n", __LINE__, API_NAMESPACE); + Phone_remove_blocking_rules(rule, length); + Phone_free_blocking_rules(rule, length); + return 1; + } + + for (index = 0; index < length; index++) + { + nRet = Phone_compare_blocking_rules(g_Blocking_rules[index+5], rule[index]); + if (PHONE_NUMBER_ERROR_NONE != (nRet)) + { + Phone_remove_blocking_rules(rule, length); + Phone_free_blocking_rules(rule, length); + return 1; + } + } + + nRet = Phone_remove_blocking_rules(rule, length); + if (PHONE_NUMBER_ERROR_NONE != nRet) + { + Phone_free_blocking_rules(rule, length); + return 1; + } + nRet = Phone_free_blocking_rules(rule, length); + if (PHONE_NUMBER_ERROR_NONE != nRet) + { + return 1; + } + + return 0; +} + + /** @}*/ /** @}*/ diff --git a/src/itc/phonenumber-utils/tct-phonenumber-utils-native_mobile.h b/src/itc/phonenumber-utils/tct-phonenumber-utils-native_mobile.h index e23d349..87eba28 100755 --- a/src/itc/phonenumber-utils/tct-phonenumber-utils-native_mobile.h +++ b/src/itc/phonenumber-utils/tct-phonenumber-utils-native_mobile.h @@ -32,6 +32,7 @@ extern int ITc_phone_number_utils_add_get_remove_blocking_rule_p(void); extern int ITc_phone_number_utils_blocking_rule_create_destroy_p(void); extern int ITc_phone_number_utils_blocking_rule_set_get_number_p(void); extern int ITc_phone_number_utils_blocking_rule_set_get_match_type_p(void); +extern int ITc_phone_number_utils_get_blocking_rules_related_p(void); testcase tc_array[] = { @@ -43,6 +44,7 @@ testcase tc_array[] = { {"ITc_phone_number_utils_blocking_rule_create_destroy_p",ITc_phone_number_utils_blocking_rule_create_destroy_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {"ITc_phone_number_utils_blocking_rule_set_get_number_p",ITc_phone_number_utils_blocking_rule_set_get_number_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {"ITc_phone_number_utils_blocking_rule_set_get_match_type_p",ITc_phone_number_utils_blocking_rule_set_get_match_type_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, +{"ITc_phone_number_utils_get_blocking_rules_related_p",ITc_phone_number_utils_get_blocking_rules_related_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {NULL, NULL} }; diff --git a/src/itc/phonenumber-utils/tct-phonenumber-utils-native_wearable.h b/src/itc/phonenumber-utils/tct-phonenumber-utils-native_wearable.h index e23d349..87eba28 100755 --- a/src/itc/phonenumber-utils/tct-phonenumber-utils-native_wearable.h +++ b/src/itc/phonenumber-utils/tct-phonenumber-utils-native_wearable.h @@ -32,6 +32,7 @@ extern int ITc_phone_number_utils_add_get_remove_blocking_rule_p(void); extern int ITc_phone_number_utils_blocking_rule_create_destroy_p(void); extern int ITc_phone_number_utils_blocking_rule_set_get_number_p(void); extern int ITc_phone_number_utils_blocking_rule_set_get_match_type_p(void); +extern int ITc_phone_number_utils_get_blocking_rules_related_p(void); testcase tc_array[] = { @@ -43,6 +44,7 @@ testcase tc_array[] = { {"ITc_phone_number_utils_blocking_rule_create_destroy_p",ITc_phone_number_utils_blocking_rule_create_destroy_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {"ITc_phone_number_utils_blocking_rule_set_get_number_p",ITc_phone_number_utils_blocking_rule_set_get_number_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {"ITc_phone_number_utils_blocking_rule_set_get_match_type_p",ITc_phone_number_utils_blocking_rule_set_get_match_type_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, +{"ITc_phone_number_utils_get_blocking_rules_related_p",ITc_phone_number_utils_get_blocking_rules_related_p,ITs_phonenumber_utils_blocking_rule_startup,ITs_phonenumber_utils_blocking_rule_cleanup}, {NULL, NULL} }; -- 2.7.4