From: dyamy-lee Date: Fri, 16 Sep 2022 04:37:32 +0000 (+0900) Subject: add mmi-ipc module tests X-Git-Tag: accepted/tizen/unified/20220927.132357~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a32bd957b3ecc06a30ce9234a1e4daeeefdb94a;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git add mmi-ipc module tests add register, activate tests about mmi-ipc module Change-Id: Ida2334d094725cb0d93b9569e60634122f5f02b5 --- diff --git a/tests/mmi-ipc-test.cpp b/tests/mmi-ipc-test.cpp index 9e549a2..7232636 100644 --- a/tests/mmi-ipc-test.cpp +++ b/tests/mmi-ipc-test.cpp @@ -18,6 +18,7 @@ #include "mmi.h" #include "mmi-tests.h" #include "mmi-ipc.h" +#include "mmi-client.h" #include #include @@ -53,3 +54,151 @@ TEST_F(MMIIpcTest, MMIIpcInitFail) mmi_deinitialize(); } + +static void voice_touch_callback(int input_event_type, const char *result_out, void *user_data) +{ +} + +TEST_F(MMIIpcTest, MMIFWIpcRegisterSuccess) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcRegisterFailNoEvent) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_NONE; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(MMI_INPUT_EVENT_TYPE_NONE, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcRegisterFailNoCallback) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, NULL); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcRegisterFailNoClient) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_client_destroy(); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcRegisterFailNoRpcHandle) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_ipc_deinitialize(); + + mmi_handle mmi_client = mmi_client_get(); + mmi_client->rpc_h = NULL; + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcActivateSuccess) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcActivateFailNoEvent) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(MMI_INPUT_EVENT_TYPE_NONE); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcActivateFailNoRpcHandle) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_ipc_deinitialize(); + + mmi_handle mmi_client = mmi_client_get(); + mmi_client->rpc_h = NULL; + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcActivateFailAlreadyDone) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +} diff --git a/tests/mmi-main-test.cpp b/tests/mmi-main-test.cpp index fdf3c5d..6b104ce 100644 --- a/tests/mmi-main-test.cpp +++ b/tests/mmi-main-test.cpp @@ -55,11 +55,11 @@ TEST_F(MMIMainTest, MmiClientCreateSuccess) mmi_client_destroy(); } -void voice_touch_callback(int input_event_type, const char *result_out, void *user_data) +static void voice_touch_callback(int input_event_type, const char *result_out, void *user_data) { } -void voice_recognition_callback(int input_event_type, const char *result_out, void *user_data) +static void voice_recognition_callback(int input_event_type, const char *result_out, void *user_data) { }