From 48f06a207625834664046ccb851a0530a7165f98 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Thu, 16 Apr 2020 21:32:36 +0900 Subject: [PATCH 01/16] Update version to 1.60.10 Change-Id: Ifd07f5baac75cce5b0c55c46c268c074397e8680 --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27c15fb..adf6a88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.60.9) +SET(VERSION 1.60.10) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 7c5fcbd..b5d2598 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.60.9 +Version: 1.60.10 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From f611b5e854674fbd9aed5e9244f68cebe42bf8a4 Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Wed, 22 Apr 2020 13:24:58 +0900 Subject: [PATCH 02/16] Fix crash bug about tts text data Change-Id: I2653c67c44672b50261d7dcedbb84c16dd337c2a Signed-off-by: sungrae jo --- server/vcd_server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/vcd_server.c b/server/vcd_server.c index 20934d8..b88f356 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -2719,8 +2719,13 @@ int vcd_server_cancel_tts(int pid, int utt_id) if (0 != ret) { SLOG(LOG_WARN, TAG_VCD, "[Server WARN] No data in vcd tts text queue"); } else { - SLOG(LOG_INFO, TAG_VCD, "[Server] Clear tts text data, pid(%d), utt_id(%d), text(%s)", pid, utt_id, tts_text_data->text); - vcd_data_clear_tts_text_data(&tts_text_data); + if (tts_text_data) { + SLOG(LOG_INFO, TAG_VCD, "[Server] Clear tts text data, pid(%d), utt_id(%d), text(%s)", pid, utt_id, tts_text_data->text); + vcd_data_clear_tts_text_data(&tts_text_data); + tts_text_data = NULL; + } else { + SLOG(LOG_INFO, TAG_VCD, "[Server] Clear tts text data, pid(%d), utt_id(%d), text(nullptr)", pid, utt_id); + } } /* Request tts to engine */ -- 2.7.4 From feff5bb00f0c5e44002065ba6140a5bb1c04f660 Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Fri, 17 Apr 2020 13:39:40 +0900 Subject: [PATCH 03/16] Add new APIs for VC-mgr - vc_mgr_send_audio_streaming() - vc_mgr_set_audio_streaming_mode() - vc_mgr_change_background_volume() - vc_mgr_recover_background_volume() - vc_mgr_set_background_volume_ratio() Change-Id: I09dbbdf6f64ea78cb4476cf3e77adae588cb3ef0 Signed-off-by: sungrae jo --- include/voice_control_manager.h | 170 +++++++++++++++++++++++++++++++ include/voice_control_manager_internal.h | 23 ----- 2 files changed, 170 insertions(+), 23 deletions(-) diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index 1475dd7..49defd3 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -124,6 +124,36 @@ typedef enum { } vc_pre_result_event_e; /** + * @brief Enumeration of audio streaming event. + * @since_tizen 6.0 + */ +typedef enum { + VC_AUDIO_STREAMING_EVENT_FAIL = -1, /**< Failed */ + VC_AUDIO_STREAMING_EVENT_START = 1, /**< Start event */ + VC_AUDIO_STREAMING_EVENT_CONTINUE = 2, /**< Continue event */ + VC_AUDIO_STREAMING_EVENT_FINISH = 3 /**< Finish event */ +} vc_audio_streaming_event_e; + +/** + * @brief Enumeration of audio streaming mode. + * @since_tizen 6.0 + */ +typedef enum { + VC_AUDIO_STREAMING_MODE_VC_SERVICE = 0, /**< Use audio recording from VC service */ + VC_AUDIO_STREAMING_MODE_MULTI_ASSISTANT = 1, /**< Use audio streaming from multi-assistant */ + VC_AUDIO_STREAMING_MODE_OUTSIDE = 2, /**< Use audio streaming from outside */ +} vc_audio_streaming_mode_e; + +/** + * @brief Enumeration of background volume event. + * @since_tizen 6.0 + */ +typedef enum { + VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_NEARFIELD = 0, /**< Background volume event for near-field */ + VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD /**< Background volume event for far-field */ +} vc_background_volume_event_e; + +/** * @brief Called when client gets the all recognition results from voice control service. * @since_tizen 5.0 * @@ -1795,6 +1825,146 @@ int vc_mgr_unset_vc_tts_streaming_cb(void); */ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status); +/** + * @platform + * @brief Sends audio streaming to the engine service. + * @details Using this function, the developer can send audio streaming after vc_mgr_start() function is called. + * @since_tizen 6.0 + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @param[in] event Audio streaming event (e.g. #VC_AUDIO_STREAMING_EVENT_START, #VC_AUDIO_STREAMING_EVENT_CONTINUE) + * @param[in] buffer Audio streaming data + * @param[in] len Length of the audio streaming data + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_OUT_OF_MEMORY Not enough memory + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_SERVICE_STATE_RECORDING. + * + * @see vc_mgr_set_audio_streaming_mode() + */ +int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char *buffer, unsigned int len); + +/** + * @platform + * @brief Sets audio streaming mode. + * @since_tizen 6.0 + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @remarks The default audio streaming mode is #VC_AUDIO_STREAMING_MODE_VC_SERVICE. \n + * If you want to use other mode, you can set mode with vc_mgr_set_audio_streaming_mode(). + * + * @param[in] mode Audio streaming mode + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_SERVICE_STATE_READY. + * + * @see vc_mgr_send_audio_streaming() + */ +int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode); + +/** + * @platform + * @brief Changes background volume. + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @remarks If @a event is #VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_NEARFIELD, the background volume will be reduced by 70%. + * And, if @a event is #VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD, the background volume will be muted. + * + * @param[in] event The background volume event + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_reset_background_volume() + * @see vc_mgr_change_background_volume_by_ratio() + */ +int vc_mgr_change_background_volume(vc_background_volume_event_e event); + +/** + * @platform + * @brief Changes background volume ratio. + * @details Calling this function sets the background volume to a given percentage of its current value. + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @param[in] ratio Current background volume ratio (Range 0.0 ~ 1.0) + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_change_background_volume() + * @see vc_mgr_reset_background_volume() + */ +int vc_mgr_change_background_volume_by_ratio(double ratio); + +/** + * @platform + * @brief Resets background volume. + * @details This function reverts all changes made by vc_mgr_change_background_volume() and vc_mgr_change_background_volume_by_ratio(). + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_change_background_volume() + * @see vc_mgr_change_background_volume_by_ratio() + */ +int vc_mgr_reset_background_volume(void); #ifdef __cplusplus } diff --git a/include/voice_control_manager_internal.h b/include/voice_control_manager_internal.h index 627f025..b86be95 100644 --- a/include/voice_control_manager_internal.h +++ b/include/voice_control_manager_internal.h @@ -28,19 +28,6 @@ extern "C" #endif typedef enum { - VC_AUDIO_STREAMING_EVENT_FAIL = -1, /**< Failed */ - VC_AUDIO_STREAMING_EVENT_START = 1, /**< Start event */ - VC_AUDIO_STREAMING_EVENT_CONTINUE = 2, /**< Continue event */ - VC_AUDIO_STREAMING_EVENT_FINISH = 3 /**< Finish event */ -} vc_audio_streaming_event_e; - -typedef enum { - VC_AUDIO_STREAMING_MODE_VC_SERVICE = 0, /**< Use audio recording from vc service */ - VC_AUDIO_STREAMING_MODE_MULTI_ASSISTANT = 1, /**< Use audio streaming from multi-assistant */ - VC_AUDIO_STREAMING_MODE_OUTSIDE = 2, /**< Use audio streaming from outside */ -} vc_audio_streaming_mode_e; - -typedef enum { VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD, VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD } vc_system_volume_event_e; @@ -99,16 +86,6 @@ int vc_mgr_unset_demandable_client_rule(void); int vc_mgr_set_domain(const char* domain); /** - * @brief Sends audio streaming to the engine service. - * @since_tizen 5.0 - * - */ -int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* buffer, unsigned int len); - -int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e streaming_mode); - - -/** * @brief Changes system volume. * @since_tizen 5.0 * -- 2.7.4 From c72d7d22a3ccd499defbf358d9b60797ceab74e8 Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Mon, 27 Apr 2020 12:35:20 +0900 Subject: [PATCH 04/16] Update version to 1.60.11 Change-Id: Icbab8f7b541de2a5305d178eec389ec905ca8b2a Signed-off-by: sungrae jo --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adf6a88..8574677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.60.10) +SET(VERSION 1.60.11) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index b5d2598..1d9f2d3 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.60.10 +Version: 1.60.11 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 7b229a23544146fe989f5a1f16f266134ab4b7b4 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 12 May 2020 18:37:20 +0900 Subject: [PATCH 05/16] Temporary integration with ma_ap library Change-Id: Ib76300f7dfe19072669e43d1b33898a6ff8b5ce8 --- CMakeLists.txt | 4 ++-- packaging/voice-control.spec | 1 + server/vcd_recorder.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8574677..90fc56b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,12 +48,12 @@ INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api + capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api multi-assistant ) ELSE() pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf + capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf multi-assistant ) ENDIF() diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 1d9f2d3..78801c1 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -40,6 +40,7 @@ BuildRequires: pkgconfig(msfapi) BuildRequires: pkgconfig(farfield-voice-api) %endif BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(multi-assistant) BuildRequires: cmake %description diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index a2d2648..7a48d61 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -43,6 +43,8 @@ #include "vcd_recorder.h" #include "vcd_main.h" +#include + #define FRAME_LENGTH 160 #define BUFFER_LENGTH FRAME_LENGTH * 2 @@ -258,6 +260,25 @@ static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_d } #endif +void audio_streaming_cb(ma_audio_streaming_event_e event, char* buffer, int len, void* user_data) +{ + if (0 == g_buffer_count || 0 == g_buffer_count % 50) { + SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] MA_ap audio function callback is invoked"); + + if (100000 == g_buffer_count) { + g_buffer_count = 0; + } + } + + g_buffer_count++; + + if (NULL != g_audio_cb) { + if (0 != g_audio_cb(buffer, len)) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); + } + } +} + #if 1 static const char* __get_focus_changed_reason_code(sound_stream_focus_change_reason_e reason) { @@ -504,11 +525,15 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb SLOG(LOG_INFO, TAG_VCD, "[Recorder] Audio type : %s", g_current_audio_type); + ma_ap_initialize(); + ma_ap_set_audio_streaming_cb(audio_streaming_cb, NULL); + return 0; } int vcd_recorder_destroy() { + ma_ap_deinitialize(); if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) { if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) { #ifdef TV_BT_MODE -- 2.7.4 From 2385286d70ecf35b96fbcb4ae46c8d6d416c7e61 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 9 Jul 2020 10:57:17 +0900 Subject: [PATCH 06/16] Remove unnecessary header Change-Id: Iecef17f7ea56028bea23b250687cb502d4917d69 Signed-off-by: Suyeon Hwang --- server/vcd_recorder.c | 1 - server/vcd_server.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 7a48d61..c781470 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -21,7 +21,6 @@ #endif #include -#include #include #include #ifdef TV_PRODUCT diff --git a/server/vcd_server.c b/server/vcd_server.c index b88f356..d675240 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -16,10 +16,6 @@ #include #include -#include -#include -#include -#include #include "vc_cmd_db.h" #include "vc_info_parser.h" -- 2.7.4 From 5db2de67c7f83bcc4ad2ea33cf81203619450e6e Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Thu, 30 Jul 2020 13:36:06 +0900 Subject: [PATCH 07/16] Fixed enum value for vc_tts_utterance_status_e Change-Id: I01fe0b9f25be912764cc8a2aeb98be053e97e8a3 Signed-off-by: sungrae jo --- client/vc_mgr.c | 2 +- include/voice_control_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 7acde3c..3caa9ae 100755 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -4359,7 +4359,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e return VC_ERROR_PERMISSION_DENIED; } - if (VC_TTS_UTTERANCE_NONE > utt_status || VC_TTS_UTTERANCE_CANCELED < utt_status) { + if (VC_TTS_UTTERANCE_NONE > utt_status || VC_TTS_UTTERANCE_CANCELED < utt_status || 0 == utt_status) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] utt_status is not valid. (%d)", utt_status); return VC_ERROR_INVALID_PARAMETER; } diff --git a/include/voice_control_common.h b/include/voice_control_common.h index f8ca800..136e628 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -138,7 +138,7 @@ typedef enum { * @since_tizen 5.5 */ typedef enum { - VC_TTS_UTTERANCE_NONE = 0, /**< None */ + VC_TTS_UTTERANCE_NONE = -1, /**< None */ VC_TTS_UTTERANCE_STARTED = 1, /**< Utterance started */ VC_TTS_UTTERANCE_COMPLETED = 2, /**< Utterance completed */ VC_TTS_UTTERANCE_CANCELED = 3 /**< Utterance canceled */ -- 2.7.4 From dc698bfe7e94c9496bdda96f8832329199fc03c7 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 30 Jul 2020 18:04:47 +0900 Subject: [PATCH 08/16] Add system_background type for vc_mgr_set_command_list_from_file() API Change-Id: I404da413b8981ee1a362d8525397c73d5edf7c73 Signed-off-by: Suyeon Hwang --- common/vc_json_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c index d6be245..63e838b 100644 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -87,6 +87,8 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati temp_type = strdup("widget"); } else if (VC_COMMAND_TYPE_SYSTEM == type) { temp_type = strdup("system"); + } else if (VC_COMMAND_TYPE_SYSTEM_BACKGROUND == type) { + temp_type = strdup("systemBackground"); } else if (VC_COMMAND_TYPE_EXCLUSIVE == type) { temp_type = strdup("exclusive"); } -- 2.7.4 From 9d346e67c083280b4a399f771ad0a5ab38f4cfd1 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 31 Jul 2020 13:38:57 +0900 Subject: [PATCH 09/16] Restore neccessary header files Change-Id: I670bd938dd27f0b035b6da899232081a31bb7eb5 Signed-off-by: Suyeon Hwang --- server/vcd_recorder.c | 1 + server/vcd_server.c | 1 + 2 files changed, 2 insertions(+) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index c781470..7a48d61 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -21,6 +21,7 @@ #endif #include +#include #include #include #ifdef TV_PRODUCT diff --git a/server/vcd_server.c b/server/vcd_server.c index d675240..cd5e3b4 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -16,6 +16,7 @@ #include #include +#include #include "vc_cmd_db.h" #include "vc_info_parser.h" -- 2.7.4 From 0142ddac3902c466834d6665a0ab99b557537f30 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 31 Jul 2020 14:24:11 +0900 Subject: [PATCH 10/16] Add to send set volume in audio_streaming_cb Change-Id: If302fa2feebff6fe2f2ac4c54448cdcf9d36f4d5 Signed-off-by: sooyeon.kim --- server/vcd_recorder.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index c781470..dddc02c 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -276,6 +276,14 @@ void audio_streaming_cb(ma_audio_streaming_event_e event, char* buffer, int len, SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); } } + + /* Set volume */ + if (0 == g_buffer_count % 15) { + float vol_db = get_volume_decibel(buffer, len); + if (0 != vcdc_send_set_volume(vcd_client_manager_get_pid(), vol_db)) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder] Fail to send recording volume(%f)", vol_db); + } + } } #if 1 -- 2.7.4 From 6593c97c375e67532e6eca421d9889ff3a1d8093 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 31 Jul 2020 15:04:08 +0900 Subject: [PATCH 11/16] Add to set audio handles as NULL Change-Id: I5bd36e406a7021764fc469b7f639d56e77a89687 Signed-off-by: sooyeon.kim --- server/vcd_recorder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index dddc02c..8695383 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -559,14 +559,17 @@ int vcd_recorder_destroy() int ret = sound_manager_remove_device_connection_changed_cb(g_device_id); if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to remove device connection changed callback, ret(%d)", ret); + g_device_id = -1; ret = sound_manager_destroy_stream_information(g_stream_info_h); if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to destroy stream info, ret(%d)", ret); + g_stream_info_h = NULL; ret = audio_in_destroy(g_audio_h); if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to audio in destroy, ret(%d)", ret); + g_audio_h = NULL; #ifdef TV_FFV_MODE if (NULL != g_farfieldvoice_h) { @@ -679,6 +682,7 @@ int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, in if (g_audio_type != type || g_audio_rate != rate || g_audio_channel != channel) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] New audio type(%d) rate(%d) channel(%d)", type, rate, channel); audio_in_destroy(g_audio_h); + g_audio_h = NULL; audio_channel_e audio_ch = AUDIO_CHANNEL_MONO; audio_sample_type_e audio_sample_type; @@ -908,6 +912,7 @@ static void __check_audio_format() if (g_audio_type != type || g_audio_rate != rate || g_audio_channel != channel) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] New audio type(%d) rate(%d) channel(%d)", type, rate, channel); audio_in_destroy(g_audio_h); + g_audio_h = NULL; audio_channel_e audio_ch; audio_sample_type_e audio_type; -- 2.7.4 From 7bab32340d618e30ce56c0ebcb84446516fb925d Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 3 Aug 2020 10:43:19 +0900 Subject: [PATCH 12/16] Version up to 1.60.12 Change-Id: Ia01ceaeb9cbc20a175c2ce036b0ec089133fa722 Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90fc56b..b93d8c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.60.11) +SET(VERSION 1.60.12) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 78801c1..69aa1e1 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.60.11 +Version: 1.60.12 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 37157c7b737df2acafa2a559773a6f6d1a94a592 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 11 Sep 2020 14:08:46 +0900 Subject: [PATCH 13/16] Exclude some logs from lcov Change-Id: I54c31c003b4c3060f23ba3cb8116e9b8eaf06776 Signed-off-by: sooyeon.kim --- client/vc.c | 170 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 89 insertions(+), 81 deletions(-) diff --git a/client/vc.c b/client/vc.c index cd57765..f5ed34d 100644 --- a/client/vc.c +++ b/client/vc.c @@ -76,19 +76,21 @@ static int __vc_get_feature_enabled() if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { if (false == vc_supported || false == mic_supported) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); g_feature_enabled = 0; return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } g_feature_enabled = 1; } else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } } else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } } @@ -111,7 +113,7 @@ static int __check_privilege(const char* uid, const char * privilege) char smack_label[1024] = {'\0',}; if (!p_cynara) { - return false; + return false; //LCOV_EXCL_LINE } fp = fopen(label_path, "r"); @@ -130,7 +132,7 @@ static int __check_privilege(const char* uid, const char * privilege) free(session); if (ret != CYNARA_API_ACCESS_ALLOWED) - return false; + return false; //LCOV_EXCL_LINE return true; } @@ -140,7 +142,7 @@ static void __check_privilege_deinitialize() { int ret = cynara_finish(p_cynara); if (ret != CYNARA_API_SUCCESS) - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] cynara finish %d", ret); + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] cynara finish %d", ret); //LCOV_EXCL_LINE } p_cynara = NULL; } @@ -156,9 +158,11 @@ static int __vc_check_privilege() bool ret = true; ret = __check_privilege_initialize(); if (false == ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } char uid[16]; @@ -167,9 +171,11 @@ static int __vc_check_privilege() ret = __check_privilege(uid, VC_PRIVILEGE); __check_privilege_deinitialize(); if (false == ret) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied"); pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } } @@ -320,10 +326,10 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) int vc_initialize(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Initialize"); @@ -412,10 +418,10 @@ int vc_deinitialize(void) int ret = VC_ERROR_NONE; if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Deinitialize"); @@ -643,10 +649,10 @@ static void __end_prepare_thread(void *data, Ecore_Thread *thread) int vc_prepare(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -676,10 +682,10 @@ int vc_prepare(void) int vc_prepare_sync(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -717,10 +723,10 @@ int vc_prepare_sync(void) int vc_unprepare(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare"); @@ -752,10 +758,10 @@ int vc_unprepare(void) int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); @@ -789,10 +795,10 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user int vc_get_current_language(char** language) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); @@ -825,10 +831,10 @@ int vc_get_current_language(char** language) int vc_get_state(vc_state_e* state) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State"); @@ -864,10 +870,10 @@ int vc_get_state(vc_state_e* state) int vc_get_service_state(vc_service_state_e* state) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); @@ -917,10 +923,10 @@ int vc_get_service_state(vc_service_state_e* state) int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list"); @@ -1034,10 +1040,10 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported"); @@ -1087,12 +1093,14 @@ static int __vc_get_invocation_name(char** invocation_name) ret = app_manager_get_app_id(getpid(), &appid); if (0 != ret || NULL == appid) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get appid, ret(%d)", ret); //LCOV_EXCL_LINE if (NULL != appid) { free(appid); appid = NULL; } return VC_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } ret = vc_get_current_language(&lang); @@ -1109,6 +1117,7 @@ static int __vc_get_invocation_name(char** invocation_name) ret = app_info_get_localed_label(appid, lang, &temp_label); if (0 != ret || NULL == temp_label) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get localed label, ret(%d) appid(%s) lang(%s)", ret, appid, lang); //LCOV_EXCL_LINE free(appid); appid = NULL; @@ -1119,6 +1128,7 @@ static int __vc_get_invocation_name(char** invocation_name) temp_label = NULL; } return VC_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *invocation_name = strdup(temp_label); @@ -1142,10 +1152,10 @@ static int __vc_get_invocation_name(char** invocation_name) int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list"); @@ -1247,10 +1257,10 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) int vc_unset_command_list(int type) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); @@ -1313,10 +1323,10 @@ int vc_unset_command_list(int type) int vc_set_command_list_from_file(const char* file_path, int type) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); @@ -1365,7 +1375,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) do { ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type); if (0 != ret) { - //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { @@ -1384,7 +1393,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) break; } } - //LCOV_EXCL_STOP } } while (0 != ret); } @@ -1794,10 +1802,10 @@ void __vc_cb_result(void) int vc_get_result(vc_result_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); @@ -1861,10 +1869,10 @@ int vc_get_result(vc_result_cb callback, void* user_data) int vc_set_result_cb(vc_result_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -1890,10 +1898,10 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) int vc_unset_result_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -1945,7 +1953,6 @@ int __vc_cb_service_state(int state) return 0; } -//LCOV_EXCL_STOP int __vc_cb_manager_pid(int manager_pid) { @@ -1956,14 +1963,15 @@ int __vc_cb_manager_pid(int manager_pid) return 0; } +//LCOV_EXCL_STOP int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -1989,10 +1997,10 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* int vc_unset_service_state_changed_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -2015,10 +2023,10 @@ int vc_unset_service_state_changed_cb(void) int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (callback == NULL) @@ -2044,10 +2052,10 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) int vc_unset_state_changed_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -2070,10 +2078,10 @@ int vc_unset_state_changed_cb(void) int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -2099,10 +2107,10 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, int vc_unset_current_language_changed_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -2125,10 +2133,10 @@ int vc_unset_current_language_changed_cb(void) int vc_set_error_cb(vc_error_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -2154,10 +2162,10 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) int vc_unset_error_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -2180,10 +2188,10 @@ int vc_unset_error_cb(void) int vc_set_invocation_name(const char* name) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -2218,10 +2226,10 @@ int vc_set_server_dialog(const char* app_id, const char* credential) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == credential) { @@ -2309,10 +2317,10 @@ int vc_unset_server_dialog(const char* app_id) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2398,10 +2406,10 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog"); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3015,10 +3023,10 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request tts"); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3085,10 +3093,10 @@ int vc_tts_cancel(int utt_id) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Cancel tts"); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3160,10 +3168,10 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get tts audio format"); if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3224,10 +3232,10 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -3253,10 +3261,10 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) int vc_tts_unset_streaming_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; @@ -3298,10 +3306,10 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } if (NULL == callback) @@ -3327,10 +3335,10 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us int vc_tts_unset_utterance_status_cb(void) { if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } vc_state_e state; -- 2.7.4 From 3b3078565a05e00ae492a2e69e0eb928b6b8e579 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 9 Sep 2020 20:48:29 +0900 Subject: [PATCH 14/16] Add unittests Change-Id: I0706d0bfc8ebd75d63b6149e5885b696a9afcaea Signed-off-by: Jihoon Kim --- CMakeLists.txt | 14 +- client/vc_setting.c | 5 - packaging/voice-control.spec | 24 +- tests/CMakeLists.txt | 46 + tests/org.tizen.vc-unittests.manifest | 5 + tests/org.tizen.vc-unittests.xml | 13 + tests/src/cynara_mock.cpp | 34 + tests/src/cynara_mock.h | 87 + tests/src/main.cpp | 7 + tests/src/system_info_mock.cpp | 11 + tests/src/system_info_mock.h | 16 + tests/src/vc_denied_unittests.cpp | 45 + tests/src/vc_unittests.cpp | 3170 +++++++++++++++++++++++++++++++++ 13 files changed, 3468 insertions(+), 9 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/org.tizen.vc-unittests.manifest create mode 100644 tests/org.tizen.vc-unittests.xml create mode 100644 tests/src/cynara_mock.cpp create mode 100644 tests/src/cynara_mock.h create mode 100644 tests/src/main.cpp create mode 100644 tests/src/system_info_mock.cpp create mode 100644 tests/src/system_info_mock.h create mode 100644 tests/src/vc_denied_unittests.cpp create mode 100644 tests/src/vc_unittests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b93d8c6..eb9b3f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,12 +48,12 @@ INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api multi-assistant + capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api multi-assistant gmock ) ELSE() pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf multi-assistant + capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf multi-assistant gmock ) ENDIF() @@ -91,3 +91,13 @@ INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/aarch64/vc_getengine DESTINATION ${TZ_S ELSEIF("${ARCH}" MATCHES "^x86_64.*") INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/x86_64/vc_getengine DESTINATION ${TZ_SYS_BIN}) ENDIF() + +## Test +IF(NOT DEFINED MINIMUM_BUILD) +ENABLE_TESTING() +SET(UNITTEST_VC vc-unittests) +ADD_TEST(NAME ${UNITTEST_VC} COMMAND ${UNITTEST_VC} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + +ADD_SUBDIRECTORY(tests) +ENDIF(NOT DEFINED MINIMUM_BUILD) diff --git a/client/vc_setting.c b/client/vc_setting.c index cbba8ad..4a8ca0e 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -45,11 +45,6 @@ static void* g_enabled_changed_user_data = NULL; static vc_setting_current_language_changed_cb g_current_language_changed_cb = NULL; static void* g_current_language_changed_user_data = NULL; -const char* vc_tag() -{ - return TAG_VCS; -} - void __config_lang_changed_cb(const char* before_lang, const char* current_lang) { SLOG(LOG_DEBUG, TAG_VCS, "Lang changed : before(%s) current(%s)", before_lang, current_lang); diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 69aa1e1..2bdd9e8 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -42,6 +42,12 @@ BuildRequires: pkgconfig(farfield-voice-api) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(multi-assistant) BuildRequires: cmake +BuildRequires: pkgconfig(gmock) + +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif %description Voice Control client library and daemon @@ -99,6 +105,14 @@ Group: Graphics & UI Framework/Voice Framework Voice control gcov objects %endif +%package unittests +Summary: Voice control tests +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description unittests +GTest for Voice Control + %prep %setup -q -n %{name}-%{version} @@ -116,10 +130,10 @@ export LDFLAGS="$LDFLAGS -lgcov" %if "%{tizen_profile_name}" == "tv" export CFLAGS="$CFLAGS -DTV_PRODUCT" cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ - -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -D_TV_PRODUCT=TRUE -DTZ_SYS_BIN=%TZ_SYS_BIN + -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -D_TV_PRODUCT=TRUE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP %else cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ - -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN + -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP %endif make %{?jobs:-j%jobs} @@ -225,3 +239,9 @@ mkdir -p %{_libdir}/voice/vc %files gcov %{_datadir}/gcov/obj/* %endif + +%files unittests +%manifest tests/org.tizen.vc-unittests.manifest +%defattr(-,root,root,-) +%{TZ_SYS_RO_PACKAGES}/org.tizen.vc-unittests.xml +%{TZ_SYS_RO_APP}/org.tizen.vc-unittests/bin/vc-unittests diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..ec00560 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,46 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gtest-voice-control CXX) + +SET(PKGNAME "org.tizen.vc-unittests") +SET(BINDIR "${TZ_SYS_RO_APP}/${PKGNAME}/bin") + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") + +SET(SOURCES "") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) + +AUX_SOURCE_DIRECTORY(src SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client VC_CLIENT_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../common VC_COMMON_SOURCES) + +ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"") + +ADD_EXECUTABLE(${UNITTEST_VC} + ${VC_COMMON_SOURCES} + ${VC_CLIENT_SOURCES} + ${SOURCES} + ) +TARGET_LINK_LIBRARIES(${UNITTEST_VC} ${GTEST_LIBRARIES} ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS}) +SET_TARGET_PROPERTIES(${UNITTEST_VC} PROPERTIES + COMPILE_FLAGS "-fPIE" + #Never add any space for LINKFLAGS + LINK_FLAGS "-Wl,\ +--wrap=system_info_get_platform_bool,\ +--wrap=cynara_initialize,\ +--wrap=cynara_finish,\ +--wrap=cynara_session_from_pid,\ +--wrap=cynara_check") + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/tests/${PKGNAME}.xml DESTINATION ${TZ_SYS_RO_PACKAGES}) +INSTALL(TARGETS ${UNITTEST_VC} DESTINATION ${BINDIR}) diff --git a/tests/org.tizen.vc-unittests.manifest b/tests/org.tizen.vc-unittests.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/tests/org.tizen.vc-unittests.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/org.tizen.vc-unittests.xml b/tests/org.tizen.vc-unittests.xml new file mode 100644 index 0000000..663ba43 --- /dev/null +++ b/tests/org.tizen.vc-unittests.xml @@ -0,0 +1,13 @@ + + + + Jihoon Kim + Voice Control unittests + + + + + + http://tizen.org/privilege/recorder + + diff --git a/tests/src/cynara_mock.cpp b/tests/src/cynara_mock.cpp new file mode 100644 index 0000000..ff6e88f --- /dev/null +++ b/tests/src/cynara_mock.cpp @@ -0,0 +1,34 @@ +#include "cynara_mock.h" +#include +#include +#include + +static int check_result = CYNARA_API_ACCESS_ALLOWED; + +void cynara_check_set_result(int result) +{ + check_result = result; +} + +EXPORT_API int __wrap_cynara_initialize(cynara** c, const cynara_configuration* conf) +{ + *c = (void *)0x1; + return 0; +} + +EXPORT_API int __wrap_cynara_finish(cynara* c) +{ + return 0; +} + +EXPORT_API int __wrap_cynara_check(cynara* c, const char* client, const char* client_session, + const char* user, + const char* privilege) +{ + return check_result; +} + +EXPORT_API char *__wrap_cynara_session_from_pid(pid_t pid) +{ + return strdup("session"); +} diff --git a/tests/src/cynara_mock.h b/tests/src/cynara_mock.h new file mode 100644 index 0000000..1becb42 --- /dev/null +++ b/tests/src/cynara_mock.h @@ -0,0 +1,87 @@ +#ifndef MOCK_CYNARA_H_ +#define MOCK_CYNARA_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void cynara; +typedef void* cynara_configuration; + +/*! \brief indicating that API call was interrupted by user*/ +#define CYNARA_API_INTERRUPTED 4 + +/*! \brief indicating access that cannot be resolved without further actions*/ +#define CYNARA_API_ACCESS_NOT_RESOLVED 3 + +/*! \brief indicating access that was checked is allowed */ +#define CYNARA_API_ACCESS_ALLOWED 2 + +/*! \brief indicating that access that was checked is denied */ +#define CYNARA_API_ACCESS_DENIED 1 + +/*! \brief indicating the result of the one specific API is successful */ +#define CYNARA_API_SUCCESS 0 + +/*! \brief indicating that value is not present in cache */ +#define CYNARA_API_CACHE_MISS -1 + +/*! \brief indicating that pending requests reached maximum */ +#define CYNARA_API_MAX_PENDING_REQUESTS -2 + +/*! \brief indicating system is running out of memory state */ +#define CYNARA_API_OUT_OF_MEMORY -3 + +/*! \brief indicating the API's parameter is malformed */ +#define CYNARA_API_INVALID_PARAM -4 + +/*! \brief indicating that service is not available */ +#define CYNARA_API_SERVICE_NOT_AVAILABLE -5 + +/*! \brief indicating that provided method is not supported by library */ +#define CYNARA_API_METHOD_NOT_SUPPORTED -6 + +/*! \brief cynara service does not allow to perform requested operation */ +#define CYNARA_API_OPERATION_NOT_ALLOWED -7 + +/*! \brief cynara service failed to perform requested operation */ +#define CYNARA_API_OPERATION_FAILED -8 + +/*! \brief cynara service hasn't found requested bucket */ +#define CYNARA_API_BUCKET_NOT_FOUND -9 + +/*! \brief indicating an unknown error */ +#define CYNARA_API_UNKNOWN_ERROR -10 + +/*! \brief indicating configuration error */ +#define CYNARA_API_CONFIGURATION_ERROR -11 + +/*! \brief indicating invalid parameter in command-line */ +#define CYNARA_API_INVALID_COMMANDLINE_PARAM -12 + +/*! \brief indicating that provided buffer is too short */ +#define CYNARA_API_BUFFER_TOO_SHORT -13 + +/*! \brief indicating that database is corrupted */ +#define CYNARA_API_DATABASE_CORRUPTED -14 + +/*! \brief indicating that user doesn't have enough permission to perform action */ +#define CYNARA_API_PERMISSION_DENIED -15 + +void cynara_check_set_result(int result); + +int __wrap_cynara_initialize(cynara** c, const cynara_configuration* conf); +int __wrap_cynara_finish(cynara* c); +int __wrap_cynara_check(cynara* c, const char* client, const char* client_session, + const char* user, + const char* privilege); + +char *__wrap_cynara_session_from_pid(pid_t pid); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_CYNARA_H_ */ diff --git a/tests/src/main.cpp b/tests/src/main.cpp new file mode 100644 index 0000000..a37d671 --- /dev/null +++ b/tests/src/main.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main(int argc, char** argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/src/system_info_mock.cpp b/tests/src/system_info_mock.cpp new file mode 100644 index 0000000..0e00a70 --- /dev/null +++ b/tests/src/system_info_mock.cpp @@ -0,0 +1,11 @@ +#include "system_info_mock.h" +#include +#include + +EXPORT_API int __wrap_system_info_get_platform_bool(const char *key, bool *value) +{ + if (value) + *value = true; + + return 0; +} diff --git a/tests/src/system_info_mock.h b/tests/src/system_info_mock.h new file mode 100644 index 0000000..075c93b --- /dev/null +++ b/tests/src/system_info_mock.h @@ -0,0 +1,16 @@ +#ifndef MOCK_SYSTEM_INFO_H_ +#define MOCK_SYSTEM_INFO_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int __wrap_system_info_get_platform_bool(const char *key, bool *value); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_SYSTEM_INFO_H_ */ diff --git a/tests/src/vc_denied_unittests.cpp b/tests/src/vc_denied_unittests.cpp new file mode 100644 index 0000000..c133af6 --- /dev/null +++ b/tests/src/vc_denied_unittests.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "cynara_mock.h" +#include "system_info_mock.h" + +namespace { + +class VCDeniedTest : public testing::Test { + public: + virtual void SetUp() { + /* start of TC */ + cynara_check_set_result(CYNARA_API_ACCESS_DENIED); + } + virtual void TearDown() { + /* end of TC */ + cynara_check_set_result(CYNARA_API_ACCESS_ALLOWED); + } +}; + +TEST_F(VCDeniedTest, utc_stt_create_denied) +{ + int ret = VC_ERROR_NONE; + + ret = vc_initialize(); + EXPECT_EQ(ret, VC_ERROR_PERMISSION_DENIED); +} + +} // namespace diff --git a/tests/src/vc_unittests.cpp b/tests/src/vc_unittests.cpp new file mode 100644 index 0000000..531f36f --- /dev/null +++ b/tests/src/vc_unittests.cpp @@ -0,0 +1,3170 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include "system_info_mock.h" +#include "cynara_mock.h" + +static int g_vc_init = false; +static vc_state_e g_vc_state = VC_STATE_NONE; +static bool g_vc_supported = false; + +static void __vc_result_cb(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void* user_data) +{ +} + +static void __vc_current_language_changed_cb(const char* previous, const char* current, void* user_data) +{ +} + +static bool __vc_supported_language_cb(const char* language, void* user_data) +{ + return true; +} + +static void __vc_state_changed_cb(vc_state_e previous, vc_state_e current, void* user_data) +{ + g_vc_state = current; +} + +static void __vc_service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data) +{ +} + +static void __vc_error_cb(vc_error_e reason, void* user_data) +{ +} + +static bool __vc_cmd_list_cb(vc_cmd_h vc_command, void* user_data) +{ + return true; +} + +namespace { + +class VCTest : public testing::Test { + public: + virtual void SetUp() { + ecore_init(); + ecore_main_loop_glib_integrate(); + + cynara_check_set_result(CYNARA_API_ACCESS_ALLOWED); + + g_vc_supported = false; + bool mic_supported = false; + bool vc_supported = false; + if (0 == system_info_get_platform_bool("http://tizen.org/feature/speech.control", &vc_supported)) + { + if (0 == system_info_get_platform_bool("http://tizen.org/feature/microphone", &mic_supported)) + { + if (true == vc_supported && true == mic_supported) + { + g_vc_supported = true; + } + } + } + + g_vc_init = false; + if (true == g_vc_supported) + { + int ret = VC_ERROR_NONE; + ret = vc_initialize(); + if (VC_ERROR_NONE == ret) + { + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + if (VC_ERROR_NONE != ret) + { + g_vc_init = false; + } + else + { + g_vc_init = true; + } + } + else + { + g_vc_init = false; + } + } + } + + virtual void TearDown() + { + if (true == g_vc_supported) + { + vc_unset_state_changed_cb(); + + vc_deinitialize(); + } + + g_vc_init = false; + + ecore_shutdown(); + } +}; + +TEST_F(VCTest, utc_vc_initialize_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + } else { + EXPECT_EQ(g_vc_init, true); + } +} + +/** + * @testcase utc_vc_deinitialize_p + * @since_tizen 2.4 + * @description Positive UTC for deinitialize voice control handle + */ +TEST_F(VCTest, vc_deinitialize_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_deinitialize_n + * @since_tizen 2.4 + * @description Negative UTC for deinitialize voice control handle (Already deinitialized) + */ +TEST_F(VCTest, vc_deinitialize_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_prepare_p + * @since_tizen 2.4 + * @description Positive UTC for connect service daemon + */ +TEST_F(VCTest, vc_prepare_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_prepare_n + * @since_tizen 2.4 + * @description Negative UTC for connect service daemon (Invalid state) + */ +TEST_F(VCTest, vc_prepare_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unprepare_p + * @since_tizen 2.4 + * @description Positive UTC for disconnect service daemon + */ +TEST_F(VCTest, vc_unprepare_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unprepare_n + * @since_tizen 2.4 + * @description Negative UTC for disconnect service daemon (Invalid state) + */ +TEST_F(VCTest, vc_unprepare_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unprepare_n2 + * @since_tizen 2.4 + * @description Negative UTC for disconnect service daemon (Invalid state) + */ +TEST_F(VCTest, vc_unprepare_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_foreach_supported_languages_p + * @since_tizen 2.4 + * @description Positive UTC for get supported language list + */ +TEST_F(VCTest, vc_foreach_supported_languages_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_foreach_supported_languages(__vc_supported_language_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_foreach_supported_languages(__vc_supported_language_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_foreach_supported_languages_n + * @since_tizen 2.4 + * @description Negative UTC for get supported language list (Invalid parameter) + */ +TEST_F(VCTest, vc_foreach_supported_languages_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_foreach_supported_languages(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_foreach_supported_languages(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_foreach_supported_languages_n2 + * @since_tizen 2.4 + * @description Negative UTC for get supported language list (Invalid state) + */ +TEST_F(VCTest, vc_foreach_supported_languages_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_foreach_supported_languages(__vc_supported_language_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_foreach_supported_languages(__vc_supported_language_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_get_current_language_p + * @since_tizen 2.4 + * @description Positive UTC for get current language + */ +TEST_F(VCTest, vc_get_current_language_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + char *lang = NULL; + ret = vc_get_current_language(&lang); + if (NULL != lang) { + free(lang); + lang = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + char *lang = NULL; + ret = vc_get_current_language(&lang); + if (NULL != lang) { + free(lang); + lang = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_current_language_n + * @since_tizen 2.4 + * @description Negative UTC for get current language (Invalid parameter) + */ +TEST_F(VCTest, vc_get_current_language_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_current_language(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_get_current_language(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_get_current_language_n2 + * @since_tizen 2.4 + * @description Negative UTC for get current language (Invalid state) + */ +TEST_F(VCTest, vc_get_current_language_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + char *lang = NULL; + ret = vc_get_current_language(&lang); + if (NULL != lang) { + free(lang); + lang = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + char *lang = NULL; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_get_current_language(&lang); + if (NULL != lang) { + free(lang); + lang = NULL; + } + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_get_state_p + * @since_tizen 2.4 + * @description Positive UTC for get current state + */ +TEST_F(VCTest, vc_get_state_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_state_p2 + * @since_tizen 2.4 + * @description Positive UTC for get current state after connection + */ +TEST_F(VCTest, vc_get_state_p2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_state_n + * @since_tizen 2.4 + * @description Negative UTC for get current state (Invalid parameter) + */ +TEST_F(VCTest, vc_get_state_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_state(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_get_state(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_get_state_n2 + * @since_tizen 2.4 + * @description Negative UTC for get current state (Invalid state) + */ +TEST_F(VCTest, vc_get_state_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_state_e state = VC_STATE_NONE; + ret = vc_get_state(&state); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_get_service_state_p + * @since_tizen 2.4 + * @description Positive UTC for get current state of service daemon + */ +TEST_F(VCTest, vc_get_service_state_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_service_state_e state = VC_SERVICE_STATE_NONE; + ret = vc_get_service_state(&state); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + vc_service_state_e state = VC_SERVICE_STATE_NONE; + ret = vc_get_service_state(&state); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_service_state_n + * @since_tizen 2.4 + * @description Negative UTC for get current state of service daemon (Invalid parameter) + */ +TEST_F(VCTest, vc_get_service_state_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_service_state(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_get_service_state(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_get_service_state_n2 + * @since_tizen 2.4 + * @description Negative UTC for get current state of service daemon (Invalid state) + */ +TEST_F(VCTest, vc_get_service_state_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_service_state_e state = VC_SERVICE_STATE_NONE; + ret = vc_get_service_state(&state); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_service_state_e state = VC_SERVICE_STATE_NONE; + ret = vc_get_service_state(&state); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_get_system_command_list_p + * @since_tizen 3.0 + * @description Positive UTC for get the system command list + */ +TEST_F(VCTest, vc_get_system_command_list_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_get_system_command_list(&list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + vc_cmd_list_h list = NULL; + ret = vc_get_system_command_list(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_system_command_list_n + * @since_tizen 3.0 + * @description Negative UTC for get the system command list (Invalid parameter) + */ +TEST_F(VCTest, vc_get_system_command_list_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_system_command_list(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_get_system_command_list(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_get_system_command_list_n2 + * @since_tizen 3.0 + * @description Negative UTC for get the system command list (Invalid state) + */ +TEST_F(VCTest, vc_get_system_command_list_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_get_system_command_list(&list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_h list = NULL; + ret = vc_get_system_command_list(&list); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_command_list_p + * @since_tizen 2.4 + * @description Positive UTC for set command list used as candidate set + */ +TEST_F(VCTest, vc_set_command_list_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_command(cmd, "voice"); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_type(cmd, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_destroy(list, true); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_command_list_n + * @since_tizen 2.4 + * @description Negative UTC for set command list used as candidate set (Invalid parameter) + */ +TEST_F(VCTest, vc_set_command_list_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_command_list(NULL, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_command_list(NULL, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_command_list_n2 + * @since_tizen 2.4 + * @description Negative UTC for set command list used as candidate set (Invalid state) + */ +TEST_F(VCTest, vc_set_command_list_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_cmd_list_destroy(list, true); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_command_list_n3 + * @since_tizen 2.4 + * @description Negative UTC for set command list used as candidate set (Invalid state) + */ +TEST_F(VCTest, vc_set_command_list_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_cmd_list_destroy(list, true); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_command_list_p + * @since_tizen 2.4 + * @description Positive UTC for unset command list used as candidate set + */ +TEST_F(VCTest, vc_unset_command_list_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_command(cmd, "voice"); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_type(cmd, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_command_list(list, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_destroy(list, true); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_command_list_n + * @since_tizen 2.4 + * @description Negative UTC for unset command list used as candidate set (Invalid state) + */ +TEST_F(VCTest, vc_unset_command_list_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_command_list_n2 + * @since_tizen 2.4 + * @description Negative UTC for unset command list used as candidate set (Invalid state) + */ +TEST_F(VCTest, vc_unset_command_list_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_command_list(VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_get_result_p + * @since_tizen 3.0 + * @description Positive UTC for getting the recognition result + */ +TEST_F(VCTest, vc_get_result_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_result(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_get_result(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_get_result_n + * @since_tizen 3.0 + * @description Negative UTC for getting the recognition result (Invalid parameter) + */ +TEST_F(VCTest, vc_get_result_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_get_result(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_get_result(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_result_cb_p + * @since_tizen 2.4 + * @description Positive UTC for set result callback + */ +TEST_F(VCTest, vc_set_result_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_result_cb_n + * @since_tizen 2.4 + * @description Negative UTC for set result callback (Invalid parameter) + */ +TEST_F(VCTest, vc_set_result_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_result_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for set result callback (Invalid state) + */ +TEST_F(VCTest, vc_set_result_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_result_cb_n3 + * @since_tizen 2.4 + * @description Negative UTC for set result callback (Invalid state) + */ +TEST_F(VCTest, vc_set_result_cb_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_result_cb_p + * @since_tizen 2.4 + * @description Positive UTC for unset result callback + */ +TEST_F(VCTest, vc_unset_result_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_result_cb(__vc_result_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_result_cb_n + * @since_tizen 2.4 + * @description Negative UTC for unset result callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_result_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_result_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for unset result callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_result_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unset_result_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_service_state_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for set service state changed callback + */ +TEST_F(VCTest, vc_set_service_state_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + } + + +} + +/** + * @testcase utc_vc_set_service_state_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for set service state changed callback (Invalid parameter) + */ +TEST_F(VCTest, vc_set_service_state_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_service_state_changed_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for set service state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_service_state_changed_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_service_state_changed_cb_n3 + * @since_tizen 2.4 + * @description Nagative UTC for set service state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_service_state_changed_cb_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_service_state_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for unset service state changed callback + */ +TEST_F(VCTest, vc_unset_service_state_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_service_state_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for unset service state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_service_state_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_service_state_changed_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for unset service state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_service_state_changed_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unset_service_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_state_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for set state changed callback + */ +TEST_F(VCTest, vc_set_state_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + int ret = VC_ERROR_NONE; + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + } +} + +/** + * @testcase utc_vc_set_state_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for set state changed callback (Invalid parameter) + */ +TEST_F(VCTest, vc_set_state_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_state_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_state_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_state_changed_cb_n2 + * @since_tizen 2.4 + * @description Nagative UTC for set state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_state_changed_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_state_changed_cb_n3 + * @since_tizen 2.4 + * @description Negative UTC for set state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_state_changed_cb_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_state_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for unset state changed callback + */ +TEST_F(VCTest, vc_unset_state_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_unset_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_state_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for unset state changed callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_state_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + ret = vc_unset_state_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_current_language_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for set current language changed callback + */ +TEST_F(VCTest, vc_set_current_language_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_current_language_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for set current language changed callback (invalid parameter) + */ +TEST_F(VCTest, vc_set_current_language_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_current_language_changed_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for set current language changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_current_language_changed_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_current_language_changed_cb_n3 + * @since_tizen 2.4 + * @description Negative UTC for set current language changed callback (Invalid state) + */ +TEST_F(VCTest, vc_set_current_language_changed_cb_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_current_language_changed_cb_p + * @since_tizen 2.4 + * @description Positive UTC for unset current language changed callback + */ +TEST_F(VCTest, vc_unset_current_language_changed_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_current_language_changed_cb(__vc_current_language_changed_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_current_language_changed_cb_n + * @since_tizen 2.4 + * @description Negative UTC for unset current language changed callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_current_language_changed_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_current_language_changed_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for unset current language changed callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_current_language_changed_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unset_current_language_changed_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_error_cb_p + * @since_tizen 2.4 + * @description Positive UTC for set error callback + */ +TEST_F(VCTest, vc_set_error_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_error_cb_n + * @since_tizen 2.4 + * @description Negative UTC for set error callback (Invalid parameter) + */ +TEST_F(VCTest, vc_set_error_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_set_error_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for set error callback (Invalid state) + */ +TEST_F(VCTest, vc_set_error_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_deinitialize(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_set_error_cb_n3 + * @since_tizen 2.4 + * @description Negative UTC for set error callback (Invalid state) + */ +TEST_F(VCTest, vc_set_error_cb_n3) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_error_cb_p + * @since_tizen 2.4 + * @description Positive UTC for unset error callback + */ +TEST_F(VCTest, vc_unset_error_cb_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_set_error_cb(__vc_error_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_unset_error_cb_n + * @since_tizen 2.4 + * @description Negative UTC for unset error callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_error_cb_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_unset_error_cb_n2 + * @since_tizen 2.4 + * @description Negative UTC for unset error callback (Invalid state) + */ +TEST_F(VCTest, vc_unset_error_cb_n2) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_unset_error_cb(); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_invocation_name_p + * @since_tizen 3.0 + * @description Positive UTC for setting the invocation name + */ +TEST_F(VCTest, vc_set_invocation_name_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + const char* invoc_name = "testapp"; + ret = vc_set_invocation_name(invoc_name); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + const char* invoc_name = "testapp"; + + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_set_invocation_name(invoc_name); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_set_invocation_name_n + * @since_tizen 3.0 + * @description Negative UTC for setting the invocation name (Invalid state) + */ +TEST_F(VCTest, vc_set_invocation_name_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + const char* invoc_name = "testapp"; + ret = vc_set_invocation_name(invoc_name); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + const char* invoc_name = "testapp"; + + ret = vc_set_invocation_name(invoc_name); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_request_dialog_p + * @since_tizen 3.0 + * @description Positive UTC for requesting the dialog + */ +TEST_F(VCTest, vc_request_dialog_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + const char* disp_txt = "test"; + const char* utt_txt = "test"; + bool is_auto_start = true; + ret = vc_request_dialog(disp_txt, utt_txt, is_auto_start); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + const char* disp_txt = "test"; + const char* utt_txt = "test"; + bool is_auto_start = true; + + ret = vc_prepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + + while (VC_STATE_READY != g_vc_state) { + ecore_main_loop_iterate(); + } + + ret = vc_request_dialog(disp_txt, utt_txt, is_auto_start); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_unprepare(); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_request_dialog_n + * @since_tizen 3.0 + * @description Negative UTC for requesting the dialog (Invalid state) + */ +TEST_F(VCTest, vc_request_dialog_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + const char* disp_txt = "voice control test"; + const char* utt_txt = "This is a test for requesting the dialog"; + bool is_auto_start = true; + ret = vc_request_dialog(disp_txt, utt_txt, is_auto_start); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + vc_deinitialize(); + + int ret = VC_ERROR_NONE; + const char* disp_txt = "voice control test"; + const char* utt_txt = "This is a test for requesting the dialog"; + bool is_auto_start = true; + ret = vc_request_dialog(disp_txt, utt_txt, is_auto_start); + EXPECT_EQ(ret, VC_ERROR_INVALID_STATE); + } +} + +/** + * @testcase utc_vc_cmd_list_create_p + * @since_tizen 2.4 + * @description Positive UTC for create command list handle + */ +TEST_F(VCTest, vc_cmd_list_create_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, false); + } +} + +/** + * @testcase utc_vc_cmd_list_create_n + * @since_tizen 2.4 + * @description Negative UTC for create command list handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_create_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_create(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_create(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_destroy_p + * @since_tizen 2.4 + * @description Positive UTC for destroy command list handle + */ +TEST_F(VCTest, vc_cmd_list_destroy_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_destroy(list, false); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_destroy(list, false); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_cmd_list_destroy_n + * @since_tizen 2.4 + * @description Negative UTC for destroy command list handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_destroy_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_destroy(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_destroy(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_get_count_p + * @since_tizen 2.4 + * @description Positive UTC for get count of command in command list + */ +TEST_F(VCTest, vc_cmd_list_get_count_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + int cnt = -1; + ret = vc_cmd_list_get_count(list, &cnt); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + int cnt = -1; + ret = vc_cmd_list_get_count(list, &cnt); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, false); + } +} + +/** + * @testcase utc_vc_cmd_list_get_count_n + * @since_tizen 2.4 + * @description Negative UTC for get count of command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_get_count_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_get_count(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_get_count(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_add_p + * @since_tizen 2.4 + * @description Positive UTC for add command in command list + */ +TEST_F(VCTest, vc_cmd_list_add_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + vc_cmd_h cmd = NULL; + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_add_n + * @since_tizen 2.4 + * @description Negative UTC for add command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_add_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_add(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_add(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_remove_p + * @since_tizen 2.4 + * @description Positive UTC for remove command in command list + */ +TEST_F(VCTest, vc_cmd_list_remove_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + vc_cmd_h cmd = NULL; + ret = vc_cmd_list_remove(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_remove(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_remove_n + * @since_tizen 2.4 + * @description Negative UTC for remove command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_remove_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_remove(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_remove(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_foreach_commands_p + * @since_tizen 2.4 + * @description Positive UTC for get whole command in command list + */ +TEST_F(VCTest, vc_cmd_list_foreach_commands_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_foreach_commands(list, __vc_cmd_list_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_foreach_commands(list, __vc_cmd_list_cb, NULL); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_foreach_commands_n + * @since_tizen 2.4 + * @description Negative UTC for get whole command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_foreach_commands_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_foreach_commands(NULL, NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_foreach_commands(NULL, NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_first_p + * @since_tizen 2.4 + * @description Positive UTC for move pointer to the first of command list + */ +TEST_F(VCTest, vc_cmd_list_first_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_first(list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_first(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_first_n + * @since_tizen 2.4 + * @description Negative UTC for move pointer to the first of command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_first_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_first(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_first(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_last_p + * @since_tizen 2.4 + * @description Positive UTC for move pointer to the last of command list + */ +TEST_F(VCTest, vc_cmd_list_last_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_last(list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_last(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_last_n + * @since_tizen 2.4 + * @description Negative UTC for move pointer to the last of command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_last_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_last(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_last(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_next_p + * @since_tizen 2.4 + * @description Positive UTC for move pointer to next command in command list + */ +TEST_F(VCTest, vc_cmd_list_next_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_next(list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + int i; + for (i = 0; i < 2; i++) { + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + } + + ret = vc_cmd_list_first(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_next(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_next_n + * @since_tizen 2.4 + * @description Negative UTC for move pointer to next command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_next_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_next(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_next(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_prev_p + * @since_tizen 2.4 + * @description Positive UTC for move pointer to previous command in command list + */ +TEST_F(VCTest, vc_cmd_list_prev_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_prev(list); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + int i; + for (i = 0; i < 2; i++) { + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + } + + ret = vc_cmd_list_last(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_prev(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_prev_n + * @since_tizen 2.4 + * @description Negative UTC for move pointer to previous command in command list (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_prev_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_prev(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_prev(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_list_get_current_p + * @since_tizen 2.4 + * @description Positive UTC for get command handle of current pointer + */ +TEST_F(VCTest, vc_cmd_list_get_current_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + vc_cmd_h cur = NULL; + ret = vc_cmd_list_get_current(list, &cur); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_list_h list = NULL; + ret = vc_cmd_list_create(&list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_add(list, cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_list_first(list); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_h cur = NULL; + ret = vc_cmd_list_get_current(list, &cur); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_list_destroy(list, true); + } +} + +/** + * @testcase utc_vc_cmd_list_get_current_n + * @since_tizen 2.4 + * @description Negative UTC for get command handle of current pointer (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_list_get_current_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_get_current(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_list_get_current(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_create_p + * @since_tizen 2.4 + * @description Positive UTC for create command handle + */ +TEST_F(VCTest, vc_cmd_create_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_create_n + * @since_tizen 2.4 + * @description Negative UTC for create command handle + */ +TEST_F(VCTest, vc_cmd_create_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_create(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_create(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_destroy_p + * @since_tizen 2.4 + * @description Positive UTC for destroy command handle + */ +TEST_F(VCTest, vc_cmd_destroy_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_destroy(cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_destroy(cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + } +} + +/** + * @testcase utc_vc_cmd_destroy_n + * @since_tizen 2.4 + * @description Negative UTC for destroy command handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_destroy_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_destroy(NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_destroy(NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_set_command_p + * @since_tizen 2.4 + * @description Positive UTC for set command text in handle + */ +TEST_F(VCTest, vc_cmd_set_command_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_set_command(cmd, "voice"); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_command(cmd, "voice"); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_set_command_n + * @since_tizen 2.4 + * @description Negative UTC for set command text in handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_set_command_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_get_command_p + * @since_tizen 2.4 + * @description Positive UTC for get command text in handle + */ +TEST_F(VCTest, vc_cmd_get_command_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + char *text = NULL; + ret = vc_cmd_get_command(cmd, &text); + if (NULL != text) { + free(text); + text = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_command(cmd, "voice"); + EXPECT_EQ(ret, VC_ERROR_NONE); + + char *text = NULL; + ret = vc_cmd_get_command(cmd, &text); + if (NULL != text) { + free(text); + text = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_get_command_n + * @since_tizen 2.4 + * @description Negative UTC for get command text in handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_get_command_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_get_unfixed_command_p + * @since_tizen 3.0 + * @description Positive UTC for getting the unfixed command text in handle + */ +TEST_F(VCTest, vc_cmd_get_unfixed_command_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + char *text = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + + ret = vc_cmd_get_unfixed_command(cmd, &text); + if (NULL != text) { + free(text); + text = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + char *text = NULL; + ret = vc_cmd_get_unfixed_command(cmd, &text); + if (NULL != text) { + free(text); + text = NULL; + } + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_get_unfixed_command_n + * @since_tizen 3.0 + * @description Negative UTC for getting the unfixed command text in handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_get_unfixed_command_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_unfixed_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_unfixed_command(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_set_type_p + * @since_tizen 2.4 + * @description Positive UTC for set command type in handle + */ +TEST_F(VCTest, vc_cmd_set_type_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_set_type(cmd, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_type(cmd, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_set_type_n + * @since_tizen 2.4 + * @description Negative UTC for set command type in handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_set_type_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_type(NULL, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_type(NULL, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_get_type_p + * @since_tizen 2.4 + * @description Positive UTC for get command type in handle + */ +TEST_F(VCTest, vc_cmd_get_type_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + int type; + ret = vc_cmd_get_type(cmd, &type); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_type(cmd, VC_COMMAND_TYPE_BACKGROUND); + EXPECT_EQ(ret, VC_ERROR_NONE); + + int type; + ret = vc_cmd_get_type(cmd, &type); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_get_type_n + * @since_tizen 2.4 + * @description Negative UTC for get command type in handle (invalid parameter) + */ +TEST_F(VCTest, vc_cmd_get_type_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_type(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_type(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_set_format_p + * @since_tizen 3.0 + * @description Positive UTC for setting command format in handle + */ +TEST_F(VCTest, vc_cmd_set_format_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + + ret = vc_cmd_set_format(cmd, VC_COMMAND_FORMAT_FIXED); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + + vc_cmd_destroy(cmd); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_format(cmd, VC_COMMAND_FORMAT_FIXED); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_set_format_n + * @since_tizen 3.0 + * @description Negative UTC for setting command format in handle (Invalid parameter) + */ +TEST_F(VCTest, vc_cmd_set_format_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_format(NULL, VC_COMMAND_FORMAT_FIXED); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_set_format(NULL, VC_COMMAND_FORMAT_FIXED); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +/** + * @testcase utc_vc_cmd_get_format_p + * @since_tizen 3.0 + * @description Positive UTC for getting command format in handle + */ +TEST_F(VCTest, vc_cmd_get_format_p) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + int format; + ret = vc_cmd_get_format(cmd, &format); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + vc_cmd_h cmd = NULL; + ret = vc_cmd_create(&cmd); + EXPECT_EQ(ret, VC_ERROR_NONE); + + ret = vc_cmd_set_format(cmd, VC_COMMAND_FORMAT_FIXED); + EXPECT_EQ(ret, VC_ERROR_NONE); + + int format; + ret = vc_cmd_get_format(cmd, &format); + EXPECT_EQ(ret, VC_ERROR_NONE); + + vc_cmd_destroy(cmd); + } +} + +/** + * @testcase utc_vc_cmd_get_format_n + * @since_tizen 3.0 + * @description Negative UTC for getting command format in handle(invalid parameter) + */ +TEST_F(VCTest, vc_cmd_get_format_n) +{ + if (false == g_vc_supported) { + EXPECT_EQ(g_vc_init, false); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_format(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_NOT_SUPPORTED); + } else { + EXPECT_EQ(g_vc_init, true); + + int ret = VC_ERROR_NONE; + ret = vc_cmd_get_format(NULL, NULL); + EXPECT_EQ(ret, VC_ERROR_INVALID_PARAMETER); + } +} + +} // namespace -- 2.7.4 From af8d8eec7e40d47070813f3f467175b0d137d096 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Mon, 28 Sep 2020 16:55:10 +0900 Subject: [PATCH 15/16] Correct wrong expression on header file Change-Id: I20ec5e27df90f3d249662b3ce72106161e53b105 --- include/voice_control_command.h | 10 +++++----- include/voice_control_manager.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/voice_control_command.h b/include/voice_control_command.h index 06b899a..d5fcfc2 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -337,7 +337,7 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command); /** * @brief Gets command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * @remark If the function succeeds, @a command must be released with free() by you if they are not NULL. + * @remarks If the function succeeds, @a command must be released with free() by you if they are not NULL. * @param[in] vc_command The command handle * @param[out] command The command text * @return @c 0 on success, @@ -354,7 +354,7 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); /** * @brief Gets the unfixed command. * @since_tizen 3.0 - * @remark If the function succeeds, the @a command must be released with free() if it is not NULL. + * @remarks If the function succeeds, the @a command must be released with free() if it is not NULL. * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL. * This function should be used for commands which have non-fixed format. * @param[in] vc_command The command handle @@ -372,7 +372,7 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); /** * @brief Sets command type. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * @remark If you do not set the command type, the default value is @c -1. + * @remarks If you do not set the command type, the default value is @c -1. * You should set type if command is valid * @param[in] vc_command The command handle * @param[in] type The command type @@ -406,7 +406,7 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type); /** * @brief Sets the command format. * @since_tizen 3.0 - * @remark The default format is #VC_COMMAND_FORMAT_FIXED. + * @remarks The default format is #VC_COMMAND_FORMAT_FIXED. * @param[in] vc_command The command handle * @param[in] format The command format * @return @c 0 on success, @@ -423,7 +423,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format); /** * @brief Gets the command format. * @since_tizen 3.0 - * @remark The default format is #VC_COMMAND_FORMAT_FIXED. + * @remarks The default format is #VC_COMMAND_FORMAT_FIXED. * @param[in] vc_command The command handle * @param[out] format The command format * @return @c 0 on success, diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index 49defd3..c728910 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -745,7 +745,7 @@ int vc_mgr_get_audio_type(char **audio_id); * * @pre The state should be #VC_STATE_READY and the service state should be #VC_SERVICE_STATE_READY. * - * @see vc_mgr_set_recognition_mode() + * @see vc_mgr_get_recognition_mode() */ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode); @@ -768,7 +768,7 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode); * * @pre The state should be #VC_STATE_READY. * - * @see vc_mgr_get_recognition_mode() + * @see vc_mgr_set_recognition_mode() */ int vc_mgr_get_recognition_mode(vc_recognition_mode_e *mode); -- 2.7.4 From f71e51fb87d8ff9d3f651c8b8133db3c6992d2f9 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 1 Dec 2020 13:36:46 +0900 Subject: [PATCH 16/16] Fix defects from static analysis tool Change-Id: Ib30853516b665e935974b938b6217df583f7510e --- client/vc.c | 91 ++++++++++++++++---------------------------------------- common/vc_main.h | 4 +++ 2 files changed, 30 insertions(+), 65 deletions(-) diff --git a/client/vc.c b/client/vc.c index f5ed34d..2cb5930 100644 --- a/client/vc.c +++ b/client/vc.c @@ -128,8 +128,7 @@ static int __check_privilege(const char* uid, const char * privilege) char *session = cynara_session_from_pid(pid); int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); SLOG(LOG_DEBUG, TAG_VCC, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied"); - if (session) - free(session); + FREE(session); if (ret != CYNARA_API_ACCESS_ALLOWED) return false; //LCOV_EXCL_LINE @@ -1095,10 +1094,7 @@ static int __vc_get_invocation_name(char** invocation_name) if (0 != ret || NULL == appid) { //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get appid, ret(%d)", ret); //LCOV_EXCL_LINE - if (NULL != appid) { - free(appid); - appid = NULL; - } + FREE(appid); return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_STOP } @@ -1106,12 +1102,8 @@ static int __vc_get_invocation_name(char** invocation_name) ret = vc_get_current_language(&lang); if (0 != ret || NULL == lang) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current language, ret(%d)", ret); //LCOV_EXCL_LINE - free(appid); - appid = NULL; - if (NULL != lang) { - free(lang); - lang = NULL; - } + FREE(appid); + FREE(lang); return VC_ERROR_OPERATION_FAILED; } @@ -1119,14 +1111,9 @@ static int __vc_get_invocation_name(char** invocation_name) if (0 != ret || NULL == temp_label) { //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get localed label, ret(%d) appid(%s) lang(%s)", ret, appid, lang); //LCOV_EXCL_LINE - free(appid); - appid = NULL; - free(lang); - lang = NULL; - if (NULL != temp_label) { - free(temp_label); - temp_label = NULL; - } + FREE(appid); + FREE(lang); + FREE(temp_label); return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_STOP } @@ -1134,15 +1121,15 @@ static int __vc_get_invocation_name(char** invocation_name) *invocation_name = strdup(temp_label); if (NULL == *invocation_name) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE + FREE(appid); + FREE(lang); + FREE(temp_label); return VC_ERROR_OUT_OF_MEMORY; } - free(appid); - appid = NULL; - free(lang); - lang = NULL; - free(temp_label); - temp_label = NULL; + FREE(appid); + FREE(lang); + FREE(temp_label); } SLOG(LOG_DEBUG, TAG_VCC, "Get invocation name(%s)", *invocation_name); @@ -1241,10 +1228,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) } while (0 != ret); } - if (NULL != invocation_name) { - free(invocation_name); - invocation_name = NULL; - } + FREE(invocation_name); if (VC_COMMAND_TYPE_BACKGROUND == type) g_backup = true; @@ -1397,10 +1381,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) } while (0 != ret); } - if (NULL != invocation_name) { - free(invocation_name); - invocation_name = NULL; - } + FREE(invocation_name); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return ret; @@ -1784,9 +1765,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_cmd_list = NULL; /* Release result */ - if (temp_text) - free(temp_text); - temp_text = NULL; + FREE(temp_text); return EINA_FALSE; } @@ -1856,10 +1835,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) vc_cmd_list = NULL; /* Release result */ - if (NULL != temp_text) { - free(temp_text); - temp_text = NULL; - } + FREE(temp_text); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); @@ -2264,8 +2240,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) ret = app_manager_get_app_id(getpid(), &tmp_appid); if (0 != ret || NULL == tmp_appid) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] app_id is NULL"); - if (NULL != tmp_appid) - free(tmp_appid); + FREE(tmp_appid); return VC_ERROR_INVALID_PARAMETER; } } else { @@ -2301,9 +2276,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) } } while (0 != ret); - - if (NULL != tmp_appid) - free(tmp_appid); + FREE(tmp_appid); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); @@ -2350,8 +2323,7 @@ int vc_unset_server_dialog(const char* app_id) ret = app_manager_get_app_id(getpid(), &tmp_appid); if (0 != ret || NULL == tmp_appid) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] app_id is NULL"); - if (NULL != tmp_appid) - free(tmp_appid); + FREE(tmp_appid); return VC_ERROR_INVALID_PARAMETER; } } else { @@ -2388,11 +2360,8 @@ int vc_unset_server_dialog(const char* app_id) } } while (0 != ret); - - if (NULL != tmp_appid) - free(tmp_appid); - if (NULL != credential) - free(credential); + FREE(tmp_appid); + FREE(credential); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); @@ -2946,12 +2915,10 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) /* If no tts data and EVENT_FINISH */ if (0 >= vc_data_get_tts_data_size() && VC_TTS_EVENT_FINISH == tts_data->event) { SLOG(LOG_INFO, TAG_VCC, "[INFO] Finish tts"); - free(tts_data); - tts_data = NULL; + FREE(tts_data) break; } - free(tts_data); - tts_data = NULL; + FREE(tts_data); } } } @@ -2995,14 +2962,8 @@ int __vc_cb_tts_streaming(int utt_id, vc_tts_event_e event, char* buffer, int le int ret = vc_data_add_tts_data(temp_tts_data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to add tts data"); - if (NULL != temp_tts_data->data) { - free(temp_tts_data->data); - temp_tts_data->data = NULL; - } - if (NULL != temp_tts_data) { - free(temp_tts_data); - temp_tts_data = NULL; - } + FREE(temp_tts_data->data); + FREE(temp_tts_data); } bool is_canceled = ecore_thread_check(g_tts_thread); diff --git a/common/vc_main.h b/common/vc_main.h index 061155e..9ed4128 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -53,6 +53,10 @@ struct vc_s { typedef struct vc_s *vc_h; +/* Define Macro */ +#define FREE(x) { if (NULL != x) { free(x); x = NULL; } } +#define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } } + #ifdef __cplusplus } #endif -- 2.7.4