From c57507a8a9e31cd2490e163f399374a1ebfeea04 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Thu, 30 Nov 2017 14:07:52 +0200 Subject: Fix missing/wrong result codes mapping There was some missings in result code convertion from HMI to Mobile. Also Fixed related unit test. --- .../src/commands/command_request_impl.cc | 10 +++++++- .../test/commands/command_request_impl_test.cc | 27 ++++++++++++---------- .../mobile/on_hmi_status_notification_test.cc | 1 - 3 files changed, 24 insertions(+), 14 deletions(-) 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 7e5ed1feaa..102817576a 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -526,7 +526,7 @@ mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode( break; } case hmi_apis::Common_Result::DATA_NOT_AVAILABLE: { - mobile_result = mobile_apis::Result::VEHICLE_DATA_NOT_AVAILABLE; + mobile_result = mobile_apis::Result::DATA_NOT_AVAILABLE; break; } case hmi_apis::Common_Result::TIMED_OUT: { @@ -589,6 +589,14 @@ mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode( mobile_result = mobile_apis::Result::SAVED; break; } + case hmi_apis::Common_Result::TRUNCATED_DATA: { + mobile_result = mobile_apis::Result::TRUNCATED_DATA; + break; + } + case hmi_apis::Common_Result::READ_ONLY: { + mobile_result = mobile_apis::Result::READ_ONLY; + break; + } default: { LOG4CXX_ERROR(logger_, "Unknown HMI result code " << hmi_code); break; diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index 5ebb030e84..5e7a780f3e 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -206,27 +206,30 @@ TEST_F(CommandRequestImplTest, GetMobileResultCode_SUCCESS) { CommandPtr command = CreateCommand(); + const std::map + mapping_exceptions = { + {hmi_apis::Common_Result::NO_DEVICES_CONNECTED, + mobile_apis::Result::APPLICATION_NOT_REGISTERED}, + {hmi_apis::Common_Result::NO_APPS_REGISTERED, + mobile_apis::Result::APPLICATION_NOT_REGISTERED}, + {hmi_apis::Common_Result::DATA_NOT_AVAILABLE, + mobile_apis::Result::DATA_NOT_AVAILABLE}, + {hmi_apis::Common_Result::SAVED, mobile_apis::Result::SAVED}}; + // Run thru all possible accordance // of HMI and Mobile result codes. ResultU result_it; for (result_it.hmi_ = hmi_apis::Common_Result::SUCCESS; - result_it.value_ < hmi_apis::Common_Result::TRUNCATED_DATA; + result_it.value_ < hmi_apis::Common_Result::READ_ONLY; ++result_it.value_) { - if (result_it.hmi_ != hmi_apis::Common_Result::NO_DEVICES_CONNECTED && - result_it.hmi_ != hmi_apis::Common_Result::NO_APPS_REGISTERED) { + if (mapping_exceptions.find(result_it.hmi_) == mapping_exceptions.end()) { EXPECT_EQ(result_it.mobile_, command->GetMobileResultCode(result_it.hmi_)); + } else { + EXPECT_EQ(mapping_exceptions.at(result_it.hmi_), + command->GetMobileResultCode(result_it.hmi_)); } } - EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, - command->GetMobileResultCode( - hmi_apis::Common_Result::NO_DEVICES_CONNECTED)); - EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, - command->GetMobileResultCode( - hmi_apis::Common_Result::NO_APPS_REGISTERED)); - EXPECT_EQ( - mobile_apis::Result::GENERIC_ERROR, - command->GetMobileResultCode(hmi_apis::Common_Result::TRUNCATED_DATA)); } TEST_F(CommandRequestImplTest, BasicMethodsOverloads_SUCCESS) { diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc index c79b664c0c..678ce52edb 100644 --- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc +++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc @@ -70,7 +70,6 @@ class OnHMIStatusNotificationTest void SetSendNotificationExpectations(MessageSharedPtr& msg) { EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) .WillOnce(Return(false)); - EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)); EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)) -- cgit v1.2.1