From 67aa2340474ba6dedd2ca2b6a875a10336add41d Mon Sep 17 00:00:00 2001 From: "jinwang.an" Date: Tue, 8 Jan 2019 17:18:16 +0900 Subject: [PATCH] Add SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS set function Change-Id: I609fa31e0365cde9a8ab4ec7c2a72930f45938a0 Signed-off-by: jinwang.an --- include/system_settings_private.h | 11 +++ src/system_setting_platform.c | 14 ++++ src/system_settings.c | 2 +- unit_test/src/unit_test.c | 149 +++++++++++++++++++++++++------------- 4 files changed, 123 insertions(+), 53 deletions(-) diff --git a/include/system_settings_private.h b/include/system_settings_private.h index 4d5b4be..5d68c48 100644 --- a/include/system_settings_private.h +++ b/include/system_settings_private.h @@ -1469,6 +1469,17 @@ int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error */ int system_setting_get_accessibility_tts(system_settings_key_e key, void **value); + +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_set_accessibility_tts(system_settings_key_e key, void *value); + /** * @internal * @since_tizen 4.0 diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c index 107c200..c0b6d8b 100644 --- a/src/system_setting_platform.c +++ b/src/system_setting_platform.c @@ -2381,6 +2381,20 @@ int system_setting_get_accessibility_tts(system_settings_key_e key, void **value return ret; } +/* LCOV_EXCL_START */ +int system_setting_set_accessibility_tts(system_settings_key_e key, void *value) +{ + SETTING_TRACE_BEGIN; + bool *vconf_value; + vconf_value = (bool *)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) { SETTING_TRACE_BEGIN; diff --git a/src/system_settings.c b/src/system_settings.c index 1be3687..5515fab 100644 --- a/src/system_settings.c +++ b/src/system_settings.c @@ -510,7 +510,7 @@ system_setting_s system_setting_table[] = { SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, SYSTEM_SETTING_DATA_TYPE_BOOL, system_setting_get_accessibility_tts, - NULL, + system_setting_set_accessibility_tts, system_setting_set_changed_callback_accessibility_tts, system_setting_unset_changed_callback_accessibility_tts, NULL, diff --git a/unit_test/src/unit_test.c b/unit_test/src/unit_test.c index 71446dd..5cc47b9 100644 --- a/unit_test/src/unit_test.c +++ b/unit_test/src/unit_test.c @@ -1647,13 +1647,18 @@ RETTYPE utc_system_settings_set_value_string_n4(void) RETTYPE utc_system_settings_set_value_bool_n1(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, state); + /* get current state */ + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, &cur_state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, &ret_state); + /* not support to set value */ + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, state); my_assert_ret(ret); + + + assert(state != cur_state); RETURN(0); } @@ -1667,13 +1672,18 @@ RETTYPE utc_system_settings_set_value_bool_n1(void) RETTYPE utc_system_settings_set_value_bool_n2(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, state); + /* get current state */ + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &cur_state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &ret_state); + + /* not support to set value */ + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, state); my_assert_ret(ret); + + assert(state != cur_state); RETURN(0); } @@ -1687,13 +1697,18 @@ RETTYPE utc_system_settings_set_value_bool_n2(void) RETTYPE utc_system_settings_set_value_bool_n3(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, state); + /* get current state */ + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, &cur_state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, &ret_state); + + /* not support to set value */ + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, state); my_assert_ret(ret); + + assert(state != cur_state); RETURN(0); } @@ -1706,13 +1721,17 @@ RETTYPE utc_system_settings_set_value_bool_n3(void) RETTYPE utc_system_settings_set_value_bool_n4(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, state); + /* get current state */ + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, &cur_state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, &ret_state); + /* not support to set value */ + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, state); my_assert_ret(ret); + + assert(state != cur_state); RETURN(0); } @@ -1726,36 +1745,21 @@ RETTYPE utc_system_settings_set_value_bool_n4(void) RETTYPE utc_system_settings_set_value_bool_n5(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_LOCK, state); + /* get current state */ + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_LOCK, &cur_state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_LOCK, &ret_state); - my_assert_ret(ret); - RETURN(0); -} -/** - * @testcase utc_system_settings_set_value_bool_n6 - * @since_tizen 2.3 - * @description check if SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS is able to get the property. - * check if SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS is able to set the property in an exceptional-case. (not supported) - */ -RETTYPE utc_system_settings_set_value_bool_n6(void) -{ - int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS , state); + /* not support to set value */ + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_LOCK, state); my_assert_ret(ret); - bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS , &ret_state); - my_assert_ret(ret); + assert(state != cur_state); RETURN(0); } - /** * @testcase utc_system_settings_set_value_string_n8 * @since_tizen 2.3 @@ -1966,15 +1970,23 @@ RETTYPE utc_system_settings_set_value_string_p4(void) RETTYPE utc_system_settings_set_value_bool_p1(void) { int ret; - bool state = true; + + bool ret_state = false; + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, &cur_state); + my_assert_ret(ret); + + bool state = !cur_state; ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, state); my_assert_ret(ret); - bool ret_state = false; + /* check current state */ ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, &ret_state); - my_assert_ret(ret); + my_assert_ret_eq_bool(ret, state, ret_state); - //assert_eq(state, ret_state); + /* roll back */ + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, cur_state); + my_assert_ret(ret); RETURN(0); } @@ -1989,22 +2001,23 @@ RETTYPE utc_system_settings_set_value_bool_p1(void) RETTYPE utc_system_settings_set_value_bool_p2(void) { int ret; - bool state = true; - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, state); - my_assert_ret(ret); bool ret_state = false; - ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, &ret_state); + bool cur_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, &cur_state); my_assert_ret(ret); - //assert_eq(state, ret_state); - - /* roll back */ - ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, !state); + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, state); my_assert_ret(ret); + /* check current state */ ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, &ret_state); - //assert_eq(ret_state, !state); + my_assert_ret_eq_bool(ret, state, ret_state); + + /* roll back */ + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, cur_state); + my_assert_ret(ret); RETURN(0); } @@ -2325,6 +2338,38 @@ RETTYPE utc_system_settings_set_value_bool_p10(void) RETURN(0); } + +/** + * @testcase utc_system_settings_set_value_bool_p11 + * @since_tizen 5.5 + * @description check if SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS is able to get the property. + * check if SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS is able to set the property. + */ +RETTYPE utc_system_settings_set_value_bool_p11(void) +{ + int ret; + /* get current state */ + bool cur_state = false; + bool ret_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, &cur_state); + my_assert_ret(ret); + + + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, state); + my_assert_ret(ret); + + /* check current state */ + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, &ret_state); + my_assert_ret_eq_bool(ret, state, ret_state); + + /* roll back */ + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, cur_state); + my_assert_ret(ret); + + RETURN(0); +} + /** * @testcase utc_system_settings_set_value_int_p2 * @since_tizen 2.3 @@ -3052,7 +3097,6 @@ void unittest_api() add_test_func("/utc_system_settings_set_value_bool_n1", utc_system_settings_set_value_bool_n1); add_test_func("/utc_system_settings_set_value_bool_n4", utc_system_settings_set_value_bool_n4); add_test_func("/utc_system_settings_set_value_bool_n5", utc_system_settings_set_value_bool_n5); - add_test_func("/utc_system_settings_set_value_bool_n6", utc_system_settings_set_value_bool_n6); add_test_func("/utc_system_settings_set_value_bool_p1", utc_system_settings_set_value_bool_p1); add_test_func("/utc_system_settings_set_value_bool_p2", utc_system_settings_set_value_bool_p2); add_test_func("/utc_system_settings_set_value_int_n1", utc_system_settings_set_value_int_n1); @@ -3067,6 +3111,7 @@ void unittest_api() add_test_func("/utc_system_settings_set_value_bool_p8", utc_system_settings_set_value_bool_p8); add_test_func("/utc_system_settings_set_value_bool_p9", utc_system_settings_set_value_bool_p9); add_test_func("/utc_system_settings_set_value_bool_p10", utc_system_settings_set_value_bool_p10); + add_test_func("/utc_system_settings_set_value_bool_p11", utc_system_settings_set_value_bool_p11); add_test_func("/utc_system_settings_set_value_int_p2", utc_system_settings_set_value_int_p2); add_test_func("/utc_system_settings_set_value_string_n6", utc_system_settings_set_value_string_n6); g_test_add_func("/utc_system_settings_unset_changed_cb_n", utc_system_settings_unset_changed_cb_n); -- 2.7.4