diff options
20 files changed, 578 insertions, 201 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 3603eacb04..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 @@ -360,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(); /** @@ -371,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/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/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 020cfa5ab1..473a2d04a0 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,23 @@ 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_not_used) { - return false; - } - - if (!second.is_ok && first.is_not_used) { - return false; + if (first.is_ok && second.is_unsupported_resource) { + 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 +150,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 +233,7 @@ void CommandRequestImpl::onTimeOut() { function_id(), correlation_id(), mobile_api::Result::GENERIC_ERROR); - + AddTimeOutComponentInfoToMessage(*response); application_manager_.ManageMobileCommand(response, ORIGIN_SDL); } @@ -768,6 +794,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,48 +818,9 @@ 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); - + (out_first.is_ok && out_second.is_not_used) || + (out_second.is_ok && out_first.is_not_used); result = result || CheckResultCode(out_first, out_second); result = result || CheckResultCode(out_second, out_first); return result; @@ -853,24 +841,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; } @@ -940,6 +932,39 @@ std::string GetComponentNameFromInterface( 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/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index cf06bbfc53..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 @@ -195,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); 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 67b34931c3..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(); @@ -208,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); 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 94b40b2606..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 @@ -378,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 2621088bc1..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 @@ -119,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); 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 813be62938..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 @@ -177,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() { @@ -359,6 +382,45 @@ void PerformAudioPassThruRequest::FinishTTSSpeak() { 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 IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || 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 7e26658c6c..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 @@ -393,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]; } @@ -929,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/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc index 4f61584be4..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 @@ -288,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( 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 d1cb0486ba..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 @@ -279,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 && 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..1916bb7150 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)) @@ -1042,7 +1043,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 +1093,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/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc index f83a40843c..80838ffbbf 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() { 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..e2163f1f73 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,7 +147,7 @@ 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(); @@ -378,11 +378,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 +431,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 +439,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 +453,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, @@ -472,14 +513,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 +528,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/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc index efa889a2c1..19765357ce 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 @@ -156,12 +156,12 @@ TEST_F(DeleteCommandRequestTest, ON_CALL(mock_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)); @@ -214,12 +214,12 @@ TEST_F(DeleteCommandRequestTest, ON_CALL(mock_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)); 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..c7a4ff9852 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 @@ -246,15 +246,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 +265,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 +276,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 +287,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 +298,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_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/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc index e133ec9119..7f5c623226 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 @@ -402,6 +402,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/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc index 7143bdf71a..2ad76f462d 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 @@ -242,10 +242,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_; @@ -1210,17 +1210,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 |