diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2017-11-15 14:42:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-15 14:42:48 -0500 |
commit | 4eb09bf0da82e320723390abd877079af9457d20 (patch) | |
tree | 26e106f042845d851062a3da59cee77c25196981 | |
parent | 10b632f27b3e04ed1e75363d0674c44279f7ac1f (diff) | |
parent | 931ce35d5d13fca2a6907f3c1bbbc21f1fa56483 (diff) | |
download | sdl_core-4eb09bf0da82e320723390abd877079af9457d20.tar.gz |
Merge pull request #1640 from LuxoftAKutsan/fix/send_correct_info_parameter_in_case_if_some_hmi_interface_is_not_available_or_do_not_respond
Fix/send correct info parameter in case if some hmi interface is not available or do not respond
72 files changed, 1021 insertions, 559 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 614f86a6f1..96a315f505 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -43,21 +43,13 @@ namespace application_manager { namespace commands { struct ResponseInfo { - ResponseInfo() - : result_code(hmi_apis::Common_Result::INVALID_ENUM) - , interface(HmiInterfaces::HMI_INTERFACE_INVALID_ENUM) - , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) - , is_ok(false) - , is_unsupported_resource(false) - , is_not_used(false) {} + // DEPRECATED ResponseInfo(hmi_apis::Common_Result::eType result, - HmiInterfaces::InterfaceID interface) - : result_code(result) - , interface(interface) - , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) - , is_ok(false) - , is_unsupported_resource(false) - , is_not_used(false) {} + HmiInterfaces::InterfaceID interface); + ResponseInfo(); + ResponseInfo(const hmi_apis::Common_Result::eType result, + const HmiInterfaces::InterfaceID hmi_interface, + ApplicationManager& application_manager); hmi_apis::Common_Result::eType result_code; HmiInterfaces::InterfaceID interface; HmiInterfaces::InterfaceState interface_state; @@ -290,6 +282,19 @@ class CommandRequestImpl : public CommandImpl, mobile_apis::Result::eType PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second); + /** + * @brief Resolves if the return code must be + * UNSUPPORTED_RESOURCE + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * @return True, if the communication return code must be + * UNSUPPORTED_RESOURCE, otherwise false. + */ + bool IsResultCodeUnsupported(const ResponseInfo& first, + const ResponseInfo& second) const; + protected: /** * @brief Returns policy parameters permissions @@ -297,6 +302,35 @@ class CommandRequestImpl : public CommandImpl, */ const CommandParametersPermissions& parameters_permissions() const; + /** + * @brief Adds interface to be awaited for by sdl request command + @param interface_id interface which SDL expects to response in given time + */ + void StartAwaitForInterface(const HmiInterfaces::InterfaceID interface_id); + + /** + * @brief Gets interface await state. + * @param interface_id interface which SDL awaits for response in given time + * @return true if SDL awaits for response from given interface in + * interface_id + */ + bool IsInterfaceAwaited(const HmiInterfaces::InterfaceID& interface_id) const; + + /** + * @brief Sets given HMI interface await status to false + * @param interface_id interface which SDL no longer awaits for response in + * given time + */ + void EndAwaitForInterface(const HmiInterfaces::InterfaceID& interface_id); + + /** + * @brief This set stores all the interfaces which are awaited by SDL to + * return a response on some request + */ + std::set<HmiInterfaces::InterfaceID> awaiting_response_interfaces_; + + mutable sync_primitives::Lock awaiting_response_interfaces_lock_; + RequestState current_state_; sync_primitives::Lock state_lock_; CommandParametersPermissions parameters_permissions_; @@ -331,10 +365,10 @@ class CommandRequestImpl : public CommandImpl, const hmi_apis::FunctionID::eType& function_id); /** - * @brief UpdateHash updates hash field for application and sends - * OnHashChanged notification to mobile side in case of approriate hash mode - * is set - */ + * @brief UpdateHash updates hash field for application and sends + * OnHashChanged notification to mobile side in case of approriate hash mode + * is set + */ void UpdateHash(); /** @@ -342,6 +376,13 @@ class CommandRequestImpl : public CommandImpl, * it is value of 'success' field of appropriate response sent to mobile */ bool is_success_result_; + + /** + * @brief Add information for the component of response in case of timeout + * @param response Response message, which info should be extended + */ + void AddTimeOutComponentInfoToMessage( + smart_objects::SmartObject& response) const; }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h b/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h index 77f1813e46..c6366f6ab2 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h @@ -77,7 +77,10 @@ class AlertRequest : public CommandRequestImpl { * If Alert request has soft buttons, timeout response should not be sent to * mobile */ - virtual void onTimeOut(); + // DEPRECATED + virtual void onTimeOut() { + CommandRequestImpl::onTimeOut(); + } /** * @brief Interface method that is called whenever new event received diff --git a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h index f783af12b3..2cd8e386e0 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h @@ -167,6 +167,16 @@ class ChangeRegistrationRequest : public CommandRequestImpl { std::string vr_response_info_; std::string tts_response_info_; + void SendVRRequest(ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params); + + void SendTTSRequest(ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params); + + void SendUIRequest(ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params, + const int32_t hmi_language); + DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest); }; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h index 99f86ea1d5..c78c57755e 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h @@ -87,13 +87,39 @@ class PerformAudioPassThruRequest : public CommandRequestImpl { private: /** * @brief Prepare result code, result and info for sending to mobile + * @brief Response params + * success for sending to mobile application + * result code for sending to mobile application + * info for sending to mobile application + */ + struct ResponseParams { + bool success; + mobile_apis::Result::eType result_code; + std::string info; + ResponseParams() + : success(false), result_code(mobile_apis::Result::INVALID_ENUM) {} + }; + + ResponseParams response_params_; + + /** + * @brief Prepare result code, result and info for sending to mobile * application * @param result_code contains result code for sending to mobile application * @return result for sending to mobile application. */ + // DEPRECATED bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, std::string& info); /** + * @brief Prepare result code, 'success' result and info for sending + * to mobile application + * @param result_code contains result code for sending to mobile application + * @return result for sending to mobile application. + */ + const ResponseParams& PrepareResponseParameters(); + + /** * @brief Sends TTS Speak request */ void SendSpeakRequest(); @@ -137,6 +163,23 @@ class PerformAudioPassThruRequest : public CommandRequestImpl { during perform audio pass thru*/ bool awaiting_tts_speak_response_; bool awaiting_ui_response_; + /** + * @brief Pair of result_code and success for mobile app + */ + typedef std::pair<mobile_apis::Result::eType, bool> AudioPassThruResults; + + /** + * @brief Checks result code from HMI for splitted RPC + * and returns parameter for sending to mobile app in + * audioPassThru communication. + * @param ui_response contains result_code from UI + * @param tts_response contains result_code from TTS + * @return pair of result code (UI error code has precedence than TTS's, + * error_code from TTS is turned to WARNINGS) and + * result for mobile app + */ + AudioPassThruResults PrepareAudioPassThruResultCodeForResponse( + const ResponseInfo& ui_response, const ResponseInfo& tts_response); hmi_apis::Common_Result::eType result_tts_speak_; hmi_apis::Common_Result::eType result_ui_; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h index eb955df197..c16a014c9f 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h @@ -131,12 +131,6 @@ class ResetGlobalPropertiesRequest : public CommandRequestImpl { DISALLOW_COPY_AND_ASSIGN(ResetGlobalPropertiesRequest); - bool is_ui_send_; - bool is_tts_send_; - - bool is_ui_received_; - bool is_tts_received_; - hmi_apis::Common_Result::eType ui_result_; hmi_apis::Common_Result::eType tts_result_; std::string ui_response_info_; diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index f461db814d..09aa4169e5 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -106,33 +106,29 @@ const std::string CreateInfoForUnsupportedResult( } bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) { - if (!first.is_ok && !second.is_ok) { - return false; + if (first.is_ok && second.is_unsupported_resource) { + return true; } - - if (!first.is_ok && second.is_not_used) { - return false; + if (first.is_ok && second.is_not_used) { + return true; } - - if (!second.is_ok && first.is_not_used) { - return false; + if (first.is_ok && second.is_ok) { + return true; } + return false; +} - if (first.is_unsupported_resource && second.is_not_used && - HmiInterfaces::STATE_NOT_AVAILABLE == first.interface_state) { - return false; - } +bool IsResultCodeWarning(const ResponseInfo& first, + const ResponseInfo& second) { + const bool first_is_ok_second_is_warn = + (first.is_ok || first.is_not_used) && + hmi_apis::Common_Result::WARNINGS == second.result_code; - return true; -} + const bool both_warnings = + hmi_apis::Common_Result::WARNINGS == first.result_code && + hmi_apis::Common_Result::WARNINGS == second.result_code; -bool IsResultCodeUnsupported(const ResponseInfo& first, - const ResponseInfo& second) { - return ((first.is_ok || first.is_not_used) && - second.is_unsupported_resource) || - ((second.is_ok || second.is_not_used) && - first.is_unsupported_resource) || - (first.is_unsupported_resource && second.is_unsupported_resource); + return first_is_ok_second_is_warn || both_warnings; } struct DisallowedParamsInserter { @@ -160,6 +156,42 @@ struct DisallowedParamsInserter { mobile_apis::VehicleDataResultCode::eType code_; }; +ResponseInfo::ResponseInfo() + : result_code(hmi_apis::Common_Result::INVALID_ENUM) + , interface(HmiInterfaces::HMI_INTERFACE_INVALID_ENUM) + , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) + , is_ok(false) + , is_unsupported_resource(false) + , is_not_used(false) {} + +ResponseInfo::ResponseInfo(const hmi_apis::Common_Result::eType result, + const HmiInterfaces::InterfaceID hmi_interface, + ApplicationManager& application_manager) + : result_code(result) + , interface(hmi_interface) + , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) + , is_ok(false) + , is_unsupported_resource(false) + , is_not_used(false) { + using namespace helpers; + + interface_state = + application_manager.hmi_interfaces().GetInterfaceState(hmi_interface); + + is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + result_code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED); + + is_not_used = hmi_apis::Common_Result::INVALID_ENUM == result_code; + + is_unsupported_resource = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code; +} + CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandImpl(message, application_manager) @@ -207,7 +239,7 @@ void CommandRequestImpl::onTimeOut() { function_id(), correlation_id(), mobile_api::Result::GENERIC_ERROR); - + AddTimeOutComponentInfoToMessage(*response); application_manager_.ManageMobileCommand(response, ORIGIN_SDL); } @@ -768,6 +800,7 @@ bool CommandRequestImpl::HasDisallowedParams() const { bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { + LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>( result_code, @@ -791,50 +824,8 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( bool CommandRequestImpl::PrepareResultForMobileResponse( ResponseInfo& out_first, ResponseInfo& out_second) const { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; - - out_first.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - out_first.result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); - - out_second.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - out_second.result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); - - out_first.is_not_used = - hmi_apis::Common_Result::INVALID_ENUM == out_first.result_code; - - out_second.is_not_used = - hmi_apis::Common_Result::INVALID_ENUM == out_second.result_code; - - out_first.is_unsupported_resource = - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_first.result_code; - - out_second.is_unsupported_resource = - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_second.result_code; - - out_first.interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - out_first.interface); - - out_second.interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - out_second.interface); - - bool result = (out_first.is_ok && out_second.is_ok) || - (out_second.is_not_used && out_first.is_ok) || - (out_first.is_not_used && out_second.is_ok); - - result = result || CheckResultCode(out_first, out_second); - result = result || CheckResultCode(out_second, out_first); + bool result = CheckResultCode(out_first, out_second) || + CheckResultCode(out_second, out_first); return result; } @@ -853,24 +844,28 @@ mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second) { LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - if (IsResultCodeUnsupported(first, second)) { - result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; - } else { - // If response contains erroneous result code SDL need return erroneus - // result code. - hmi_apis::Common_Result::eType first_result = - hmi_apis::Common_Result::INVALID_ENUM; - hmi_apis::Common_Result::eType second_result = - hmi_apis::Common_Result::INVALID_ENUM; - if (!first.is_unsupported_resource) { - first_result = first.result_code; - } - if (!second.is_unsupported_resource) { - second_result = second.result_code; - } - result_code = - MessageHelper::HMIToMobileResult(std::max(first_result, second_result)); - } + if (IsResultCodeUnsupported(first, second) || + IsResultCodeUnsupported(second, first)) { + return mobile_apis::Result::UNSUPPORTED_RESOURCE; + } + if (IsResultCodeWarning(first, second) || + IsResultCodeWarning(second, first)) { + return mobile_apis::Result::WARNINGS; + } + // If response contains erroneous result code SDL need return erroneus + // result code. + hmi_apis::Common_Result::eType first_result = + hmi_apis::Common_Result::INVALID_ENUM; + hmi_apis::Common_Result::eType second_result = + hmi_apis::Common_Result::INVALID_ENUM; + if (!first.is_unsupported_resource) { + first_result = first.result_code; + } + if (!second.is_unsupported_resource) { + second_result = second.result_code; + } + result_code = + MessageHelper::HMIToMobileResult(std::max(first_result, second_result)); return result_code; } @@ -879,6 +874,100 @@ const CommandParametersPermissions& CommandRequestImpl::parameters_permissions() return parameters_permissions_; } +void CommandRequestImpl::StartAwaitForInterface( + const HmiInterfaces::InterfaceID interface_id) { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + awaiting_response_interfaces_.insert(interface_id); +} + +bool CommandRequestImpl::IsInterfaceAwaited( + const HmiInterfaces::InterfaceID& interface_id) const { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + std::set<HmiInterfaces::InterfaceID>::const_iterator it = + awaiting_response_interfaces_.find(interface_id); + return (it != awaiting_response_interfaces_.end()); +} + +void CommandRequestImpl::EndAwaitForInterface( + const HmiInterfaces::InterfaceID& interface_id) { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + std::set<HmiInterfaces::InterfaceID>::const_iterator it = + awaiting_response_interfaces_.find(interface_id); + if (it != awaiting_response_interfaces_.end()) { + awaiting_response_interfaces_.erase(it); + } else { + LOG4CXX_WARN(logger_, + "EndAwaitForInterface called on interface \ + which was not put into await state: " + << interface_id); + } +} + +bool CommandRequestImpl::IsResultCodeUnsupported( + const ResponseInfo& first, const ResponseInfo& second) const { + const bool first_ok_second_unsupported = + (first.is_ok || first.is_not_used) && second.is_unsupported_resource; + const bool both_unsupported = + first.is_unsupported_resource && second.is_unsupported_resource; + return first_ok_second_unsupported || both_unsupported; +} + +std::string GetComponentNameFromInterface( + const HmiInterfaces::InterfaceID& interface) { + switch (interface) { + case HmiInterfaces::HMI_INTERFACE_Buttons: + return "Buttons"; + case HmiInterfaces::HMI_INTERFACE_BasicCommunication: + return "BasicCommunication"; + case HmiInterfaces::HMI_INTERFACE_VR: + return "VR"; + case HmiInterfaces::HMI_INTERFACE_TTS: + return "TTS"; + case HmiInterfaces::HMI_INTERFACE_UI: + return "UI"; + case HmiInterfaces::HMI_INTERFACE_Navigation: + return "Navigation"; + case HmiInterfaces::HMI_INTERFACE_VehicleInfo: + return "VehicleInfo"; + case HmiInterfaces::HMI_INTERFACE_SDL: + return "SDL"; + default: + return "Unknown type"; + } +} + +const std::string InfoInterfaceSeparator( + const std::string& sum, const HmiInterfaces::InterfaceID container_value) { + return sum.empty() + ? GetComponentNameFromInterface(container_value) + : sum + ", " + GetComponentNameFromInterface(container_value); +} + +void CommandRequestImpl::AddTimeOutComponentInfoToMessage( + smart_objects::SmartObject& response) const { + using NsSmartDeviceLink::NsSmartObjects::SmartObject; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + if (awaiting_response_interfaces_.empty()) { + LOG4CXX_ERROR(logger_, "No interfaces awaiting, info param is empty"); + return; + } + + const std::string not_responding_interfaces_string = + std::accumulate(awaiting_response_interfaces_.begin(), + awaiting_response_interfaces_.end(), + std::string(""), + InfoInterfaceSeparator); + LOG4CXX_DEBUG( + logger_, + "Not responding interfaces string: " << not_responding_interfaces_string); + if (!not_responding_interfaces_string.empty()) { + const std::string component_info = + not_responding_interfaces_string + " component does not respond"; + response[strings::msg_params][strings::info] = component_info; + } +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc index c748ddcbb6..69948b8122 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -192,10 +192,12 @@ void AddCommandRequest::Run() { } if (send_ui_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &ui_msg_params, true); } if (send_vr_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &vr_msg_params, true); } } @@ -317,6 +319,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_AddCommand: { LOG4CXX_INFO(logger_, "Received UI_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -328,6 +331,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_AddCommand: { LOG4CXX_INFO(logger_, "Received VR_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); is_vr_received_ = true; vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc index a5491481dc..fe44e5a41f 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc @@ -94,6 +94,7 @@ void AddSubMenuRequest::Run() { (*message_)[strings::msg_params][strings::menu_name]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); } @@ -103,6 +104,7 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_AddSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index 78b05e452f..d5767690d7 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -111,6 +111,7 @@ void AlertManeuverRequest::Run() { } pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_AlertManeuver, &msg_params, true); @@ -123,6 +124,7 @@ void AlertManeuverRequest::Run() { msg_params[hmi_request::speak_type] = hmi_apis::Common_MethodName::ALERT_MANEUVER; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); } } @@ -134,6 +136,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { switch (event_id) { case hmi_apis::FunctionID::Navigation_AlertManeuver: { LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); pending_requests_.Remove(event_id); navi_alert_maneuver_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -143,6 +146,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); pending_requests_.Remove(event_id); tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -191,10 +195,13 @@ bool AlertManeuverRequest::PrepareResponseParameters( application_manager::commands::ResponseInfo navigation_alert_info( navi_alert_maneuver_result_code_, - HmiInterfaces::HMI_INTERFACE_Navigation); + HmiInterfaces::HMI_INTERFACE_Navigation, + application_manager_); application_manager::commands::ResponseInfo tts_alert_info( - tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS); + tts_speak_result_code_, + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); const bool result = PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info); @@ -243,7 +250,8 @@ bool AlertManeuverRequest::IsWhiteSpaceExist() { SmartArray::const_iterator it_soft_button = soft_button_array->begin(); for (; it_soft_button != soft_button_array->end(); ++it_soft_button) { - const char* soft_button_text = (*it_soft_button)[strings::text].asCharArray(); + const char* soft_button_text = + (*it_soft_button)[strings::text].asCharArray(); if (!CheckSyntax(soft_button_text)) { LOG4CXX_ERROR(logger_, "Invalid soft_buttons syntax check failed"); return true; diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index 53515a810a..3c42e43767 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -116,18 +116,6 @@ void AlertRequest::Run() { } } -void AlertRequest::onTimeOut() { - LOG4CXX_AUTO_TRACE(logger_); - if (false == - (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { - CommandRequestImpl::onTimeOut(); - return; - } - LOG4CXX_INFO(logger_, - "Default timeout ignored. " - "AlertRequest with soft buttons wait timeout on HMI side"); -} - void AlertRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); @@ -148,6 +136,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::UI_Alert: { LOG4CXX_INFO(logger_, "Received UI_Alert event"); // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert); awaiting_ui_alert_response_ = false; HmiInterfaces::InterfaceState ui_interface_state = @@ -157,6 +146,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { if (awaiting_tts_speak_response_ && HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) { awaiting_tts_stop_speaking_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true); } alert_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -170,6 +160,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak); awaiting_tts_speak_response_ = false; tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -179,6 +170,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_StopSpeaking: { LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); // Unsubscribe from event to avoid unwanted messages unsubscribe_from_event(hmi_apis::FunctionID::TTS_StopSpeaking); awaiting_tts_stop_speaking_response_ = false; @@ -204,9 +196,11 @@ void AlertRequest::on_event(const event_engine::Event& event) { bool AlertRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { - ResponseInfo ui_alert_info(alert_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_alert_info( + alert_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); ResponseInfo tts_alert_info(tts_speak_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info); @@ -350,6 +344,7 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { msg_params.keyExists(hmi_request::soft_buttons)) { awaiting_ui_alert_response_ = true; is_ui_alert_sent_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true); } } @@ -374,6 +369,7 @@ void AlertRequest::SendSpeakRequest(int32_t app_id, } msg_params[strings::app_id] = app_id; msg_params[hmi_request::speak_type] = Common_MethodName::ALERT; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index f1f3b93e24..f55767c723 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -66,6 +66,73 @@ ChangeRegistrationRequest::ChangeRegistrationRequest( ChangeRegistrationRequest::~ChangeRegistrationRequest() {} +void ChangeRegistrationRequest::SendVRRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::VR_ChangeRegistration; + pending_requests_.Add(function); + smart_objects::SmartObject vr_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + vr_params[strings::language] = msg_params[strings::language]; + + vr_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::vr_synonyms)) { + vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms]; + app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &vr_params, true); +} + +void ChangeRegistrationRequest::SendTTSRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::TTS_ChangeRegistration; + pending_requests_.Add(function); + + smart_objects::SmartObject tts_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + tts_params[strings::language] = msg_params[strings::language]; + + tts_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::tts_name)) { + tts_params[strings::tts_name] = msg_params[strings::tts_name]; + app->set_tts_name(msg_params[strings::tts_name]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &tts_params, true); +} + +void ChangeRegistrationRequest::SendUIRequest( + ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params, + const int32_t hmi_language) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::UI_ChangeRegistration; + pending_requests_.Add(function); + // UI processing + smart_objects::SmartObject ui_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ui_params[strings::language] = hmi_language; + ui_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::app_name)) { + ui_params[strings::app_name] = msg_params[strings::app_name]; + app->set_name(msg_params[strings::app_name].asCustomString()); + } + if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { + ui_params[strings::ngn_media_screen_app_name] = + msg_params[strings::ngn_media_screen_app_name]; + app->set_ngn_media_screen_name( + msg_params[strings::ngn_media_screen_app_name]); + } + + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &ui_params, true); +} + void ChangeRegistrationRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; @@ -111,53 +178,42 @@ void ChangeRegistrationRequest::Run() { return; } - pending_requests_.Add(hmi_apis::FunctionID::UI_ChangeRegistration); - pending_requests_.Add(hmi_apis::FunctionID::VR_ChangeRegistration); - pending_requests_.Add(hmi_apis::FunctionID::TTS_ChangeRegistration); + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); - // UI processing - SmartObject ui_params = SmartObject(SmartType_Map); + const HmiInterfaces::InterfaceState vr_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_VR); + const HmiInterfaces::InterfaceState ui_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); + const HmiInterfaces::InterfaceState tts_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); - ui_params[strings::language] = hmi_language; - ui_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::app_name)) { - ui_params[strings::app_name] = msg_params[strings::app_name]; - app->set_name(msg_params[strings::app_name].asCustomString()); + using helpers::Compare; + using helpers::EQ; + using helpers::ALL; + + if (Compare<HmiInterfaces::InterfaceState, EQ, ALL>( + HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE, + vr_state, + tts_state, + ui_state)) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; } - if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { - ui_params[strings::ngn_media_screen_app_name] = - msg_params[strings::ngn_media_screen_app_name]; - app->set_ngn_media_screen_name( - msg_params[strings::ngn_media_screen_app_name]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != vr_state) { + // VR processing + SendVRRequest(app, msg_params); } - - SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration, &ui_params, true); - - // VR processing - SmartObject vr_params = SmartObject(SmartType_Map); - - vr_params[strings::language] = msg_params[strings::language]; - - vr_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::vr_synonyms)) { - vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms]; - app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != tts_state) { + // TTS processing + SendTTSRequest(app, msg_params); } - SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration, &vr_params, true); - - // TTS processing - SmartObject tts_params = SmartObject(SmartType_Map); - tts_params[strings::language] = msg_params[strings::language]; - - tts_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::tts_name)) { - tts_params[strings::tts_name] = msg_params[strings::tts_name]; - app->set_tts_name(msg_params[strings::tts_name]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != ui_state) { + SendUIRequest(app, msg_params, hmi_language); } - - SendHMIRequest( - hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true); } void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { @@ -169,6 +225,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { switch (event_id) { case hmi_apis::FunctionID::UI_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); pending_requests_.Remove(event_id); ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -177,6 +234,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); pending_requests_.Remove(event_id); vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -185,6 +243,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); pending_requests_.Remove(event_id); tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -295,12 +354,14 @@ bool ChangeRegistrationRequest::PrepareResponseParameters( hmi_interfaces.GetInterfaceState( HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); - ResponseInfo vr_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo vr_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported && is_ui_succeeded_unsupported && is_vr_succeeded_unsupported); @@ -338,6 +399,9 @@ bool ChangeRegistrationRequest::PrepareResponseParameters( } result_code = MessageHelper::HMIToMobileResult( std::max(std::max(ui_result, vr_result), tts_result)); + if (mobile_api::Result::INVALID_ENUM == result_code) { + result_code = mobile_api::Result::UNSUPPORTED_RESOURCE; + } } const bool is_tts_state_available = diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index e1148bd126..20387ef230 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -287,6 +287,7 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( sync_primitives::AutoLock commands_lock(vr_commands_lock_); const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); const uint32_t vr_corr_id = SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); @@ -356,6 +357,7 @@ void CreateInteractionChoiceSetRequest::on_event( uint32_t corr_id = static_cast<uint32_t>( message[strings::params][strings::correlation_id].asUInt()); if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); { sync_primitives::AutoLock commands_lock(vr_commands_lock_); if (is_no_error) { @@ -376,6 +378,7 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { if (!error_from_hmi_) { SendResponse(false, mobile_apis::Result::GENERIC_ERROR); } + CommandRequestImpl::onTimeOut(); DeleteChoices(); // We have to keep request alive until receive all responses from HMI diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc index cfc8e12144..f894ed452c 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc @@ -104,12 +104,14 @@ void DeleteCommandRequest::Run() { is_vr_send_ = true; } if (is_ui_send_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true); } if (is_vr_send_) { // VR params msg_params[strings::grammar_id] = application->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true); } } @@ -117,8 +119,10 @@ void DeleteCommandRequest::Run() { bool DeleteCommandRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { using namespace helpers; - ResponseInfo ui_delete_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo vr_delete_info(vr_result_, HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo ui_delete_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo vr_delete_info( + vr_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); const bool result = PrepareResultForMobileResponse(ui_delete_info, vr_delete_info); @@ -143,6 +147,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::UI_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -153,6 +158,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { break; } case hmi_apis::FunctionID::VR_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); is_vr_received_ = true; vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc index 21c7ecce90..09f3139245 100644 --- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc @@ -74,6 +74,7 @@ void DeleteSubMenuRequest::Run() { msg_params[strings::menu_id] = (*message_)[strings::msg_params][strings::menu_id]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true); } @@ -143,6 +144,7 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_DeleteSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc index 5c5d250026..7704d700f9 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc @@ -83,6 +83,7 @@ void DiagnosticMessageRequest::Run() { // Add app_id for HMI request (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage, &(*message_)[strings::msg_params], true); @@ -94,6 +95,7 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc index 64685afe2e..d0ab42e266 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -87,6 +87,7 @@ void DialNumberRequest::Run() { (*message_)[strings::msg_params][strings::number].asString(); msg_params[strings::app_id] = application->hmi_app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest( hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true); } @@ -106,6 +107,7 @@ void DialNumberRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::BasicCommunication_DialNumber: { LOG4CXX_INFO(logger_, "Received DialNumber event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); result_code = CommandRequestImpl::GetMobileResultCode( static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt())); diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc index f67d1f2434..0bd83078e5 100644 --- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc @@ -47,6 +47,7 @@ EndAudioPassThruRequest::~EndAudioPassThruRequest() {} void EndAudioPassThruRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true); } @@ -56,6 +57,7 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_EndAudioPassThru: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc index d98207c772..88fd07234a 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc @@ -72,6 +72,7 @@ void GetDTCsRequest::Run() { msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true); } @@ -81,6 +82,7 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index 25e2da3eb6..84c6e0ba7c 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -250,6 +250,7 @@ void GetVehicleDataRequest::Run() { } } if (msg_params.length() > min_length_msg_params) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest( hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true); return; @@ -266,6 +267,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc index c313d74d4b..da4ce38646 100644 --- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc @@ -31,6 +31,7 @@ void GetWayPointsRequest::Run() { msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints, msg_params.empty() ? NULL : &msg_params, true); @@ -48,6 +49,7 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::Navigation_GetWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index 9f5fd937f9..cff16e577c 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -47,8 +47,6 @@ namespace str = strings; PerformAudioPassThruRequest::PerformAudioPassThruRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , awaiting_tts_speak_response_(false) - , awaiting_ui_response_(false) , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM) , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) { subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); @@ -97,7 +95,7 @@ void PerformAudioPassThruRequest::Run() { // According with new implementation processing of UNSUPPORTE_RESOURCE // need set flag before sending to hmi - awaiting_ui_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { // In case TTS Speak, subscribe on notification @@ -119,7 +117,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_PerformAudioPassThru: { LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru"); - awaiting_ui_response_ = false; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); result_ui_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); @@ -142,7 +140,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); GetInfo(message, tts_info_); - awaiting_tts_speak_response_ = false; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); const bool is_tts_speak_success_unsuported = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( result_tts_speak_, @@ -179,36 +177,59 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { return; } - std::string return_info; - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - const bool result = PrepareResponseParameters(result_code, return_info); + const ResponseParams response_params = PrepareResponseParameters(); - SendResponse(result, - result_code, - return_info.empty() ? NULL : return_info.c_str(), - &(message[strings::msg_params])); + SendResponse( + response_params.success, + response_params.result_code, + response_params.info.empty() ? NULL : response_params.info.c_str(), + &(message[strings::msg_params])); } -bool PerformAudioPassThruRequest::PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info) { +const PerformAudioPassThruRequest::ResponseParams& +PerformAudioPassThruRequest::PrepareResponseParameters() { LOG4CXX_AUTO_TRACE(logger_); - ResponseInfo ui_perform_info(result_ui_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_perform_info( + result_ui_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); ResponseInfo tts_perform_info(result_tts_speak_, - HmiInterfaces::HMI_INTERFACE_TTS); - const bool result = - PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); + // Note(dtrunov): According to requirment "WARNINGS, success:true on getting + // UNSUPPORTED_RESOURCE for "ttsChunks" if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) { - result_code = mobile_apis::Result::WARNINGS; + response_params_.result_code = mobile_apis::Result::WARNINGS; tts_info_ = "Unsupported phoneme type sent in a prompt"; - info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); - return result; + response_params_.info = + MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); + response_params_.success = true; + return response_params_; } - result_code = PrepareResultCodeForResponse(ui_perform_info, tts_perform_info); - info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); - return result; + + response_params_.success = + PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); + if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) { + response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; + } else { + AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse( + ui_perform_info, tts_perform_info); + response_params_.success = results.second; + response_params_.result_code = results.first; + } + response_params_.info = + MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); + + return response_params_; +} + +// DEPRECATED +bool PerformAudioPassThruRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + LOG4CXX_AUTO_TRACE(logger_); + NOTREACHED(); + return false; } void PerformAudioPassThruRequest::SendSpeakRequest() { @@ -229,7 +250,7 @@ void PerformAudioPassThruRequest::SendSpeakRequest() { // app_id msg_params[strings::app_id] = connection_key(); msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU; - awaiting_tts_speak_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } @@ -273,6 +294,7 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() { msg_params[str::mute_audio] = true; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true); } @@ -353,16 +375,56 @@ void PerformAudioPassThruRequest::FinishTTSSpeak() { LOG4CXX_DEBUG(logger_, "Stop AudioPassThru."); application_manager_.StopAudioPassThru(connection_key()); } - if (!awaiting_tts_speak_response_) { + if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) { LOG4CXX_WARN(logger_, "TTS Speak is inactive."); return; } SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL); } +PerformAudioPassThruRequest::AudioPassThruResults +PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse( + const ResponseInfo& ui_response, const ResponseInfo& tts_response) { + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + hmi_apis::Common_Result::eType common_result = + hmi_apis::Common_Result::INVALID_ENUM; + const hmi_apis::Common_Result::eType ui_result = ui_response.result_code; + const hmi_apis::Common_Result::eType tts_result = tts_response.result_code; + bool result = false; + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result == hmi_apis::Common_Result::SUCCESS)) { + result = true; + } + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result == hmi_apis::Common_Result::INVALID_ENUM)) { + result = true; + } + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result != hmi_apis::Common_Result::SUCCESS) && + (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) { + common_result = hmi_apis::Common_Result::WARNINGS; + result = true; + } else if (ui_response.is_ok && + tts_result == hmi_apis::Common_Result::WARNINGS) { + common_result = hmi_apis::Common_Result::WARNINGS; + result = true; + } else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) { + common_result = tts_result; + } else { + common_result = ui_result; + } + result_code = MessageHelper::HMIToMobileResult(common_result); + return std::make_pair(result_code, result); +} + bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { LOG4CXX_AUTO_TRACE(logger_); - return awaiting_tts_speak_response_ || awaiting_ui_response_; + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index b199e652a6..68940158b9 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -226,6 +226,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::UI_PerformInteraction: { LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); ui_response_received_ = true; unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -236,6 +237,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_PerformInteraction: { LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); vr_response_received_ = true; unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction); vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -391,14 +393,14 @@ void PerformInteractionRequest::ProcessUIResponse( if (result) { if (is_pi_warning) { ui_result_code_ = hmi_apis::Common_Result::WARNINGS; - ui_info_ = "Unsupported phoneme type was sent in an item"; + ui_info_ = message[strings::msg_params][strings::info].asString(); if (message.keyExists(strings::params) && message[strings::params].keyExists(strings::data)) { msg_params = message[strings::params][strings::data]; } } else if (is_pi_unsupported) { ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; - ui_info_ = "Unsupported phoneme type was sent in an item"; + ui_info_ = message[strings::msg_params][strings::info].asString(); } else if (message.keyExists(strings::msg_params)) { msg_params = message[strings::msg_params]; } @@ -502,6 +504,7 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( (*message_)[strings::msg_params][hmi_request::interaction_layout] .asInt(); } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true); } @@ -594,6 +597,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( msg_params[strings::timeout] = default_timeout_; } msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest( hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); } @@ -925,10 +929,10 @@ void PerformInteractionRequest::SendBothModeResponse( LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType perform_interaction_result_code = mobile_apis::Result::INVALID_ENUM; - ResponseInfo ui_perform_info(ui_result_code_, - HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo vr_perform_info(vr_result_code_, - HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo ui_perform_info( + ui_result_code_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo vr_perform_info( + vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); const bool result = PrepareResultForMobileResponse(ui_perform_info, vr_perform_info); perform_interaction_result_code = diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc index 0bf747bde3..c51f545e7e 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc @@ -87,6 +87,7 @@ void ReadDIDRequest::Run() { (*message_)[strings::msg_params][strings::ecu_name]; msg_params[strings::did_location] = (*message_)[strings::msg_params][strings::did_location]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true); } @@ -97,6 +98,7 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_ReadDID: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc index 713d50e190..a7c2db0e65 100644 --- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc @@ -46,10 +46,6 @@ namespace commands { ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , is_ui_send_(false) - , is_tts_send_(false) - , is_ui_received_(false) - , is_tts_received_(false) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} @@ -111,11 +107,11 @@ void ResetGlobalPropertiesRequest::Run() { if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) { - is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); } if (timeout_prompt || helpt_promt) { - is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); } app->set_reset_global_properties_active(true); @@ -245,7 +241,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); - is_ui_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, ui_response_info_); @@ -253,7 +249,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); - is_tts_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, tts_response_info_); @@ -292,9 +288,10 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( using namespace helpers; bool result = false; - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); HmiInterfaces::InterfaceState tts_interface_state = application_manager_.hmi_interfaces().GetInterfaceState( @@ -321,7 +318,8 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( } bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { - return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc index 0c770953fe..b0b2d5f464 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc @@ -109,7 +109,7 @@ void ScrollableMessageRequest::Run() { MessageHelper::SubscribeApplicationToSoftButton( (*message_)[strings::msg_params], app, function_id()); } - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true); } @@ -126,6 +126,7 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::UI_ScrollableMessage: { LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index 9ec4ca3fcc..54664a8771 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -125,6 +125,7 @@ void SendLocationRequest::Run() { SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); request_msg_params = msg_params; request_msg_params[strings::app_id] = app->hmi_app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_SendLocation, &request_msg_params, true); } @@ -135,6 +136,7 @@ void SendLocationRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) { LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const Common_Result::eType result_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); std::string response_info; diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc index 5afddfb4d0..ee544e956a 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -114,7 +114,7 @@ void SetAppIconRequest::Run() { // for further use in on_event function (*message_)[strings::msg_params][strings::sync_file_name] = msg_params[strings::sync_file_name]; - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); } @@ -242,6 +242,7 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc index 984690384a..38b62ce731 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -58,6 +58,7 @@ void SetDisplayLayoutRequest::Run() { } (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, &((*message_)[strings::msg_params]), true); @@ -70,6 +71,7 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetDisplayLayout: { LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index 096c4ed783..e811f5d154 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -229,6 +229,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -237,6 +238,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); is_tts_received_ = true; tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -277,10 +279,11 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters( LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); const bool result = PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); if (result && @@ -397,6 +400,7 @@ void SetGlobalPropertiesRequest::SendTTSRequest( const smart_objects::SmartObject& params, bool use_events) { LOG4CXX_AUTO_TRACE(logger_); is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest( hmi_apis::FunctionID::TTS_SetGlobalProperties, ¶ms, use_events); } @@ -405,6 +409,7 @@ void SetGlobalPropertiesRequest::SendUIRequest( const smart_objects::SmartObject& params, bool use_events) { LOG4CXX_AUTO_TRACE(logger_); is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, use_events); } diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc index 85f34aead9..037de54456 100644 --- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc @@ -95,7 +95,7 @@ void SetIconRequest::Run() { // for further use in on_event function (*message_)[strings::msg_params][strings::sync_file_name] = msg_params[strings::sync_file_name]; - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); } @@ -105,6 +105,7 @@ void SetIconRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc index 1e0a00318d..54727abe01 100644 --- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc @@ -71,6 +71,7 @@ void SetMediaClockRequest::Run() { // copy entirely msg msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true); @@ -85,6 +86,7 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetMediaClockTimer: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc index b1cc40009d..42bfea4864 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -172,6 +172,7 @@ void ShowConstantTBTRequest::Run() { } app->set_tbt_show_command(msg_params); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, true); } @@ -184,6 +185,7 @@ void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const Common_Result::eType result_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc index 5b8e98d7ea..ad598efc1d 100644 --- a/src/components/application_manager/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_request.cc @@ -263,6 +263,7 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::custom_presets]; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); MessageSharedPtr persistentData = new smart_objects::SmartObject(msg_params); @@ -278,6 +279,7 @@ void ShowRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_Show: { LOG4CXX_DEBUG(logger_, "Received UI_Show event."); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); std::string response_info; hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc index 054d0ec16d..f98869b08f 100644 --- a/src/components/application_manager/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/src/commands/mobile/slider_request.cc @@ -107,6 +107,7 @@ void SliderRequest::Run() { msg_params[strings::timeout] = default_timeout_; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); } @@ -132,7 +133,7 @@ void SliderRequest::on_event(const event_engine::Event& event) { } LOG4CXX_DEBUG(logger_, "Received UI_Slider event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); const Common_Result::eType response_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc index 6cbb762102..1954cde181 100644 --- a/src/components/application_manager/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -72,6 +72,7 @@ void SpeakRequest::Run() { (*message_)[strings::msg_params][strings::app_id] = app->app_id(); (*message_)[strings::msg_params][hmi_request::speak_type] = hmi_apis::Common_MethodName::SPEAK; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &message_->getElement(strings::msg_params), true); @@ -82,7 +83,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); ProcessTTSSpeakResponse(event.smart_object()); break; } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc index 28651cded4..f4b7e7c8aa 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -149,6 +149,7 @@ void SubscribeVehicleDataRequest::Run() { ++it) SendHMIRequest(it->func_id, &msg_params, true); #else + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, &msg_params, true); @@ -165,7 +166,7 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { LOG4CXX_ERROR(logger_, "Received unknown event."); return; } - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc index 0e0d760228..965741edf7 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc @@ -36,6 +36,7 @@ void SubscribeWayPointsRequest::Run() { return; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, true); } @@ -47,6 +48,7 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index f3fcf85b65..fe38b93732 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -587,6 +587,7 @@ void SystemRequest::Run() { msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, &msg_params, true); @@ -600,6 +601,7 @@ void SystemRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); mobile_apis::Result::eType result_code = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index fa3a9ad400..037c3fa4a4 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -234,6 +234,7 @@ void UnsubscribeVehicleDataRequest::Run() { ++it) SendHMIRequest(it->func_id, &msg_params, true); #else + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, &msg_params, true); @@ -250,6 +251,7 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { LOG4CXX_ERROR(logger_, "Received unknown event."); return; } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); #ifdef HMI_DBUS_API for (HmiRequests::iterator it = hmi_requests_.begin(); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc index 953bbc7a12..88ed396250 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -30,6 +30,7 @@ void UnSubscribeWayPointsRequest::Run() { return; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true); } @@ -41,6 +42,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index becab175e9..44fe9d0d07 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -138,6 +138,7 @@ void UpdateTurnListRequest::Run() { if ((*message_)[strings::msg_params].keyExists(strings::turn_list) || (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true); } else { @@ -154,7 +155,7 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_UpdateTurnList: { LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc index dec0ffe7ad..cd9d6999a8 100644 --- a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc @@ -209,7 +209,8 @@ class AddCommandRequestTest EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); EXPECT_CALL(app_mngr_, ManageHMICommand(HMIResultCodeIs(cmd_to_delete))) .WillOnce(Return(true)); - SmartObjectSPtr response; + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; EXPECT_CALL( mock_message_helper_, CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) @@ -516,9 +517,6 @@ TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) { utils::SharedPtr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); request_ptr->on_event(event); } @@ -530,9 +528,6 @@ TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) { Event event(hmi_apis::FunctionID::VR_AddCommand); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params])); am::CommandsMap commands_map; @@ -619,9 +614,6 @@ TEST_F(AddCommandRequestTest, utils::SharedPtr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::REJECTED)) - .WillOnce(Return(mobile_apis::Result::REJECTED)); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); EXPECT_CALL(app_mngr_, ManageMobileCommand( @@ -695,9 +687,6 @@ TEST_F( .WillOnce(Return(true)); } - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::GENERIC_ERROR)) - .WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR)); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); utils::SharedPtr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); @@ -742,9 +731,6 @@ TEST_F( .WillOnce(Return(true)); } - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::GENERIC_ERROR)) - .WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR)); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); utils::SharedPtr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); @@ -973,9 +959,6 @@ TEST_F(AddCommandRequestTest, event_ui.set_smart_object(*msg_ui); Event event_vr(hmi_apis::FunctionID::VR_AddCommand); event_vr.set_smart_object(*msg_); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::ABORTED)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); EXPECT_CALL( app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand))) @@ -1015,9 +998,6 @@ TEST_F(AddCommandRequestTest, utils::SharedPtr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::ABORTED)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); Event event_ui(hmi_apis::FunctionID::UI_AddCommand); event_ui.set_smart_object(*msg_); @@ -1042,7 +1022,8 @@ TEST_F(AddCommandRequestTest, EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(0); - SmartObjectSPtr response; + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; EXPECT_CALL( mock_message_helper_, CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) @@ -1091,7 +1072,8 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) { CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); - SmartObjectSPtr response; + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; EXPECT_CALL( mock_message_helper_, CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) diff --git a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc index 9617f91016..fede3c5c68 100644 --- a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc @@ -97,10 +97,6 @@ TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { Event event(hmi_apis::FunctionID::UI_AddSubMenu); event.set_smart_object(*ev_msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, diff --git a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc index fd577621cd..d892b18020 100644 --- a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc @@ -91,11 +91,6 @@ class AlertManeuverRequestTest MockAppPtr mock_app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); - if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != hmi_response) { - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response)) - .WillOnce(Return(mobile_response)); - } - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(state)); diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc index f83a40843c..d77067bcc5 100644 --- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc @@ -128,12 +128,12 @@ class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault( - Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) .WillByDefault( - Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE)); } void Expectations() { @@ -248,9 +248,6 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) { (*msg)[am::strings::msg_params][am::strings::info] = "UI is not supported by system"; - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); - MessageSharedPtr msg_tts = CreateMessage(); (*msg_tts)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; @@ -263,9 +260,6 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) { event.set_smart_object(*msg); MessageSharedPtr ui_command_result; - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillByDefault(Return(am::mobile_api::Result::UNSUPPORTED_RESOURCE)); EXPECT_CALL( app_mngr_, ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) @@ -302,14 +296,6 @@ TEST_F(AlertRequestTest, Init_DurationNotExists_SUCCESS) { EXPECT_TRUE(command->Init()); } -TEST_F(AlertRequestTest, OnTimeOut_UNSUCCESS) { - Expectations(); - (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0; - CommandPtr command(CreateCommand<AlertRequest>(msg_)); - command->onTimeOut(); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); -} - TEST_F(AlertRequestTest, OnTimeOut_SUCCESS) { Expectations(); MessageSharedPtr result_msg(CreateMessage(smart_objects::SmartType_Null)); @@ -442,8 +428,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_UI_OnResetTimeout_SUCCESS) { Event event(hmi_apis::FunctionID::UI_OnResetTimeout); event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event); } @@ -504,8 +488,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { Event event(hmi_apis::FunctionID::TTS_Speak); event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event); } @@ -574,16 +556,12 @@ TEST_F(AlertRequestTest, Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); tts_stop_event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(tts_stop_event); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); Event event(hmi_apis::FunctionID::TTS_Speak); event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event); } @@ -711,8 +689,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); tts_stop_event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(tts_stop_event); (*msg_)[am::strings::params][am::hmi_response::code] = @@ -722,8 +698,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { Event event(hmi_apis::FunctionID::TTS_Speak); event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event); } @@ -750,8 +724,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarningUiAlertWarning_SUCCESS) { Event ui_event(hmi_apis::FunctionID::UI_Alert); ui_event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(ui_event); Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); @@ -762,8 +734,6 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarningUiAlertWarning_SUCCESS) { Event event(hmi_apis::FunctionID::TTS_Speak); event.set_smart_object(*msg_); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event); } diff --git a/src/components/application_manager/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/test/commands/mobile/change_registration_test.cc index cbf8ce1abe..68eea31188 100644 --- a/src/components/application_manager/test/commands/mobile/change_registration_test.cc +++ b/src/components/application_manager/test/commands/mobile/change_registration_test.cc @@ -120,26 +120,26 @@ class ChangeRegistrationRequestTest EXPECT_CALL( mock_hmi_interfaces_, GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration)) - .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); EXPECT_CALL( mock_hmi_interfaces_, GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) - .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); EXPECT_CALL( mock_hmi_interfaces_, GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration)) - .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); } void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response, @@ -147,14 +147,11 @@ class ChangeRegistrationRequestTest const am::HmiInterfaces::InterfaceState state, const bool success, const hmi_apis::Common_Result::eType ui_hmi_response = - hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, const hmi_apis::Common_Result::eType vr_hmi_response = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) { MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_response)); - utils::SharedPtr<ChangeRegistrationRequest> command = CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); MockAppPtr mock_app = CreateMockApp(); @@ -172,6 +169,8 @@ class ChangeRegistrationRequestTest EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); PrepareExpectationBeforeRun(); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(state)); command->Run(); MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map); @@ -183,9 +182,6 @@ class ChangeRegistrationRequestTest (*tts_response)[strings::params][hmi_response::code] = hmi_response; (*tts_response)[strings::msg_params] = 0; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) - .WillRepeatedly(Return(state)); - am::event_engine::Event event_ui( hmi_apis::FunctionID::UI_ChangeRegistration); event_ui.set_smart_object(*ui_response); @@ -378,11 +374,52 @@ TEST_F(ChangeRegistrationRequestTest, } TEST_F(ChangeRegistrationRequestTest, - OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_true) { - CheckExpectations(hmi_apis::Common_Result::SUCCESS, - mobile_apis::Result::UNSUPPORTED_RESOURCE, - am::HmiInterfaces::STATE_NOT_AVAILABLE, - true); + OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) { + MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); + utils::SharedPtr<ChangeRegistrationRequest> command = + CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(1)); + am::ApplicationSet application_set; + const utils::custom_string::CustomString name("name"); + MockAppPtr app = CreateMockApp(); + app->set_name(name); + DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_); + application_set.insert(app); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); + + ON_CALL(app_mngr_, hmi_capabilities()) + .WillByDefault(ReturnRef(hmi_capabilities_)); + (*supported_languages_)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); + EXPECT_CALL(hmi_capabilities_, ui_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(hmi_capabilities_, vr_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(hmi_capabilities_, tts_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr response_to_mobile; + EXPECT_CALL( + app_mngr_, + ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + command->Run(); + + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::success].asBool(), + false); + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(mobile_apis::Result::UNSUPPORTED_RESOURCE)); } TEST_F(ChangeRegistrationRequestTest, @@ -390,7 +427,7 @@ TEST_F(ChangeRegistrationRequestTest, CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, mobile_apis::Result::UNSUPPORTED_RESOURCE, am::HmiInterfaces::STATE_NOT_RESPONSE, - true); + false); } TEST_F(ChangeRegistrationRequestTest, @@ -398,11 +435,11 @@ TEST_F(ChangeRegistrationRequestTest, CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, mobile_apis::Result::UNSUPPORTED_RESOURCE, am::HmiInterfaces::STATE_AVAILABLE, - true); + false); } TEST_F(ChangeRegistrationRequestTest, - OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_false) { + OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_true) { CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, mobile_apis::Result::UNSUPPORTED_RESOURCE, am::HmiInterfaces::STATE_AVAILABLE, @@ -412,7 +449,7 @@ TEST_F(ChangeRegistrationRequestTest, } TEST_F(ChangeRegistrationRequestTest, - OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_false) { + OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_true) { CheckExpectations(hmi_apis::Common_Result::SUCCESS, mobile_apis::Result::SUCCESS, am::HmiInterfaces::STATE_AVAILABLE, @@ -424,7 +461,7 @@ TEST_F(ChangeRegistrationRequestTest, TEST_F(ChangeRegistrationRequestTest, OnEvent_TTS_WRONG_LANGUAGE_STATE_AVAILABLE_Expect_true) { CheckExpectations(hmi_apis::Common_Result::WRONG_LANGUAGE, - mobile_apis::Result::SUCCESS, + mobile_apis::Result::WRONG_LANGUAGE, am::HmiInterfaces::STATE_AVAILABLE, true, hmi_apis::Common_Result::SUCCESS, @@ -434,7 +471,7 @@ TEST_F(ChangeRegistrationRequestTest, TEST_F(ChangeRegistrationRequestTest, OnEvent_TTS_INVALID_DATA_STATE_AVAILABLE_Expect_false) { CheckExpectations(hmi_apis::Common_Result::INVALID_DATA, - mobile_apis::Result::SUCCESS, + mobile_apis::Result::INVALID_DATA, am::HmiInterfaces::STATE_AVAILABLE, false, hmi_apis::Common_Result::SUCCESS, @@ -472,14 +509,14 @@ TEST_F(ChangeRegistrationRequestTest, .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL( mock_hmi_interfaces_, @@ -487,7 +524,7 @@ TEST_F(ChangeRegistrationRequestTest, .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); command->Run(); diff --git a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc index a627740588..6854ff0a9e 100644 --- a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc @@ -230,9 +230,6 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr)); EXPECT_EQ(NULL, ptr); - ON_CALL(message_helper_mock_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); - am::CommandsMap commands_map; ON_CALL(*mock_app_, commands_map()) .WillByDefault( diff --git a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc index efa889a2c1..1222e36836 100644 --- a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc @@ -61,6 +61,7 @@ using am::commands::DeleteCommandRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; using am::MockMessageHelper; +using am::MockHmiInterfaces; typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr; @@ -129,12 +130,15 @@ class DeleteCommandRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(hmi_interfaces_)); } void TearDown() OVERRIDE { Mock::VerifyAndClearExpectations(&mock_message_helper_); } + NiceMock<MockHmiInterfaces> hmi_interfaces_; MockMessageHelper& mock_message_helper_; MockAppPtr mock_app_; }; @@ -154,14 +158,14 @@ TEST_F(DeleteCommandRequestTest, (*test_msg)[am::strings::vr_commands] = 0; (*test_msg)[am::strings::menu_params] = 0; - ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); - ON_CALL(mock_hmi_interfaces_, + ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - ON_CALL(mock_hmi_interfaces_, + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(*mock_app_, FindCommand(kCommandId)) .WillByDefault(Return(test_msg.get())); ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey)); @@ -171,7 +175,7 @@ TEST_F(DeleteCommandRequestTest, hmi_apis::Common_Result::SUCCESS; Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand); event_ui.set_smart_object(*msg); - + command->Init(); command->Run(); command->on_event(event_ui); @@ -185,6 +189,8 @@ TEST_F(DeleteCommandRequestTest, EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId)); + EXPECT_CALL(*mock_app_, UpdateHash()); + MessageSharedPtr vr_command_result; EXPECT_CALL( app_mngr_, @@ -212,14 +218,14 @@ TEST_F(DeleteCommandRequestTest, (*test_msg)[am::strings::vr_commands] = 0; (*test_msg)[am::strings::menu_params] = 0; - ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); - ON_CALL(mock_hmi_interfaces_, + ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - ON_CALL(mock_hmi_interfaces_, + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get())); ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey)); @@ -229,6 +235,7 @@ TEST_F(DeleteCommandRequestTest, Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand); event_vr.set_smart_object(*msg); + command->Init(); command->Run(); command->on_event(event_vr); @@ -242,6 +249,8 @@ TEST_F(DeleteCommandRequestTest, EXPECT_CALL(*app, RemoveCommand(kCommandId)); + EXPECT_CALL(*app, UpdateHash()); + MessageSharedPtr result_msg( CatchMobileCommandResult(CallOnEvent(*command, event_ui))); diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc index beff4c3584..61adc05681 100644 --- a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc +++ b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc @@ -149,10 +149,6 @@ TEST_F(DeleteSubMenuRequestTest, DISABLED_OnEvent_UI_UNSUPPORTED_RESOURCE) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - am::CommandsMap commands_map; smart_objects::SmartObject commands_msg(smart_objects::SmartType_Map); commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &commands_msg)); @@ -243,9 +239,6 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) { (*message_)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::eType::SUCCESS; event.set_smart_object(*message_); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); MockAppPtr invalid_app; EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0); @@ -265,8 +258,6 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) { const hmi_apis::Common_Result::eType result_code = hmi_apis::Common_Result::SUCCESS; (*message_)[am::strings::params][am::hmi_response::code] = result_code; - ON_CALL(mock_message_helper_, HMIToMobileResult(result_code)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); event.set_smart_object(*message_); commands_map_.insert( @@ -318,10 +309,6 @@ TEST_F(DeleteSubMenuRequestTest, commands_map_.insert( std::make_pair(0, &((*message_)[am::strings::msg_params]))); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); @@ -345,9 +332,6 @@ TEST_F(DeleteSubMenuRequestTest, commands_map_.insert( std::make_pair(0, &((*message_)[am::strings::msg_params]))); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillRepeatedly(Return(am::mobile_api::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); diff --git a/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc index 60697446f2..a041f921d7 100644 --- a/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc @@ -181,10 +181,6 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) { DiagnosticMessageRequestPtr command( CreateCommand<DiagnosticMessageRequest>()); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc index b8c0ed23f3..27788622e6 100644 --- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc @@ -89,10 +89,6 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) { Event event(hmi_apis::FunctionID::UI_EndAudioPassThru); event.set_smart_object(*event_msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); MessageSharedPtr ui_command_result; diff --git a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc index dfa38a758b..e6b419329d 100644 --- a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc @@ -125,11 +125,7 @@ TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) { Event event(hmi_apis::FunctionID::VehicleInfo_GetDTCs); event.set_smart_object(*event_msg); - MockMessageHelper& mock_message_helper = - *MockMessageHelper::message_helper_mock(); - ON_CALL(mock_message_helper, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); diff --git a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc index a851a72f8e..41d9ea99c1 100644 --- a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc @@ -235,7 +235,7 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { const hmi_apis::Common_Result::eType hmi_response_code = hmi_apis::Common_Result::DATA_NOT_AVAILABLE; const mobile_result::eType mobile_response_code = - mobile_result::VEHICLE_DATA_NOT_AVAILABLE; + mobile_result::DATA_NOT_AVAILABLE; MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = @@ -251,10 +251,6 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { Event event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData); event.set_smart_object(*event_msg); - - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response_code)) - .WillOnce(Return(mobile_response_code)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); diff --git a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc index d886a2b1bd..838a544cac 100644 --- a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc @@ -61,6 +61,7 @@ using application_manager::MockHmiInterfaces; typedef SharedPtr<GetWayPointsRequest> CommandPtr; typedef mobile_apis::Result::eType MobileResult; +typedef hmi_apis::Common_Result::eType HmiResult; namespace { const uint32_t kCorrelationId = 2u; @@ -73,10 +74,10 @@ class GetWayPointsRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: GetWayPointsRequestTest() - : message_helper_mock_(*am::MockMessageHelper::message_helper_mock()) { + : message_helper_mock_(*am::MockMessageHelper::message_helper_mock()) + , mock_app_(CreateMockApp()) { Mock::VerifyAndClearExpectations(&message_helper_mock_); } - ~GetWayPointsRequestTest() { Mock::VerifyAndClearExpectations(&message_helper_mock_); } @@ -89,11 +90,7 @@ class GetWayPointsRequestTest command_sptr_ = CreateCommand<application_manager::commands::GetWayPointsRequest>( message_); - mock_app_ = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - - ON_CALL(message_helper_mock_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); } MockMessageHelper& message_helper_mock_; @@ -116,7 +113,7 @@ class GetWayPointsRequestOnEventTest } void CheckOnEventResponse(const std::string& wayPointsParam, - const MobileResult ResultCode, + const HmiResult ResultCode, const bool success) { Event event(Event::EventID::Navigation_GetWayPoints); CommandPtr command(CreateCommand<GetWayPointsRequest>()); @@ -131,17 +128,13 @@ class GetWayPointsRequestOnEventTest event.set_smart_object(*event_msg); - EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_)) - .WillOnce(Return(ResultCode)); - - MockAppPtr app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); + const MobileResult mobile_result = static_cast<MobileResult>(ResultCode); MessageSharedPtr result_msg( CatchMobileCommandResult(CallOnEvent(*command, event))); EXPECT_EQ( - ResultCode, - static_cast<mobile_apis::Result::eType>( + mobile_result, + static_cast<MobileResult>( (*result_msg)[am::strings::msg_params][am::strings::result_code] .asInt())); EXPECT_EQ( @@ -246,15 +239,15 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_WrongEventId_UNSUCCESS) { } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case1) { - CheckOnEventResponse("0", SUCCESS, true); + CheckOnEventResponse("0", HmiResult::SUCCESS, true); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case2) { - CheckOnEventResponse("", SUCCESS, true); + CheckOnEventResponse("", HmiResult::SUCCESS, true); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case3) { - CheckOnEventResponse("test", SUCCESS, true); + CheckOnEventResponse("test", HmiResult::SUCCESS, true); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case1) { @@ -265,7 +258,7 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case1) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - CheckOnEventResponse(" ", GENERIC_ERROR, false); + CheckOnEventResponse(" ", HmiResult::GENERIC_ERROR, false); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case2) { @@ -276,7 +269,7 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case2) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - CheckOnEventResponse("test\t", GENERIC_ERROR, false); + CheckOnEventResponse("test\t", HmiResult::GENERIC_ERROR, false); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case3) { @@ -287,7 +280,7 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case3) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - CheckOnEventResponse("test\n", GENERIC_ERROR, false); + CheckOnEventResponse("test\n", HmiResult::GENERIC_ERROR, false); } TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case4) { @@ -298,7 +291,7 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case4) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - CheckOnEventResponse("test\t\n", GENERIC_ERROR, false); + CheckOnEventResponse("test\t\n", HmiResult::GENERIC_ERROR, false); } } // namespace get_way_points_request diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc index e2adc38f50..189cbedc76 100644 --- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -197,28 +197,29 @@ TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) { TEST_F(PerformAudioPassThruRequestTest, OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) { - MessageSharedPtr msg_ui = CreateFullParamsUISO(); - (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey; + MessageSharedPtr mobile_request = CreateFullParamsUISO(); + (*mobile_request)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + smart_objects::SmartObject initial_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + initial_prompt[0] = smart_objects::SmartObject(smart_objects::SmartType_Map); + initial_prompt[0][am::strings::text] = "tts chunk text"; + initial_prompt[0][am::strings::type] = 0; + (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] = + initial_prompt; + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); utils::SharedPtr<PerformAudioPassThruRequest> command = - CreateCommand<PerformAudioPassThruRequest>(msg_ui); - - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); - (*msg)[am::strings::params][am::hmi_response::code] = - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; - (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; - (*msg)[am::strings::msg_params][am::strings::info] = - "UI is not supported by system"; - - am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru); - event.set_smart_object(*msg); + CreateCommand<PerformAudioPassThruRequest>(mobile_request); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); MessageSharedPtr response_msg_tts = CreateMessage(smart_objects::SmartType_Map); @@ -227,21 +228,39 @@ TEST_F(PerformAudioPassThruRequestTest, (*response_msg_tts)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak); event_tts.set_smart_object(*response_msg_tts); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); - command->on_event(event_tts); - MessageSharedPtr ui_command_result; + MessageSharedPtr response_ui = CreateMessage(smart_objects::SmartType_Map); + (*response_ui)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*response_ui)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*response_ui)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + am::event_engine::Event event_ui( + hmi_apis::FunctionID::UI_PerformAudioPassThru); + event_ui.set_smart_object(*response_ui); + + MessageSharedPtr response_to_mobile; EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); + EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true)); EXPECT_CALL( app_mngr_, ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) - .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); - command->on_event(event); + command->Run(); + command->on_event(event_tts); + command->on_event(event_ui); - ResultCommandExpectations(ui_command_result, "UI is not supported by system"); + EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(), + false); + EXPECT_EQ( + (*response_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::info] + .asString(), + "UI is not supported by system"); } TEST_F(PerformAudioPassThruRequestTest, @@ -546,10 +565,6 @@ TEST_F(PerformAudioPassThruRequestTest, OnEvent_UIPAPT_Rejected) { hmi_apis::Common_Result::REJECTED; event.set_smart_object(*message_); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::REJECTED)) - .WillOnce(Return(am::mobile_api::Result::REJECTED)); - CallOnEvent caller(*command_sptr_, event); MessageSharedPtr result_message = CatchMobileCommandResult(caller); @@ -582,15 +597,12 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(am::mobile_api::Result::SUCCESS)); - CallOnEvent caller(*command_sptr_, event); caller(); } TEST_F(PerformAudioPassThruRequestTest, - OnEvent_PAPTunsupportedResource_CorrectInfo) { + DISABLED_OnEvent_PAPTunsupportedResource_CorrectInfo) { const std::string return_info = "Unsupported phoneme type sent in a prompt"; am::event_engine::Event event_speak(hmi_apis::FunctionID::TTS_Speak); @@ -646,8 +658,6 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); CallOnEvent caller(*command_sptr_, event); caller(); @@ -771,8 +781,6 @@ TEST_F(PerformAudioPassThruRequestTest, app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) .WillOnce(Return(false)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(am::mobile_api::Result::SUCCESS)); command_sptr_->onTimeOut(); } diff --git a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc index 84a0e0b354..c097eeadf7 100644 --- a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc +++ b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc @@ -191,10 +191,10 @@ TEST_F(PerformInteractionRequestTest, EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); MessageSharedPtr response_to_mobile; @@ -222,10 +222,10 @@ TEST_F(PerformInteractionRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); MessageSharedPtr response_msg_vr = CreateMessage(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc index 7e46f6942f..72b79f2114 100644 --- a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc @@ -92,8 +92,6 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { am::MockMessageHelper& mock_message_helper( *am::MockMessageHelper::message_helper_mock()); - EXPECT_CALL(mock_message_helper, HMIToMobileResult(hmi_response_code)) - .WillOnce(Return(mobile_response_code)); EXPECT_CALL(app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); diff --git a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc index e133ec9119..4a655076b7 100644 --- a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc @@ -272,8 +272,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, const hmi_apis::Common_Result::eType result_code = hmi_apis::Common_Result::SUCCESS; (*msg_)[am::strings::params][am::hmi_response::code] = result_code; - ON_CALL(*mock_message_helper_, HMIToMobileResult(result_code)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); (*msg_)[am::strings::msg_params][am::strings::properties][0] = mobile_apis::GlobalProperty::VRHELPTITLE; @@ -346,16 +344,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, command_->on_event(event); } -TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) { - Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); - event.set_smart_object(*msg_); - - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*mock_app_, UpdateHash()).Times(0); - - command_->on_event(event); -} - TEST_F(ResetGlobalPropertiesResponseTest, Run_Sendmsg_SUCCESS) { MessageSharedPtr message(CreateMessage()); ResetGlobalPropertiesResponsePtr command( @@ -389,9 +377,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { CreateCommand<ResetGlobalPropertiesRequest>(msg_); command->Run(); - EXPECT_CALL(*mock_message_helper_, HMIToMobileResult(_)) - .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), @@ -402,6 +387,186 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { command->on_event(event); } +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitTTS_Timeout_GENERIC_ERROR_TTSNotRespond) { + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + ResetGlobalPropertiesRequestPtr command = + CreateCommand<ResetGlobalPropertiesRequest>(msg_); + command->Run(); + + // Received response only from UI + MessageSharedPtr ui_msg = CreateMessage(); + (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + (*ui_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*ui_msg)[am::strings::msg_params] = + SmartObject(smart_objects::SmartType_Map); + Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties); + ui_event.set_smart_object(*ui_msg); + command->on_event(ui_event); + + // TTS doesn't respond, so timeout should send generic error + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + const std::string info = "TTS component does not respond"; + EXPECT_CALL( + app_mngr_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::ORIGIN_SDL)); + command->onTimeOut(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitUI_Timeout_GENERIC_ERROR_UINotRespond) { + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); + + // Received response only from TTS + MessageSharedPtr tts_msg = CreateMessage(); + (*tts_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + (*tts_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + + Event tts_event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + tts_event.set_smart_object(*tts_msg); + command_->on_event(tts_event); + + // UI doesn't respond, so timeout should send generic error + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + + const std::string info = "UI component does not respond"; + EXPECT_CALL( + app_mngr_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::ORIGIN_SDL)); + command_->onTimeOut(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitUIAndTTS_Timeout_GENERIC_ERROR_TTSAndUINotRespond) { + Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); + // TTS and UI don't respond, so timeout should send generic error + std::string info = "TTS, UI component does not respond"; + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + EXPECT_CALL( + app_mngr_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::ORIGIN_SDL)); + command_->onTimeOut(); +} + } // namespace reset_global_properties } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc index d9fac769e5..f4a84181e2 100644 --- a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc +++ b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc @@ -159,10 +159,6 @@ TEST_F(ScrollableMessageRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { Event event(hmi_apis::FunctionID::UI_ScrollableMessage); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, @@ -274,8 +270,6 @@ TEST_F(ScrollableMessageRequestTest, DISABLED_OnEvent_ReceivedUIScrollableMessage_SUCCESS) { (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); @@ -289,9 +283,6 @@ TEST_F(ScrollableMessageRequestTest, (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - EXPECT_CALL( app_mngr_, ManageMobileCommand( diff --git a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc index 03cc715188..80f8cb0f38 100644 --- a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc @@ -356,10 +356,6 @@ TEST_F(SendLocationRequestTest, OnEvent_Success) { Event event(hmi_apis::FunctionID::Navigation_SendLocation); event.set_smart_object(*message_); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(app)); diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc index 60b01f2cfa..7be7b41a26 100644 --- a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc @@ -134,10 +134,6 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { Event event(hmi_apis::FunctionID::UI_SetAppIcon); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc index 68aa76010f..26f2239275 100644 --- a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc @@ -164,9 +164,6 @@ TEST_F(SetDisplayLayoutRequestTest, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, @@ -245,17 +242,12 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { (*dispaly_capabilities_msg)[am::hmi_response::templates_available] = "templates_available"; - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) .WillOnce(ReturnRef(hmi_capabilities)); EXPECT_CALL(hmi_capabilities, display_capabilities()) .WillOnce(Return(dispaly_capabilities_msg.get())); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc index 7143bdf71a..4496aa0f41 100644 --- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc @@ -118,6 +118,8 @@ class SetGlobalPropertiesRequestTest vr_help_array[0][am::strings::text] = kText; vr_help_array[0][am::strings::position] = kPosition; (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); } void OnEventUISetupHelper(MessageSharedPtr msg, @@ -152,6 +154,8 @@ class SetGlobalPropertiesRequestTest (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); @@ -242,10 +246,10 @@ class SetGlobalPropertiesRequestTest .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) - .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); } sync_primitives::Lock lock_; MockMessageHelper& mock_message_helper_; @@ -323,6 +327,9 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) { utils::SharedPtr<SetGlobalPropertiesRequest> command = CreateCommand<SetGlobalPropertiesRequest>(response); + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + EXPECT_CALL( app_mngr_, ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) @@ -348,9 +355,6 @@ TEST_F(SetGlobalPropertiesRequestTest, utils::SharedPtr<SetGlobalPropertiesRequest> command = CreateCommand<SetGlobalPropertiesRequest>(response); - ON_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); @@ -1032,8 +1036,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) { SharedPtr<SetGlobalPropertiesRequest> command( CreateCommand<SetGlobalPropertiesRequest>(msg)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0); - Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); event.set_smart_object(*msg); @@ -1061,8 +1063,8 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) { Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); @@ -1091,15 +1093,14 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) { .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); OnEventUISetupHelper(msg, command); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); event.set_smart_object(*msg); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL)) .WillOnce(Return(true)); @@ -1126,9 +1127,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) { EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(MockAppPtr())); @@ -1146,7 +1144,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidEventID_Canceled) { SharedPtr<SetGlobalPropertiesRequest> command( CreateCommand<SetGlobalPropertiesRequest>(msg)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0); EXPECT_CALL(app_mngr_, application(kConnectionKey)).Times(0); EXPECT_CALL(*mock_app_, UpdateHash()).Times(0); @@ -1180,8 +1177,8 @@ TEST_F(SetGlobalPropertiesRequestTest, ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL)) .WillOnce(Return(true)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(response_code)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); event.set_smart_object(*msg); @@ -1192,7 +1189,7 @@ TEST_F(SetGlobalPropertiesRequestTest, TEST_F(SetGlobalPropertiesRequestTest, OnEvent_TTSAndWarningsResultCode_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - hmi_apis::Common_Result::eType response_code = + const hmi_apis::Common_Result::eType response_code = hmi_apis::Common_Result::WARNINGS; (*msg)[am::strings::params][am::hmi_response::code] = response_code; ON_CALL( @@ -1210,17 +1207,27 @@ TEST_F(SetGlobalPropertiesRequestTest, EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL)) - .WillOnce(Return(true)); + MessageSharedPtr ui_command_result; + EXPECT_CALL( + app_mngr_, + ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); event.set_smart_object(*msg); command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::WARNINGS)); } } // namespace set_global_properties_request diff --git a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc index d91087acae..4fd6f0e170 100644 --- a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc @@ -140,10 +140,6 @@ TEST_F(SetMediaClockRequestTest, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_RESPONSE)); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, @@ -328,12 +324,8 @@ TEST_F(SetMediaClockRequestTest, Run_InvalidApp_Canceled) { TEST_F(SetMediaClockRequestTest, OnEvent_Success) { MessageSharedPtr msg = CreateMessage(); (*msg)[am::strings::params][am::hmi_response::code] = - mobile_apis::Result::SUCCESS; - (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); - - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Null); EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)); @@ -342,7 +334,6 @@ TEST_F(SetMediaClockRequestTest, OnEvent_Success) { Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); event.set_smart_object(*msg); - SharedPtr<SetMediaClockRequest> command( CreateCommand<SetMediaClockRequest>(msg)); command->on_event(event); diff --git a/src/components/application_manager/test/commands/mobile/show_test.cc b/src/components/application_manager/test/commands/mobile/show_test.cc index d1e3c14181..085f83b626 100644 --- a/src/components/application_manager/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/test/commands/mobile/show_test.cc @@ -238,10 +238,6 @@ TEST_F(ShowRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { Event event(hmi_apis::FunctionID::UI_Show); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr vr_command_result; EXPECT_CALL( app_mngr_, @@ -745,10 +741,6 @@ TEST_F(ShowRequestTest, Run_MainField1_MetadataTagWithNoFieldData) { Event event(hmi_apis::FunctionID::UI_Show); event.set_smart_object(*ev_msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, @@ -943,9 +935,6 @@ TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); - ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); EXPECT_CALL(app_mngr_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), _)); @@ -967,9 +956,6 @@ TEST_F(ShowRequestTest, OnEvent_WarningsResultCode_SUCCESS) { SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::WARNINGS)) - .WillOnce(Return(mobile_apis::Result::WARNINGS)); EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)); Event event(hmi_apis::FunctionID::UI_Show); diff --git a/src/components/application_manager/test/commands/mobile/slider_test.cc b/src/components/application_manager/test/commands/mobile/slider_test.cc index 20262ed35a..0c78304855 100644 --- a/src/components/application_manager/test/commands/mobile/slider_test.cc +++ b/src/components/application_manager/test/commands/mobile/slider_test.cc @@ -167,10 +167,6 @@ TEST_F(SliderRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { Event event(hmi_apis::FunctionID::UI_Slider); event.set_smart_object(*msg); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) - .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE)); - MessageSharedPtr ui_command_result; EXPECT_CALL( app_mngr_, @@ -325,9 +321,6 @@ TEST_F(SliderRequestTest, OnEvent_UISliderPositionExists_SUCCESS) { (*msg_)[am::strings::params][am::strings::data] [am::strings::slider_position] = "position"; - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::TIMED_OUT)) - .WillOnce(Return(mobile_apis::Result::TIMED_OUT)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::TIMED_OUT); Event event(hmi_apis::FunctionID::UI_Slider); @@ -343,9 +336,6 @@ TEST_F(SliderRequestTest, OnEvent_UISliderAborted_SUCCESS) { (*msg_)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::ABORTED; - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::ABORTED)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::ABORTED); Event event(hmi_apis::FunctionID::UI_Slider); diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc index f8a7d22b40..5d8955535b 100644 --- a/src/components/application_manager/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/speak_request_test.cc @@ -114,10 +114,6 @@ class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { MessageSharedPtr response_to_mobile; EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(state)); - MockMessageHelper* mock_message_helper = - MockMessageHelper::message_helper_mock(); - EXPECT_CALL(*mock_message_helper, HMIToMobileResult(_)) - .WillOnce(Return(mobile_response)); EXPECT_CALL(app_mngr_, ManageMobileCommand( @@ -156,9 +152,6 @@ TEST_F(SpeakRequestTest, OnEvent_SUCCESS_Expect_true) { MessageSharedPtr response_to_mobile; - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( app_mngr_, ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) @@ -349,8 +342,6 @@ TEST_F(SpeakRequestTest, OnEvent_TTS_Speak_SUCCESS) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) - .WillOnce(Return(am::mobile_api::Result::SUCCESS)); EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); @@ -369,8 +360,6 @@ TEST_F(SpeakRequestTest, OnEvent_TTS_SpeakWithWarning_WarningWithSuccess) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) - .WillOnce(Return(am::mobile_api::Result::WARNINGS)); EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::WARNINGS), _)); diff --git a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc index 4546293172..26f5ee224f 100644 --- a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc @@ -115,8 +115,6 @@ TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { { InSequence dummy; EXPECT_CALL(app_mngr_, SubscribeAppForWayPoints(_)); - EXPECT_CALL(*mock_message_helper, HMIToMobileResult(result_code)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)); EXPECT_CALL(*app, UpdateHash()); } diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc index 9652364646..a3cad29b73 100644 --- a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc @@ -243,12 +243,9 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) { SmartObject message(smart_objects::SmartType_Map); const hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::SUCCESS; - const mobile_apis::Result::eType mob_result = mobile_apis::Result::SUCCESS; message[am::strings::params][am::hmi_response::code] = hmi_result; message[am::strings::msg_params][kMsgParamKey] = true; test_event.set_smart_object(message); - EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), - HMIToMobileResult(hmi_result)).WillOnce(Return(mob_result)); EXPECT_CALL( app_mngr_, @@ -272,14 +269,10 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) { SmartObject message(smart_objects::SmartType_Map); const hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::SUCCESS; - const mobile_apis::Result::eType mob_result = mobile_apis::Result::SUCCESS; message[am::strings::params][am::hmi_response::code] = hmi_result; message[am::strings::msg_params][kMsgParamKey] = true; test_event.set_smart_object(message); - EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), - HMIToMobileResult(hmi_result)).WillOnce(Return(mob_result)); - EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc index 50567a7c62..edba1b01bd 100644 --- a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -165,10 +165,6 @@ TEST_F(UnSubscribeWayPointsRequestTest, EXPECT_CALL(app_mngr_, UnsubscribeAppFromWayPoints(kAppId)); - EXPECT_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc index cab67e641c..027231f529 100644 --- a/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc @@ -275,9 +275,6 @@ TEST_F(UpdateTurnListRequestTest, OnEvent_UnsupportedResource_SUCCESS) { Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); event.set_smart_object(*event_msg); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response_code)) - .WillOnce(Return(mobile_response_code)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); @@ -297,9 +294,6 @@ TEST_F(UpdateTurnListRequestTest, Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); event.set_smart_object(*event_msg); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response_code)) - .WillOnce(Return(mobile_response_code)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h index b6733b5818..6c85d67b52 100644 --- a/src/components/application_manager/test/include/application_manager/commands/commands_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h @@ -44,7 +44,7 @@ #include "test/application_manager/mock_application_manager_settings.h" #include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_application.h" - +#include "application_manager/mock_message_helper.h" namespace test { namespace components { namespace commands_test { @@ -63,6 +63,7 @@ using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; using am::ApplicationSharedPtr; +using am::MockMessageHelper; using ::test::components::application_manager_test::MockApplication; // Depending on the value type will be selected @@ -152,6 +153,57 @@ class CommandsTest : public ::testing::Test { .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_SDL)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + InitHMIToMobileResultConverter(); + } + + void InitHMIToMobileResultConverter() { + namespace MobileResult = mobile_apis::Result; + namespace HMIResult = hmi_apis::Common_Result; + MockMessageHelper& mock_message_helper = + *MockMessageHelper::message_helper_mock(); + auto link_hmi_to_mob_result = [&mock_message_helper]( + HMIResult::eType hmi_result, MobileResult::eType mobile_result) { + ON_CALL(mock_message_helper, HMIToMobileResult(hmi_result)) + .WillByDefault(Return(mobile_result)); + }; + link_hmi_to_mob_result(HMIResult::INVALID_ENUM, MobileResult::INVALID_ENUM); + link_hmi_to_mob_result(HMIResult::SUCCESS, MobileResult::SUCCESS); + link_hmi_to_mob_result(HMIResult::UNSUPPORTED_REQUEST, + MobileResult::UNSUPPORTED_REQUEST); + link_hmi_to_mob_result(HMIResult::UNSUPPORTED_RESOURCE, + MobileResult::UNSUPPORTED_RESOURCE); + link_hmi_to_mob_result(HMIResult::DISALLOWED, MobileResult::DISALLOWED); + link_hmi_to_mob_result(HMIResult::REJECTED, MobileResult::REJECTED); + link_hmi_to_mob_result(HMIResult::ABORTED, MobileResult::ABORTED); + link_hmi_to_mob_result(HMIResult::IGNORED, MobileResult::IGNORED); + link_hmi_to_mob_result(HMIResult::RETRY, MobileResult::RETRY); + link_hmi_to_mob_result(HMIResult::IN_USE, MobileResult::IN_USE); + link_hmi_to_mob_result(HMIResult::TIMED_OUT, MobileResult::TIMED_OUT); + link_hmi_to_mob_result(HMIResult::INVALID_DATA, MobileResult::INVALID_DATA); + link_hmi_to_mob_result(HMIResult::CHAR_LIMIT_EXCEEDED, + MobileResult::CHAR_LIMIT_EXCEEDED); + link_hmi_to_mob_result(HMIResult::INVALID_ID, MobileResult::INVALID_ID); + link_hmi_to_mob_result(HMIResult::DUPLICATE_NAME, + MobileResult::DUPLICATE_NAME); + link_hmi_to_mob_result(HMIResult::APPLICATION_NOT_REGISTERED, + MobileResult::APPLICATION_NOT_REGISTERED); + link_hmi_to_mob_result(HMIResult::WRONG_LANGUAGE, + MobileResult::WRONG_LANGUAGE); + link_hmi_to_mob_result(HMIResult::OUT_OF_MEMORY, + MobileResult::OUT_OF_MEMORY); + link_hmi_to_mob_result(HMIResult::TOO_MANY_PENDING_REQUESTS, + MobileResult::TOO_MANY_PENDING_REQUESTS); + link_hmi_to_mob_result(HMIResult::WARNINGS, MobileResult::WARNINGS); + link_hmi_to_mob_result(HMIResult::GENERIC_ERROR, + MobileResult::GENERIC_ERROR); + link_hmi_to_mob_result(HMIResult::USER_DISALLOWED, + MobileResult::USER_DISALLOWED); + link_hmi_to_mob_result(HMIResult::TRUNCATED_DATA, + MobileResult::TRUNCATED_DATA); + link_hmi_to_mob_result(HMIResult::SAVED, MobileResult::SAVED); + link_hmi_to_mob_result(HMIResult::DATA_NOT_AVAILABLE, + MobileResult::DATA_NOT_AVAILABLE); + link_hmi_to_mob_result(HMIResult::READ_ONLY, MobileResult::READ_ONLY); } }; |