From 0ad40707366d7d1322b9f904a9aba75b62b4f141 Mon Sep 17 00:00:00 2001 From: Sungmin Kwak Date: Fri, 5 Jun 2015 15:52:20 +0900 Subject: [PATCH] Changes for TCT coverage Change-Id: Ib99676b5032aa5f973ac535f8a39e369b10e68db --- src/inputmethod.cpp | 185 +++++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 90 deletions(-) diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 2faf8da..d27749b 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -733,16 +733,16 @@ int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forw int ime_commit_string(const char *str) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!str) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + g_core.commit_string(-1, NULL, str); return IME_ERROR_NONE; @@ -774,16 +774,16 @@ int ime_hide_preedit_string(void) int ime_update_preedit_string(const char *str, Eina_List *attrs) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!str) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + scim::AttributeList attrv; ime_preedit_attribute *attr = NULL; @@ -820,16 +820,16 @@ int ime_request_surrounding_text(int maxlen_before, int maxlen_after) int ime_delete_surrounding_text(int offset, int len) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (len <= 0) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + g_core.delete_surrounding_text(offset, len); return IME_ERROR_NONE; @@ -861,6 +861,11 @@ int ime_set_size(int portrait_width, int portrait_height, int landscape_width, i { SclSize portrait_size, landscape_size; + if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + if (!g_running) { LOGW("IME_ERROR_NOT_RUNNING"); return IME_ERROR_NOT_RUNNING; @@ -899,16 +904,16 @@ int ime_create_option_window(void) int ime_destroy_option_window(Evas_Object *window) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!window) { LOGW("Window pointer is null."); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); return IME_ERROR_NO_CALLBACK_FUNCTION; @@ -921,16 +926,16 @@ int ime_destroy_option_window(Evas_Object *window) int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !layout) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *layout = context->layout; return IME_ERROR_NONE; @@ -938,16 +943,16 @@ int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout * int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !layout_variation) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *layout_variation = static_cast(context->layout_variation); return IME_ERROR_NONE; @@ -955,16 +960,16 @@ int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !cursor_pos) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *cursor_pos = context->cursor_pos; return IME_ERROR_NONE; @@ -972,16 +977,16 @@ int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !autocapital_type) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *autocapital_type = context->autocapital_type; return IME_ERROR_NONE; @@ -989,16 +994,16 @@ int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapita int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !return_key_type) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *return_key_type = context->return_key_type; return IME_ERROR_NONE; @@ -1006,16 +1011,16 @@ int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !return_key_state) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *return_key_state = static_cast(context->return_key_disabled); return IME_ERROR_NONE; @@ -1023,16 +1028,16 @@ int ime_context_get_return_key_state(ime_context_h context, bool *return_key_sta int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !prediction_mode) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *prediction_mode = static_cast(context->prediction_allow); return IME_ERROR_NONE; @@ -1040,16 +1045,16 @@ int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode int ime_context_get_password_mode(ime_context_h context, bool *password_mode) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !password_mode) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *password_mode = static_cast(context->password_mode); return IME_ERROR_NONE; @@ -1057,16 +1062,16 @@ int ime_context_get_password_mode(ime_context_h context, bool *password_mode) int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !input_hint) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *input_hint = context->input_hint; return IME_ERROR_NONE; @@ -1074,16 +1079,16 @@ int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *inp int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !bidi) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *bidi = context->bidi_direction; return IME_ERROR_NONE; @@ -1091,16 +1096,16 @@ int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Directi int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!context || !language) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *language = context->language; return IME_ERROR_NONE; @@ -1108,16 +1113,16 @@ int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang * int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!dev_info || !dev_name) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + if (!dev_info->dev_name) *dev_name = strdup(""); else @@ -1128,16 +1133,16 @@ int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!dev_info || !dev_class) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *dev_class = dev_info->dev_class; return IME_ERROR_NONE; @@ -1145,16 +1150,16 @@ int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass) { - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - if (!dev_info || !dev_subclass) { LOGW("IME_ERROR_INVALID_PARAMETER"); return IME_ERROR_INVALID_PARAMETER; } + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + *dev_subclass = dev_info->dev_subclass; return IME_ERROR_NONE; -- 2.7.4