From f903c8548ff83f355679407cc2431e166a03a522 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Mon, 5 Sep 2022 18:44:08 +0900 Subject: [PATCH] Create set result cb API in mmi and test A client(ex.reference app) is calling of mmi modeule. This function is calling for saving in client Change-Id: Ic9749d464a2dfb3298417fc1e1a8325851f05193 --- src/mmi.c | 15 +++++++++++++++ src/mmi.h | 1 + tests/mmi-main-test.cpp | 27 ++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/mmi.c b/src/mmi.c index 022974c..c698a4f 100644 --- a/src/mmi.c +++ b/src/mmi.c @@ -46,3 +46,18 @@ MMI_API int mmi_shutdown(void) return MMI_ERROR_NONE; } + +MMI_API int mmi_set_result_cb(int input_event_type, result_cb callback, void* user_data) +{ + LOGI("Set result cb about input event type(%d)", input_event_type); + + int ret; + + ret = mmi_client_set_result_cb(input_event_type, callback, user_data); + if(ret != MMI_ERROR_NONE) { + LOGE("Fail to set result cb(%d)", ret); + return MMI_ERROR_NOT_SUPPORTED; + } + + return MMI_ERROR_NONE; +} diff --git a/src/mmi.h b/src/mmi.h index 31ef08f..d65003f 100644 --- a/src/mmi.h +++ b/src/mmi.h @@ -32,6 +32,7 @@ extern "C" { MMI_API int mmi_init(void); MMI_API int mmi_shutdown(void); +MMI_API int mmi_set_result_cb(int input_event_type, result_cb callback, void* user_data); #ifdef __cplusplus } diff --git a/tests/mmi-main-test.cpp b/tests/mmi-main-test.cpp index ec312a7..4e9fb6a 100644 --- a/tests/mmi-main-test.cpp +++ b/tests/mmi-main-test.cpp @@ -84,7 +84,7 @@ TEST_F(MMIMainTest, MMIClientSetResultCbSuccess) data = (result_cb_s*)iter->data; EXPECT_NE(data->result_callback, nullptr); EXPECT_EQ(data->result_callback, voice_touch_callback); - EXPECT_EQ(data->input_event_type, MMI_VOICE_TOUCH); + EXPECT_EQ(data->input_event_type, input_event_type); } else { EXPECT_TRUE(false); @@ -105,3 +105,28 @@ TEST_F(MMIMainTest, MMIClientSetResultCbFail) mmi_shutdown(); } + +TEST_F(MMIMainTest, MMISetResultCbSuccess) +{ + int res = mmi_init(); + mmi_input_event_type_e input_event_type = MMI_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); + + mmi_shutdown(); +} + +TEST_F(MMIMainTest, MMISetResultCbFail) +{ + int res = mmi_init(); + mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_set_result_cb(input_event_type, NULL, NULL); + EXPECT_EQ(res, MMI_ERROR_NOT_SUPPORTED); + + mmi_shutdown(); +} -- 2.7.4