Skip to content
Open
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 @@ -46,12 +46,27 @@ bool CheckAvailabilityHMIInterfaces(ApplicationManager& application_manager,
bool ChangeInterfaceState(ApplicationManager& application_manager,
const smart_objects::SmartObject& response_from_hmi,
HmiInterfaces::InterfaceID interface) {
using namespace helpers;
if (response_from_hmi[strings::msg_params].keyExists(strings::available)) {
const hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
response_from_hmi[strings::params][hmi_response::code].asInt());

bool is_successful_resultCode =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VVeremjova , is_successful_result_code

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);

const bool is_available =
response_from_hmi[strings::msg_params][strings::available].asBool();
const HmiInterfaces::InterfaceState interface_state =
is_available ? HmiInterfaces::STATE_AVAILABLE
: HmiInterfaces::STATE_NOT_AVAILABLE;
(is_available && is_successful_resultCode)
? HmiInterfaces::STATE_AVAILABLE
: HmiInterfaces::STATE_NOT_AVAILABLE;
application_manager.hmi_interfaces().SetInterfaceState(interface,
interface_state);
return is_available;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ TEST_F(NaviIsReadyRequestTest,
MessageSharedPtr event_msg = CreateMessage();
(*event_msg)[am::strings::msg_params][am::strings::available] =
is_hmi_interface_available;
(*event_msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;

Event event(kEventID);
event.set_smart_object(*event_msg);
Expand All @@ -99,6 +101,29 @@ TEST_F(NaviIsReadyRequestTest,
command_->on_event(event);
}

TEST_F(NaviIsReadyRequestTest,
OnEvent_HmiInterfaceIsAvailableWithErrorCode_NaviIsNotAvailable) {
const bool is_hmi_interface_available = true;

MessageSharedPtr event_msg = CreateMessage();
(*event_msg)[am::strings::msg_params][am::strings::available] =
is_hmi_interface_available;
(*event_msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::GENERIC_ERROR;

Event event(kEventID);
event.set_smart_object(*event_msg);

EXPECT_CALL(mock_hmi_interfaces_,
SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation,
am::HmiInterfaces::STATE_NOT_AVAILABLE));

EXPECT_CALL(mock_hmi_capabilities_,
set_is_navi_cooperating(is_hmi_interface_available));

command_->on_event(event);
}

TEST_F(NaviIsReadyRequestTest,
OnEvent_HmiInterfaceIsNotAvailable_NaviCooperatingIsNotAvailable) {
const bool is_hmi_interface_available = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ class UIIsReadyRequestTest
Event& event,
bool is_ui_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);

(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_ui_cooperating_available;
}
event.set_smart_object(*msg);
}

void PrepareErrorEvent(bool is_message_contain_param,
Event& event,
bool is_ui_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);

(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::GENERIC_ERROR;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_ui_cooperating_available;
Expand Down Expand Up @@ -199,6 +216,21 @@ TEST_F(UIIsReadyRequestTest, OnEvent_KeyAvailableEqualToTrue_StateAvailable) {
command_->on_event(event);
}

TEST_F(UIIsReadyRequestTest,
OnEvent_KeyAvailableEqualToTrue_ResultCodeError_StateNotAvailable) {
const bool is_ui_cooperating_available = true;
const bool is_send_message_to_hmi = false;
const bool is_message_contain_param = true;
Event event(hmi_apis::FunctionID::UI_IsReady);
PrepareErrorEvent(
is_message_contain_param, event, is_ui_cooperating_available);
SetUpExpectations(is_ui_cooperating_available,
is_send_message_to_hmi,
is_message_contain_param,
am::HmiInterfaces::STATE_NOT_AVAILABLE);
command_->on_event(event);
}

TEST_F(UIIsReadyRequestTest, OnTimeout_SUCCESS) {
ExpectSendMessagesToHMI();
command_->onTimeOut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,29 @@ class VIIsReadyRequestTest
Event& event,
bool is_vi_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_vi_cooperating_available;
}
event.set_smart_object(*msg);
}

void PrepareErrorEvent(bool is_message_contain_param,
Event& event,
bool is_ui_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);

(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::GENERIC_ERROR;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_ui_cooperating_available;
}
event.set_smart_object(*msg);
}

VIIsReadyRequestPtr command_;
am::MockHmiInterfaces mock_hmi_interfaces_;
application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
Expand Down Expand Up @@ -165,6 +181,21 @@ TEST_F(VIIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
command_->on_event(event);
}

TEST_F(VIIsReadyRequestTest,
OnEvent_KeyAvailableEqualToTrue_ResultCodeError_StateNotAvailable) {
const bool is_vi_cooperating_available = true;
const bool is_send_message_to_hmi = false;
const bool is_message_contain_param = true;
Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
PrepareErrorEvent(
is_message_contain_param, event, is_vi_cooperating_available);
SetUpExpectations(is_vi_cooperating_available,
is_send_message_to_hmi,
is_message_contain_param,
am::HmiInterfaces::STATE_NOT_AVAILABLE);
command_->on_event(event);
}

TEST_F(VIIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
ExpectSendMessagesToHMI();
command_->onTimeOut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,28 @@ class VRIsReadyRequestTest
Event& event,
bool is_vr_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_vr_cooperating_available;
}
event.set_smart_object(*msg);
}

void PrepareErrorEvent(bool is_message_contain_param,
Event& event,
bool is_ui_cooperating_available = false) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::GENERIC_ERROR;
if (is_message_contain_param) {
(*msg)[am::strings::msg_params][am::strings::available] =
is_ui_cooperating_available;
}
event.set_smart_object(*msg);
}

VRIsReadyRequestPtr command_;
am::MockHmiInterfaces mock_hmi_interfaces_;
application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
Expand Down Expand Up @@ -182,6 +197,21 @@ TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
command_->on_event(event);
}

TEST_F(VRIsReadyRequestTest,
OnEvent_KeyAvailableEqualToTrue_ResultCodeError_StateNotAvailable) {
const bool is_vr_cooperating_available = true;
const bool is_send_message_to_hmi = false;
const bool is_message_contain_param = true;
Event event(hmi_apis::FunctionID::VR_IsReady);
PrepareErrorEvent(
is_message_contain_param, event, is_vr_cooperating_available);
SetUpExpectations(is_vr_cooperating_available,
is_send_message_to_hmi,
is_message_contain_param,
am::HmiInterfaces::STATE_NOT_AVAILABLE);
command_->on_event(event);
}

TEST_F(VRIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
const bool is_send_message_by_timeout = true;
ExpectSendMessagesToHMI(is_send_message_by_timeout);
Expand Down