add mmi-ipc module tests 21/281621/1
authordyamy-lee <dyamy.lee@samsung.com>
Fri, 16 Sep 2022 04:37:32 +0000 (13:37 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 20 Sep 2022 05:09:40 +0000 (14:09 +0900)
add register, activate tests about mmi-ipc module

Change-Id: Ida2334d094725cb0d93b9569e60634122f5f02b5

tests/mmi-ipc-test.cpp
tests/mmi-main-test.cpp

index 9e549a2231bc92634a95bcacbf6d51905f725845..7232636e191b318cff502207c6166efe9d441979 100644 (file)
@@ -18,6 +18,7 @@
 #include "mmi.h"
 #include "mmi-tests.h"
 #include "mmi-ipc.h"
+#include "mmi-client.h"
 
 #include <Ecore.h>
 #include <rpc-port-internal.h>
@@ -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();
+}
index fdf3c5ddb4f610ce5949d981642e1097f2595a1b..6b104cee0e0962ce789cac5e2da88e04d30fe1da 100644 (file)
@@ -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)
 {
 }