summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan (GitHub) <akutsan@luxoft.com>2020-09-02 20:11:18 +0300
committerGitHub <noreply@github.com>2020-09-02 13:11:18 -0400
commit161dd3a0ae0f36178b7d7bc3cf4c2be575868ac6 (patch)
tree00f240aefc31c036733944663691b259e422a7f5
parent6a88f810484c4e5ee66405c3f0b971a4e8510913 (diff)
downloadsdl_core-161dd3a0ae0f36178b7d7bc3cf4c2be575868ac6.tar.gz
Fix dangerous work with app commands (#3375)
* SDLCORE-665: Fix dangerous work with app commands SDLCORE-665 There was related to a thread safety violation while working with application internal commands array. This array is a thread safe itself as it is protected with mutexes, however FindCommand() function is returing a raw pointer to an internal array element so the external component is able to get access to this element at any time even without locking the mutex. Core crash which was found in DeleteCommand request instance is happening by exactly the same reason - DeleteCommand is using a raw pointer to find the command, however this command might be destroyed from another thread at this point of time. As a result, working thread can access to a destroyed object by pointer. As a quick solution, each FindCommand() was followed by a command accessor which prevents unexpected command destruction. Working thread will use the temporary copy of command, but not command itself. However, the better solution would be to change a design and to avoid using of the raw pointers. * Update an Application class methods to return by value instead of raw pointer Updates the next methods: FindCommand FindSubMenu FindChoiceSet Updates related logic and Unit tests * fixup! Update an Application class methods to return by value instead of raw pointer * fixup! Update an Application class methods to return by value instead of raw pointer * Review fix: log that submenu already exist instead of not found * fixup! Update an Application class methods to return by value instead of raw pointer Co-authored-by: ZhdanovP <pzhdanov@luxoft.com> Co-authored-by: Igor Gapchuk <igapchuck@luxoft.com>
-rw-r--r--src/components/application_manager/include/application_manager/application.h6
-rw-r--r--src/components/application_manager/include/application_manager/application_data_impl.h6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc9
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc18
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc100
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc57
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc40
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc19
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc8
-rw-r--r--src/components/application_manager/src/application_data_impl.cc21
-rw-r--r--src/components/application_manager/test/application_helper_test.cc23
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h7
20 files changed, 230 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 082bb10ce3..6280d83278 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -348,7 +348,7 @@ class DynamicApplicationData {
/*
* @brief Finds command with the specified command id
*/
- virtual smart_objects::SmartObject* FindCommand(uint32_t cmd_id) = 0;
+ virtual smart_objects::SmartObject FindCommand(uint32_t cmd_id) = 0;
/*
* @brief Adds a menu to the application
@@ -364,7 +364,7 @@ class DynamicApplicationData {
/*
* @brief Finds menu with the specified id
*/
- virtual smart_objects::SmartObject* FindSubMenu(uint32_t menu_id) const = 0;
+ virtual smart_objects::SmartObject FindSubMenu(uint32_t menu_id) const = 0;
/*
* @brief Returns true if sub menu with such name already exist
@@ -407,7 +407,7 @@ class DynamicApplicationData {
*
* @param choice_set_id Unique ID of the interaction choice set
*/
- virtual smart_objects::SmartObject* FindChoiceSet(uint32_t choice_set_id) = 0;
+ virtual smart_objects::SmartObject FindChoiceSet(uint32_t choice_set_id) = 0;
/*
* @brief Adds perform interaction choice set to the application
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 f04d3122fa..4a1bf9d411 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
@@ -174,7 +174,7 @@ class DynamicApplicationDataImpl : public virtual Application {
* @brief Finds command with the specified command id
* @param[in] cmd_id Command id
*/
- smart_objects::SmartObject* FindCommand(const uint32_t cmd_id);
+ smart_objects::SmartObject FindCommand(const uint32_t cmd_id) OVERRIDE;
/*
* @brief Adds a menu to the application
@@ -189,7 +189,7 @@ class DynamicApplicationDataImpl : public virtual Application {
/*
* @brief Finds menu with the specified id
*/
- smart_objects::SmartObject* FindSubMenu(uint32_t menu_id) const;
+ smart_objects::SmartObject FindSubMenu(uint32_t menu_id) const OVERRIDE;
/*
* @brief Returns true if sub menu with such name already exist
@@ -223,7 +223,7 @@ class DynamicApplicationDataImpl : public virtual Application {
*
* @param choice_set_id Unique ID of the interaction choice set
*/
- smart_objects::SmartObject* FindChoiceSet(uint32_t choice_set_id);
+ smart_objects::SmartObject FindChoiceSet(uint32_t choice_set_id) OVERRIDE;
/*
* @brief Adds perform interaction choice set to the application
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 0267073e41..de6ff5cc08 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
@@ -112,8 +112,12 @@ void AddCommandRequest::Run() {
return;
}
- if (app->FindCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asUInt())) {
+ const auto command_id = static_cast<uint32_t>(
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+
+ const auto command = app->FindCommand(command_id);
+
+ if (smart_objects::SmartType_Null != command.getType()) {
SDL_LOG_ERROR("INVALID_ID");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
@@ -301,9 +305,9 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
(*message_)[strings::msg_params][strings::menu_params]
[hmi_request::parent_id]
.asInt();
- smart_objects::SmartObject* parent = app->FindSubMenu(parent_id);
+ smart_objects::SmartObject parent = app->FindSubMenu(parent_id);
- if (!parent) {
+ if (smart_objects::SmartType_Null == parent.getType()) {
SDL_LOG_INFO(
"AddCommandRequest::CheckCommandParentId received"
" submenu doesn't exist");
@@ -359,7 +363,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- SDL_LOG_ERROR("Received unknown event " << event.id());
+ SDL_LOG_ERROR("Received unknown event" << event.id());
return;
}
}
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 d79cd57953..288cafb94e 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
@@ -87,8 +87,11 @@ void AddSubMenuRequest::Run() {
}
const int32_t menu_id = received_msg_params[strings::menu_id].asInt();
- if (app->FindSubMenu(menu_id)) {
- SDL_LOG_ERROR("Menu with id " << menu_id << " is not found.");
+
+ const auto sub_menu = app->FindSubMenu(menu_id);
+
+ if (smart_objects::SmartType_Null != sub_menu.getType()) {
+ SDL_LOG_ERROR("Menu with id " << menu_id << " already exists.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
}
@@ -193,7 +196,7 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- SDL_LOG_ERROR("Received unknown event " << event.id());
+ SDL_LOG_ERROR("Received unknown event" << event.id());
return;
}
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
index 6b7e1d917d..eef4d65282 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -121,7 +121,9 @@ void CreateInteractionChoiceSetRequest::Run() {
(*message_)[strings::msg_params][strings::interaction_choice_set_id]
.asInt();
- if (app->FindChoiceSet(choice_set_id_)) {
+ const auto choice_set = app->FindChoiceSet(choice_set_id_);
+
+ if (smart_objects::SmartType_Null != choice_set.getType()) {
SDL_LOG_ERROR("Choice set with id " << choice_set_id_ << " is not found.");
SendResponse(false, Result::INVALID_ID);
return;
@@ -218,8 +220,9 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms(
CreateInteractionChoiceSetRequest::compareStr);
if (it != vr_cmds_1->end()) {
- SDL_LOG_INFO("Incoming choice set has duplicated VR synonyms "
- << it->asString());
+ SDL_LOG_INFO(
+
+ "Incoming choice set has duplicated VR synonyms " << it->asString());
return true;
}
@@ -330,8 +333,9 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
VRCommandInfo vr_command(vr_cmd_id);
sent_commands_map_[vr_corr_id] = vr_command;
- SDL_LOG_DEBUG("VR_command sent corr_id " << vr_corr_id << " cmd_id "
- << vr_corr_id);
+ SDL_LOG_DEBUG(
+
+ "VR_command sent corr_id " << vr_corr_id << " cmd_id " << vr_corr_id);
}
expected_chs_count_ = chs_num;
SDL_LOG_DEBUG("expected_chs_count_ = " << expected_chs_count_);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
index 6b6f500602..0c731a027b 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
@@ -81,9 +81,9 @@ void DeleteCommandRequest::Run() {
const int32_t cmd_id =
(*message_)[strings::msg_params][strings::cmd_id].asInt();
- smart_objects::SmartObject* command = application->FindCommand(cmd_id);
+ smart_objects::SmartObject command = application->FindCommand(cmd_id);
- if (!command) {
+ if (smart_objects::SmartType::SmartType_Null == command.getType()) {
SDL_LOG_ERROR("Command with id " << cmd_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
@@ -98,20 +98,20 @@ void DeleteCommandRequest::Run() {
// we should specify amount of required responses in the 1st request
uint32_t chaining_counter = 0;
- if ((*command).keyExists(strings::menu_params)) {
+ if (command.keyExists(strings::menu_params)) {
++chaining_counter;
}
- if ((*command).keyExists(strings::vr_commands)) {
+ if (command.keyExists(strings::vr_commands)) {
++chaining_counter;
}
/* Need to set all flags before sending request to HMI
* for correct processing this flags in method on_event */
- if ((*command).keyExists(strings::menu_params)) {
+ if (command.keyExists(strings::menu_params)) {
is_ui_send_ = true;
}
// check vr params
- if ((*command).keyExists(strings::vr_commands)) {
+ if (command.keyExists(strings::vr_commands)) {
is_vr_send_ = true;
}
if (is_ui_send_) {
@@ -179,7 +179,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- SDL_LOG_ERROR("Received unknown event " << event.id());
+ SDL_LOG_ERROR("Received unknown event" << event.id());
return;
}
}
@@ -200,9 +200,9 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
const uint32_t cmd_id = msg_params[strings::cmd_id].asUInt();
- smart_objects::SmartObject* command = application->FindCommand(cmd_id);
+ const auto command = application->FindCommand(cmd_id);
- if (!command) {
+ if (smart_objects::SmartType_Null == command.getType()) {
SDL_LOG_ERROR("Command id " << cmd_id
<< " not found for "
"application with connection key "
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc
index 6c52d60007..d8b74eb770 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc
@@ -65,8 +65,9 @@ void DeleteInteractionChoiceSetRequest::Run() {
ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- SDL_LOG_ERROR("No application associated with connection key "
- << connection_key());
+ SDL_LOG_ERROR(
+
+ "No application associated with connection key " << connection_key());
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -75,7 +76,9 @@ void DeleteInteractionChoiceSetRequest::Run() {
(*message_)[strings::msg_params][strings::interaction_choice_set_id]
.asInt();
- if (!app->FindChoiceSet(choice_set_id)) {
+ const auto choice_set = app->FindChoiceSet(choice_set_id);
+
+ if (smart_objects::SmartType_Null == choice_set.getType()) {
SDL_LOG_ERROR("Choice set with id " << choice_set_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
@@ -142,9 +145,9 @@ void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand(
(*message_)[strings::msg_params][strings::interaction_choice_set_id]
.asUInt();
- smart_objects::SmartObject* choice_set = app->FindChoiceSet(choice_set_id);
+ smart_objects::SmartObject choice_set = app->FindChoiceSet(choice_set_id);
- if (!choice_set) {
+ if (smart_objects::SmartType_Null == choice_set.getType()) {
SDL_LOG_ERROR("Choice set with id " << choice_set_id << " is not found.");
return;
}
@@ -153,10 +156,10 @@ void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand(
smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
- msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id];
- choice_set = &((*choice_set)[strings::choice_set]);
- for (uint32_t i = 0; i < (*choice_set).length(); ++i) {
- msg_params[strings::cmd_id] = (*choice_set)[i][strings::choice_id];
+ msg_params[strings::grammar_id] = choice_set[strings::grammar_id];
+ choice_set = choice_set[strings::choice_set];
+ for (uint32_t i = 0; i < choice_set.length(); ++i) {
+ msg_params[strings::cmd_id] = choice_set[i][strings::choice_id];
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
}
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
index b4a1d7f0c1..19ec2dfb27 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
@@ -74,7 +74,9 @@ void DeleteSubMenuRequest::Run() {
const int32_t menu_id =
(*message_)[strings::msg_params][strings::menu_id].asInt();
- if (!app->FindSubMenu(menu_id)) {
+ const auto sub_menu = app->FindSubMenu(menu_id);
+
+ if (smart_objects::SmartType_Null == sub_menu.getType()) {
SDL_LOG_ERROR("Menu with id " << menu_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
@@ -155,7 +157,6 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(
ApplicationSharedPtr const app, uint32_t parentID) {
SDL_LOG_AUTO_TRACE();
SDL_LOG_DEBUG("Delete UI Commands with Parent ID: " << parentID);
-
const DataAccessor<CommandsMap> accessor(app->commands_map());
const CommandsMap& commands = accessor.GetData();
CommandsMap::const_iterator it = commands.begin();
@@ -230,7 +231,7 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- SDL_LOG_ERROR("Received unknown event " << event.id());
+ SDL_LOG_ERROR("Received unknown event" << event.id());
return;
}
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc
index afd73e7e4a..e973a546af 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc
@@ -39,7 +39,6 @@ namespace sdl_rpc_plugin {
using namespace application_manager;
namespace commands {
-
SDL_CREATE_LOG_VARIABLE("Commands")
OnCommandNotification::OnCommandNotification(
@@ -70,8 +69,10 @@ void OnCommandNotification::Run() {
const uint32_t cmd_id =
(*message_)[strings::msg_params][strings::cmd_id].asUInt();
- if (!app->FindCommand(cmd_id)) {
- SDL_LOG_ERROR("No applications found for the command " << cmd_id);
+ const auto command = app->FindCommand(cmd_id);
+
+ if (smart_objects::SmartType_Null == command.getType()) {
+ SDL_LOG_ERROR(" No applications found for the command " << cmd_id);
return;
}
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 3e25a4b094..9c218e0e99 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
@@ -271,7 +271,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- SDL_LOG_ERROR("Received unknown event " << event.id());
+ SDL_LOG_ERROR("Received unknown event" << event.id());
break;
}
}
@@ -517,24 +517,24 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest(
}
int32_t index_array_of_vr_help = 0;
for (size_t i = 0; i < choice_set_id_list.length(); ++i) {
- smart_objects::SmartObject* choice_set =
+ smart_objects::SmartObject choice_set =
app->FindChoiceSet(choice_set_id_list[i].asInt());
- if (choice_set) {
+ if (smart_objects::SmartType_Null != choice_set.getType()) {
// save perform interaction choice set
app->AddPerformInteractionChoiceSet(
- correlation_id(), choice_set_id_list[i].asInt(), *choice_set);
- for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
+ correlation_id(), choice_set_id_list[i].asInt(), choice_set);
+ for (size_t j = 0; j < choice_set[strings::choice_set].length(); ++j) {
if (mobile_apis::InteractionMode::VR_ONLY != mode) {
size_t index = msg_params[strings::choice_set].length();
msg_params[strings::choice_set][index] =
- (*choice_set)[strings::choice_set][j];
+ choice_set[strings::choice_set][j];
// vrCommands should be added via VR.AddCommand only
msg_params[strings::choice_set][index].erase(strings::vr_commands);
}
if (mobile_apis::InteractionMode::MANUAL_ONLY != mode &&
!is_vr_help_item) {
smart_objects::SmartObject& vr_commands =
- (*choice_set)[strings::choice_set][j][strings::vr_commands];
+ choice_set[strings::choice_set][j][strings::vr_commands];
if (0 < vr_commands.length()) {
// copy only first synonym
smart_objects::SmartObject item(smart_objects::SmartType_Map);
@@ -579,14 +579,14 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
int32_t grammar_id_index = 0;
for (uint32_t i = 0; i < choice_list.length(); ++i) {
- smart_objects::SmartObject* choice_set =
- app->FindChoiceSet(choice_list[i].asInt());
- if (!choice_set) {
- SDL_LOG_WARN("Couldn't found choiceset");
+ const auto choice_id = choice_list[i].asInt();
+ smart_objects::SmartObject choice_set = app->FindChoiceSet(choice_id);
+ if (smart_objects::SmartType_Null == choice_set.getType()) {
+ SDL_LOG_WARN("Couldn't found choiceset : " << choice_id);
continue;
}
msg_params[strings::grammar_id][grammar_id_index++] =
- (*choice_set)[strings::grammar_id].asUInt();
+ choice_set[strings::grammar_id].asUInt();
}
}
@@ -598,8 +598,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_);
if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) {
- SDL_LOG_WARN("MessageHelper::VerifyTtsFiles return "
- << verification_result);
+ SDL_LOG_WARN(
+
+ "MessageHelper::VerifyTtsFiles return " << verification_result);
invalid_params.push_back("help_prompt");
} else {
msg_params[strings::help_prompt] = help_prompt;
@@ -611,14 +612,14 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
}
int32_t index = 0;
for (uint32_t i = 0; i < choice_list.length(); ++i) {
- smart_objects::SmartObject* choice_set =
+ smart_objects::SmartObject choice_set =
app->FindChoiceSet(choice_list[i].asInt());
- if (choice_set) {
- for (uint32_t j = 0; j < (*choice_set)[strings::choice_set].length();
+ if (smart_objects::SmartType_Null != choice_set.getType()) {
+ for (uint32_t j = 0; j < choice_set[strings::choice_set].length();
++j) {
smart_objects::SmartObject& vr_commands =
- (*choice_set)[strings::choice_set][j][strings::vr_commands];
+ choice_set[strings::choice_set][j][strings::vr_commands];
if (0 < vr_commands.length()) {
// copy only first synonym
smart_objects::SmartObject item(smart_objects::SmartType_Map);
@@ -645,8 +646,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
timeout_prompt, app, application_manager_);
if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) {
- SDL_LOG_WARN("MessageHelper::VerifyTtsFiles return "
- << verification_result);
+ SDL_LOG_WARN(
+
+ "MessageHelper::VerifyTtsFiles return " << verification_result);
invalid_params.push_back("timeout_prompt");
} else {
msg_params[strings::timeout_prompt] = timeout_prompt;
@@ -665,8 +667,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
initial_prompt, app, application_manager_);
if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) {
- SDL_LOG_WARN("MessageHelper::VerifyTtsFiles return "
- << verification_result);
+ SDL_LOG_WARN(
+
+ "MessageHelper::VerifyTtsFiles return " << verification_result);
invalid_params.push_back("initial_prompt");
} else {
msg_params[strings::initial_prompt] = initial_prompt;
@@ -705,11 +708,11 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames(
for (size_t i = 0; i < choice_list.length(); ++i) {
// choice_set contains SmartObject msg_params
- smart_objects::SmartObject* i_choice_set =
+ 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 =
+ smart_objects::SmartObject j_choice_set =
app->FindChoiceSet(choice_list[j].asInt());
if (i == j) {
@@ -717,7 +720,8 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames(
continue;
}
- if (!i_choice_set || !j_choice_set) {
+ 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;
@@ -725,13 +729,13 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames(
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) {
+ 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]
+ 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]
+ j_choice_set[strings::choice_set][jj][strings::menu_name]
.asString();
if (ii_menu_name == jj_menu_name) {
@@ -758,11 +762,11 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
for (size_t i = 0; i < choice_list.length(); ++i) {
// choice_set contains SmartObject msg_params
- smart_objects::SmartObject* i_choice_set =
+ 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 =
+ smart_objects::SmartObject j_choice_set =
app->FindChoiceSet(choice_list[j].asInt());
if (i == j) {
@@ -770,7 +774,8 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
continue;
}
- if ((!i_choice_set) || (!j_choice_set)) {
+ 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;
@@ -778,11 +783,11 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
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) {
- if (!((*i_choice_set)[strings::choice_set][ii].keyExists(
+ for (; ii < i_choice_set[strings::choice_set].length(); ++ii) {
+ for (; jj < j_choice_set[strings::choice_set].length(); ++jj) {
+ if (!(i_choice_set[strings::choice_set][ii].keyExists(
strings::vr_commands) &&
- (*j_choice_set)[strings::choice_set][jj].keyExists(
+ j_choice_set[strings::choice_set][jj].keyExists(
strings::vr_commands))) {
SDL_LOG_DEBUG(
"One or both sets has missing vr commands, skipping "
@@ -791,10 +796,10 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
}
// choice_set pointer contains SmartObject msg_params
smart_objects::SmartObject& ii_vr_commands =
- (*i_choice_set)[strings::choice_set][ii][strings::vr_commands];
+ i_choice_set[strings::choice_set][ii][strings::vr_commands];
smart_objects::SmartObject& jj_vr_commands =
- (*j_choice_set)[strings::choice_set][jj][strings::vr_commands];
+ j_choice_set[strings::choice_set][jj][strings::vr_commands];
for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) {
for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) {
@@ -997,21 +1002,20 @@ bool PerformInteractionRequest::CheckChoiceSetListVRCommands(
const smart_objects::SmartObject& choice_set_id_list =
(*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
- smart_objects::SmartObject* choice_set = nullptr;
-
for (size_t i = 0; i < choice_set_id_list.length(); ++i) {
- choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
+ auto choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
// this should never ever happen since this was already checked
- if (choice_set == nullptr) {
+ if (smart_objects::SmartType_Null == choice_set.getType()) {
SDL_LOG_ERROR(
+
"Couldn't find choiceset_id = " << choice_set_id_list[i].asInt());
SendResponse(false, mobile_apis::Result::INVALID_ID);
return false;
}
const smart_objects::SmartObject& choices_list =
- (*choice_set)[strings::choice_set];
+ choice_set[strings::choice_set];
auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list);
// if not all choices have vr commands
@@ -1036,20 +1040,20 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
size_t choice_list_length = 0;
std::set<uint32_t> choice_id_set;
- smart_objects::SmartObject* choice_set = 0;
std::pair<std::set<uint32_t>::iterator, bool> ins_res;
for (size_t i = 0; i < choice_set_id_list_length; ++i) {
- choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
- if (!choice_set) {
+ auto choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
+ if (smart_objects::SmartType_Null == choice_set.getType()) {
SDL_LOG_ERROR(
+
"Couldn't find choiceset_id = " << choice_set_id_list[i].asInt());
return false;
}
- choice_list_length = (*choice_set)[strings::choice_set].length();
+ choice_list_length = choice_set[strings::choice_set].length();
const smart_objects::SmartObject& choices_list =
- (*choice_set)[strings::choice_set];
+ choice_set[strings::choice_set];
for (size_t k = 0; k < choice_list_length; ++k) {
ins_res =
choice_id_set.insert(choices_list[k][strings::choice_id].asInt());
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc
index c652764f16..7d2751ed0d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc
@@ -39,7 +39,6 @@ namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
namespace commands {
-
SDL_CREATE_LOG_VARIABLE("Commands")
ShowAppMenuRequest::ShowAppMenuRequest(
@@ -63,8 +62,9 @@ void ShowAppMenuRequest::Run() {
ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- SDL_LOG_ERROR("Application with id " << connection_key()
- << " is not registered.");
+ SDL_LOG_ERROR(
+
+ "Application with id " << connection_key() << " is not registered.");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -77,8 +77,9 @@ void ShowAppMenuRequest::Run() {
app->system_context(mobile_apis::PredefinedWindows::DEFAULT_WINDOW),
mobile_apis::SystemContext::SYSCTXT_MAIN,
mobile_apis::SystemContext::SYSCTXT_MENU)) {
- SDL_LOG_ERROR("Application with id " << connection_key()
- << " is not activated.");
+ SDL_LOG_ERROR(
+
+ "Application with id " << connection_key() << " is not activated.");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
@@ -89,7 +90,10 @@ void ShowAppMenuRequest::Run() {
const auto& received_msg_params = (*message_)[strings::msg_params];
if (received_msg_params.keyExists(strings::menu_id)) {
const int32_t menu_id = received_msg_params[strings::menu_id].asInt();
- if (!app->FindSubMenu(menu_id)) {
+
+ const auto sub_menu = app->FindSubMenu(menu_id);
+
+ if (smart_objects::SmartType_Null == sub_menu.getType()) {
SDL_LOG_ERROR("Menu with id " << menu_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
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 b11312eb33..6a0d799ce5 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
@@ -104,6 +104,7 @@ class AddCommandRequestTest
public:
AddCommandRequestTest()
: msg_(CreateMessage())
+ , smart_obj_(smart_objects::SmartType_Null)
, default_app_name_("test_default_app_name_")
, lock_ptr_(std::make_shared<sync_primitives::Lock>())
, mock_help_prompt_manager_(
@@ -124,8 +125,7 @@ class AddCommandRequestTest
void InitGetters() {
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
- ON_CALL(*mock_app_, FindCommand(kCmdId))
- .WillByDefault(Return(so_ptr_.get()));
+ ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(smart_obj_));
}
void CreateBasicParamsUIRequest() {
@@ -173,8 +173,7 @@ class AddCommandRequestTest
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
const am::CommandsMap commands_map =
@@ -182,9 +181,9 @@ class AddCommandRequestTest
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
- so_ptr_ = std::make_shared<SmartObject>(SmartType_Map);
+ SmartObject sub_menu(SmartType_Map);
EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
+ .WillOnce(Return(sub_menu));
{
InSequence dummy;
@@ -227,7 +226,7 @@ class AddCommandRequestTest
}
MessageSharedPtr msg_;
- SmartObjectSPtr so_ptr_;
+ smart_objects::SmartObject smart_obj_;
const utils::custom_string::CustomString default_app_name_;
std::shared_ptr<sync_primitives::Lock> lock_ptr_;
std::shared_ptr<am_test::MockHelpPromptManager> mock_help_prompt_manager_;
@@ -292,14 +291,13 @@ TEST_F(AddCommandRequestTest, Run_MenuNameHasSyntaxError_EXPECT_INVALID_DATA) {
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
am::CommandsMap commands_map;
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
SmartObject parent = SmartObject(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kFirstParentId))
- .WillOnce(Return(&parent));
+ EXPECT_CALL(*mock_app_, FindSubMenu(kFirstParentId)).WillOnce(Return(parent));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
@@ -314,7 +312,7 @@ TEST_F(AddCommandRequestTest,
CreateBasicParamsVRRequest();
SmartObject& msg_params = (*msg_)[strings::msg_params];
msg_params[vr_commands][0] = kErroredVRCommand;
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
am::CommandsMap commands_map;
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
@@ -340,7 +338,7 @@ TEST_F(AddCommandRequestTest, Run_CMDIconHasError_EXPECT_INVALID_DATA) {
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
am::CommandsMap commands_map;
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
@@ -360,8 +358,9 @@ TEST_F(AddCommandRequestTest, Run_CommandIDAlreadyExists_EXPECT_INVALID_ID) {
SmartObject& image = msg_params[cmd_icon];
EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- so_ptr_ = std::make_shared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
+ SmartObject existing_cmd_so(smart_objects::SmartType_Map);
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId))
+ .WillOnce(Return(existing_cmd_so));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
@@ -379,7 +378,7 @@ TEST_F(AddCommandRequestTest,
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
const am::CommandsMap commands_map =
@@ -404,7 +403,7 @@ TEST_F(AddCommandRequestTest,
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
const am::CommandsMap commands_map =
@@ -412,8 +411,10 @@ TEST_F(AddCommandRequestTest,
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
+
+ SmartObject invalid_command(SmartType_Null);
EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
+ .WillOnce(Return(invalid_command));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
@@ -432,7 +433,7 @@ TEST_F(AddCommandRequestTest,
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
@@ -441,9 +442,9 @@ TEST_F(AddCommandRequestTest,
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
- so_ptr_ = std::make_shared<SmartObject>(SmartType_Map);
+ SmartObject sub_menu(SmartType_Map);
EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
+ .WillOnce(Return(sub_menu));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
@@ -459,7 +460,7 @@ TEST_F(AddCommandRequestTest, Run_MsgDataEmpty_EXPECT_INVALID_DATA) {
SmartObject& msg_params = (*msg)[strings::msg_params];
msg_params[app_id] = kAppId;
msg_params[cmd_id] = kCmdId;
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
@@ -478,7 +479,7 @@ TEST_F(AddCommandRequestTest,
SmartObject& image = 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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
const am::CommandsMap commands_map =
@@ -486,9 +487,9 @@ TEST_F(AddCommandRequestTest,
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
- so_ptr_ = std::make_shared<SmartObject>(SmartType_Map);
+ SmartObject sub_menu(SmartType_Map);
EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
+ .WillOnce(Return(sub_menu));
{
InSequence dummy;
@@ -512,7 +513,7 @@ TEST_F(AddCommandRequestTest, GetRunMethods_SUCCESS) {
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(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params]));
am::CommandsMap commands_map;
@@ -1106,7 +1107,7 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) {
msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
+ EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_));
SmartObject first_command = SmartObject(SmartType_Map);
SmartObject second_command = SmartObject(SmartType_Map);
const am::CommandsMap commands_map =
@@ -1114,9 +1115,9 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) {
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
commands_map, lock_ptr_)));
- so_ptr_ = std::make_shared<SmartObject>(SmartType_Map);
+ SmartObject sub_menu(SmartType_Map);
EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
+ .WillOnce(Return(sub_menu));
{
InSequence dummy;
EXPECT_CALL(mock_rpc_service_,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
index 73a0008624..2677731e07 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
@@ -207,7 +207,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
- smart_objects::SmartObject* null_obj = NULL;
+ smart_objects::SmartObject null_obj(smart_objects::SmartType_Null);
ON_CALL(*mock_app_, FindChoiceSet(_)).WillByDefault(Return(null_obj));
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
@@ -219,9 +219,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
am::event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand);
event.set_smart_object(*msg);
- smart_objects::SmartObject* ptr = NULL;
- ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr));
- EXPECT_EQ(NULL, ptr);
+ smart_objects::SmartObject invalid_command(smart_objects::SmartType_Null);
+ ON_CALL(*mock_app_, FindCommand(kCmdId))
+ .WillByDefault(Return(invalid_command));
am::CommandsMap commands_map;
ON_CALL(*mock_app_, commands_map())
@@ -293,9 +293,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* invalid_choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
+ smart_objects::SmartObject invalid_choice_set_id =
+ (*message_)[am::strings::msg_params]
+ [am::strings::interaction_choice_set_id];
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(invalid_choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
@@ -329,7 +329,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -358,7 +358,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
@@ -435,7 +435,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -478,7 +478,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -511,7 +511,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_WithoutVrCommands_SUCCESS) {
EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
.WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::NONE));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -549,7 +549,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
.WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::MIXED));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -598,7 +598,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -635,7 +635,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -673,7 +673,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -724,7 +724,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -769,7 +769,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -813,7 +813,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -889,7 +889,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
index 081058f05a..b8ae3af7fd 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
@@ -152,9 +152,10 @@ TEST_F(DeleteCommandRequestTest,
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
- MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
- (*test_msg)[am::strings::vr_commands] = 0;
- (*test_msg)[am::strings::menu_params] = 0;
+ smart_objects::SmartObject test_msg(
+ *CreateMessage(smart_objects::SmartType_Map));
+ test_msg[am::strings::vr_commands] = 0;
+ test_msg[am::strings::menu_params] = 0;
ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
@@ -164,8 +165,7 @@ TEST_F(DeleteCommandRequestTest,
ON_CALL(hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(*mock_app_, FindCommand(kCommandId))
- .WillByDefault(Return(test_msg.get()));
+ ON_CALL(*mock_app_, FindCommand(kCommandId)).WillByDefault(Return(test_msg));
ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey));
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::params][am::hmi_response::code] =
@@ -216,9 +216,10 @@ TEST_F(DeleteCommandRequestTest,
MockAppPtr app = CreateMockApp();
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
- (*test_msg)[am::strings::vr_commands] = 0;
- (*test_msg)[am::strings::menu_params] = 0;
+ smart_objects::SmartObject test_msg(
+ *CreateMessage(smart_objects::SmartType_Map));
+ test_msg[am::strings::vr_commands] = 0;
+ test_msg[am::strings::menu_params] = 0;
ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
@@ -228,7 +229,7 @@ TEST_F(DeleteCommandRequestTest,
ON_CALL(hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get()));
+ ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg));
ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::params][am::hmi_response::code] =
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc
index fa96b21ca7..dd4c6fd526 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc
@@ -142,7 +142,7 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
- smart_objects::SmartObject* choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id(smart_objects::SmartType_Null);
EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -161,9 +161,9 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_ChoiceSetInUse_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
+ smart_objects::SmartObject choice_set_id =
+ (*message_)[am::strings::msg_params]
+ [am::strings::interaction_choice_set_id];
choice_set_map_[0].insert(
std::make_pair(kChoiceSetId,
@@ -189,10 +189,11 @@ TEST_F(DeleteInteractionChoiceSetRequestTest,
kConnectionKey;
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
- smart_objects::SmartObject* invalid_choice_set_id = NULL;
+ smart_objects::SmartObject choice_set_id =
+ (*message_)[am::strings::msg_params]
+ [am::strings::interaction_choice_set_id];
+ smart_objects::SmartObject invalid_choice_set_id(
+ smart_objects::SmartType_Null);
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(app_));
@@ -228,8 +229,8 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
(*message_)[am::strings::msg_params][am::strings::grammar_id] = kGrammarId;
(*message_)[am::strings::msg_params][am::strings::choice_set][0]
[am::strings::choice_id] = kChoiceId;
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]);
+ smart_objects::SmartObject choice_set_id =
+ (*message_)[am::strings::msg_params];
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(app_));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
index cd832d3122..f5856a8eda 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
@@ -203,7 +203,7 @@ TEST_F(DeleteSubMenuRequestTest, Run_FindSubMenuFalse_UNSUCCESS) {
(*message_)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
- smart_objects::SmartObject* invalid_sub_menu = NULL;
+ smart_objects::SmartObject invalid_sub_menu(smart_objects::SmartType_Null);
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(invalid_sub_menu));
@@ -220,8 +220,8 @@ TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) {
(*message_)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
- smart_objects::SmartObject* sub_menu =
- &((*message_)[am::strings::msg_params][am::strings::menu_id]);
+ smart_objects::SmartObject sub_menu =
+ (*message_)[am::strings::msg_params][am::strings::menu_id];
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(sub_menu));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc
index 1356b1c5fa..10a84452e9 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc
@@ -86,8 +86,10 @@ TEST_F(OnCommandNotificationTest, Run_NoAppsForTheCommand_UNSUCCESS) {
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+ smart_objects::SmartObject invalid_command(smart_objects::SmartType_Null);
+
EXPECT_CALL(*mock_app, FindCommand(kCommandId))
- .WillOnce(Return(static_cast<SmartObject*>(NULL)));
+ .WillOnce(Return(invalid_command));
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0);
@@ -121,9 +123,9 @@ TEST_F(OnCommandNotificationTest, Run_SUCCESS) {
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
- MessageSharedPtr dummy_msg(CreateMessage());
+ smart_objects::SmartObject empty_command(smart_objects::SmartType_Map);
EXPECT_CALL(*mock_app, FindCommand(kCommandId))
- .WillOnce(Return(dummy_msg.get()));
+ .WillOnce(Return(empty_command));
EXPECT_CALL(mock_rpc_service_,
SendMessageToMobile(CheckNotificationMessage(), _));
diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc
index 35d95c3efd..817db2b361 100644
--- a/src/components/application_manager/src/application_data_impl.cc
+++ b/src/components/application_manager/src/application_data_impl.cc
@@ -801,7 +801,7 @@ void DynamicApplicationDataImpl::RemoveCommand(const uint32_t cmd_id) {
<< " is not found. Removal skipped.");
}
-smart_objects::SmartObject* DynamicApplicationDataImpl::FindCommand(
+smart_objects::SmartObject DynamicApplicationDataImpl::FindCommand(
const uint32_t cmd_id) {
sync_primitives::AutoLock lock(commands_lock_ptr_);
@@ -812,10 +812,11 @@ smart_objects::SmartObject* DynamicApplicationDataImpl::FindCommand(
if (it != commands_.end()) {
SDL_LOG_DEBUG("Command with internal number " << (it->first) << " and id "
<< cmd_id << " is found.");
- return it->second;
+ smart_objects::SmartObject command(*it->second);
+ return command;
}
- return NULL;
+ return smart_objects::SmartObject(smart_objects::SmartType_Null);
}
// TODO(VS): Create common functions for processing collections
@@ -838,15 +839,16 @@ void DynamicApplicationDataImpl::RemoveSubMenu(uint32_t menu_id) {
}
}
-smart_objects::SmartObject* DynamicApplicationDataImpl::FindSubMenu(
+smart_objects::SmartObject DynamicApplicationDataImpl::FindSubMenu(
uint32_t menu_id) const {
sync_primitives::AutoLock lock(sub_menu_lock_ptr_);
SubMenuMap::const_iterator it = sub_menu_.find(menu_id);
if (it != sub_menu_.end()) {
- return it->second;
+ smart_objects::SmartObject sub_menu(*it->second);
+ return sub_menu;
}
- return NULL;
+ return smart_objects::SmartObject(smart_objects::SmartType_Null);
}
bool DynamicApplicationDataImpl::IsSubMenuNameAlreadyExist(
@@ -909,15 +911,16 @@ void DynamicApplicationDataImpl::RemoveChoiceSet(uint32_t choice_set_id) {
}
}
-smart_objects::SmartObject* DynamicApplicationDataImpl::FindChoiceSet(
+smart_objects::SmartObject DynamicApplicationDataImpl::FindChoiceSet(
uint32_t choice_set_id) {
sync_primitives::AutoLock lock(choice_set_map_lock_ptr_);
ChoiceSetMap::const_iterator it = choice_set_map_.find(choice_set_id);
if (it != choice_set_map_.end()) {
- return it->second;
+ smart_objects::SmartObject choice_set(*it->second);
+ return choice_set;
}
- return NULL;
+ return smart_objects::SmartObject(smart_objects::SmartType_Null);
}
void DynamicApplicationDataImpl::AddPerformInteractionChoiceSet(
diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc
index ec84acc697..cf0fc250e8 100644
--- a/src/components/application_manager/test/application_helper_test.cc
+++ b/src/components/application_manager/test/application_helper_test.cc
@@ -151,10 +151,12 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) {
const uint32_t choice_set_id = 3;
const mobile_apis::ButtonName::eType button = mobile_apis::ButtonName::AC;
- smart_objects::SmartObject cmd;
+ smart_objects::SmartObject cmd(smart_objects::SmartType_Map);
cmd[strings::msg_params][strings::cmd_id] = cmd_id;
cmd[strings::msg_params][strings::vr_commands][0] = "vrCmd";
cmd[strings::msg_params][strings::menu_id] = menu_id;
+ cmd[strings::menu_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
cmd[strings::msg_params][strings::interaction_choice_set_id] = choice_set_id;
app_impl_->AddCommand(cmd_id, cmd[strings::msg_params]);
@@ -182,9 +184,12 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) {
app_impl_->AddFile(file);
- EXPECT_TRUE(NULL != app_impl_->FindCommand(cmd_id));
- EXPECT_TRUE(NULL != app_impl_->FindSubMenu(menu_id));
- EXPECT_TRUE(NULL != app_impl_->FindChoiceSet(choice_set_id));
+ const auto command1 = app_impl_->FindCommand(cmd_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null != command1.getType());
+ const auto sub_menu1 = app_impl_->FindSubMenu(menu_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null != sub_menu1.getType());
+ const auto choice_set1 = app_impl_->FindChoiceSet(choice_set_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null != choice_set1.getType());
EXPECT_TRUE(app_impl_->IsSubscribedToButton(button));
auto help_prompt = app_impl_->help_prompt();
EXPECT_TRUE(help_prompt->asString() == some_string);
@@ -206,9 +211,13 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) {
// Act
application_manager::DeleteApplicationData(app_impl_, app_manager_impl_);
- EXPECT_FALSE(NULL != app_impl_->FindCommand(cmd_id));
- EXPECT_FALSE(NULL != app_impl_->FindSubMenu(menu_id));
- EXPECT_FALSE(NULL != app_impl_->FindChoiceSet(choice_set_id));
+
+ const auto command2 = app_impl_->FindCommand(cmd_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null == command2.getType());
+ const auto sub_menu2 = app_impl_->FindSubMenu(menu_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null == sub_menu2.getType());
+ const auto choice_set2 = app_impl_->FindChoiceSet(choice_set_id);
+ EXPECT_TRUE(smart_objects::SmartType_Null == choice_set2.getType());
EXPECT_FALSE(app_impl_->IsSubscribedToButton(button));
help_prompt = app_impl_->help_prompt();
EXPECT_FALSE(help_prompt->asString() == some_string);
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 224fea0456..2aab8cf727 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
@@ -317,12 +317,11 @@ class MockApplication : public ::application_manager::Application {
void(uint32_t cmd_id,
const smart_objects::SmartObject& command));
MOCK_METHOD1(RemoveCommand, void(uint32_t cmd_id));
- MOCK_METHOD1(FindCommand, smart_objects::SmartObject*(uint32_t cmd_id));
+ MOCK_METHOD1(FindCommand, smart_objects::SmartObject(uint32_t cmd_id));
MOCK_METHOD2(AddSubMenu,
void(uint32_t menu_id, const smart_objects::SmartObject& menu));
MOCK_METHOD1(RemoveSubMenu, void(uint32_t menu_id));
- MOCK_CONST_METHOD1(FindSubMenu,
- smart_objects::SmartObject*(uint32_t menu_id));
+ MOCK_CONST_METHOD1(FindSubMenu, smart_objects::SmartObject(uint32_t menu_id));
MOCK_METHOD2(IsSubMenuNameAlreadyExist,
bool(const std::string& name, const uint32_t parent_id));
MOCK_METHOD2(AddChoiceSet,
@@ -330,7 +329,7 @@ class MockApplication : public ::application_manager::Application {
const smart_objects::SmartObject& choice_set));
MOCK_METHOD1(RemoveChoiceSet, void(uint32_t choice_set_id));
MOCK_METHOD1(FindChoiceSet,
- smart_objects::SmartObject*(uint32_t choice_set_id));
+ smart_objects::SmartObject(uint32_t choice_set_id));
MOCK_METHOD3(AddPerformInteractionChoiceSet,
void(uint32_t correlation_id,
uint32_t choice_set_id,