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

Complement checks that consider HMI response to be invalid #1541

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 @@ -232,8 +232,7 @@ void CommandRequestImpl::SendResponse(
}

// Add disallowed parameters and info from request back to response with
// appropriate
// reasons (VehicleData result codes)
// appropriate reasons (VehicleData result codes)
if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) {
const mobile_apis::FunctionID::eType& id =
static_cast<mobile_apis::FunctionID::eType>(function_id());
Expand All @@ -247,7 +246,20 @@ void CommandRequestImpl::SendResponse(
}

response[strings::msg_params][strings::success] = success;
response[strings::msg_params][strings::result_code] = result_code;

// In case result type was not recognized the response that we received from
// HMI is considered as invalid response
if (mobile_apis::Result::INVALID_ENUM == result_code) {
LOG4CXX_ERROR(logger_,
"HMI response contains unrecognizable result code, so it is "
"considered as invalid response");
response[strings::msg_params][strings::result_code] =
mobile_apis::Result::GENERIC_ERROR;
response[strings::msg_params][strings::info] =
std::string("Invalid message received from vehicle");
} else {
response[strings::msg_params][strings::result_code] = result_code;
}

application_manager_.ManageMobileCommand(result, ORIGIN_SDL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ TEST_F(AlertManeuverRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) {

MessageSharedPtr result_msg(
CatchMobileCommandResult(CallOnEvent(*command, event)));
EXPECT_EQ(mobile_apis::Result::INVALID_ENUM,
EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR,
static_cast<mobile_apis::Result::eType>(
(*result_msg)[am::strings::msg_params][am::strings::result_code]
.asInt()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ TEST_F(AlertRequestTest, Run_AlertFrequencyIsTooHigh_UNSUCCESS) {
TEST_F(AlertRequestTest, Run_FailToProcessSoftButtons_UNSUCCESS) {
Expectations();
const mobile_apis::Result::eType result_code =
mobile_apis::Result::INVALID_ENUM;
mobile_apis::Result::GENERIC_ERROR;

EXPECT_CALL(mock_message_helper_,
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ TEST_F(UpdateTurnListRequestTest,
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillOnce(ReturnRef(mock_policy_handler_));

const mobile_result::eType kExpectedResult = mobile_result::INVALID_ENUM;
const mobile_result::eType kExpectedResult = mobile_result::GENERIC_ERROR;
EXPECT_CALL(mock_message_helper_,
ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
Eq(mock_app),
Expand Down