change mmi_input_event_type_e and add tests more about activate 17/281617/1
authordyamy-lee <dyamy.lee@samsung.com>
Thu, 15 Sep 2022 02:45:25 +0000 (11:45 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 20 Sep 2022 05:09:38 +0000 (14:09 +0900)
add mmi input event type none because of mmi manager logic
rename enum of mmi_input_event_type_e following mmi manager
add other tests related mmi_activate_input_event

Change-Id: Idf90955cd4d2cca067abd690ffea5f84f7eed318

src/mmi-ipc.c
src/mmi.h
tests/mmi-main-test.cpp

index 651527a003ed52e49530117f8cff3ddd34c7ab43..03fcc31b4622098a3308cc195637b0faa9edf1b3 100644 (file)
@@ -138,6 +138,11 @@ int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_
                return MMI_ERROR_INVALID_PARAMETER;
        }
 
+       if (input_event_type == MMI_INPUT_EVENT_TYPE_NONE) {
+               LOGE("Parameter input event type is NULL");
+               return MMI_ERROR_INVALID_PARAMETER;
+       }
+
        mmi_handle client = mmi_client_get();
        if (client == NULL) {
                LOGE("Fail to get client");
@@ -187,6 +192,11 @@ int mmi_ipc_activate_input_event(int input_event_type)
 
        int ret;
 
+       if (input_event_type == MMI_INPUT_EVENT_TYPE_NONE) {
+               LOGE("Parameter input event type is NULL");
+               return MMI_ERROR_INVALID_PARAMETER;
+       }
+
        mmi_handle client = mmi_client_get();
        if (client == NULL) {
                LOGE("Fail to get client");
index 8c1da0c399e9f4e7a15740836306625803a2ec79..3b7e7aa37808e723860f7a413d1d20f96f96bd3b 100644 (file)
--- a/src/mmi.h
+++ b/src/mmi.h
@@ -45,8 +45,9 @@ typedef enum {
 typedef void (*mmi_result_cb)(int input_event_type, const char *result_out, void *user_data);
 
 typedef enum {
-       MMI_VOICE_TOUCH,
-       MMI_VOICE_RECOGNITION,
+       MMI_INPUT_EVENT_TYPE_NONE,
+       MMI_INPUT_EVENT_TYPE_VOICE_TOUCH,
+       MMI_INPUT_EVENT_TYPE_VOICE_RECOGNITION,
 } mmi_input_event_type_e;
 
 #ifdef __cplusplus
index 4170cbffd1e007723c6407f2947786d7d18a08d3..224a12c97d5dcfc184212fae8b653e4da05d6752 100644 (file)
@@ -66,7 +66,7 @@ void voice_recognition_callback(int input_event_type, const char *result_out, vo
 TEST_F(MMIMainTest, MMIClientSetResultCbSuccess)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -95,7 +95,7 @@ TEST_F(MMIMainTest, MMIClientSetResultCbSuccess)
 TEST_F(MMIMainTest, MMIClientSetResultCbFail)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -108,7 +108,7 @@ TEST_F(MMIMainTest, MMIClientSetResultCbFail)
 TEST_F(MMIMainTest, MMISetResultCbSuccess)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -121,7 +121,7 @@ TEST_F(MMIMainTest, MMISetResultCbSuccess)
 TEST_F(MMIMainTest, MMISetResultCbFail)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -134,14 +134,14 @@ TEST_F(MMIMainTest, MMISetResultCbFail)
 TEST_F(MMIMainTest, MMIClientDestroyRemoveGList)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
        res = mmi_set_result_cb(input_event_type, voice_touch_callback, NULL);
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
-       res = mmi_set_result_cb(MMI_VOICE_RECOGNITION, voice_recognition_callback, NULL);
+       res = mmi_set_result_cb(MMI_INPUT_EVENT_TYPE_VOICE_RECOGNITION, voice_recognition_callback, NULL);
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
        mmi_client_destroy();
@@ -150,7 +150,7 @@ TEST_F(MMIMainTest, MMIClientDestroyRemoveGList)
 TEST_F(MMIMainTest, MMISetResultCbFailNoClient)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -165,7 +165,7 @@ TEST_F(MMIMainTest, MMISetResultCbFailNoClient)
 TEST_F(MMIMainTest, MMISetResultCbFailNoRpcHandle)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -183,7 +183,7 @@ TEST_F(MMIMainTest, MMISetResultCbFailNoRpcHandle)
 TEST_F(MMIMainTest, MMIActivateInputEventSuccess)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -199,14 +199,14 @@ TEST_F(MMIMainTest, MMIActivateInputEventSuccess)
 TEST_F(MMIMainTest, MMIActivateInputEventFailNoEvent)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
        res = mmi_set_result_cb(input_event_type, voice_touch_callback, NULL);
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
-       res = mmi_activate_input_event(MMI_VOICE_RECOGNITION);
+       res = mmi_activate_input_event(MMI_INPUT_EVENT_TYPE_VOICE_RECOGNITION);
        EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER);
 
        mmi_deinitialize();
@@ -215,7 +215,7 @@ TEST_F(MMIMainTest, MMIActivateInputEventFailNoEvent)
 TEST_F(MMIMainTest, MMIActivateInputEventFailNoCallback)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -228,7 +228,7 @@ TEST_F(MMIMainTest, MMIActivateInputEventFailNoCallback)
 TEST_F(MMIMainTest, MMIActivateInputEventFailNoRpcHandle)
 {
        int res = mmi_initialize();
-       mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH;
+       mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH;
 
        EXPECT_EQ(res, MMI_ERROR_NONE);
 
@@ -245,3 +245,22 @@ TEST_F(MMIMainTest, MMIActivateInputEventFailNoRpcHandle)
 
        mmi_deinitialize();
 }
+
+TEST_F(MMIMainTest, MMIActivateInputEventFailAlreadyDone)
+{
+       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_set_result_cb(input_event_type, voice_touch_callback, NULL);
+       EXPECT_EQ(res, MMI_ERROR_NONE);
+
+       res = mmi_activate_input_event(input_event_type);
+       EXPECT_EQ(res, MMI_ERROR_NONE);
+
+       res = mmi_activate_input_event(input_event_type);
+       EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED);
+
+       mmi_deinitialize();
+}