mmi_deactivate_input_event is called by client, and it check saved input event.
If it has matched one, invoke deactivate input event to stub.
Also, add tests for deactivate.
Change-Id: I9b0173cf14485e028892eeac2e8c8cb924d8f7a4
return MMI_ERROR_NONE;
}
+
+int mmi_ipc_deactivate_input_event(int input_event_type)
+{
+ LOGE("Dectivate about input event type(%d)", input_event_type);
+
+ int ret;
+ rpc_port_proxy_mmi_h rpc_h = NULL;
+
+ if (input_event_type == MMI_INPUT_EVENT_TYPE_NONE) {
+ LOGE("Parameter input event type is NULL");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ rpc_h = mmi_ipc_get_rpc_h();
+ if (rpc_h == NULL) {
+ LOGE("Fail to get tidl rpc info");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ ret = rpc_port_proxy_mmi_invoke_deactivate_input_event(rpc_h, input_event_type);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Fail to invoke activate input event");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ return MMI_ERROR_NONE;
+}
void mmi_ipc_deinitialize(void);
int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_mmi_result_cb_cb callback);
int mmi_ipc_activate_input_event(int input_event_type);
+int mmi_ipc_deactivate_input_event(int input_event_type);
rpc_port_proxy_mmi_h mmi_ipc_get_rpc_h(void);
int mmi_ipc_get_uid(void);
LOGE("No match callback about input event type(%d)", input_event_type);
return MMI_ERROR_INVALID_PARAMETER;
}
+
+MMI_API int mmi_deactivate_input_event(int input_event_type)
+{
+ LOGI("Deactivate input event(%d)", input_event_type);
+
+ int ret;
+ GList* iter = NULL;
+ mmi_result_cb_s *data = NULL;
+ mmi_handle client = mmi_client_get();
+
+ if (g_list_length(client->result_cb_list) > 0) {
+ LOGD("Check length of callback lists = %d", g_list_length(client->result_cb_list));
+
+ iter = g_list_first(client->result_cb_list);
+
+ while (NULL != iter) {
+ data = iter->data;
+
+ if (NULL != data) {
+ int type = data->input_event_type;
+
+ if (type == input_event_type) {
+ ret = mmi_ipc_deactivate_input_event(input_event_type);
+ if(ret != MMI_ERROR_NONE) {
+ LOGE("Fail to deactivate input event(%d)", ret);
+ return ret;
+ }
+
+ return MMI_ERROR_NONE;
+ }
+ }
+
+ iter = g_list_next(iter);
+ }
+ }
+
+ LOGE("Fail to deactivate input event type(%d)", input_event_type);
+ return MMI_ERROR_INVALID_PARAMETER;
+}
MMI_API int mmi_deinitialize(void);
MMI_API int mmi_set_result_cb(int input_event_type, mmi_result_cb callback, void* user_data);
MMI_API int mmi_activate_input_event(int input_event_type);
+MMI_API int mmi_deactivate_input_event(int input_event_type);
#ifdef __cplusplus
}
mmi_deinitialize();
}
+
+TEST_F(MMIIpcTest, MMIFWIpcDeactivateSuccess)
+{
+ 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_deactivate_input_event(input_event_type);
+ EXPECT_EQ(res, MMI_ERROR_NONE);
+
+ mmi_deinitialize();
+}
+
+TEST_F(MMIIpcTest, MMIFWIpcDeactivateFailNoEvent)
+{
+ 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_deactivate_input_event(MMI_INPUT_EVENT_TYPE_NONE);
+ EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER);
+
+ mmi_deinitialize();
+}
+
+TEST_F(MMIIpcTest, MMIFWIpcDeactivateFailNoRpcHandle)
+{
+ 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_ipc_deinitialize();
+
+ mmi_handle mmi_client = mmi_client_get();
+ mmi_client->rpc_h = NULL;
+
+ res = mmi_ipc_deactivate_input_event(input_event_type);
+ EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED);
+
+ mmi_deinitialize();
+}
mmi_deinitialize();
}
+
+TEST_F(MMIMainTest, MMIDeactivateInputEventSuccess)
+{
+ 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_deactivate_input_event(input_event_type);
+ EXPECT_EQ(res, MMI_ERROR_NONE);
+
+ mmi_deinitialize();
+}
+
+TEST_F(MMIMainTest, MMIDeactivateInputEventFailNoEvent)
+{
+ 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_deactivate_input_event(MMI_INPUT_EVENT_TYPE_VOICE_RECOGNITION);
+ EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER);
+
+ mmi_deinitialize();
+}
+
+TEST_F(MMIMainTest, MMIDeactivateInputEventFailNoRpcHandle)
+{
+ 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);
+
+ mmi_ipc_deinitialize();
+
+ mmi_handle mmi_client = mmi_client_get();
+ mmi_client->rpc_h = NULL;
+
+ res = mmi_deactivate_input_event(input_event_type);
+ EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED);
+
+ mmi_deinitialize();
+}