From b9e460579ead5736bbe7c92d3177a22adc4f8544 Mon Sep 17 00:00:00 2001 From: "Maksym Ked (GitHub)" Date: Mon, 3 Sep 2018 17:50:11 +0300 Subject: added CreateMessageForHMI function --- .../include/application_manager/message_helper.h | 17 ++++++++------ .../src/message_helper/message_helper.cc | 27 +++++++++++++--------- .../src/resumption/resumption_data_processor.cc | 10 ++++---- .../application_manager/mock_message_helper.h | 6 ++--- .../test/mock_message_helper.cc | 13 +++++------ 5 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index babd07fd51..a89066f3a1 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -605,13 +605,6 @@ class MessageHelper { */ static bool SendUnsubscribedWayPoints(ApplicationManager& app_mngr); - /** - * @brief Creates SubscribeWayPointsMessage to be sent to HMI - * @return filled smart object with relevant message data - */ - static smart_objects::SmartObjectSPtr CreateSubscribeWayPointsMessageToHMI( - const uint32_t correlation_id); - static smart_objects::SmartObjectSPtr CreateNegativeResponse( uint32_t connection_key, int32_t function_id, @@ -895,6 +888,16 @@ class MessageHelper { static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); + /** + * @brief CreateMessageForHMI Creates HMI message with prepared header + * acccoring to message type + * @param function_id function id + * @param correlation_id Correlation id + * @return HMI message object with filled header + */ + static smart_objects::SmartObjectSPtr CreateMessageForHMI( + hmi_apis::FunctionID::eType function_id, const uint32_t correlation_id); + /** * @brief CreateUIResetGlobalPropertiesRequest Creates request * to reset global properties for UI diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index b5908e821a..8e996098b4 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -323,6 +323,22 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( + hmi_apis::FunctionID::eType function_id, const uint32_t correlation_id) { + using namespace smart_objects; + + SmartObjectSPtr message = std::make_shared(SmartType_Map); + SmartObject& ref = *message; + + ref[strings::params][strings::function_id] = static_cast(function_id); + ref[strings::params][strings::protocol_version] = + commands::CommandImpl::protocol_version_; + ref[strings::params][strings::protocol_type] = + commands::CommandImpl::hmi_protocol_type_; + ref[strings::params][strings::correlation_id] = correlation_id; + return message; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -2246,17 +2262,6 @@ bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { return app_mngr.GetRPCService().ManageHMICommand(result); } -smart_objects::SmartObjectSPtr -MessageHelper::CreateSubscribeWayPointsMessageToHMI( - const uint32_t correlation_id) { - auto msg = - CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); - (*msg)[strings::params][strings::function_id] = - hmi_apis::FunctionID::Navigation_SubscribeWayPoints; - - return msg; -} - void MessageHelper::SendPolicySnapshotNotification( uint32_t connection_key, const std::vector& policy_data, diff --git a/src/components/application_manager/src/resumption/resumption_data_processor.cc b/src/components/application_manager/src/resumption/resumption_data_processor.cc index 508c86ea94..7f73bc04f4 100644 --- a/src/components/application_manager/src/resumption/resumption_data_processor.cc +++ b/src/components/application_manager/src/resumption/resumption_data_processor.cc @@ -517,10 +517,12 @@ void ResumptionDataProcessor::AddWayPointsSubscription( if (true == subscribed_for_way_points_so.asBool()) { application_manager_.SubscribeAppForWayPoints(application); auto subscribe_waypoints_msg = - MessageHelper::CreateSubscribeWayPointsMessageToHMI( - application_manager_.GetNextHMICorrelationID()); - application_manager_.GetRPCService().ManageHMICommand( - subscribe_waypoints_msg); + MessageHelper::CreateMessageForHMI( + hmi_apis::FunctionID::Navigation_SubscribeWayPoints, + application_manager_.GetNextHMICorrelationID()); + (*subscribe_waypoints_msg)[strings::params][strings::message_type] = + hmi_apis::messageType::request; + ProcessHMIRequest(subscribe_waypoints_msg, true); } } diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 7b0083db88..94b937b7b5 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -128,6 +128,9 @@ class MockMessageHelper { MOCK_METHOD2(CreateMessageForHMI, smart_objects::SmartObjectSPtr(hmi_apis::messageType::eType, const uint32_t)); + MOCK_METHOD2(CreateMessageForHMI, + smart_objects::SmartObjectSPtr(hmi_apis::FunctionID::eType, + const uint32_t)); MOCK_METHOD2(SendHMIStatusNotification, void(const Application& application_impl, ApplicationManager& application_manager)); @@ -259,9 +262,6 @@ class MockMessageHelper { ApplicationManager& app_man)); MOCK_METHOD1(SendUnsubscribedWayPoints, bool(ApplicationManager& app_mngr)); - MOCK_METHOD1(CreateSubscribeWayPointsMessageToHMI, - smart_objects::SmartObjectSPtr(const uint32_t correlation_id)); - MOCK_METHOD2(SendQueryApps, void(const uint32_t connection_key, ApplicationManager& app_man)); diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 8732a12a19..154fe895c7 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -257,6 +257,12 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( message_type, correlation_id); } +smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( + hmi_apis::FunctionID::eType function_id, const uint32_t correlation_id) { + return MockMessageHelper::message_helper_mock()->CreateMessageForHMI( + function_id, correlation_id); +} + void MessageHelper::SendHMIStatusNotification( const Application& application_impl, ApplicationManager& application_manager) { @@ -476,13 +482,6 @@ bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { app_mngr); } -smart_objects::SmartObjectSPtr -MessageHelper::CreateSubscribeWayPointsMessageToHMI( - const uint32_t correlation_id) { - return MockMessageHelper::message_helper_mock() - ->CreateSubscribeWayPointsMessageToHMI(correlation_id); -} - void MessageHelper::SendQueryApps(const uint32_t connection_key, ApplicationManager& app_man) { MockMessageHelper::message_helper_mock()->SendQueryApps(connection_key, -- cgit v1.2.1