Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix result codes of CreateInteractionChoiceSet response #3901

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ class CreateInteractionChoiceSetRequest
* @brief Calls after all responses from HMI were received.
* Terminates request and sends successful response to mobile
* if all responses were SUCCESS or calls DeleteChoices in other case.
* @param vr_result the result code from hmi.
*/
void OnAllHMIResponsesReceived();
void OnAllHMIResponsesReceived(
const hmi_apis::Common_Result::eType vr_result);

/**
* @brief The VRCommand struct
Expand Down Expand Up @@ -201,8 +203,9 @@ class CreateInteractionChoiceSetRequest
* @brief CountReceivedVRResponses counts received HMI responses. Updated
* request timeout if not all responses received
* Send response to mobile if all responses received.
* @param vr_result the result code from hmi.
*/
void CountReceivedVRResponses();
void CountReceivedVRResponses(const hmi_apis::Common_Result::eType vr_result);

DISALLOW_COPY_AND_ASSIGN(CreateInteractionChoiceSetRequest);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ bool CreateInteractionChoiceSetRequest::ProcessSuccesfulHMIResponse(
return true;
}

void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() {
void CreateInteractionChoiceSetRequest::CountReceivedVRResponses(
const hmi_apis::Common_Result::eType vr_result) {
++received_chs_count_;
SDL_LOG_DEBUG("Got VR.AddCommand response, there are "
<< expected_chs_count_ - received_chs_count_
Expand All @@ -378,7 +379,7 @@ void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() {
connection_key(), correlation_id(), default_timeout());
SDL_LOG_DEBUG("Timeout for request was updated");
} else {
OnAllHMIResponsesReceived();
OnAllHMIResponsesReceived(vr_result);
}
}

Expand All @@ -392,7 +393,15 @@ void CreateInteractionChoiceSetRequest::on_event(
const Common_Result::eType result = static_cast<Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
const bool is_no_error = Compare<Common_Result::eType, EQ, ONE>(
result, Common_Result::SUCCESS, Common_Result::WARNINGS);
result,
Common_Result::SUCCESS,
Common_Result::WARNINGS,
Common_Result::WRONG_LANGUAGE,
Common_Result::RETRY,
Common_Result::SAVED,
Common_Result::TRUNCATED_DATA,
Common_Result::UNSUPPORTED_RESOURCE);

uint32_t corr_id = static_cast<uint32_t>(
message[strings::params][strings::correlation_id].asUInt());
if (event.id() == hmi_apis::FunctionID::VR_AddCommand) {
Expand All @@ -407,7 +416,7 @@ void CreateInteractionChoiceSetRequest::on_event(
ProcessHmiError(result);
}
}
CountReceivedVRResponses();
CountReceivedVRResponses(result);
}
}

Expand Down Expand Up @@ -464,7 +473,8 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
sent_commands_map_.clear();
}

void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived(
const hmi_apis::Common_Result::eType vr_result) {
SDL_LOG_AUTO_TRACE();

ApplicationSharedPtr application =
Expand All @@ -478,7 +488,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
if (!error_from_hmi_ && should_send_warnings_) {
SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo);
} else if (!error_from_hmi_) {
SendResponse(true, mobile_apis::Result::SUCCESS);
SendResponse(true, MessageHelper::HMIToMobileResult(vr_result));
} else {
DeleteChoices();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {

EXPECT_EQ(
(*vr_command_result)[strings::msg_params][strings::success].asBool(),
false);
true);
EXPECT_EQ(
(*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
Expand Down