diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 33fa1ae914b..e018c28c54a 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -113,14 +113,15 @@ class InitialApplicationData { public: virtual ~InitialApplicationData() {} - virtual const smart_objects::SmartObject* app_types() const = 0; - virtual const smart_objects::SmartObject* vr_synonyms() const = 0; + virtual const smart_objects::SmartObjectSPtr app_types() const = 0; + virtual const smart_objects::SmartObjectSPtr vr_synonyms() const = 0; virtual const std::string& mac_address() const = 0; virtual const std::string& bundle_id() const = 0; virtual void set_bundle_id(const std::string& bundle_id) = 0; virtual std::string policy_app_id() const = 0; - virtual const smart_objects::SmartObject* tts_name() const = 0; - virtual const smart_objects::SmartObject* ngn_media_screen_name() const = 0; + virtual const smart_objects::SmartObjectSPtr tts_name() const = 0; + virtual const smart_objects::SmartObjectSPtr ngn_media_screen_name() + const = 0; virtual const mobile_api::Language::eType& language() const = 0; virtual const mobile_api::Language::eType& ui_language() const = 0; virtual const utils::SemanticVersion& msg_version() const = 0; @@ -195,18 +196,18 @@ typedef std::vector MobileMessageQueue; class DynamicApplicationData { public: virtual ~DynamicApplicationData() {} - virtual const smart_objects::SmartObject* help_prompt() const = 0; - virtual const smart_objects::SmartObject* timeout_prompt() const = 0; - virtual const smart_objects::SmartObject* vr_help_title() const = 0; - virtual const smart_objects::SmartObject* vr_help() const = 0; + virtual const smart_objects::SmartObjectSPtr help_prompt() const = 0; + virtual const smart_objects::SmartObjectSPtr timeout_prompt() const = 0; + virtual const smart_objects::SmartObjectSPtr vr_help_title() const = 0; + virtual const smart_objects::SmartObjectSPtr vr_help() const = 0; virtual const mobile_api::TBTState::eType& tbt_state() const = 0; - virtual const smart_objects::SmartObject* show_command() const = 0; - virtual const smart_objects::SmartObject* tbt_show_command() const = 0; + virtual const smart_objects::SmartObjectSPtr show_command() const = 0; + virtual const smart_objects::SmartObjectSPtr tbt_show_command() const = 0; virtual DataAccessor SubscribedButtons() const = 0; - virtual const smart_objects::SmartObject* keyboard_props() const = 0; - virtual const smart_objects::SmartObject* menu_title() const = 0; - virtual const smart_objects::SmartObject* menu_icon() const = 0; - virtual const smart_objects::SmartObject* menu_layout() const = 0; + virtual const smart_objects::SmartObjectSPtr keyboard_props() const = 0; + virtual const smart_objects::SmartObjectSPtr menu_title() const = 0; + virtual const smart_objects::SmartObjectSPtr menu_icon() const = 0; + virtual const smart_objects::SmartObjectSPtr menu_layout() const = 0; virtual smart_objects::SmartObject day_color_scheme() const = 0; virtual smart_objects::SmartObject night_color_scheme() const = 0; virtual std::string display_layout() const = 0; @@ -558,8 +559,10 @@ class Application : public virtual InitialApplicationData, * @brief Returns message belonging to the application * that is currently executed (i.e. on HMI). * @return smart_objects::SmartObject * Active message + * @deprecated will always return NULL */ - virtual const smart_objects::SmartObject* active_message() const = 0; + DEPRECATED virtual const smart_objects::SmartObject* active_message() + const = 0; /** * @brief returns current hash value @@ -615,7 +618,8 @@ class Application : public virtual InitialApplicationData, */ virtual void set_app_data_resumption_allowance(const bool allowed) = 0; - virtual void CloseActiveMessage() = 0; + // Deprecated, has no effect + DEPRECATED virtual void CloseActiveMessage() = 0; virtual bool IsFullscreen() const = 0; virtual void ChangeSupportingAppHMIType() = 0; diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h index e349fd7d4ca..b24fb96a2d1 100644 --- a/src/components/application_manager/include/application_manager/application_data_impl.h +++ b/src/components/application_manager/include/application_manager/application_data_impl.h @@ -50,11 +50,11 @@ class InitialApplicationDataImpl : public virtual Application { InitialApplicationDataImpl(); ~InitialApplicationDataImpl(); - const smart_objects::SmartObject* app_types() const; - const smart_objects::SmartObject* vr_synonyms() const; + const smart_objects::SmartObjectSPtr app_types() const; + const smart_objects::SmartObjectSPtr vr_synonyms() const; virtual std::string policy_app_id() const; - const smart_objects::SmartObject* tts_name() const; - const smart_objects::SmartObject* ngn_media_screen_name() const; + const smart_objects::SmartObjectSPtr tts_name() const; + const smart_objects::SmartObjectSPtr ngn_media_screen_name() const; const mobile_api::Language::eType& language() const; const mobile_api::Language::eType& ui_language() const; const utils::SemanticVersion& msg_version() const; @@ -73,11 +73,11 @@ class InitialApplicationDataImpl : public virtual Application { mobile_api::LayoutMode::eType perform_interaction_layout() const OVERRIDE; protected: - smart_objects::SmartObject* app_types_; - smart_objects::SmartObject* vr_synonyms_; + smart_objects::SmartObjectSPtr app_types_; + smart_objects::SmartObjectSPtr vr_synonyms_; std::string mobile_app_id_; - smart_objects::SmartObject* tts_name_; - smart_objects::SmartObject* ngn_media_screen_name_; + smart_objects::SmartObjectSPtr tts_name_; + smart_objects::SmartObjectSPtr ngn_media_screen_name_; mobile_api::Language::eType language_; mobile_api::Language::eType ui_language_; mobile_apis::LayoutMode::eType perform_interaction_layout_; @@ -92,17 +92,17 @@ class DynamicApplicationDataImpl : public virtual Application { typedef std::map AppWindowsTemplates; DynamicApplicationDataImpl(); ~DynamicApplicationDataImpl(); - const smart_objects::SmartObject* help_prompt() const; - const smart_objects::SmartObject* timeout_prompt() const; - const smart_objects::SmartObject* vr_help_title() const; - const smart_objects::SmartObject* vr_help() const; + const smart_objects::SmartObjectSPtr help_prompt() const; + const smart_objects::SmartObjectSPtr timeout_prompt() const; + const smart_objects::SmartObjectSPtr vr_help_title() const; + const smart_objects::SmartObjectSPtr vr_help() const; const mobile_api::TBTState::eType& tbt_state() const; - const smart_objects::SmartObject* show_command() const; - const smart_objects::SmartObject* tbt_show_command() const; - const smart_objects::SmartObject* keyboard_props() const; - const smart_objects::SmartObject* menu_title() const; - const smart_objects::SmartObject* menu_icon() const; - const smart_objects::SmartObject* menu_layout() const; + const smart_objects::SmartObjectSPtr show_command() const; + const smart_objects::SmartObjectSPtr tbt_show_command() const; + const smart_objects::SmartObjectSPtr keyboard_props() const; + const smart_objects::SmartObjectSPtr menu_title() const; + const smart_objects::SmartObjectSPtr menu_icon() const; + const smart_objects::SmartObjectSPtr menu_layout() const; smart_objects::SmartObject day_color_scheme() const OVERRIDE; smart_objects::SmartObject night_color_scheme() const OVERRIDE; @@ -321,17 +321,17 @@ class DynamicApplicationDataImpl : public virtual Application { bool is_choice_set_allowed(const uint32_t choice_set_id) const; protected: - smart_objects::SmartObject* help_prompt_; - smart_objects::SmartObject* timeout_prompt_; - smart_objects::SmartObject* vr_help_title_; - smart_objects::SmartObject* vr_help_; + smart_objects::SmartObjectSPtr help_prompt_; + smart_objects::SmartObjectSPtr timeout_prompt_; + smart_objects::SmartObjectSPtr vr_help_title_; + smart_objects::SmartObjectSPtr vr_help_; mobile_api::TBTState::eType tbt_state_; - smart_objects::SmartObject* show_command_; - smart_objects::SmartObject* keyboard_props_; - smart_objects::SmartObject* menu_title_; - smart_objects::SmartObject* menu_icon_; - smart_objects::SmartObject* menu_layout_; - smart_objects::SmartObject* tbt_show_command_; + smart_objects::SmartObjectSPtr show_command_; + smart_objects::SmartObjectSPtr keyboard_props_; + smart_objects::SmartObjectSPtr menu_title_; + smart_objects::SmartObjectSPtr menu_icon_; + smart_objects::SmartObjectSPtr menu_layout_; + smart_objects::SmartObjectSPtr tbt_show_command_; smart_objects::SmartObjectSPtr display_capabilities_; AppWindowsTemplates window_templates_; diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index 69fc5437dec..ee9972b98cc 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -269,7 +269,7 @@ class ResumptionData { * @return smartObject from pointer */ smart_objects::SmartObject PointerToSmartObj( - const smart_objects::SmartObject* ptr) const; + const smart_objects::SmartObjectSPtr ptr) const; /** * @brief creates smart object containing window info diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 376723b9648..eef3b23d724 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -146,7 +146,7 @@ void RCCommandRequest::Run() { if (!policy_handler_.CheckHMIType( app->policy_app_id(), mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - app->app_types())) { + app->app_types().get())) { SDL_LOG_WARN("Application has no remote control functions"); SendResponse(false, mobile_apis::Result::DISALLOWED, ""); return; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index f4ef39f4883..17d4f05be75 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -97,10 +97,12 @@ class ButtonPressRequestTest ON_CALL(mock_hmi_capabilities_, rc_capability()) .WillByDefault(Return(rc_capabilities_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); - ON_CALL(mock_policy_handler_, - CheckHMIType(kPolicyAppId, - mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - nullptr)) + ON_CALL(*mock_app_, app_types()) + .WillByDefault(Return(std::shared_ptr())); + ON_CALL( + mock_policy_handler_, + CheckHMIType( + kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, _)) .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index 5fa474c631f..b4f9d177eab 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -104,6 +104,10 @@ class GetInteriorVehicleDataRequestTest smart_objects::SmartType::SmartType_Array)) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2)); + ON_CALL(*mock_app_, app_types()) + .WillByDefault(Return(std::shared_ptr())); + ON_CALL(*mock_app2_, app_types()) + .WillByDefault(Return(std::shared_ptr())); ON_CALL(*mock_app_, is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL(*mock_app2_, is_remote_control_supported()) @@ -158,8 +162,7 @@ class GetInteriorVehicleDataRequestTest ON_CALL(mock_hmi_capabilities_, rc_capability()) .WillByDefault(Return(rc_capabilities_)); ON_CALL(mock_policy_handler_, - CheckHMIType( - _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) + CheckHMIType(_, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, _)) .WillByDefault(Return(true)); ON_CALL(mock_policy_handler_, CheckModule(_, _)) .WillByDefault(Return(true)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc index 82d1b128f09..07ab2026207 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc @@ -131,6 +131,8 @@ class RCGetInteriorVehicleDataConsentTest smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); (*rc_capabilities_)[strings::kradioControlCapabilities] = control_caps; ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, app_types()) + .WillByDefault(Return(std::shared_ptr())); ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); ON_CALL( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index fe190a796fb..3e6c271ed31 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -98,6 +98,8 @@ class SetInteriorVehicleDataRequestTest ON_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillByDefault(Return(AcquireResult::ALLOWED)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, app_types()) + .WillByDefault(Return(std::shared_ptr())); ON_CALL(mock_policy_handler_, CheckHMIType(kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 0624c873fa3..0e2fafe82b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -168,6 +168,10 @@ class RegisterAppInterfaceRequestTest ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); ON_CALL(*mock_app, hybrid_app_preference()) .WillByDefault(ReturnRef(kHybridAppPreference)); + ON_CALL(*mock_app, vr_synonyms()) + .WillByDefault(Return(std::shared_ptr())); + ON_CALL(*mock_app, tts_name()) + .WillByDefault(Return(std::shared_ptr())); ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId1)); ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 4272005fbab..de7548cc289 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -123,13 +123,14 @@ class SetGlobalPropertiesRequestTest } void VRArraySetupHelper(MessageSharedPtr msg, - SmartObject& vr_help_title, - SmartObject& vr_help_array) { - (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; - vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); - vr_help_array[0][am::strings::text] = kText; - vr_help_array[0][am::strings::position] = kPosition; - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + smart_objects::SmartObjectSPtr vr_help_title, + smart_objects::SmartObjectSPtr vr_help_array) { + (*msg)[am::strings::msg_params][am::strings::vr_help_title] = + *vr_help_title; + (*vr_help_array)[0] = SmartObject(smart_objects::SmartType_Map); + (*vr_help_array)[0][am::strings::text] = kText; + (*vr_help_array)[0][am::strings::position] = kPosition; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); } @@ -137,18 +138,20 @@ class SetGlobalPropertiesRequestTest void OnEventUISetupHelper( MessageSharedPtr msg, std::shared_ptr command) { - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); EXPECT_CALL(mock_message_helper_, - VerifyImageVrHelpItems(vr_help_array, _, _)) + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0); @@ -165,27 +168,29 @@ class SetGlobalPropertiesRequestTest void OnEventTTSSetupHelper( MessageSharedPtr msg, std::shared_ptr command) { - SmartObject help_prompt(smart_objects::SmartType_Array); - help_prompt[0][am::strings::text] = "Help_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; - SmartObject timeout_prompt(smart_objects::SmartType_Array); - timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; + smart_objects::SmartObjectSPtr help_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*help_prompt)[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = *help_prompt; + smart_objects::SmartObjectSPtr timeout_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*timeout_prompt)[0][am::strings::text] = "Timeout_Prompt_One"; (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = - timeout_prompt; + *timeout_prompt; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*help_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*timeout_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); - EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); - EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); - EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, set_help_prompt(*help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(*timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(timeout_prompt)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(*mock_app_, help_prompt_manager()) @@ -437,12 +442,14 @@ TEST_F(SetGlobalPropertiesRequestTest, CreateCommand(msg_vr); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - const smart_objects::SmartObject* vr_help_title = - &((*msg_vr)[am::strings::msg_params][am::strings::vr_help_title]); - const smart_objects::SmartObject* vr_help = - &((*msg_vr)[am::strings::msg_params][am::strings::vr_help]); - const smart_objects::SmartObject* vr_help_prompt = - &((*msg_vr)[am::strings::msg_params][am::strings::help_prompt]); + const smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared( + (*msg_vr)[am::strings::msg_params][am::strings::vr_help_title]); + const smart_objects::SmartObjectSPtr vr_help = std::make_shared( + (*msg_vr)[am::strings::msg_params][am::strings::vr_help]); + const smart_objects::SmartObjectSPtr vr_help_prompt = + std::make_shared( + (*msg_vr)[am::strings::msg_params][am::strings::help_prompt]); ON_CALL(*mock_app_, vr_help_title()).WillByDefault(Return(vr_help_title)); ON_CALL(*mock_app_, vr_help()).WillByDefault(Return(vr_help)); ON_CALL(*mock_app_, help_prompt()).WillByDefault(Return(vr_help_prompt)); @@ -606,31 +613,37 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRNoMenuAndKeyboard_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); - EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( @@ -656,31 +669,37 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_Menu_WARNINGS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::WARNINGS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); - EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(*mock_app_, help_prompt_manager()) .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); @@ -704,31 +723,37 @@ TEST_F(SetGlobalPropertiesRequestTest, TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_VR_WARNINGS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::WARNINGS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); - EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(*mock_app_, help_prompt_manager()) .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); @@ -772,25 +797,28 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenVRHelp_Canceled) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::ABORTED))); EmptyExpectationsSetupHelper(); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); @@ -809,16 +837,19 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRIncorrectSyntax_Canceled) { MessageSharedPtr msg = CreateMsgParams(); (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId; - SmartObject vr_help_title("wrong syntax string\\n"); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("wrong syntax string\\n"); SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); EmptyExpectationsSetupHelper(); @@ -869,15 +900,18 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRMissingArray_Canceled) { TEST_F(SetGlobalPropertiesRequestTest, Run_VRWrongOrder_Canceled) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); - vr_help_array[1] = SmartObject(smart_objects::SmartType_Map); - vr_help_array[1][am::strings::text] = "two"; - vr_help_array[1][am::strings::position] = 3u; - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + (*vr_help_array)[1] = SmartObject(smart_objects::SmartType_Map); + (*vr_help_array)[1][am::strings::text] = "two"; + (*vr_help_array)[1][am::strings::position] = 3u; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); EmptyExpectationsSetupHelper(); @@ -890,9 +924,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWrongOrder_Canceled) { TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; @@ -902,7 +937,9 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); - EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( @@ -921,15 +958,19 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); std::shared_ptr command( @@ -951,6 +992,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) { EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); EXPECT_CALL(*mock_app_, set_keyboard_props(_)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); EXPECT_CALL(*mock_app_, app_id()); EXPECT_CALL( @@ -980,6 +1023,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) { EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( mock_hmi_interfaces_, @@ -1014,6 +1059,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( mock_hmi_interfaces_, @@ -1030,25 +1077,28 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject help_prompt(smart_objects::SmartType_Array); - help_prompt[0][am::strings::text] = "Help_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; - SmartObject timeout_prompt(smart_objects::SmartType_Array); - timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + smart_objects::SmartObjectSPtr help_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*help_prompt)[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = *help_prompt; + smart_objects::SmartObjectSPtr timeout_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*timeout_prompt)[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = + *timeout_prompt; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*help_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*timeout_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); - EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); - EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); - EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, set_help_prompt(*help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(*timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(timeout_prompt)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( @@ -1072,18 +1122,19 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject help_prompt(smart_objects::SmartType_Array); - help_prompt[0][am::strings::text] = "Help_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; + smart_objects::SmartObjectSPtr help_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*help_prompt)[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = *help_prompt; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*help_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); - EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); + EXPECT_CALL(*mock_app_, set_help_prompt(*help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(help_prompt)); EXPECT_CALL(*mock_app_, set_timeout_prompt(_)).Times(0); EXPECT_CALL(*mock_app_, timeout_prompt()).Times(0); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); @@ -1106,20 +1157,22 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) { TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject timeout_prompt(smart_objects::SmartType_Array); - timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + smart_objects::SmartObjectSPtr timeout_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*timeout_prompt)[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = + *timeout_prompt; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*timeout_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); EXPECT_CALL(*mock_app_, set_help_prompt(_)).Times(0); EXPECT_CALL(*mock_app_, help_prompt()).Times(0); - EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); - EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(*timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(timeout_prompt)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( mock_hmi_interfaces_, @@ -1335,11 +1388,12 @@ TEST_F(SetGlobalPropertiesRequestTest, ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_request::keyboard_layout] = + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_request::keyboard_layout] = hmi_apis::Common_KeyboardLayout::QWERTZ; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillOnce(Return(&saved_keyboard_props)); + .WillOnce(Return(saved_keyboard_props)); const int num_allowed_keys = 0; auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( @@ -1371,6 +1425,9 @@ TEST_F(SetGlobalPropertiesRequestTest, std::shared_ptr command( CreateCommand(msg)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); + ExpectInvalidData(); command->Run(); @@ -1421,6 +1478,8 @@ TEST_F(SetGlobalPropertiesRequestTest, CreateCommand(msg)); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); command->Run(); } @@ -1433,11 +1492,12 @@ TEST_F( ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_request::keyboard_layout] = + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_request::keyboard_layout] = hmi_apis::Common_KeyboardLayout::QWERTZ; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); const int num_allowed_keys = 3; auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( @@ -1472,6 +1532,8 @@ TEST_F( .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, display_capabilities()) .WillByDefault(Return(display_capabilities)); + ON_CALL(*mock_app_, keyboard_props()) + .WillByDefault(Return(std::shared_ptr())); std::shared_ptr command( CreateCommand(msg)); @@ -1494,6 +1556,8 @@ TEST_F(SetGlobalPropertiesRequestTest, CreateCommand(msg)); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); command->Run(); } @@ -1504,11 +1568,12 @@ TEST_F(SetGlobalPropertiesRequestTest, ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_response::language] = + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_response::language] = hmi_apis::Common_Language::EN_GB; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); std::shared_ptr command( CreateCommand(msg)); @@ -1534,6 +1599,8 @@ TEST_F(SetGlobalPropertiesRequestTest, CreateCommand(msg)); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(std::shared_ptr())); command->Run(); } @@ -1545,11 +1612,12 @@ TEST_F( ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_request::mask_input_characters] = + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_request::mask_input_characters] = hmi_apis::Common_KeyboardInputMask::USER_CHOICE_INPUT_KEY_MASK; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); std::shared_ptr command( CreateCommand(msg)); @@ -1569,14 +1637,16 @@ TEST_F(SetGlobalPropertiesRequestTest, ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); SmartObject autocomplete_list(smart_objects::SmartType_Array); autocomplete_list[0] = "first"; autocomplete_list[1] = "second"; - saved_keyboard_props[am::hmi_request::auto_complete_list] = autocomplete_list; + (*saved_keyboard_props)[am::hmi_request::auto_complete_list] = + autocomplete_list; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); std::shared_ptr command( CreateCommand(msg)); @@ -1607,10 +1677,11 @@ TEST_F( SmartObject old_list(smart_objects::SmartType_Array); old_list[0] = "old_value"; old_list[1] = "another_old_value"; - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_request::auto_complete_list] = old_list; + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_request::auto_complete_list] = old_list; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); std::shared_ptr command( CreateCommand(msg)); @@ -1635,10 +1706,11 @@ TEST_F( SmartObject old_list(smart_objects::SmartType_Array); old_list[0] = "old_value"; old_list[1] = "another_old_value"; - auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); - saved_keyboard_props[am::hmi_request::auto_complete_list] = old_list; + auto saved_keyboard_props = + std::make_shared(smart_objects::SmartType_Map); + (*saved_keyboard_props)[am::hmi_request::auto_complete_list] = old_list; EXPECT_CALL(*mock_app_, keyboard_props()) - .WillRepeatedly(Return(&saved_keyboard_props)); + .WillRepeatedly(Return(saved_keyboard_props)); std::shared_ptr command( CreateCommand(msg)); diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index 7e5eaf43a00..4d2ec307191 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -67,34 +67,14 @@ InitialApplicationDataImpl::InitialApplicationDataImpl() , language_(mobile_api::Language::INVALID_ENUM) , ui_language_(mobile_api::Language::INVALID_ENUM) {} -InitialApplicationDataImpl::~InitialApplicationDataImpl() { - if (app_types_) { - delete app_types_; - app_types_ = NULL; - } - - if (vr_synonyms_) { - delete vr_synonyms_; - vr_synonyms_ = NULL; - } +InitialApplicationDataImpl::~InitialApplicationDataImpl() {} - if (tts_name_) { - delete tts_name_; - tts_name_ = NULL; - } - - if (ngn_media_screen_name_) { - delete ngn_media_screen_name_; - ngn_media_screen_name_ = NULL; - } -} - -const smart_objects::SmartObject* InitialApplicationDataImpl::app_types() +const smart_objects::SmartObjectSPtr InitialApplicationDataImpl::app_types() const { return app_types_; } -const smart_objects::SmartObject* InitialApplicationDataImpl::vr_synonyms() +const smart_objects::SmartObjectSPtr InitialApplicationDataImpl::vr_synonyms() const { return vr_synonyms_; } @@ -103,11 +83,12 @@ std::string InitialApplicationDataImpl::policy_app_id() const { return mobile_app_id_; } -const smart_objects::SmartObject* InitialApplicationDataImpl::tts_name() const { +const smart_objects::SmartObjectSPtr InitialApplicationDataImpl::tts_name() + const { return tts_name_; } -const smart_objects::SmartObject* +const smart_objects::SmartObjectSPtr InitialApplicationDataImpl::ngn_media_screen_name() const { return ngn_media_screen_name_; } @@ -128,19 +109,12 @@ const utils::SemanticVersion& InitialApplicationDataImpl::msg_version() const { void InitialApplicationDataImpl::set_app_types( const smart_objects::SmartObject& app_types) { - if (app_types_) { - delete app_types_; - } - - app_types_ = new smart_objects::SmartObject(app_types); + app_types_.reset(new smart_objects::SmartObject(app_types)); } void InitialApplicationDataImpl::set_vr_synonyms( const smart_objects::SmartObject& vr_synonyms) { - if (vr_synonyms_) { - delete vr_synonyms_; - } - vr_synonyms_ = new smart_objects::SmartObject(vr_synonyms); + vr_synonyms_.reset(new smart_objects::SmartObject(vr_synonyms)); } void InitialApplicationDataImpl::set_mobile_app_id( @@ -150,20 +124,12 @@ void InitialApplicationDataImpl::set_mobile_app_id( void InitialApplicationDataImpl::set_tts_name( const smart_objects::SmartObject& tts_name) { - if (tts_name_) { - delete tts_name_; - } - - tts_name_ = new smart_objects::SmartObject(tts_name); + tts_name_.reset(new smart_objects::SmartObject(tts_name)); } void InitialApplicationDataImpl::set_ngn_media_screen_name( const smart_objects::SmartObject& ngn_name) { - if (ngn_media_screen_name_) { - delete ngn_media_screen_name_; - } - - ngn_media_screen_name_ = new smart_objects::SmartObject(ngn_name); + ngn_media_screen_name_.reset(new smart_objects::SmartObject(ngn_name)); } void InitialApplicationDataImpl::set_language( @@ -192,17 +158,7 @@ InitialApplicationDataImpl::perform_interaction_layout() const { } DynamicApplicationDataImpl::DynamicApplicationDataImpl() - : help_prompt_(nullptr) - , timeout_prompt_(nullptr) - , vr_help_title_(nullptr) - , vr_help_(nullptr) - , tbt_state_(mobile_api::TBTState::INVALID_ENUM) - , show_command_(nullptr) - , keyboard_props_(nullptr) - , menu_title_(nullptr) - , menu_icon_(nullptr) - , menu_layout_(nullptr) - , tbt_show_command_(nullptr) + : tbt_state_(mobile_api::TBTState::INVALID_ENUM) , commands_() , commands_lock_ptr_(std::make_shared()) , sub_menu_() @@ -222,51 +178,6 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , display_capabilities_builder_(*this) {} DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { - if (help_prompt_) { - delete help_prompt_; - help_prompt_ = NULL; - } - - if (timeout_prompt_) { - delete timeout_prompt_; - timeout_prompt_ = NULL; - } - - if (vr_help_title_) { - delete vr_help_title_; - vr_help_title_ = NULL; - } - - if (vr_help_) { - delete vr_help_; - vr_help_ = NULL; - } - - if (show_command_) { - delete show_command_; - show_command_ = NULL; - } - - if (keyboard_props_) { - delete keyboard_props_; - keyboard_props_ = NULL; - } - - if (menu_title_) { - delete menu_title_; - menu_title_ = NULL; - } - - if (menu_icon_) { - delete menu_icon_; - menu_icon_ = NULL; - } - - if (tbt_show_command_) { - delete tbt_show_command_; - tbt_show_command_ = NULL; - } - for (CommandsMap::iterator command_it = commands_.begin(); commands_.end() != command_it; ++command_it) { @@ -301,22 +212,23 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { window_params_map_.clear(); } -const smart_objects::SmartObject* DynamicApplicationDataImpl::help_prompt() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::help_prompt() const { return help_prompt_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::timeout_prompt() - const { +const smart_objects::SmartObjectSPtr +DynamicApplicationDataImpl::timeout_prompt() const { return timeout_prompt_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::vr_help_title() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::vr_help_title() const { return vr_help_title_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::vr_help() const { +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::vr_help() + const { return vr_help_; } @@ -325,32 +237,32 @@ const mobile_api::TBTState::eType& DynamicApplicationDataImpl::tbt_state() return tbt_state_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::show_command() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::show_command() const { return show_command_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::tbt_show_command() - const { +const smart_objects::SmartObjectSPtr +DynamicApplicationDataImpl::tbt_show_command() const { return tbt_show_command_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::keyboard_props() - const { +const smart_objects::SmartObjectSPtr +DynamicApplicationDataImpl::keyboard_props() const { return keyboard_props_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_title() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::menu_title() const { return menu_title_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::menu_icon() const { return menu_icon_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_layout() +const smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::menu_layout() const { return menu_layout_; } @@ -479,48 +391,30 @@ void DynamicApplicationDataImpl::load_global_properties( void DynamicApplicationDataImpl::set_help_prompt( const smart_objects::SmartObject& help_prompt) { - if (help_prompt_) { - delete help_prompt_; - } - help_prompt_ = new smart_objects::SmartObject(help_prompt); + help_prompt_.reset(new smart_objects::SmartObject(help_prompt)); } void DynamicApplicationDataImpl::set_timeout_prompt( const smart_objects::SmartObject& timeout_prompt) { - if (timeout_prompt_) { - delete timeout_prompt_; - } - timeout_prompt_ = new smart_objects::SmartObject(timeout_prompt); + timeout_prompt_.reset(new smart_objects::SmartObject(timeout_prompt)); } void DynamicApplicationDataImpl::set_vr_help_title( const smart_objects::SmartObject& vr_help_title) { - if (vr_help_title_) { - delete vr_help_title_; - } - vr_help_title_ = new smart_objects::SmartObject(vr_help_title); + vr_help_title_.reset(new smart_objects::SmartObject(vr_help_title)); } void DynamicApplicationDataImpl::reset_vr_help_title() { - if (vr_help_title_) { - delete vr_help_title_; - vr_help_title_ = NULL; - } + vr_help_title_.reset(); } void DynamicApplicationDataImpl::set_vr_help( const smart_objects::SmartObject& vr_help) { - if (vr_help_) { - delete vr_help_; - } - vr_help_ = new smart_objects::SmartObject(vr_help); + vr_help_.reset(new smart_objects::SmartObject(vr_help)); } void DynamicApplicationDataImpl::reset_vr_help() { - if (vr_help_) { - delete vr_help_; - } - vr_help_ = NULL; + vr_help_.reset(); } void DynamicApplicationDataImpl::set_tbt_state( @@ -530,50 +424,32 @@ void DynamicApplicationDataImpl::set_tbt_state( void DynamicApplicationDataImpl::set_show_command( const smart_objects::SmartObject& show_command) { - if (show_command_) { - delete show_command_; - } - show_command_ = new smart_objects::SmartObject(show_command); + show_command_.reset(new smart_objects::SmartObject(show_command)); } void DynamicApplicationDataImpl::set_tbt_show_command( const smart_objects::SmartObject& tbt_show) { - if (tbt_show_command_) { - delete tbt_show_command_; - } - tbt_show_command_ = new smart_objects::SmartObject(tbt_show); + tbt_show_command_.reset(new smart_objects::SmartObject(tbt_show)); } void DynamicApplicationDataImpl::set_keyboard_props( const smart_objects::SmartObject& keyboard_props) { - if (keyboard_props_) { - delete keyboard_props_; - } - keyboard_props_ = new smart_objects::SmartObject(keyboard_props); + keyboard_props_.reset(new smart_objects::SmartObject(keyboard_props)); } void DynamicApplicationDataImpl::set_menu_title( const smart_objects::SmartObject& menu_title) { - if (menu_title_) { - delete menu_title_; - } - menu_title_ = new smart_objects::SmartObject(menu_title); + menu_title_.reset(new smart_objects::SmartObject(menu_title)); } void DynamicApplicationDataImpl::set_menu_icon( const smart_objects::SmartObject& menu_icon) { - if (menu_icon_) { - delete menu_icon_; - } - menu_icon_ = new smart_objects::SmartObject(menu_icon); + menu_icon_.reset(new smart_objects::SmartObject(menu_icon)); } void DynamicApplicationDataImpl::set_menu_layout( const smart_objects::SmartObject& menu_layout) { - if (menu_layout_) { - delete menu_layout_; - } - menu_layout_ = new smart_objects::SmartObject(menu_layout); + menu_layout_.reset(new smart_objects::SmartObject(menu_layout)); } void DynamicApplicationDataImpl::set_day_color_scheme( diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index acf174eb395..ec37e3b51f1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1856,8 +1856,9 @@ bool ApplicationManagerImpl::CheckResumptionRequiredTransportAvailable( const std::string secondary_transport_type = GetTransportTypeProfileString(application->secondary_device()); - const smart_objects::SmartObject* app_types_array = application->app_types(); - if (app_types_array == NULL || app_types_array->length() == 0) { + const smart_objects::SmartObjectSPtr app_types_array = + application->app_types(); + if (!app_types_array || app_types_array->length() == 0) { // This app does not have any AppHMIType. In this case, check "EMPTY_APP" // entry std::map >::const_iterator it = @@ -4493,7 +4494,7 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( std::vector hmi_types_from_policy; smart_objects::SmartObject transform_app_hmi_types( smart_objects::SmartType_Array); - bool flag_diffirence_app_hmi_type; + bool flag_difference_app_hmi_type; DataAccessor accessor(applications()); for (ApplicationSetIt it = accessor.GetData().begin(); it != accessor.GetData().end(); @@ -4516,19 +4517,18 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( } ApplicationConstSharedPtr app = *it; - const smart_objects::SmartObject* save_application_hmi_type = + const smart_objects::SmartObjectSPtr save_application_hmi_type = app->app_types(); - if (save_application_hmi_type == NULL || - ((*save_application_hmi_type).length() != - transform_app_hmi_types.length())) { - flag_diffirence_app_hmi_type = true; + if (!save_application_hmi_type || (save_application_hmi_type->length() != + transform_app_hmi_types.length())) { + flag_difference_app_hmi_type = true; } else { - flag_diffirence_app_hmi_type = !(CompareAppHMIType( + flag_difference_app_hmi_type = !(CompareAppHMIType( transform_app_hmi_types, *save_application_hmi_type)); } - if (flag_diffirence_app_hmi_type) { + if (flag_difference_app_hmi_type) { ApplicationSharedPtr app = *it; app->set_app_types(transform_app_hmi_types); 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 0a9d8af9da9..2e60bb2c66f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -801,8 +801,8 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, { SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); - msg_params[strings::help_prompt] = application->help_prompt(); - msg_params[strings::timeout_prompt] = application->timeout_prompt(); + msg_params[strings::help_prompt] = *(application->help_prompt()); + msg_params[strings::timeout_prompt] = *(application->timeout_prompt()); msg_params[strings::app_id] = application->app_id(); SmartObjectSPtr message = CreateMessageForHMI( @@ -1417,7 +1417,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp( smart_objects::SmartType_Map); smart_objects::SmartObject& vr_help = *result; - const smart_objects::SmartObject* vr_help_title = app->vr_help_title(); + const smart_objects::SmartObjectSPtr vr_help_title = app->vr_help_title(); if (vr_help_title) { vr_help[strings::vr_help_title] = vr_help_title->asString(); } @@ -1646,7 +1646,7 @@ void MessageHelper::SendUIChangeRegistrationRequestToHMI( CreateChangeRegistration(hmi_apis::FunctionID::UI_ChangeRegistration, app->ui_language(), app->app_id(), - app->app_types(), + app->app_types().get(), app_mngr); if (ui_command) { @@ -1823,8 +1823,8 @@ bool MessageHelper::CreateHMIApplicationStruct( return false; } - const smart_objects::SmartObject* app_types = app->app_types(); - const smart_objects::SmartObject* ngn_media_screen_name = + const smart_objects::SmartObjectSPtr app_types = app->app_types(); + const smart_objects::SmartObjectSPtr ngn_media_screen_name = app->ngn_media_screen_name(); const smart_objects::SmartObject day_color_scheme = app->day_color_scheme(); const smart_objects::SmartObject night_color_scheme = diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index c72231d334d..50b95dba427 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -250,10 +250,10 @@ smart_objects::SmartObject ResumptionData::CreateWindowInfoSO( } smart_objects::SmartObject ResumptionData::PointerToSmartObj( - const smart_objects::SmartObject* ptr) const { + const smart_objects::SmartObjectSPtr ptr) const { SDL_LOG_AUTO_TRACE(); smart_objects::SmartObject temp; - if (ptr != NULL) { + if (ptr) { temp = *ptr; } return temp; 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 48ba75275bf..539bc39eb20 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -29,8 +29,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/application_manager_impl.h" + #include #include + #include #include #include @@ -38,7 +41,6 @@ #include "application_manager/application.h" #include "application_manager/application_impl.h" -#include "application_manager/application_manager_impl.h" #include "application_manager/hmi_state.h" #include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_application.h" @@ -51,6 +53,7 @@ #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler.h" +#include "encryption/hashing.h" #include "gtest/gtest.h" #include "hmi_message_handler/mock_hmi_message_handler.h" #include "media_manager/mock_media_manager.h" @@ -65,8 +68,6 @@ #include "utils/file_system.h" #include "utils/lock.h" -#include "encryption/hashing.h" - namespace test { namespace components { namespace application_manager_test { @@ -324,7 +325,7 @@ class ApplicationManagerImplTest : public ::testing::Test { } bool CheckResumptionRequiredTransportAvailableTest( - smart_objects::SmartObject* app_types_array, + smart_objects::SmartObjectSPtr app_types_array, connection_handler::DeviceHandle primary_device_handle, std::string primary_transport_device_string, connection_handler::DeviceHandle secondary_device_handle, @@ -1402,7 +1403,7 @@ static std::map > CreateTransportMap() { } bool ApplicationManagerImplTest::CheckResumptionRequiredTransportAvailableTest( - smart_objects::SmartObject* app_types_array, + smart_objects::SmartObjectSPtr app_types_array, connection_handler::DeviceHandle primary_device_handle, std::string primary_transport_device_string, connection_handler::DeviceHandle secondary_device_handle, @@ -1446,8 +1447,9 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_PrimaryOnly_Success) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::DEFAULT; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::DEFAULT; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 0; @@ -1462,7 +1464,7 @@ TEST_F(ApplicationManagerImplTest, // - We have SPP_BLUETOOTH for primary transport. // -> Conclusion: the app has required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1474,8 +1476,9 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_PrimaryOnly_NotListed) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::SOCIAL; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::SOCIAL; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 0; @@ -1487,7 +1490,7 @@ TEST_F(ApplicationManagerImplTest, // - We do not have an entry in .ini file for SOCIAL apps. // -> In this case, resumption is always enabled for backward compatibility. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1499,8 +1502,9 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_PrimaryOnly_Disabled) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::TESTING; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::TESTING; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 0; @@ -1512,7 +1516,7 @@ TEST_F(ApplicationManagerImplTest, // - We do not have any transports allowed for TESTING apps. // -> In this case, resumption is always disabled. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1524,7 +1528,8 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_PrimaryOnly_NoAppTypes) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); // we don't specify any app type const connection_handler::DeviceHandle primary_device_handle = 1; @@ -1537,7 +1542,7 @@ TEST_F(ApplicationManagerImplTest, // - .ini file specifies TCP_WIFI for EMPTY_APP entry. // -> The app does not have required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1571,8 +1576,9 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_TwoTransports_Success) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::MEDIA; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::MEDIA; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 2; @@ -1587,7 +1593,7 @@ TEST_F(ApplicationManagerImplTest, // - We have TCP_WIFI for secondary transport. // -> Conclusion: the app has required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1599,8 +1605,9 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_TwoTransports_Failure) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::NAVIGATION; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::NAVIGATION; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 2; @@ -1615,7 +1622,7 @@ TEST_F(ApplicationManagerImplTest, // - We have IAP_USB for primary and TCP_WIFI for secondary transport. // -> Conclusion: the app does not have required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1627,9 +1634,10 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_MultipleAppTypes_Failure) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::MEDIA; - app_types_array[1] = mobile_apis::AppHMIType::eType::NAVIGATION; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::MEDIA; + (*app_types_array)[1] = mobile_apis::AppHMIType::eType::NAVIGATION; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 2; @@ -1645,7 +1653,7 @@ TEST_F(ApplicationManagerImplTest, // - We have IAP_USB for primary and TCP_WIFI is secondary // -> Conclusion: the app does NOT have required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, @@ -1657,9 +1665,10 @@ TEST_F(ApplicationManagerImplTest, CheckResumptionRequiredTransportAvailableTest_MultipleAppTypes_Empty) { using namespace ns_smart_device_link::ns_smart_objects; - smart_objects::SmartObject app_types_array(SmartType_Array); - app_types_array[0] = mobile_apis::AppHMIType::eType::NAVIGATION; - app_types_array[1] = mobile_apis::AppHMIType::eType::SYSTEM; + smart_objects::SmartObjectSPtr app_types_array = + std::make_shared(SmartType_Array); + (*app_types_array)[0] = mobile_apis::AppHMIType::eType::NAVIGATION; + (*app_types_array)[1] = mobile_apis::AppHMIType::eType::SYSTEM; const connection_handler::DeviceHandle primary_device_handle = 1; const connection_handler::DeviceHandle secondary_device_handle = 2; @@ -1675,7 +1684,7 @@ TEST_F(ApplicationManagerImplTest, // - We have SPP_BLUETOOTH for primary and TCP_WIFI is secondary // -> Conclusion: the app does NOT have required transport. bool result = CheckResumptionRequiredTransportAvailableTest( - &app_types_array, + app_types_array, primary_device_handle, primary_transport_device_string, secondary_device_handle, diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc index d9fb0b82d95..5cb4204cbfd 100644 --- a/src/components/application_manager/test/help_prompt_manager_test.cc +++ b/src/components/application_manager/test/help_prompt_manager_test.cc @@ -121,8 +121,8 @@ class HelpPromptManagerTest : public ::testing::Test { void TearDown() OVERRIDE; MessageSharedPtr CreateMsgParams(); void VRArraySetupHelper(MessageSharedPtr msg, - SmartObject& vr_help_title, - SmartObject& vr_help_array); + smart_objects::SmartObjectSPtr vr_help_title, + smart_objects::SmartObjectSPtr vr_help_array); void CreateBasicParamsVRRequest(MessageSharedPtr msg); void CreateApplication(MockHelpPromptManager& mock_help_prompt_manager); HmiStatePtr CreateTestHmiState(); @@ -203,14 +203,15 @@ MessageSharedPtr HelpPromptManagerTest::CreateMsgParams() { return msg; } -void HelpPromptManagerTest::VRArraySetupHelper(MessageSharedPtr msg, - SmartObject& vr_help_title, - SmartObject& vr_help_array) { - (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; - vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); - vr_help_array[0][am::strings::text] = kText; - vr_help_array[0][am::strings::position] = kPosition; - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; +void HelpPromptManagerTest::VRArraySetupHelper( + MessageSharedPtr msg, + smart_objects::SmartObjectSPtr vr_help_title, + smart_objects::SmartObjectSPtr vr_help_array) { + (*msg)[am::strings::msg_params][am::strings::vr_help_title] = *vr_help_title; + (*vr_help_array)[0] = SmartObject(smart_objects::SmartType_Map); + (*vr_help_array)[0][am::strings::text] = kText; + (*vr_help_array)[0][am::strings::position] = kPosition; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; } void HelpPromptManagerTest::CreateBasicParamsVRRequest(MessageSharedPtr msg) { @@ -284,17 +285,20 @@ TEST_F(HelpPromptManagerTest, RemoveCommand_OnVrCommandDeleted) { TEST_F(HelpPromptManagerTest, Request_OnSetGlobalPropertiesReceived_TTS_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject help_prompt(smart_objects::SmartType_Array); - help_prompt[0][am::strings::text] = "Help_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; - SmartObject timeout_prompt(smart_objects::SmartType_Array); - timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; - (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + smart_objects::SmartObjectSPtr help_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*help_prompt)[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = *help_prompt; + smart_objects::SmartObjectSPtr timeout_prompt = + std::make_shared(smart_objects::SmartType_Array); + (*timeout_prompt)[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = + *timeout_prompt; EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*help_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(*timeout_prompt, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) @@ -302,10 +306,10 @@ TEST_F(HelpPromptManagerTest, EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); - EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); - EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); - EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); - EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, set_help_prompt(*help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(*timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(timeout_prompt)); EXPECT_CALL( mock_hmi_interfaces_, GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) @@ -325,34 +329,40 @@ TEST_F(HelpPromptManagerTest, TEST_F(HelpPromptManagerTest, Request_OnSetGlobalPropertiesReceived_UI_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - SmartObject vr_help_title("yes"); - SmartObject vr_help_array(smart_objects::SmartType_Array); + smart_objects::SmartObjectSPtr vr_help_title = + std::make_shared("yes"); + smart_objects::SmartObjectSPtr vr_help_array = + std::make_shared(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); - (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + (*msg)[am::strings::msg_params][am::strings::vr_help] = *vr_help_array; SmartObject menu_title("Menu_Title"); (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; SmartObject menu_icon(smart_objects::SmartType_Map); menu_icon[am::strings::value] = "1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; - SmartObject keyboard_properties(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr keyboard_properties = + std::make_shared(smart_objects::SmartType_Map); (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = - keyboard_properties; + *keyboard_properties; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); - EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(*vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); - EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); - EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); - EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(*vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(*vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(vr_help_array)); EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); - EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, set_keyboard_props(*keyboard_properties)); + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL( mock_hmi_interfaces_, diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 93755ef8f48..e94ffa5961f 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -217,12 +217,12 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(IsVideoApplication, bool()); MOCK_METHOD0(LoadPersistentFiles, void()); // InitialApplicationData methods - MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(vr_synonyms, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(vr_synonyms, const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0(policy_app_id, std::string()); - MOCK_CONST_METHOD0(tts_name, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(tts_name, const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0(ngn_media_screen_name, - const smart_objects::SmartObject*()); + const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0(language, const mobile_apis::Language::eType&()); MOCK_CONST_METHOD0(ui_language, const mobile_apis::Language::eType&()); MOCK_CONST_METHOD0(msg_version, const utils::SemanticVersion&()); @@ -240,20 +240,20 @@ class MockApplication : public ::application_manager::Application { void(const mobile_apis::Language::eType& ui_language)); MOCK_METHOD1(set_msg_version, void(const utils::SemanticVersion& version)); // DynamicApplicationData methods - MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(vr_help_title, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(vr_help, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(vr_help_title, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(vr_help, const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0(tbt_state, const mobile_apis::TBTState::eType&()); - MOCK_CONST_METHOD0(show_command, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(tbt_show_command, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(show_command, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(tbt_show_command, const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0( SubscribedButtons, DataAccessor< ::application_manager::ButtonSubscriptions>()); - MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(menu_layout, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD0(menu_layout, const smart_objects::SmartObjectSPtr()); MOCK_CONST_METHOD0(day_color_scheme, smart_objects::SmartObject()); MOCK_CONST_METHOD0(night_color_scheme, smart_objects::SmartObject()); MOCK_CONST_METHOD0(display_layout, std::string()); diff --git a/src/components/application_manager/test/include/application_manager/resumption_data_test.h b/src/components/application_manager/test/include/application_manager/resumption_data_test.h index 0596b4e500e..bea920e44e4 100644 --- a/src/components/application_manager/test/include/application_manager/resumption_data_test.h +++ b/src/components/application_manager/test/include/application_manager/resumption_data_test.h @@ -63,15 +63,7 @@ using namespace mobile_apis; class ResumptionDataTest : public ::testing::Test { protected: ResumptionDataTest() - : help_prompt_(NULL) - , timeout_prompt_(NULL) - , vr_help_(NULL) - , vr_help_title_(NULL) - , vr_synonyms_(NULL) - , keyboard_props_(NULL) - , menu_title_(NULL) - , menu_icon_(NULL) - , kCountOfCommands_(5u) + : kCountOfCommands_(5u) , kCountOfChoice_(2u) , kCountOfChoiceSets_(4u) , kCountOfSubmenues_(3u) @@ -106,14 +98,15 @@ class ResumptionDataTest : public ::testing::Test { bool is_audio_; const connection_handler::DeviceHandle device_handle_ = 10; - sm::SmartObject* help_prompt_; - sm::SmartObject* timeout_prompt_; - sm::SmartObject* vr_help_; - sm::SmartObject* vr_help_title_; - sm::SmartObject* vr_synonyms_; - sm::SmartObject* keyboard_props_; - sm::SmartObject* menu_title_; - sm::SmartObject* menu_icon_; + sm::SmartObjectSPtr help_prompt_; + sm::SmartObjectSPtr timeout_prompt_; + sm::SmartObjectSPtr vr_help_; + sm::SmartObjectSPtr vr_help_title_; + sm::SmartObjectSPtr vr_synonyms_; + sm::SmartObjectSPtr keyboard_props_; + sm::SmartObjectSPtr menu_title_; + sm::SmartObjectSPtr menu_icon_; + sm::SmartObjectSPtr menu_layout_; void SetCommands(); void SetSubmenues(); @@ -121,7 +114,7 @@ class ResumptionDataTest : public ::testing::Test { void SetAppFiles(); void SetGlobalProporties(); void SetKeyboardProperties(); - void SetMenuTitleAndIcon(); + void SetMenuParams(); void SetHelpAndTimeoutPrompt(); void SetVRHelpTitle(); void SetSubscriptions(); @@ -137,6 +130,7 @@ class ResumptionDataTest : public ::testing::Test { void CheckKeyboardProperties(sm::SmartObject& res_list); void CheckMenuTitle(sm::SmartObject& res_list); void CheckMenuIcon(sm::SmartObject& res_list); + void CheckMenuLayout(sm::SmartObject& res_list); void CheckHelpPrompt(sm::SmartObject& res_list); void CheckTimeoutPrompt(sm::SmartObject& res_list); void CheckVRHelp( 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 4b36647a112..2dd6b511d46 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 @@ -156,10 +156,32 @@ TEST(MessageHelperTestCreate, CreateSetAppIcon_SendPathImagetype_Equal) { TEST(MessageHelperTestCreate, CreateGlobalPropertiesRequestsToHMI_SmartObject_EmptyList) { MockApplicationSharedPtr appSharedMock = std::make_shared(); - EXPECT_CALL(*appSharedMock, vr_help_title()).Times(AtLeast(1)); - EXPECT_CALL(*appSharedMock, vr_help()).Times(AtLeast(1)); - EXPECT_CALL(*appSharedMock, help_prompt()).Times(AtLeast(1)); - EXPECT_CALL(*appSharedMock, timeout_prompt()).Times(AtLeast(1)); + smart_objects::SmartObjectSPtr emptyObject = + std::shared_ptr(); + EXPECT_CALL(*appSharedMock, vr_help_title()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, vr_help()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, help_prompt()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, timeout_prompt()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, menu_title()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, menu_icon()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, menu_layout()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); + EXPECT_CALL(*appSharedMock, keyboard_props()) + .Times(AtLeast(1)) + .WillOnce(Return(emptyObject)); std::shared_ptr mock_help_prompt_manager = std::make_shared(); @@ -185,16 +207,23 @@ TEST(MessageHelperTestCreate, TEST(MessageHelperTestCreate, CreateGlobalPropertiesRequestsToHMI_SmartObject_NotEmpty) { MockApplicationSharedPtr appSharedMock = std::make_shared(); - smart_objects::SmartObjectSPtr objPtr = - std::make_shared(); - (*objPtr)[0][strings::vr_help_title] = "111"; - (*objPtr)[1][strings::vr_help] = "222"; - (*objPtr)[2][strings::keyboard_properties] = "333"; - (*objPtr)[3][strings::menu_title] = "444"; - (*objPtr)[4][strings::menu_icon] = "555"; - (*objPtr)[5][strings::help_prompt] = "666"; - (*objPtr)[6][strings::timeout_prompt] = "777"; + smart_objects::SmartObjectSPtr vrHelpTitle = + std::make_shared("111"); + smart_objects::SmartObjectSPtr vrHelp = + std::make_shared("222"); + smart_objects::SmartObjectSPtr keyboardProperties = + std::make_shared("333"); + smart_objects::SmartObjectSPtr menuTitle = + std::make_shared("444"); + smart_objects::SmartObjectSPtr menuIcon = + std::make_shared("555"); + smart_objects::SmartObjectSPtr helpPrompt = + std::make_shared("666"); + smart_objects::SmartObjectSPtr timeoutPrompt = + std::make_shared("777"); + smart_objects::SmartObjectSPtr menuLayout = + std::make_shared("888"); smart_objects::SmartObject user_loc = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -202,25 +231,28 @@ TEST(MessageHelperTestCreate, EXPECT_CALL(*appSharedMock, vr_help_title()) .Times(AtLeast(3)) - .WillRepeatedly(Return(&(*objPtr)[0])); + .WillRepeatedly(Return(vrHelpTitle)); EXPECT_CALL(*appSharedMock, vr_help()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&(*objPtr)[1])); + .WillRepeatedly(Return(vrHelp)); EXPECT_CALL(*appSharedMock, help_prompt()) .Times(AtLeast(3)) - .WillRepeatedly(Return(&(*objPtr)[5])); + .WillRepeatedly(Return(helpPrompt)); EXPECT_CALL(*appSharedMock, timeout_prompt()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&(*objPtr)[6])); + .WillRepeatedly(Return(timeoutPrompt)); EXPECT_CALL(*appSharedMock, keyboard_props()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&(*objPtr)[2])); + .WillRepeatedly(Return(keyboardProperties)); EXPECT_CALL(*appSharedMock, menu_title()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&(*objPtr)[3])); + .WillRepeatedly(Return(menuTitle)); EXPECT_CALL(*appSharedMock, menu_icon()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&(*objPtr)[4])); + .WillRepeatedly(Return(menuIcon)); + EXPECT_CALL(*appSharedMock, menu_layout()) + .Times(AtLeast(2)) + .WillRepeatedly(Return(menuLayout)); EXPECT_CALL(*appSharedMock, app_id()).WillRepeatedly(Return(0)); EXPECT_CALL(*appSharedMock, get_user_location()) .WillRepeatedly(ReturnRef(user_loc)); @@ -242,14 +274,16 @@ TEST(MessageHelperTestCreate, smart_objects::SmartObject& first = *ptr[0]; smart_objects::SmartObject& second = *ptr[1]; - EXPECT_EQ((*objPtr)[0], first[strings::msg_params][strings::vr_help_title]); - EXPECT_EQ((*objPtr)[1], first[strings::msg_params][strings::vr_help]); - EXPECT_EQ((*objPtr)[2], + EXPECT_EQ(*vrHelpTitle, first[strings::msg_params][strings::vr_help_title]); + EXPECT_EQ(*vrHelp, first[strings::msg_params][strings::vr_help]); + EXPECT_EQ(*keyboardProperties, first[strings::msg_params][strings::keyboard_properties]); - EXPECT_EQ((*objPtr)[3], first[strings::msg_params][strings::menu_title]); - EXPECT_EQ((*objPtr)[4], first[strings::msg_params][strings::menu_icon]); - EXPECT_EQ((*objPtr)[5], second[strings::msg_params][strings::help_prompt]); - EXPECT_EQ((*objPtr)[6], second[strings::msg_params][strings::timeout_prompt]); + EXPECT_EQ(*menuTitle, first[strings::msg_params][strings::menu_title]); + EXPECT_EQ(*menuIcon, first[strings::msg_params][strings::menu_icon]); + EXPECT_EQ(*helpPrompt, second[strings::msg_params][strings::help_prompt]); + EXPECT_EQ(*timeoutPrompt, + second[strings::msg_params][strings::timeout_prompt]); + EXPECT_EQ(*menuLayout, first[strings::msg_params][strings::menu_layout]); } TEST(MessageHelperTestCreate, CreateShowRequestToHMI_SendSmartObject_Equal) { @@ -258,11 +292,9 @@ TEST(MessageHelperTestCreate, CreateShowRequestToHMI_SendSmartObject_Equal) { smart_objects::SmartObjectSPtr smartObjectPtr = std::make_shared(); - const smart_objects::SmartObject& object = *smartObjectPtr; - EXPECT_CALL(*appSharedMock, show_command()) .Times(AtLeast(2)) - .WillRepeatedly(Return(&object)); + .WillRepeatedly(Return(smartObjectPtr)); smart_objects::SmartObjectList ptr = MessageHelper::CreateShowRequestToHMI(appSharedMock, 0u); diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index a416cbbad52..cb5a4d9a569 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/resumption_data_test.h" + #include #include -#include "gtest/gtest.h" #include "application_manager/application.h" #include "application_manager/message_helper.h" #include "application_manager/mock_resumption_data.h" #include "application_manager/usage_statistics.h" +#include "gtest/gtest.h" #include "utils/custom_string.h" #include "utils/data_accessor.h" -#include "application_manager/resumption_data_test.h" - namespace test { namespace components { namespace resumption_test { @@ -53,15 +53,6 @@ using ::testing::ReturnPointee; using ::testing::ReturnRef; ResumptionDataTest::~ResumptionDataTest() { - delete help_prompt_; - delete timeout_prompt_; - delete vr_help_; - delete vr_help_title_; - delete vr_synonyms_; - delete keyboard_props_; - delete menu_title_; - delete menu_icon_; - for (am::CommandsMap::iterator it = test_commands_map.begin(); test_commands_map.end() != it; ++it) { @@ -266,6 +257,7 @@ void ResumptionDataTest::CheckGlobalProporties(sm::SmartObject& res_list) { CheckKeyboardProperties(res_list[am::strings::keyboard_properties]); CheckMenuTitle(res_list[am::strings::menu_title]); CheckMenuIcon(res_list[am::strings::menu_icon]); + CheckMenuLayout(res_list[am::strings::menu_layout]); } void ResumptionDataTest::CheckKeyboardProperties(sm::SmartObject& res_list) { @@ -317,6 +309,12 @@ void ResumptionDataTest::CheckMenuIcon(sm::SmartObject& res_list) { static_cast(res_list[am::strings::image_type].asInt())); } +void ResumptionDataTest::CheckMenuLayout(sm::SmartObject& res_list) { + MenuLayout::eType value = static_cast( + (*menu_layout_)[am::strings::menu_layout].asInt()); + EXPECT_EQ(value, res_list[am::strings::menu_layout].asInt()); +} + void ResumptionDataTest::CheckHelpPrompt(sm::SmartObject& res_list) { for (uint i = 0; i < tts_chunks_count; ++i) { std::string promt = (*help_prompt_)[i][am::strings::help_prompt].asString(); @@ -420,17 +418,15 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, sub_menu_map()).WillByDefault(Return(sub_menu_m)); ON_CALL(*app_mock, choice_set_map()).WillByDefault(Return(choice_set_m)); - ON_CALL(*app_mock, help_prompt()).WillByDefault(ReturnPointee(&help_prompt_)); - ON_CALL(*app_mock, timeout_prompt()) - .WillByDefault(ReturnPointee(&timeout_prompt_)); - ON_CALL(*app_mock, vr_help()).WillByDefault(ReturnPointee(&vr_help_)); - ON_CALL(*app_mock, vr_help_title()) - .WillByDefault(ReturnPointee(&vr_help_title_)); + ON_CALL(*app_mock, help_prompt()).WillByDefault(Return(help_prompt_)); + ON_CALL(*app_mock, timeout_prompt()).WillByDefault(Return(timeout_prompt_)); + ON_CALL(*app_mock, vr_help()).WillByDefault(Return(vr_help_)); + ON_CALL(*app_mock, vr_help_title()).WillByDefault(Return(vr_help_title_)); - ON_CALL(*app_mock, keyboard_props()) - .WillByDefault(ReturnPointee(&keyboard_props_)); - ON_CALL(*app_mock, menu_title()).WillByDefault(ReturnPointee(&menu_title_)); - ON_CALL(*app_mock, menu_icon()).WillByDefault(ReturnPointee(&menu_icon_)); + ON_CALL(*app_mock, keyboard_props()).WillByDefault(Return(keyboard_props_)); + ON_CALL(*app_mock, menu_title()).WillByDefault(Return(menu_title_)); + ON_CALL(*app_mock, menu_icon()).WillByDefault(Return(menu_icon_)); + ON_CALL(*app_mock, menu_layout()).WillByDefault(Return(menu_layout_)); ON_CALL(*app_mock, SubscribedButtons()).WillByDefault(Return(btn_sub)); @@ -456,12 +452,12 @@ void ResumptionDataTest::SetDefaultWindowIds() { void ResumptionDataTest::SetGlobalProporties() { SetKeyboardProperties(); - SetMenuTitleAndIcon(); + SetMenuParams(); SetHelpAndTimeoutPrompt(); SetVRHelpTitle(); } -void ResumptionDataTest::SetMenuTitleAndIcon() { +void ResumptionDataTest::SetMenuParams() { custom_str::CustomString icon_name("test icon"); sm::SmartObject sm_icon; sm_icon[am::strings::value] = "test icon"; @@ -470,8 +466,13 @@ void ResumptionDataTest::SetMenuTitleAndIcon() { sm::SmartObject sm_title; sm_title = "test title"; - menu_title_ = new sm::SmartObject(sm_title); - menu_icon_ = new sm::SmartObject(sm_icon); + + sm::SmartObject sm_layout; + sm_layout = MenuLayout::LIST; + + menu_title_ = std::make_shared(sm_title); + menu_icon_ = std::make_shared(sm_icon); + menu_layout_ = std::make_shared(sm_layout); } void ResumptionDataTest::SetHelpAndTimeoutPrompt() { @@ -484,7 +485,7 @@ void ResumptionDataTest::SetHelpAndTimeoutPrompt() { help_prompt[i][am::strings::text] = "help prompt name" + std::string(numb); help_prompt[i][am::strings::type] = SpeechCapabilities::PRE_RECORDED; } - help_prompt_ = new sm::SmartObject(help_prompt); + help_prompt_ = std::make_shared(help_prompt); for (uint i = 0; i < tts_chunks_count; ++i) { char numb[12]; std::snprintf(numb, 12, "%d", i); @@ -492,7 +493,7 @@ void ResumptionDataTest::SetHelpAndTimeoutPrompt() { timeout_prompt[i][am::strings::type] = SpeechCapabilities::SC_TEXT; } - timeout_prompt_ = new sm::SmartObject(timeout_prompt); + timeout_prompt_ = std::make_shared(timeout_prompt); } void ResumptionDataTest::SetVRHelpTitle() { @@ -507,8 +508,8 @@ void ResumptionDataTest::SetVRHelpTitle() { vr_help[i][am::strings::position] = i; } - vr_help_ = new sm::SmartObject(vr_help); - vr_help_title_ = new sm::SmartObject(vr_help_title); + vr_help_ = std::make_shared(vr_help); + vr_help_title_ = std::make_shared(vr_help_title); } void ResumptionDataTest::SetCommands() { @@ -618,7 +619,7 @@ void ResumptionDataTest::SetKeyboardProperties() { keyboard[am::strings::auto_complete_text] = "complete"; keyboard[am::strings::limited_character_list][0] = "y"; keyboard[am::strings::limited_character_list][1] = "n"; - keyboard_props_ = new sm::SmartObject(keyboard); + keyboard_props_ = std::make_shared(keyboard); } void ResumptionDataTest::SetSubscriptions() {