[UTC][phonenumber-utils][ACR-1055][Add telephony feature]
authorJongkyu Koo <jk.koo@samsung.com>
Mon, 7 Aug 2017 03:08:58 +0000 (12:08 +0900)
committerJihun Park <jihun87.park@samsung.com>
Thu, 24 Aug 2017 22:42:01 +0000 (22:42 +0000)
Change-Id: I03009aa141f4fc6e7a0f35c2184d0f82d99b323b
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
src/utc/phonenumber-utils/utc-phonenumber-utils-blocking-rule.c
src/utc/phonenumber-utils/utc-phonenumber-utils-service.c
src/utc/phonenumber-utils/utc-phonenumber-utils.c

index e79978c7d680cf20058c0f76ec6b912fb443dd18..e1b8858d061e0131d9a2d28e12bdcafc74041229 100755 (executable)
@@ -65,6 +65,8 @@ const bool blocking_result[TEST_NUMBER_COUNT] = {false, true, false, true, false
                                                                                        true, true, true, false, false};
 
 
+extern bool phn_support_telephony_feature(void);
+
 static int _startup_err;
 
 static int _phn_tc_add_blocking_rules(phn_blocking_rule_s *rules, int length)
@@ -140,6 +142,9 @@ void utc_phonenumber_utils_blocking_rule_startup(void)
 {
        _startup_err = PHONE_NUMBER_ERROR_NONE;
        _startup_err = phone_number_connect();
+       if (PHONE_NUMBER_ERROR_NOT_SUPPORTED == _startup_err
+               && false == phn_support_telephony_feature())
+               _startup_err = PHONE_NUMBER_ERROR_NONE;
 }
 
 /**
@@ -163,6 +168,13 @@ int utc_phonenumber_utils_blocking_rule_create_p(void)
        assert_eq(_startup_err, PHONE_NUMBER_ERROR_NONE);
        int ret = 0;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_create(&rule);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_destroy(rule))) break;
@@ -183,6 +195,13 @@ int utc_phonenumber_utils_blocking_rule_destroy_p(void)
        assert_eq(_startup_err, PHONE_NUMBER_ERROR_NONE);
        int ret = 0;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_destroy(rule);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_destroy(rule))) break;
@@ -204,6 +223,13 @@ int utc_phonenumber_utils_blocking_rule_get_number_p(void)
        int ret = 0;
        char *number = NULL;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_get_number(rule, &number);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_set_number(rule, blocking_rules[0].number))) break;
@@ -234,6 +260,13 @@ int utc_phonenumber_utils_blocking_rule_get_match_type_p(void)
        int ret = 0;
        phone_number_blocking_rule_match_type_e match_type = -1;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_get_match_type(rule, &match_type);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_set_match_type(rule, blocking_rules[0].match_type))) break;
@@ -261,6 +294,13 @@ int utc_phonenumber_utils_blocking_rule_set_number_p(void)
        int ret = 0;
        char *number = NULL;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_set_number(rule, blocking_rules[0].number);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_set_number(rule, blocking_rules[0].number))) break;
@@ -291,6 +331,13 @@ int utc_phonenumber_utils_blocking_rule_set_match_type_p(void)
        int ret = 0;
        phone_number_blocking_rule_match_type_e match_type = -1;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_set_match_type(rule, blocking_rules[0].match_type);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_set_match_type(rule, blocking_rules[0].match_type))) break;
@@ -321,6 +368,14 @@ int utc_phonenumber_utils_add_blocking_rule_p(void)
        int length = 0;
        int idx = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               phone_number_blocking_rule_h rule = NULL;
+
+               ret = phone_number_add_blocking_rule(rule);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_get_blocking_rules(0, 0, &rules, &length))) break;
@@ -361,6 +416,14 @@ int utc_phonenumber_utils_remove_blocking_rule_p(void)
        phone_number_blocking_rule_h *rules = NULL;
        int length = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               phone_number_blocking_rule_h rule = NULL;
+
+               ret = phone_number_remove_blocking_rule(rule);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_get_blocking_rules(0, 0, &rules, &length))) break;
@@ -400,6 +463,12 @@ int utc_phonenumber_utils_get_blocking_rules_with_limit_p(void)
        phone_number_blocking_rule_h *rules = NULL;
        int length = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_get_blocking_rules(0, limit, &rules, &length);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
 
@@ -451,6 +520,12 @@ int utc_phonenumber_utils_get_blocking_rules_with_offset_p(void)
        phone_number_blocking_rule_h *rules = NULL;
        int length = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_get_blocking_rules(offset, 0, &rules, &length);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
 
@@ -502,6 +577,12 @@ int utc_phonenumber_utils_get_blocking_rules_p(void)
        int length = 0;
        int idx = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_get_blocking_rules(0, 0, &rules, &length);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_get_blocking_rules(0, 0, &rules, &length))) break;
@@ -541,6 +622,12 @@ int utc_phonenumber_utils_get_blocking_rules_related_p(void)
        phone_number_blocking_rule_h *rules = NULL;
        int length = 0;
 
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_get_blocking_rules_related("070-1500-1500", &rules, &length);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_NONE != (ret = _phn_tc_add_blocking_rules(blocking_rules, test_rules_count))) break;
 
@@ -600,6 +687,14 @@ int utc_phonenumber_utils_check_blocking_p(void)
        char *normalized_number = NULL;
        const bool *result = blocking_result;
 
+       if (false == phn_support_telephony_feature()) {
+               bool is_blocked = false;
+
+               ret = phone_number_check_blocking(test_number[idx], &is_blocked);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        phone_number_get_normalized_number(test_number[0], &normalized_number);
        if (normalized_number) {
                if (0 ==  strncmp(normalized_number, "+82", 3))
@@ -653,8 +748,10 @@ int utc_phonenumber_utils_blocking_rule_create_n(void)
        int ret = 0;
 
        ret = phone_number_blocking_rule_create(NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
-
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
        return 0;
 }
 
@@ -669,8 +766,10 @@ int utc_phonenumber_utils_blocking_rule_destroy_n(void)
        int ret = 0;
 
        ret = phone_number_blocking_rule_destroy(NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
-
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
        return 0;
 }
 
@@ -685,6 +784,13 @@ int utc_phonenumber_utils_blocking_rule_get_number_n(void)
        int ret = 0;
        char *number = NULL;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_get_number(NULL, &number);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_INVALID_PARAMETER != (ret = phone_number_blocking_rule_get_number(NULL, &number))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
@@ -711,6 +817,13 @@ int utc_phonenumber_utils_blocking_rule_get_match_type_n(void)
        int ret = 0;
        phone_number_blocking_rule_match_type_e match_type = 0;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_get_match_type(NULL, &match_type);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_INVALID_PARAMETER != (ret = phone_number_blocking_rule_get_match_type(NULL, &match_type))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
@@ -735,6 +848,13 @@ int utc_phonenumber_utils_blocking_rule_set_number_n(void)
        assert_eq(_startup_err, PHONE_NUMBER_ERROR_NONE);
        int ret = 0;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_set_number(rule, NULL);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_INVALID_PARAMETER != (ret = phone_number_blocking_rule_set_number(NULL, blocking_rules[0].number))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
@@ -759,6 +879,13 @@ int utc_phonenumber_utils_blocking_rule_set_match_type_n(void)
        assert_eq(_startup_err, PHONE_NUMBER_ERROR_NONE);
        int ret = 0;
        phone_number_blocking_rule_h rule = NULL;
+
+       if (false == phn_support_telephony_feature()) {
+               ret = phone_number_blocking_rule_set_match_type(NULL, blocking_rules[0].match_type);
+               assert_eq(ret, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+
        do {
                if (PHONE_NUMBER_ERROR_INVALID_PARAMETER != (ret = phone_number_blocking_rule_set_match_type(NULL, blocking_rules[0].match_type))) break;
                if (PHONE_NUMBER_ERROR_NONE != (ret = phone_number_blocking_rule_create(&rule))) break;
@@ -786,7 +913,10 @@ int utc_phonenumber_utils_add_blocking_rule_n(void)
 
 
        ret = phone_number_add_blocking_rule(NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
 
        return 0;
 }
@@ -802,7 +932,10 @@ int utc_phonenumber_utils_remove_blocking_rule_n(void)
        int ret = 0;
 
        ret = phone_number_remove_blocking_rule(NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
 
        return 0;
 }
@@ -821,13 +954,28 @@ int utc_phonenumber_utils_get_blocking_rules_n(void)
        int length = 0;
 
        ret = phone_number_get_blocking_rules(-1, 0, &rules, &length);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_get_blocking_rules(0, -1, &rules, &length);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_get_blocking_rules(0, 0, NULL, &length);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_get_blocking_rules(0, 0, &rules, NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
 
        return 0;
 }
@@ -846,11 +994,22 @@ int utc_phonenumber_utils_get_blocking_rules_related_n(void)
        int length = 0;
 
        ret = phone_number_get_blocking_rules_related(NULL, &rules, &length);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_get_blocking_rules_related(test_number[0], NULL, &length);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_get_blocking_rules_related(test_number[0], &rules, NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
 
        return 0;
 }
@@ -867,9 +1026,16 @@ int utc_phonenumber_utils_check_blocking_n(void)
        bool is_blocked = false;
 
        ret = phone_number_check_blocking(NULL, &is_blocked);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
+
        ret = phone_number_check_blocking(test_number[0], NULL);
-       assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       if (phn_support_telephony_feature())
+               assert_eq(PHONE_NUMBER_ERROR_INVALID_PARAMETER, ret);
+       else
+               assert_eq(PHONE_NUMBER_ERROR_NOT_SUPPORTED, ret);
 
        return 0;
 }
index 054ef53eace1eb75b5bd9680acda30e19b599e94..f8b1dfd4afb85eea71025be5014832f543f86491 100755 (executable)
 #define PHONE_NUMBER_TEST_NUMBER "13112345678"
 static int _startup_err;
 
+#define PHN_FEATURE_TELEPHONY "http://tizen.org/feature/network.telephony"
+
+bool phn_support_telephony_feature(void)
+{
+       int ret;
+       static bool feature_checked = false;
+       static bool telephony_feature = false;
+
+       if (feature_checked)
+               return telephony_feature;
+
+       ret = system_info_get_platform_bool(PHN_FEATURE_TELEPHONY, &telephony_feature);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               return telephony_feature;
+       }
+
+       feature_checked = true;
+       return telephony_feature;
+}
+
 /**
  * @function           utc_phonenumber_utils_service_startup
  * @description                Called before each test
@@ -32,6 +52,9 @@ void utc_phonenumber_utils_service_startup(void)
 {
        _startup_err = PHONE_NUMBER_ERROR_NONE;
        _startup_err = phone_number_connect();
+       if (PHONE_NUMBER_ERROR_NOT_SUPPORTED == _startup_err
+               && false == phn_support_telephony_feature())
+               _startup_err = PHONE_NUMBER_ERROR_NONE;
 }
 
 /**
@@ -45,36 +68,6 @@ void utc_phonenumber_utils_service_cleanup(void)
        phone_number_disconnect();
 }
 
-#define API_NAME_PHONENUMBER_UTILS_GET_LOCATION_FROM_NUMBER "phone_number_get_location_from_number"
-#define API_NAME_PHONENUMBER_UTILS_GET_FORMATTED_NUMBER "phone_number_get_formatted_number"
-
-#define PHN_FEATURE_TELEPHONY "http://tizen.org/feature/network.telephony"
-#define PHN_FEATURE_TELEPHONY_INIT_STATE -1
-#define PHN_FEATURE_TELEPHONY_NOT_SUPPORTED 0
-#define PHN_FEATURE_TELEPHONY_SUPPORTED 1
-
-static int _phn_have_telephony_feature = -1;
-
-static int _phn_get_telephony_feature(void)
-{
-       int ret;
-       bool telephony_feature = false;
-
-       if (PHN_FEATURE_TELEPHONY_INIT_STATE != _phn_have_telephony_feature)
-               return _phn_have_telephony_feature;
-
-       ret = system_info_get_platform_bool(PHN_FEATURE_TELEPHONY, &telephony_feature);
-       if (SYSTEM_INFO_ERROR_NONE != ret) {
-               return PHN_FEATURE_TELEPHONY_INIT_STATE;
-       }
-
-       if (false == telephony_feature)
-               _phn_have_telephony_feature = PHN_FEATURE_TELEPHONY_NOT_SUPPORTED;
-       else
-               _phn_have_telephony_feature = PHN_FEATURE_TELEPHONY_SUPPORTED;
-
-       return _phn_have_telephony_feature;
-}
 
 /**
  * @testcase           utc_phonenumber_utils_service_phone_number_disconnect_p
@@ -87,7 +80,10 @@ int utc_phonenumber_utils_service_phone_number_disconnect_p(void)
        int err;
 
        err = phone_number_disconnect();
-       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
        return 0;
 }
 
@@ -107,7 +103,10 @@ int utc_phonenumber_utils_service_phone_number_get_location_from_number_p(void)
                        char *location = NULL;
                        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, i, j, &location);
                        free(location);
-                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       if (phn_support_telephony_feature())
+                               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       else
+                               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
                }
        }
        return 0;
@@ -129,7 +128,10 @@ int utc_phonenumber_utils_service_phone_number_get_location_from_number2_p(void)
                        char *location = NULL;
                        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, i, j, &location);
                        free(location);
-                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       if (phn_support_telephony_feature())
+                               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       else
+                               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
                }
        }
        return 0;
@@ -148,18 +150,30 @@ int utc_phonenumber_utils_service_phone_number_get_location_from_number_n(void)
 
        err = phone_number_get_location_from_number(NULL, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_KOREAN, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, -1, PHONE_NUMBER_LANG_KOREAN, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, -1, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_KOREAN, NULL);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        return 0;
 }
@@ -179,7 +193,10 @@ int utc_phonenumber_utils_service_phone_number_get_formatted_number_p(void)
                char *formatted_number = NULL;
                err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, i, &formatted_number);
                free(formatted_number);
-               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+               if (phn_support_telephony_feature())
+                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+               else
+                       assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
        }
        return 0;
 }
@@ -198,14 +215,23 @@ int utc_phonenumber_utils_service_phone_number_get_formatted_number_n(void)
 
        err = phone_number_get_formatted_number(NULL, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, &formatted_number);
        free(formatted_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, -1, &formatted_number);
        free(formatted_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, NULL);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
    return 0;
 }
@@ -221,16 +247,12 @@ int utc_phonenumber_utils_service_phone_number_get_normalized_number_p(void)
        int err;
        char *normalized_number = NULL;
 
-       if(PHN_FEATURE_TELEPHONY_NOT_SUPPORTED == _phn_get_telephony_feature()) {
-               err = phone_number_get_normalized_number(PHONE_NUMBER_TEST_NUMBER, &normalized_number);
-               free(normalized_number);
-        assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
-        return 0;
-    }
-
        err = phone_number_get_normalized_number(PHONE_NUMBER_TEST_NUMBER, &normalized_number);
        free(normalized_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        return 0;
 }
@@ -246,22 +268,18 @@ int utc_phonenumber_utils_service_phone_number_get_normalized_number_n(void)
        int err;
        char *normalized_number = NULL;
 
-       if(PHN_FEATURE_TELEPHONY_NOT_SUPPORTED == _phn_get_telephony_feature()) {
-               err = phone_number_get_normalized_number(NULL, &normalized_number);
-               free(normalized_number);
-               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
-
-               err = phone_number_get_normalized_number(PHONE_NUMBER_TEST_NUMBER, NULL);
-               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
-               return 0;
-       }
-
        err = phone_number_get_normalized_number(NULL, &normalized_number);
        free(normalized_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_normalized_number(PHONE_NUMBER_TEST_NUMBER, NULL);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        return 0;
 }
index 027fc3445130c4226ad2eb47f89ad7a7da689559..eea7b1a3e7ba08a77f2c59afc561a6e403e4e8e3 100755 (executable)
@@ -19,6 +19,7 @@
 //& set: PhonenumberUtils
 
 #define PHONE_NUMBER_TEST_NUMBER "13112345678"
+extern bool phn_support_telephony_feature(void);
 
 /**
  * @function           utc_phonenumber_utils_startup
@@ -40,9 +41,6 @@ void utc_phonenumber_utils_cleanup(void)
 {
 }
 
-#define API_NAME_PHONENUMBER_UTILS_GET_LOCATION_FROM_NUMBER "phone_number_get_location_from_number"
-#define API_NAME_PHONENUMBER_UTILS_GET_FORMATTED_NUMBER "phone_number_get_formatted_number"
-
 /**
  * @testcase           utc_phonenumber_utils_phone_number_get_location_from_number_p
  * @since_tizen                2.4
@@ -58,7 +56,10 @@ int utc_phonenumber_utils_phone_number_get_location_from_number_p(void)
                        char *location = NULL;
                        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, i, j, &location);
                        free(location);
-                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       if (phn_support_telephony_feature())
+                               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       else
+                               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
                }
        }
        return 0;
@@ -79,7 +80,10 @@ int utc_phonenumber_utils_phone_number_get_location_from_number2_p(void)
                        char *location = NULL;
                        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, i, j, &location);
                        free(location);
-                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       if (phn_support_telephony_feature())
+                               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+                       else
+                               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
                }
        }
        return 0;
@@ -97,18 +101,30 @@ int utc_phonenumber_utils_phone_number_get_location_from_number_n(void)
 
        err = phone_number_get_location_from_number(NULL, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_KOREAN, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, -1, PHONE_NUMBER_LANG_KOREAN, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, -1, &location);
        free(location);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_location_from_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_KOREAN, NULL);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        return 0;
 }
@@ -127,7 +143,10 @@ int utc_phonenumber_utils_phone_number_get_formatted_number_p(void)
                char *formatted_number = NULL;
                err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, i, &formatted_number);
                free(formatted_number);
-               assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+               if (phn_support_telephony_feature())
+                       assert_eq(err, PHONE_NUMBER_ERROR_NONE);
+               else
+                       assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
        }
        return 0;
 }
@@ -145,14 +164,23 @@ int utc_phonenumber_utils_phone_number_get_formatted_number_n(void)
 
        err = phone_number_get_formatted_number(NULL, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, &formatted_number);
        free(formatted_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, -1, &formatted_number);
        free(formatted_number);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
        err = phone_number_get_formatted_number(PHONE_NUMBER_TEST_NUMBER, PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, NULL);
-       assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       if (phn_support_telephony_feature())
+               assert_eq(err, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
+       else
+               assert_eq(err, PHONE_NUMBER_ERROR_NOT_SUPPORTED);
 
    return 0;
 }