diff options
author | Yana Chernysheva <ychernysheva@luxoft.com> | 2020-06-16 17:53:50 +0300 |
---|---|---|
committer | Yana Chernysheva <ychernysheva@luxoft.com> | 2020-06-19 17:45:15 +0300 |
commit | 668ac995133a1faad009fb07a32c9f3a62648653 (patch) | |
tree | c80ed7a58f1955f94a2a96c850527c500e14e4d9 /src | |
parent | 137d3288abb75af3233e0a7271f5351132ddac3d (diff) | |
download | sdl_core-668ac995133a1faad009fb07a32c9f3a62648653.tar.gz |
Add template functions and delete or mark unused methods as deprecated
Diffstat (limited to 'src')
23 files changed, 196 insertions, 523 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 633bea87be..20824be0ee 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1218,21 +1218,6 @@ class ApplicationManagerImpl smart_objects::SmartObject& vrSynonym); /** - * @brief Method transforms string to AppHMIType - * @param str contains string AppHMIType - * @return enum AppHMIType - */ - mobile_apis::AppHMIType::eType StringToAppHMIType(std::string str); - - /** - * @brief Returns a string representation of AppHMIType - * @param type an enum value of AppHMIType - * @return string representation of the enum value - */ - const std::string AppHMITypeToString( - mobile_apis::AppHMIType::eType type) const; - - /** * @brief Method compares arrays of app HMI type * @param from_policy contains app HMI type from policy * @param from_application contains app HMI type from application 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 09d225a120..4316aa0cca 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -49,6 +49,7 @@ #include "interfaces/MOBILE_API.h" #include "policy/policy_types.h" #include "protocol_handler/session_observer.h" +#include "smart_objects/enum_schema_item.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" #include "utils/macro.h" @@ -69,6 +70,35 @@ namespace mobile_api = mobile_apis; typedef std::map<std::string, mobile_apis::VehicleDataType::eType> VehicleData; /** + * @brief Converts stringified value to enum value + * @param str stringified value + * @return Enum value if succedeed, otherwise - + * INVALID_ENUM + */ +template <typename T> +T StringToEnum(const std::string& str) { + using namespace ns_smart_device_link::ns_smart_objects; + T enum_value; + EnumConversionHelper<T>::StringToEnum(str, &enum_value); + return enum_value; +} + +/** + * @brief Converts enum value to string + * @param enum_value enum value + * @return stringified value for enum if succedeed, otherwise - empty string + */ +template <typename T> +std::string EnumToString(T enum_value) { + using namespace ns_smart_device_link::ns_smart_objects; + const char* str = 0; + if (EnumConversionHelper<T>::EnumToCString(enum_value, &str)) { + return str; + } + return std::string(); +} + +/** * @brief MessageHelper class **/ class MessageHelper { @@ -151,40 +181,44 @@ class MessageHelper { static const VehicleData& vehicle_data(); /** + * @deprecated Unused due to creation template EnumToString function * @brief Converts HMI Result enum value to string * @param hmi_result HMI Result enum value * @return stringified value for enum if succedeed, otherwise - empty string */ - static std::string HMIResultToString( + DEPRECATED static std::string HMIResultToString( hmi_apis::Common_Result::eType hmi_result); /** + * @deprecated Unused due to creation template StringToEnum function * @brief Converts string to HMI Result enum value * @param hmi_result stringified value * @return HMI Result enum value if succedeed, otherwise - INVALID_ENUM * value */ - static hmi_apis::Common_Result::eType HMIResultFromString( + DEPRECATED static hmi_apis::Common_Result::eType HMIResultFromString( const std::string& hmi_result); /** + * @deprecated Unused due to creation template EnumToString function * @brief Converts mobile Result enum value to string * @param mobile_result mobile Result enum value * @return stringified value for enum if succedeed, otherwise - empty string */ - static std::string MobileResultToString( + DEPRECATED static std::string MobileResultToString( mobile_apis::Result::eType mobile_result); static std::string GetDeviceMacAddressForHandle( const transport_manager::DeviceHandle device_handle, const ApplicationManager& app_mngr); /** + * @deprecated Unused due to creation template StringToEnum function * @brief Converts string to mobile Result enum value * @param mobile_result stringified value * @return mobile Result enum value if succedeed, otherwise - INVALID_ENUM * value */ - static mobile_api::Result::eType MobileResultFromString( + DEPRECATED static mobile_api::Result::eType MobileResultFromString( const std::string& mobile_result); /** @@ -205,23 +239,25 @@ class MessageHelper { const mobile_api::Result::eType mobile_result); /** + * @deprecated Unused due to creation template StringToEnum function * @brief Convert string to HMI level, if possible * @param hmi_level Stringified HMI level * @return Appropriate enum from HMI level, or INVALID_ENUM, if conversiion * is not possible */ - static mobile_api::HMILevel::eType StringToHMILevel( + DEPRECATED static mobile_api::HMILevel::eType StringToHMILevel( const std::string& hmi_level); - /* + /** + * @deprecated Unused due to creation template EnumToString function * @brief Used to obtain string representation of app's * HMI Level. * @param hmi_level Desired HMI Level */ - static std::string StringifiedHMILevel( + DEPRECATED static std::string StringifiedHMILevel( const mobile_apis::HMILevel::eType hmi_level); - /* + /** * @brief Used to obtain function name by its id * @param function_id Function ID */ @@ -802,28 +838,32 @@ class MessageHelper { } static const uint32_t GetPriorityCode(const std::string& priority); + /** + * @deprecated Unused due to creation template EnumToString function * @brief Convert common language to string representation * @param language Common language * @return Common language string representation */ - static std::string CommonLanguageToString( + DEPRECATED static std::string CommonLanguageToString( hmi_apis::Common_Language::eType language); /** + * @deprecated Unused due to creation template EnumToString function * @brief Converts mobile language to string representation * @param language Mobile UI language * @return Mobile language string representation */ - static std::string MobileLanguageToString( + DEPRECATED static std::string MobileLanguageToString( mobile_apis::Language::eType language); /** + * @deprecated Unused due to creation template StringToEnum function * @brief Converts string to mobile language enum value * @param language language as string * @return Mobile language enum value */ - static mobile_apis::Language::eType MobileLanguageFromString( + DEPRECATED static mobile_apis::Language::eType MobileLanguageFromString( const std::string& language); /** @@ -877,15 +917,16 @@ class MessageHelper { const std::string& icon_path, ApplicationManager& application_manager); - static hmi_apis::Common_Language::eType CommonLanguageFromString( + DEPRECATED static hmi_apis::Common_Language::eType CommonLanguageFromString( const std::string& language); /** + * @deprecated Unused due to creation template StringToEnum function * @brief CommonLightNameFromString convert string to LightName enum value * @param lightName string to convert * @return value LightName enum value */ - static hmi_apis::Common_LightName::eType CommonLightNameFromString( + DEPRECATED static hmi_apis::Common_LightName::eType CommonLightNameFromString( const std::string& lightName); static smart_objects::SmartObjectSPtr diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc index baff925a4e..1bbd8dc52f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc @@ -81,7 +81,7 @@ const SystemInfo GetSystemInfoResponse::GetSystemInfo( const uint32_t lang_code = (*message_)[strings::msg_params]["language"].asUInt(); - info.language = application_manager::MessageHelper::CommonLanguageToString( + info.language = application_manager::EnumToString( static_cast<hmi_apis::Common_Language::eType>(lang_code)); hmi_capabilities_.set_ccpu_version(info.ccpu_version); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc index a743c58672..a74d399fcd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc @@ -78,8 +78,7 @@ struct OnDriverDistractionProcessor { if (is_lock_screen_dismissal_exists && msg_params[mobile_notification::lock_screen_dismissal_enabled] .asBool()) { - const auto language = - MessageHelper::MobileLanguageToString(application->ui_language()); + const auto language = EnumToString(application->ui_language()); const auto warning_message = application_manager_.GetPolicyHandler() diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc index 171c144055..55ead3959d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc @@ -58,9 +58,8 @@ void OnSystemInfoChangedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); uint32_t lang_code = (*message_)[strings::msg_params][strings::language].asUInt(); - const std::string language = - application_manager::MessageHelper::CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code)); + const std::string language = application_manager::EnumToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); policy_handler_.OnSystemInfoChanged(language); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc index f853cf814c..db6168c3a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc @@ -85,15 +85,13 @@ void SDLGetUserFriendlyMessageRequest::Run() { if ((*message_)[strings::msg_params].keyExists(strings::language)) { uint32_t lang_code = (*message_)[strings::msg_params][strings::language].asUInt(); - required_language = - application_manager::MessageHelper::CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code)); + required_language = application_manager::EnumToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); } else { hmi_apis::Common_Language::eType ui_language = hmi_capabilities_.active_ui_language(); - required_language = - application_manager::MessageHelper::CommonLanguageToString(ui_language); + required_language = application_manager::EnumToString(ui_language); } policy_handler_.OnGetUserFriendlyMessage( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc index 363b14f92f..2d28d686bb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -163,7 +163,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { message[strings::params][hmi_response::code].asInt()); LOG4CXX_DEBUG(logger_, "Received UI_DeleteCommand event with result " - << MessageHelper::HMIResultToString(ui_result_)); + << EnumToString(ui_result_)); GetInfo(message, ui_info_); break; } @@ -174,7 +174,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { message[strings::params][hmi_response::code].asInt()); LOG4CXX_DEBUG(logger_, "Received VR_DeleteCommand event with result " - << MessageHelper::HMIResultToString(vr_result_)); + << EnumToString(vr_result_)); GetInfo(message, vr_info_); break; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 5fb66c25ac..4d16026d3e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -56,63 +56,14 @@ namespace { namespace custom_str = utils::custom_string; -mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) { - if ("DEFAULT" == str) { - return mobile_apis::AppHMIType::DEFAULT; - } else if ("COMMUNICATION" == str) { - return mobile_apis::AppHMIType::COMMUNICATION; - } else if ("MEDIA" == str) { - return mobile_apis::AppHMIType::MEDIA; - } else if ("MESSAGING" == str) { - return mobile_apis::AppHMIType::MESSAGING; - } else if ("NAVIGATION" == str) { - return mobile_apis::AppHMIType::NAVIGATION; - } else if ("INFORMATION" == str) { - return mobile_apis::AppHMIType::INFORMATION; - } else if ("SOCIAL" == str) { - return mobile_apis::AppHMIType::SOCIAL; - } else if ("BACKGROUND_PROCESS" == str) { - return mobile_apis::AppHMIType::BACKGROUND_PROCESS; - } else if ("TESTING" == str) { - return mobile_apis::AppHMIType::TESTING; - } else if ("SYSTEM" == str) { - return mobile_apis::AppHMIType::SYSTEM; - } else if ("PROJECTION" == str) { - return mobile_apis::AppHMIType::PROJECTION; - } else if ("REMOTE_CONTROL" == str) { - return mobile_apis::AppHMIType::REMOTE_CONTROL; - } else { - return mobile_apis::AppHMIType::INVALID_ENUM; - } -} - -std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) { - const std::map<mobile_apis::AppHMIType::eType, std::string> app_hmi_type_map = - {{mobile_apis::AppHMIType::DEFAULT, "DEFAULT"}, - {mobile_apis::AppHMIType::REMOTE_CONTROL, "REMOTE_CONTROL"}, - {mobile_apis::AppHMIType::COMMUNICATION, "COMMUNICATION"}, - {mobile_apis::AppHMIType::MEDIA, "MEDIA"}, - {mobile_apis::AppHMIType::MESSAGING, "MESSAGING"}, - {mobile_apis::AppHMIType::NAVIGATION, "NAVIGATION"}, - {mobile_apis::AppHMIType::INFORMATION, "INFORMATION"}, - {mobile_apis::AppHMIType::SOCIAL, "SOCIAL"}, - {mobile_apis::AppHMIType::BACKGROUND_PROCESS, "BACKGROUND_PROCESS"}, - {mobile_apis::AppHMIType::TESTING, "TESTING"}, - {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"}, - {mobile_apis::AppHMIType::PROJECTION, "PROJECTION"}}; - - std::map<mobile_apis::AppHMIType::eType, std::string>::const_iterator iter = - app_hmi_type_map.find(type); - - return app_hmi_type_map.end() != iter ? iter->second : std::string(""); -} - struct AppHMITypeInserter { AppHMITypeInserter(smart_objects::SmartObject& so_array) : index_(0), so_array_(so_array) {} bool operator()(const std::string& app_hmi_type) { - so_array_[index_] = StringToAppHMIType(app_hmi_type); + so_array_[index_] = + application_manager::StringToEnum<mobile_apis::AppHMIType::eType>( + app_hmi_type); ++index_; return true; } @@ -128,7 +79,7 @@ struct CheckMissedTypes { : policy_app_types_(policy_app_types), log_(log) {} bool operator()(const smart_objects::SmartArray::value_type& value) { - std::string app_type_str = AppHMITypeToString( + std::string app_type_str = application_manager::EnumToString( static_cast<mobile_apis::AppHMIType::eType>(value.asInt())); if (!app_type_str.empty()) { policy::StringArray::const_iterator it = policy_app_types_.begin(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc index 11589683be..fb10dd656f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc @@ -69,8 +69,7 @@ namespace { const uint32_t kConnectionKey = 2u; const std::string ccpu_version("4.1.3.B_EB355B"); const std::string wers_country_code("WAEGB"); -const uint32_t lang_code = 0u; -const std::string kLanguage = ""; +const std::string lang_code("EN-US"); } // namespace class GetSystemInfoResponseTest @@ -99,15 +98,8 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) { ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); - std::string language; - EXPECT_CALL(mock_message_helper_, - CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code))) - .WillOnce(Return(language)); - EXPECT_EQ(kLanguage, language); - EXPECT_CALL(mock_policy_handler_, - OnGetSystemInfo(ccpu_version, wers_country_code, kLanguage)); + OnGetSystemInfo(ccpu_version, wers_country_code, lang_code)); command->Run(); } @@ -121,11 +113,6 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); - EXPECT_CALL(mock_message_helper_, - CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code))) - .Times(0); - EXPECT_CALL(mock_policy_handler_, OnGetSystemInfo("", "", "")); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index 26f7a63872..e493468593 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -254,8 +254,6 @@ class HMICommandsNotificationsTest ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); - ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) - .WillByDefault(Return(kDefaultLanguage)); } am::ApplicationSharedPtr ConfigureApp(NiceMock<MockApplication>** app_mock, @@ -767,7 +765,6 @@ TEST_F(HMICommandsNotificationsTest, std::shared_ptr<Command> command = CreateCommand<OnSystemInfoChangedNotification>(message); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)); EXPECT_CALL(mock_policy_handler_, OnSystemInfoChanged(_)); command->Run(); } @@ -1824,7 +1821,7 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) .WillByDefault(Return(OptionalBool(true))); - std::string required_language = "en-us"; + std::string required_language = "EN-US"; ON_CALL(mock_policy_handler_, LockScreenDismissalWarningMessage(required_language)) .WillByDefault(Return( @@ -1854,7 +1851,7 @@ TEST_F(HMICommandsNotificationsTest, typedef boost::optional<bool> OptionalBool; ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) .WillByDefault(Return(OptionalBool(true))); - std::string required_language = "en-us"; + std::string required_language = "EN-US"; ON_CALL(mock_policy_handler_, LockScreenDismissalWarningMessage(required_language)) .WillByDefault(Return( @@ -1882,7 +1879,9 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) { typedef boost::optional<bool> OptionalBool; ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) .WillByDefault(Return(OptionalBool(true))); - std::string required_language = "en-us"; + std::string required_language = "EN-US"; + ON_CALL(*app_ptr_, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); + ON_CALL(mock_policy_handler_, LockScreenDismissalWarningMessage(required_language)) .WillByDefault(Return( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc index fe6ba7c4e3..642b4e651d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc @@ -95,8 +95,6 @@ class HMIOnDriverDistractionNotificationTest .WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) - .WillByDefault(Return(kDefaultLanguage)); } MockAppPtr mock_app_; @@ -327,8 +325,6 @@ TEST_F(HMIOnDriverDistractionNotificationTest, mobile_apis::Language::FR_FR; std::string required_language = "FR-FR"; ON_CALL(*mock_app_, ui_language()).WillByDefault(ReturnRef(mobile_language)); - ON_CALL(mock_message_helper_, MobileLanguageToString(mobile_language)) - .WillByDefault(Return(required_language)); policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcAllowed; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc index 0e87acef1f..d457b2a697 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc @@ -62,8 +62,8 @@ using testing::ReturnRef; namespace { const uint32_t kCorrelationID = 1u; const uint32_t kAppID = 2u; -const std::string kLanguageDe = "de-de"; -const std::string kLanguageEn = "en-gb"; +const std::string kLanguageDe = "DE-DE"; +const std::string kLanguageEn = "EN-GB"; const std::string kMessageCodes = "messageCodes"; const hmi_apis::Common_Language::eType kLanguage = hmi_apis::Common_Language::EN_GB; @@ -102,8 +102,6 @@ TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageSet_SUCCESS) { std::shared_ptr<SDLGetUserFriendlyMessageRequest> command( CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) - .WillOnce(Return(kLanguageEn)); std::vector<std::string> msg_codes; msg_codes.push_back(kLanguageDe); msg_codes.push_back(kLanguageEn); @@ -129,8 +127,6 @@ TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageNotSet_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) .WillOnce(Return(kLanguage)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) - .WillOnce(Return(kLanguageEn)); std::vector<std::string> msg_codes; msg_codes.push_back(kLanguageDe); msg_codes.push_back(kLanguageEn); @@ -149,7 +145,6 @@ TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_NoMsgCodes_Canceled) { std::shared_ptr<SDLGetUserFriendlyMessageRequest> command( CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)).Times(0); EXPECT_CALL(mock_policy_handler_, OnGetUserFriendlyMessage(_, _, _)).Times(0); command->Init(); @@ -181,7 +176,6 @@ TEST_F( std::shared_ptr<SDLGetUserFriendlyMessageRequest> command( CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)).Times(0); EXPECT_CALL(mock_policy_handler_, OnGetUserFriendlyMessage(_, _, _)).Times(0); command->Init(); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 009052bc72..1e79afaf38 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1821,8 +1821,8 @@ bool ApplicationManagerImpl::CheckResumptionRequiredTransportAvailable( } else { // check all AppHMITypes that the app has for (size_t i = 0; i < app_types_array->length(); i++) { - const std::string app_type_string = - AppHMITypeToString(static_cast<mobile_apis::AppHMIType::eType>( + std::string app_type_string = + EnumToString(static_cast<mobile_apis::AppHMIType::eType>( app_types_array->getElement(i).asUInt())); bool transport_is_found = false; @@ -2737,8 +2737,7 @@ void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data, } const HMICapabilities& hmi_cap = hmi_capabilities(); - std::string cur_vr_lang( - MessageHelper::CommonLanguageToString(hmi_cap.active_vr_language())); + std::string cur_vr_lang(EnumToString(hmi_cap.active_vr_language())); const SmartObject& languages = app_data[json::languages]; std::transform( @@ -3391,8 +3390,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( #ifdef ENABLE_LOG const std::string log_msg = "Application: " + app->policy_app_id() + ", RPC: " + function_id + - ", window_id: " + std::to_string(window_id) + ", HMI status: " + - MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); + ", window_id: " + std::to_string(window_id) + + ", HMI status: " + EnumToString(app->hmi_level(window_id)); #endif // ENABLE_LOG if (result.hmi_level_permitted != policy::kRpcAllowed) { LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg); @@ -4173,69 +4172,6 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList( tts_global_properties_app_list_lock_.Release(); } -mobile_apis::AppHMIType::eType ApplicationManagerImpl::StringToAppHMIType( - std::string str) { - LOG4CXX_AUTO_TRACE(logger_); - if ("DEFAULT" == str) { - return mobile_apis::AppHMIType::DEFAULT; - } else if ("COMMUNICATION" == str) { - return mobile_apis::AppHMIType::COMMUNICATION; - } else if ("MEDIA" == str) { - return mobile_apis::AppHMIType::MEDIA; - } else if ("MESSAGING" == str) { - return mobile_apis::AppHMIType::MESSAGING; - } else if ("NAVIGATION" == str) { - return mobile_apis::AppHMIType::NAVIGATION; - } else if ("PROJECTION" == str) { - return mobile_apis::AppHMIType::PROJECTION; - } else if ("INFORMATION" == str) { - return mobile_apis::AppHMIType::INFORMATION; - } else if ("SOCIAL" == str) { - return mobile_apis::AppHMIType::SOCIAL; - } else if ("BACKGROUND_PROCESS" == str) { - return mobile_apis::AppHMIType::BACKGROUND_PROCESS; - } else if ("TESTING" == str) { - return mobile_apis::AppHMIType::TESTING; - } else if ("SYSTEM" == str) { - return mobile_apis::AppHMIType::SYSTEM; - } else { - return mobile_apis::AppHMIType::INVALID_ENUM; - } -} - -const std::string ApplicationManagerImpl::AppHMITypeToString( - mobile_apis::AppHMIType::eType type) const { - LOG4CXX_AUTO_TRACE(logger_); - switch (type) { - case mobile_apis::AppHMIType::DEFAULT: - return "DEFAULT"; - case mobile_apis::AppHMIType::COMMUNICATION: - return "COMMUNICATION"; - case mobile_apis::AppHMIType::MEDIA: - return "MEDIA"; - case mobile_apis::AppHMIType::MESSAGING: - return "MESSAGING"; - case mobile_apis::AppHMIType::NAVIGATION: - return "NAVIGATION"; - case mobile_apis::AppHMIType::INFORMATION: - return "INFORMATION"; - case mobile_apis::AppHMIType::SOCIAL: - return "SOCIAL"; - case mobile_apis::AppHMIType::BACKGROUND_PROCESS: - return "BACKGROUND_PROCESS"; - case mobile_apis::AppHMIType::TESTING: - return "TESTING"; - case mobile_apis::AppHMIType::SYSTEM: - return "SYSTEM"; - case mobile_apis::AppHMIType::PROJECTION: - return "PROJECTION"; - case mobile_apis::AppHMIType::REMOTE_CONTROL: - return "REMOTE_CONTROL"; - default: - return "INVALID_ENUM"; - } -} - bool ApplicationManagerImpl::CompareAppHMIType( const smart_objects::SmartObject& from_policy, const smart_objects::SmartObject& from_application) { @@ -4287,7 +4223,8 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( for (uint32_t i = 0; i < hmi_types_from_policy.size(); ++i) { transform_app_hmi_types[i] = - StringToAppHMIType(hmi_types_from_policy[i]); + StringToEnum<mobile_api::AppHMIType::eType>( + hmi_types_from_policy[i]); } ApplicationConstSharedPtr app = *it; @@ -4434,8 +4371,7 @@ void ApplicationManagerImpl::SendDriverDistractionState( driver_distraction_state()) { bool dismissal_enabled = *lock_screen_dismissal; if (dismissal_enabled) { - const auto language = - MessageHelper::MobileLanguageToString(application->ui_language()); + const auto language = EnumToString(application->ui_language()); const auto warning_message = policy_handler_->LockScreenDismissalWarningMessage(language); diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 6a0fbf78e3..874d1cb015 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -924,10 +924,11 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { if (check_existing_json_member(ui, "language")) { const std::string lang = ui.get("language", "EN-US").asString(); - set_active_ui_language(MessageHelper::CommonLanguageFromString(lang)); + set_active_ui_language( + StringToEnum<hmi_apis::Common_Language::eType>(lang)); } else { set_active_ui_language( - MessageHelper::CommonLanguageFromString("EN-US")); + StringToEnum<hmi_apis::Common_Language::eType>("EN-US")); } if (check_existing_json_member(ui, "languages")) { @@ -1210,8 +1211,9 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { auto it = lights.asArray()->begin(); for (; it != lights.asArray()->end(); ++it) { smart_objects::SmartObject& light_name_so = (*it)["name"]; - auto light_name = MessageHelper::CommonLightNameFromString( - light_name_so.asString()); + auto light_name = + StringToEnum<hmi_apis::Common_LightName::eType>( + light_name_so.asString()); light_name_so = light_name; } } @@ -1238,10 +1240,11 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value vr = root_json.get("VR", ""); if (check_existing_json_member(vr, "language")) { const std::string lang = vr.get("language", "EN-US").asString(); - set_active_vr_language(MessageHelper::CommonLanguageFromString(lang)); + set_active_vr_language( + StringToEnum<hmi_apis::Common_Language::eType>(lang)); } else { set_active_vr_language( - MessageHelper::CommonLanguageFromString("EN-US")); + StringToEnum<hmi_apis::Common_Language::eType>("EN-US")); } if (check_existing_json_member(vr, "languages")) { @@ -1270,10 +1273,11 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { if (check_existing_json_member(tts, "language")) { const std::string lang = tts.get("language", "EN-US").asString(); - set_active_tts_language(MessageHelper::CommonLanguageFromString(lang)); + set_active_tts_language( + StringToEnum<hmi_apis::Common_Language::eType>(lang)); } else { set_active_tts_language( - MessageHelper::CommonLanguageFromString("EN-US")); + StringToEnum<hmi_apis::Common_Language::eType>("EN-US")); } if (check_existing_json_member(tts, "languages")) { @@ -1359,8 +1363,8 @@ void HMICapabilitiesImpl::convert_json_languages_to_obj( const Json::Value& json_languages, smart_objects::SmartObject& languages) const { for (uint32_t i = 0, j = 0; i < json_languages.size(); ++i) { - languages[j++] = - MessageHelper::CommonLanguageFromString(json_languages[i].asString()); + languages[j++] = StringToEnum<hmi_apis::Common_Language::eType>( + json_languages[i].asString()); } } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 646d523cf4..b672f5ed06 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -767,9 +767,8 @@ void PolicyHandler::OnGetUserFriendlyMessage( POLICY_LIB_CHECK_VOID(); #ifdef EXTERNAL_PROPRIETARY_MODE - const std::string active_hmi_language = - application_manager::MessageHelper::CommonLanguageToString( - application_manager_.hmi_capabilities().active_ui_language()); + const std::string active_hmi_language = application_manager::EnumToString( + application_manager_.hmi_capabilities().active_ui_language()); const std::vector<UserFriendlyMessage> result = policy_manager_->GetUserFriendlyMessages( message_codes, language, active_hmi_language); @@ -1511,8 +1510,7 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, // level to default mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); - mobile_apis::HMILevel::eType hmi_level = - MessageHelper::StringToHMILevel(default_hmi); + auto hmi_level = StringToEnum<mobile_apis::HMILevel::eType>(default_hmi); if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) { LOG4CXX_WARN( @@ -1731,7 +1729,7 @@ void PolicyHandler::CheckPermissions( CheckPermissionResult& result) { POLICY_LIB_CHECK_VOID(); const std::string hmi_level = - MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); + application_manager::EnumToString(app->hmi_level(window_id)); if (hmi_level.empty()) { LOG4CXX_WARN(logger_, "HMI level for " << app->policy_app_id() << " is invalid, rpc " @@ -2774,8 +2772,7 @@ void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id, "Could not find application: " << device_id << " - " << policy_app_id); return; } - mobile_apis::HMILevel::eType level = - MessageHelper::StringToHMILevel(hmi_level); + auto level = StringToEnum<mobile_apis::HMILevel::eType>(hmi_level); if (mobile_apis::HMILevel::INVALID_ENUM == level) { LOG4CXX_WARN( logger_, @@ -2851,8 +2848,7 @@ void PolicyHandler::OnUpdateHMILevel(const std::string& device_id, "Could not find application: " << device_id << " - " << policy_app_id); return; } - mobile_apis::HMILevel::eType level = - MessageHelper::StringToHMILevel(hmi_level); + auto level = StringToEnum<mobile_apis::HMILevel::eType>(hmi_level); if (mobile_apis::HMILevel::INVALID_ENUM == level) { LOG4CXX_WARN( logger_, diff --git a/src/components/application_manager/src/request_tracker.cc b/src/components/application_manager/src/request_tracker.cc index 052667dc3f..7bb33dc6dd 100644 --- a/src/components/application_manager/src/request_tracker.cc +++ b/src/components/application_manager/src/request_tracker.cc @@ -49,9 +49,7 @@ TrackResult RequestTracker::Track(const ApplicationID& app_id, LOG4CXX_AUTO_TRACE(logger_); bool track_result = false; - LOG4CXX_DEBUG(logger_, - "Tracking request for level: " - << MessageHelper::StringifiedHMILevel(level)); + LOG4CXX_DEBUG(logger_, "Tracking request for level: " << EnumToString(level)); if (mobile_apis::HMILevel::HMI_NONE == level) { track_result = Track(app_id, diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 2c16048e97..a4538094b1 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -1516,7 +1516,7 @@ TEST_F(ApplicationManagerImplTest, // - .ini file specifies TCP_WIFI for EMPTY_APP entry. // -> The app does not have required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - NULL, + nullptr, primary_device_handle, primary_transport_device_string, secondary_device_handle, diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index afa5fa6056..a3b93f6343 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -1,44 +1,44 @@ { "UI": { - "language":"EN_US", + "language":"EN-US", "languages":[ - "EN_US", - "ES_MX", - "FR_CA", - "DE_DE", - "ES_ES", - "EN_GB", - "RU_RU", - "TR_TR", - "PL_PL", - "FR_FR", - "IT_IT", - "SV_SE", - "PT_PT", - "NL_NL", - "ZH_TW", - "JA_JP", - "AR_SA", - "KO_KR", - "PT_BR", - "CS_CZ", - "DA_DK", - "NO_NO", - "NL_BE", - "EL_GR", - "HU_HU", - "FI_FI", - "SK_SK", - "EN_IN", - "TH_TH", - "EN_SA", - "HE_IL", - "RO_RO", - "UK_UA", - "ID_ID", - "VI_VN", - "MS_MY", - "HI_IN" + "EN-US", + "ES-MX", + "FR-CA", + "DE-DE", + "ES-ES", + "EN-GB", + "RU-RU", + "TR-TR", + "PL-PL", + "FR-FR", + "IT-IT", + "SV-SE", + "PT-PT", + "NL-NL", + "ZH-TW", + "JA-JP", + "AR-SA", + "KO-KR", + "PT-BR", + "CS-CZ", + "DA-DK", + "NO-NO", + "NL-BE", + "EL-GR", + "HU-HU", + "FI-FI", + "SK-SK", + "EN-IN", + "TH-TH", + "EN-SA", + "HE-IL", + "RO-RO", + "UK-UA", + "ID-ID", + "VI-VN", + "MS-MY", + "HI-IN" ], "displayCapabilities": { "displayType": "GEN2_8_DMA", @@ -559,60 +559,60 @@ "capabilities": [ "TEXT" ], - "language": "ES_MX", + "language": "ES-MX", "languages": [ - "AR_SA", - "EN_US", - "ES_MX", - "FR_CA", - "DE_DE", - "ES_ES", - "EN_GB", - "RU_RU", - "TR_TR", - "PL_PL", - "FR_FR", - "IT_IT", - "SV_SE", - "PT_PT", - "NL_NL", - "ZH_TW", - "JA_JP", - "KO_KR", - "PT_BR", - "CS_CZ", - "DA_DK", - "NO_NO" + "AR-SA", + "EN-US", + "ES-MX", + "FR-CA", + "DE-DE", + "ES-ES", + "EN-GB", + "RU-RU", + "TR-TR", + "PL-PL", + "FR-FR", + "IT-IT", + "SV-SE", + "PT-PT", + "NL-NL", + "ZH-TW", + "JA-JP", + "KO-KR", + "PT-BR", + "CS-CZ", + "DA-DK", + "NO-NO" ] }, "TTS": { "capabilities": [ "TEXT" ], - "language": "DE_DE", + "language": "DE-DE", "languages": [ - "DA_DK", - "CS_CZ", - "KO_KR", - "EN_US", - "ES_MX", - "FR_CA", - "DE_DE", - "ES_ES", - "EN_GB", - "RU_RU", - "TR_TR", - "PL_PL", - "FR_FR", - "IT_IT", - "SV_SE", - "PT_PT", - "NL_NL", - "ZH_TW", - "JA_JP", - "AR_SA", - "PT_BR", - "NO_NO" + "DA-DK", + "CS-CZ", + "KO-KR", + "EN-US", + "ES-MX", + "FR-CA", + "DE-DE", + "ES-ES", + "EN-GB", + "RU-RU", + "TR-TR", + "PL-PL", + "FR-FR", + "IT-IT", + "SV-SE", + "PT-PT", + "NL-NL", + "ZH-TW", + "JA-JP", + "AR-SA", + "PT-BR", + "NO-NO" ] }, "Buttons": { diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index 6234830f50..35bb909a72 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -157,37 +157,10 @@ CStringToEnumMap InitCStringToEnumMap() { return result; } -bool StringToEnum(const char* str, hmi_apis::Common_Language::eType& value) { - size_t count_value = sizeof(cstring_values_) / sizeof(cstring_values_[0]); - CStringToEnumMap result; - for (size_t i = 0; i < count_value; ++i) { - result[cstring_values_[i]] = enum_values_[i]; - } - - CStringToEnumMap::const_iterator it = result.find(str); - if (it == result.end()) { - return false; - } - value = it->second; - return true; -} - -hmi_apis::Common_Language::eType TestCommonLanguageFromString( - const std::string& language) { - hmi_apis::Common_Language::eType value; - if (StringToEnum(language.c_str(), value)) { - return value; - } - return hmi_apis::Common_Language::INVALID_ENUM; -} - TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { const std::string hmi_capabilities_file = "hmi_capabilities.json"; EXPECT_CALL(mock_application_manager_settings_, hmi_capabilities_file_name()) .WillOnce(ReturnRef(hmi_capabilities_file)); - EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), - CommonLanguageFromString(_)) - .WillRepeatedly(Invoke(TestCommonLanguageFromString)); if (file_system::FileExists("./app_info_data")) { EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); @@ -593,9 +566,6 @@ TEST_F(HMICapabilitiesTest, EXPECT_CALL(mock_dispatcher, remove_observer(_)).Times(1); EXPECT_CALL(mock_application_manager_settings, launch_hmi()) .WillOnce(Return(false)); - EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), - CommonLanguageFromString(_)) - .WillRepeatedly(Invoke(TestCommonLanguageFromString)); if (file_system::FileExists("./app_info_data")) { EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); 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 5f6e613123..a4cb20993e 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 @@ -57,22 +57,12 @@ class MockMessageHelper { smart_objects::SmartObjectSPtr(const uint32_t app_id)); MOCK_METHOD2(SendHashUpdateNotification, void(const uint32_t app_id, ApplicationManager& app_mngr)); - MOCK_METHOD1(HMIResultToString, - std::string(hmi_apis::Common_Result::eType hmi_result)); - MOCK_METHOD1(HMIResultFromString, - hmi_apis::Common_Result::eType(const std::string& hmi_result)); - MOCK_METHOD1(MobileResultToString, - std::string(mobile_apis::Result::eType mobile_result)); - MOCK_METHOD1(MobileResultFromString, - mobile_api::Result::eType(const std::string& mobile_result)); MOCK_METHOD1(HMIToMobileResult, mobile_api::Result::eType( const hmi_apis::Common_Result::eType hmi_result)); MOCK_METHOD1(MobileToHMIResult, hmi_apis::Common_Result::eType( const mobile_api::Result::eType mobile_result)); - MOCK_METHOD1(StringToHMILevel, - mobile_api::HMILevel::eType(const std::string& hmi_level)); MOCK_METHOD3(CreateDeviceListSO, smart_objects::SmartObjectSPtr( const connection_handler::DeviceMap& devices, @@ -170,14 +160,6 @@ class MockMessageHelper { const std::vector<uint8_t>& policy_data, const std::string& url, ApplicationManager& app_mngr)); - MOCK_METHOD1(CommonLanguageFromString, - hmi_apis::Common_Language::eType(const std::string& language)); - MOCK_METHOD1(CommonLightNameFromString, - hmi_apis::Common_LightName::eType(const std::string& lightName)); - MOCK_METHOD1(CommonLanguageToString, - std::string(hmi_apis::Common_Language::eType)); - MOCK_METHOD1(MobileLanguageToString, - std::string(mobile_apis::Language::eType)); MOCK_METHOD2(CreateModuleInfoSO, smart_objects::SmartObjectSPtr(uint32_t function_id, ApplicationManager& app_mngr)); @@ -310,8 +292,6 @@ class MockMessageHelper { void(const uint32_t app_id, const std::string& icon_path, ApplicationManager& application_manager)); - MOCK_METHOD1(StringifiedHMILevel, - std::string(const mobile_apis::HMILevel::eType hmi_level)); MOCK_METHOD2(GetDeviceMacAddressForHandle, std::string(const transport_manager::DeviceHandle device_handle, const ApplicationManager& app_mngr)); diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index f85c569bdb..7c5eeaa017 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -615,41 +615,6 @@ class MessageHelperTest : public ::testing::Test { const size_t delta_from_functions_id; }; -TEST_F(MessageHelperTest, - CommonLanguageFromString_StringValueOfEnum_CorrectEType) { - HmiLanguage::eType enum_value; - HmiLanguage::eType enum_from_string_value; - // Check all languages >= 0 - for (size_t array_index = 0; array_index < language_strings.size(); - ++array_index) { - enum_value = static_cast<HmiLanguage::eType>(array_index); - enum_from_string_value = - MessageHelper::CommonLanguageFromString(language_strings[array_index]); - EXPECT_EQ(enum_value, enum_from_string_value); - } - // Check InvalidEnum == -1 - enum_value = HmiLanguage::INVALID_ENUM; - enum_from_string_value = MessageHelper::CommonLanguageFromString(""); - EXPECT_EQ(enum_value, enum_from_string_value); -} - -TEST_F(MessageHelperTest, - CommonLanguageToString_ETypeValueOfEnum_CorrectString) { - std::string string_from_enum; - HmiLanguage::eType casted_enum; - // Check all languages >=0 - for (size_t array_index = 0; array_index < language_strings.size(); - ++array_index) { - casted_enum = static_cast<HmiLanguage::eType>(array_index); - string_from_enum = MessageHelper::CommonLanguageToString(casted_enum); - EXPECT_EQ(language_strings[array_index], string_from_enum); - } - // Check InvalidEnum == -1 - string_from_enum = - MessageHelper::CommonLanguageToString(HmiLanguage::INVALID_ENUM); - EXPECT_EQ("", string_from_enum); -} - TEST_F(MessageHelperTest, ConvertEnumAPINoCheck_AnyEnumType_AnotherEnumType) { hmi_apis::Common_LayoutMode::eType tested_enum_value = hmi_apis::Common_LayoutMode::ICON_ONLY; @@ -660,38 +625,6 @@ TEST_F(MessageHelperTest, ConvertEnumAPINoCheck_AnyEnumType_AnotherEnumType) { EXPECT_EQ(hmi_apis::Common_AppHMIType::DEFAULT, converted); } -TEST_F(MessageHelperTest, HMIResultFromString_StringValueOfEnum_CorrectEType) { - HmiResults::eType enum_value; - HmiResults::eType enum_from_string_value; - // Check all results >= 0 - for (size_t array_index = 0; array_index < hmi_result_strings.size(); - ++array_index) { - enum_value = static_cast<HmiResults::eType>(array_index); - enum_from_string_value = - MessageHelper::HMIResultFromString(hmi_result_strings[array_index]); - EXPECT_EQ(enum_value, enum_from_string_value); - } - // Check InvalidEnum == -1 - enum_value = HmiResults::INVALID_ENUM; - enum_from_string_value = MessageHelper::HMIResultFromString(""); - EXPECT_EQ(enum_value, enum_from_string_value); -} - -TEST_F(MessageHelperTest, HMIResultToString_ETypeValueOfEnum_CorrectString) { - std::string string_from_enum; - HmiResults::eType casted_enum; - // Check all results >=0 - for (size_t array_index = 0; array_index < hmi_result_strings.size(); - ++array_index) { - casted_enum = static_cast<HmiResults::eType>(array_index); - string_from_enum = MessageHelper::HMIResultToString(casted_enum); - EXPECT_EQ(hmi_result_strings[array_index], string_from_enum); - } - // Check InvalidEnum == -1 - string_from_enum = MessageHelper::HMIResultToString(HmiResults::INVALID_ENUM); - EXPECT_EQ("", string_from_enum); -} - TEST_F(MessageHelperTest, HMIToMobileResult_HmiResultEType_GetCorrectMobileResultEType) { MobileResults::eType tested_enum; @@ -701,7 +634,7 @@ TEST_F(MessageHelperTest, for (size_t enum_index = 0; enum_index < hmi_result_strings.size(); ++enum_index) { tested_enum = - MessageHelper::MobileResultFromString(hmi_result_strings[enum_index]); + StringToEnum<MobileResults::eType>(hmi_result_strings[enum_index]); casted_hmi_enum = static_cast<HmiResults::eType>(enum_index); converted_enum = MessageHelper::HMIToMobileResult(casted_hmi_enum); EXPECT_EQ(tested_enum, converted_enum); @@ -929,27 +862,6 @@ TEST_F(MessageHelperTest, } } -TEST_F(MessageHelperTest, - StringifiedHmiLevel_LevelEnum_EqualsWithStringsInArray) { - mobile_apis::HMILevel::eType casted_enum; - std::string converted_value; - for (size_t i = 0; i < hmi_level_strings.size(); ++i) { - casted_enum = static_cast<mobile_apis::HMILevel::eType>(i); - converted_value = MessageHelper::StringifiedHMILevel(casted_enum); - EXPECT_EQ(hmi_level_strings[i], converted_value); - } -} - -TEST_F(MessageHelperTest, StringToHmiLevel_LevelString_EqEType) { - mobile_apis::HMILevel::eType tested_enum; - mobile_apis::HMILevel::eType converted_enum; - for (size_t i = 0; i < hmi_level_strings.size(); ++i) { - tested_enum = static_cast<mobile_apis::HMILevel::eType>(i); - converted_enum = MessageHelper::StringToHMILevel(hmi_level_strings[i]); - EXPECT_EQ(tested_enum, converted_enum); - } -} - TEST_F(MessageHelperTest, SubscribeApplicationToSoftButton_CallFromApp) { // Create application mock MockApplicationSharedPtr appSharedPtr = std::make_shared<MockApplication>(); diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index a001e852b8..37afecee6e 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -102,30 +102,6 @@ smart_objects::SmartObjectSPtr GetHashUpdateNotification( app_id); } -std::string MessageHelper::HMIResultToString( - hmi_apis::Common_Result::eType hmi_result) { - return MockMessageHelper::message_helper_mock()->HMIResultToString( - hmi_result); -} - -hmi_apis::Common_Result::eType MessageHelper::HMIResultFromString( - const std::string& hmi_result) { - return MockMessageHelper::message_helper_mock()->HMIResultFromString( - hmi_result); -} - -std::string MessageHelper::MobileResultToString( - mobile_apis::Result::eType mobile_result) { - return MockMessageHelper::message_helper_mock()->MobileResultToString( - mobile_result); -} - -mobile_api::Result::eType MessageHelper::MobileResultFromString( - const std::string& mobile_result) { - return MockMessageHelper::message_helper_mock()->MobileResultFromString( - mobile_result); -} - mobile_api::Result::eType MessageHelper::HMIToMobileResult( const hmi_apis::Common_Result::eType hmi_result) { return MockMessageHelper::message_helper_mock()->HMIToMobileResult( @@ -138,11 +114,6 @@ hmi_apis::Common_Result::eType MessageHelper::MobileToHMIResult( mobile_result); } -mobile_api::HMILevel::eType MessageHelper::StringToHMILevel( - const std::string& hmi_level) { - return MockMessageHelper::message_helper_mock()->StringToHMILevel(hmi_level); -} - smart_objects::SmartObjectSPtr MessageHelper::CreateDeviceListSO( const connection_handler::DeviceMap& devices, const policy::PolicyHandlerInterface& policy_handler, @@ -282,18 +253,6 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result, result, correlation_id, app_mngr); } -hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString( - const std::string& language) { - return MockMessageHelper::message_helper_mock()->CommonLanguageFromString( - language); -} - -hmi_apis::Common_LightName::eType MessageHelper::CommonLightNameFromString( - const std::string& lightName) { - return MockMessageHelper::message_helper_mock()->CommonLightNameFromString( - lightName); -} - smart_objects::SmartObjectSPtr MessageHelper::CreateModuleInfoSO( uint32_t function_id, ApplicationManager& app_mngr) { return MockMessageHelper::message_helper_mock()->CreateModuleInfoSO( @@ -372,16 +331,6 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( message, app, app_mngr); } -std::string MessageHelper::CommonLanguageToString( - hmi_apis::Common_Language::eType lang) { - return MockMessageHelper::message_helper_mock()->CommonLanguageToString(lang); -} - -std::string MessageHelper::MobileLanguageToString( - mobile_apis::Language::eType lang) { - return MockMessageHelper::message_helper_mock()->MobileLanguageToString(lang); -} - smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, const policy::PolicyHandlerInterface& policy_handler, @@ -569,12 +518,6 @@ void MessageHelper::SendSetAppIcon(const uint32_t app_id, app_id, icon_path, application_manager); } -std::string MessageHelper::StringifiedHMILevel( - const mobile_apis::HMILevel::eType hmi_level) { - return MockMessageHelper::message_helper_mock()->StringifiedHMILevel( - hmi_level); -} - std::string MessageHelper::GetDeviceMacAddressForHandle( const transport_manager::DeviceHandle device_handle, const ApplicationManager& app_mngr) { diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index ad94c4d1c8..c60ab57538 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -248,8 +248,6 @@ class PolicyHandlerTest : public ::testing::Test { EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); - EXPECT_CALL(mock_message_helper_, StringToHMILevel(default_hmi_level)) - .WillOnce(Return(hmi_level)); ChangePolicyManagerToMock(); const policy::EncryptionRequired require_encryption; EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) @@ -593,16 +591,13 @@ TEST_F(PolicyHandlerTest, TEST_F(PolicyHandlerTest, OnPermissionsUpdated_MethodWith3Parameters_FromNONE_ToFULL) { // Set hmi level from NONE to FULL - const std::string new_kHmiLevel_string = "HMI_FULL"; + const std::string new_kHmiLevel_string = "FULL"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; // Check expectations EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); - EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) - .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); ChangePolicyManagerToMock(); @@ -625,7 +620,7 @@ TEST_F(PolicyHandlerTest, TEST_F(PolicyHandlerTest, OnPermissionsUpdated_MethodWith3Parameters_FromNONE_ToNotFull) { // Set hmi level from NONE to Limited - const std::string new_kHmiLevel_string = "HMI_LIMITED"; + const std::string new_kHmiLevel_string = "LIMITED"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; // Check expectations @@ -633,9 +628,6 @@ TEST_F(PolicyHandlerTest, .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); - EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) - .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); ChangePolicyManagerToMock(); @@ -658,15 +650,12 @@ TEST_F(PolicyHandlerTest, TEST_F(PolicyHandlerTest, OnPermissionsUpdated_MethodWith3Parameters_FromNotNONE) { // Set hmi level from LIMITED to FULL - std::string new_kHmiLevel_string = "HMI_FULL"; - mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; + std::string new_kHmiLevel_string = "FULL"; // Check expectations EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); - EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) - .WillOnce(Return(new_hmi_level)); EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_LIMITED)); @@ -716,8 +705,6 @@ TEST_F(PolicyHandlerTest, CheckPermissions) { CheckPermissions( kDeviceId, kPolicyAppId_, kHmiLevel_, kRpc_, kRpc_params, _)); #endif // EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL(mock_message_helper_, StringifiedHMILevel(hmi_level)) - .WillOnce(Return(kHmiLevel_)); EXPECT_CALL(mock_message_helper_, GetDeviceMacAddressForHandle(device, _)) .WillOnce(Return(kDeviceId)); // Act @@ -1248,17 +1235,15 @@ TEST_F(PolicyHandlerTest, OnGetUserFriendlyMessage) { ChangePolicyManagerToMock(); // Check expectations std::vector<std::string> message_codes; - const std::string language("ru-ru"); + const std::string language("RU-RU"); const uint32_t correlation_id = 2; #ifdef EXTERNAL_PROPRIETARY_MODE const hmi_apis::Common_Language::eType default_language = hmi_apis::Common_Language::EN_US; - const std::string default_language_string = "EN_US"; + const std::string default_language_string = "EN-US"; application_manager_test::MockHMICapabilities mock_hmi_capabilities; EXPECT_CALL(app_manager_, hmi_capabilities()) .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(default_language)) - .WillOnce(Return(default_language_string)); EXPECT_CALL(mock_hmi_capabilities, active_ui_language()) .WillOnce(Return(default_language)); EXPECT_CALL( |