diff options
author | Collin <iCollin@users.noreply.github.com> | 2021-02-10 12:42:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 12:42:36 -0500 |
commit | 89278810d0e5657579457773f35be5aedb0eb29d (patch) | |
tree | 63628a467c280efec195b2877a805b43cc1695f0 | |
parent | 4d77cd72e8f761f9e5edb9a3230f2369b6721755 (diff) | |
download | sdl_core-89278810d0e5657579457773f35be5aedb0eb29d.tar.gz |
[SDL 0180] Broaden Choice Uniqueness (#3607)
* remove duplicate name error response from addcommand where the two command texts matched, remove unused CoincidencePredicateMenuName from cics, update add command unit test to check new functionality
* remove PerformInteractionRequest::CheckChoiceSetMenuNames
* fix ut style
* remove unused CICS CoincidencePredicates
* update rpc_spec to develop
* AddSubMenu can add duplicate menuName
* Revert "AddSubMenu can add duplicate menuName"
This reverts commit 0ec23309e10907e7e3889ca19058a5c02ce42192.
* remove DUPLICATE_NAME check and branch from AddSubMenu
* deprecate DynamicApplicationData::IsSubMenuNameAlreadyExist
8 files changed, 14 insertions, 190 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 2eb4501bcc..4a3dc473ed 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -374,8 +374,8 @@ class DynamicApplicationData { /* * @brief Returns true if sub menu with such name already exist */ - virtual bool IsSubMenuNameAlreadyExist(const std::string& name, - const uint32_t parent_id) = 0; + DEPRECATED virtual bool IsSubMenuNameAlreadyExist( + const std::string& name, const uint32_t parent_id) = 0; /* * @brief Adds a interaction choice set to the application diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h index 8cac0d686d..6ccd57947c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h @@ -91,16 +91,6 @@ class AddCommandRequest : public app_mngr::commands::CommandRequestImpl { private: /* - * @brief Check if command name doesn't exist in application - * Please see SDLAQ-CRS-407 for more information - * - * @param app Mobile application - * - * @return TRUE on success, otherwise FALSE - */ - bool CheckCommandName(app_mngr::ApplicationConstSharedPtr app); - - /* * @brief Check if command VR synonyms doesn't exist in application commands * Please see SDLAQ-CRS-407 for more information * diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index a1bc866347..aba2ce3be5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -162,56 +162,6 @@ class CreateInteractionChoiceSetRequest app_mngr::ApplicationConstSharedPtr app); /* - * @brief Predicate for using with CheckChoiceSet method to compare choice ID - *param - * - * return TRUE if there is coincidence of choice ID, otherwise FALSE - */ - struct CoincidencePredicateChoiceID { - CoincidencePredicateChoiceID(const uint32_t newItem) : newItem_(newItem) {} - - bool operator()(smart_objects::SmartObject obj) { - return obj[app_mngr::strings::choice_id].asUInt() == newItem_; - } - - const uint32_t newItem_; - }; - - /* - * @brief Predicate for using with CheckChoiceSet method to compare menu name - *param - * - * return TRUE if there is coincidence of menu name, otherwise FALSE - */ - struct CoincidencePredicateMenuName { - CoincidencePredicateMenuName(const std::string& newItem) - : newItem_(newItem) {} - - bool operator()(smart_objects::SmartObject obj) { - return obj[app_mngr::strings::menu_name].asString() == newItem_; - } - - const std::string& newItem_; - }; - - /* - * @brief Predicate for using with CheckChoiceSet method to compare VR - *commands param - * - * return TRUE if there is coincidence of VR commands, otherwise FALSE - */ - struct CoincidencePredicateVRCommands { - CoincidencePredicateVRCommands(const smart_objects::SmartObject& newItem) - : newItem_(newItem) {} - - bool operator()(smart_objects::SmartObject obj) { - return compareStr(obj, newItem_); - } - - const smart_objects::SmartObject& newItem_; - }; - - /* * @brief Checks if incoming choice set doesn't has similar VR synonyms. * * @param choice1 Choice to compare diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 9d14b248b6..88182a0b8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -162,16 +162,6 @@ class PerformInteractionRequest void SendUIShowVRHelpRequest(app_mngr::ApplicationSharedPtr const app); /* - * @brief Checks if incoming choice set doesn't has similar menu names. - * - * @param app_id Application ID - * - * return Return TRUE if there are no similar menu names in choice set, - * otherwise FALSE - */ - bool CheckChoiceSetMenuNames(app_mngr::ApplicationSharedPtr const app); - - /* * @brief Checks if incoming choice set doesn't has similar VR synonyms. * * @param app_id Application ID diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index 6717f332f8..7460197904 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -127,10 +127,6 @@ void AddCommandRequest::Run() { bool data_exist = false; if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { - if (!CheckCommandName(app)) { - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); - return; - } if (((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) && (0 != (*message_)[strings::msg_params][strings::menu_params] @@ -220,47 +216,6 @@ void AddCommandRequest::Run() { } } -bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { - if (!app) { - return false; - } - - const DataAccessor<CommandsMap> accessor = app->commands_map(); - const CommandsMap& commands = accessor.GetData(); - CommandsMap::const_iterator i = commands.begin(); - uint32_t saved_parent_id = 0; - uint32_t parent_id = 0; - if ((*message_)[strings::msg_params][strings::menu_params].keyExists( - hmi_request::parent_id)) { - parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id] - .asUInt(); - } - - for (; commands.end() != i; ++i) { - if (!(*i->second).keyExists(strings::menu_params)) { - continue; - } - - saved_parent_id = 0; - if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) { - saved_parent_id = - (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); - } - if (((*i->second)[strings::menu_params][strings::menu_name].asString() == - (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name] - .asString()) && - (saved_parent_id == parent_id)) { - SDL_LOG_INFO( - "AddCommandRequest::CheckCommandName received" - " command name already exist in same level menu"); - return false; - } - } - return true; -} - bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { if (!app) { return false; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc index e2a37f17bd..efc1a6ee18 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -114,12 +114,6 @@ void AddSubMenuRequest::Run() { const std::string& menu_name = received_msg_params[strings::menu_name].asString(); - if (app->IsSubMenuNameAlreadyExist(menu_name, parent_id)) { - SDL_LOG_ERROR("Menu name " << menu_name << " is duplicated."); - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); - return; - } - if (!CheckSubMenuName()) { SDL_LOG_ERROR("Sub-menu name is not valid."); SendResponse(false, mobile_apis::Result::INVALID_DATA); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index 5d3b203afe..5bd3ce697e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -195,8 +195,7 @@ void PerformInteractionRequest::Run() { switch (interaction_mode_) { case mobile_apis::InteractionMode::BOTH: { SDL_LOG_DEBUG("Interaction Mode: BOTH"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app) || + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || !CheckChoiceSetListVRCommands(app)) { return; } @@ -204,8 +203,7 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::MANUAL_ONLY: { SDL_LOG_DEBUG("Interaction Mode: MANUAL_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { return; } break; @@ -683,60 +681,6 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); } -bool PerformInteractionRequest::CheckChoiceSetMenuNames( - application_manager::ApplicationSharedPtr const app) { - SDL_LOG_AUTO_TRACE(); - - smart_objects::SmartObject& choice_list = - (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; - - for (size_t i = 0; i < choice_list.length(); ++i) { - // choice_set contains SmartObject msg_params - smart_objects::SmartObject i_choice_set = - app->FindChoiceSet(choice_list[i].asInt()); - - for (size_t j = 0; j < choice_list.length(); ++j) { - smart_objects::SmartObject j_choice_set = - app->FindChoiceSet(choice_list[j].asInt()); - - if (i == j) { - // skip check the same element - continue; - } - - if ((smart_objects::SmartType_Null == i_choice_set.getType()) || - (smart_objects::SmartType_Null == j_choice_set.getType())) { - SDL_LOG_ERROR("Invalid ID"); - SendResponse(false, mobile_apis::Result::INVALID_ID); - return false; - } - - size_t ii = 0; - size_t jj = 0; - for (; ii < i_choice_set[strings::choice_set].length(); ++ii) { - for (; jj < j_choice_set[strings::choice_set].length(); ++jj) { - const std::string& ii_menu_name = - i_choice_set[strings::choice_set][ii][strings::menu_name] - .asString(); - const std::string& jj_menu_name = - j_choice_set[strings::choice_set][jj][strings::menu_name] - .asString(); - - if (ii_menu_name == jj_menu_name) { - SDL_LOG_ERROR("Choice set has duplicated menu name"); - SendResponse(false, - mobile_apis::Result::DUPLICATE_NAME, - "Choice set has duplicated menu name"); - return false; - } - } - } - } - } - - return true; -} - bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( application_manager::ApplicationSharedPtr const app) { SDL_LOG_AUTO_TRACE(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index aa199bd112..93ae813535 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -373,26 +373,27 @@ TEST_F(AddCommandRequestTest, Run_CommandIDAlreadyExists_EXPECT_INVALID_ID) { request_ptr->Run(); } -TEST_F(AddCommandRequestTest, - Run_CommandNameAlreadyExists_EXPECT_DUPLICATE_NAME) { +TEST_F(AddCommandRequestTest, Run_CommandNameAlreadyExists_EXPECT_Forwarded) { CreateBasicParamsUIRequest(); - SmartObject& msg_params = (*msg_)[strings::msg_params]; - msg_params[menu_params][hmi_request::parent_id] = kFirstParentId; - SmartObject& image = msg_params[cmd_icon]; + (*msg_)[msg_params][menu_name] = kMenuName; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_)); + EXPECT_CALL(*mock_app_, AddCommand(_, (*msg_)[msg_params])); + SmartObject first_command = SmartObject(SmartType_Map); SmartObject second_command = SmartObject(SmartType_Map); - const am::CommandsMap commands_map = + am::CommandsMap commands_map = CreateCommandsMap(first_command, second_command); EXPECT_CALL(*mock_app_, commands_map()) .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( commands_map, lock_ptr_))); - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) + .WillOnce(Return(true)); std::shared_ptr<AddCommandRequest> request_ptr = CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); |