summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-15 13:32:36 -0400
committerGitHub <noreply@github.com>2018-08-15 13:32:36 -0400
commit946e25fa31411a4a00b547cee2d0f1dd12b94a7d (patch)
tree671503be0f2707db4dcd37f4ab88dd622a44ff4a
parent2b888220c30edfb6dd706f7ea267ff069619fdc4 (diff)
parentcf7a1c6b71904159dcc4a0b77d36c7c0465d0ea1 (diff)
downloadsdl_core-fix/sdl_must_processing_systemrequest_for_requesttype_climate.tar.gz
Merge pull request #2415 from smartdevicelink/feature/choice_vr_optionalfix/sdl_must_processing_systemrequest_for_requesttype_climate
Feature/choice vr optional
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h7
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc35
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc61
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc102
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc34
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h3
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc7
-rw-r--r--src/components/interfaces/MOBILE_API.xml6
9 files changed, 258 insertions, 13 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index 127ff967b4..73f49e3477 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -50,6 +50,7 @@
#include "application_manager/policies/policy_handler_interface.h"
#include "smart_objects/smart_object.h"
#include "transport_manager/common.h"
+#include <application_manager/smart_object_keys.h>
namespace policy {
class PolicyHandlerInterface;
@@ -634,6 +635,21 @@ class MessageHelper {
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr);
+ /**
+ * @brief Stores whether each choice in a set has the vrCommands parameter
+ * MIXED means some choices have vrCommands and others don't
+ * ALL means all do, NONE means none do
+ */
+ enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE };
+
+ /**
+ * @brief Check whether each choice in the set has the vrCommands parameter
+ * @param choice set to check
+ * @return a ChoiceSetVRCommandsStatus with the state of the choice set
+ */
+ static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set);
+
/*
* @brief Finds "Image" structure in request and verify image file presence
* in Core.
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 40e706b851..2d4cbc9afc 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
@@ -213,6 +213,13 @@ class PerformInteractionRequest
const smart_objects::SmartObject& choice_set_id_list) const;
/**
+ * @brief Checks each choice in each set for having a VRcommands parameter
+ * @param app contains pointer to application.
+ * @return returns false if request has choice sets with no vrCommands
+ */
+ bool CheckChoiceSetListVRCommands(app_mngr::ApplicationSharedPtr app);
+
+ /**
* @brief Tells if there are sent requests without responses
* @return If there is request without response method returns TRUE
* otherwise returns FALSE
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 9b7653ac52..d50708c4eb 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
@@ -130,10 +130,30 @@ void CreateInteractionChoiceSetRequest::Run() {
SendResponse(false, result);
return;
}
- uint32_t grammar_id = application_manager_.GenerateGrammarID();
- (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
+ auto vr_status = MessageHelper::CheckChoiceSetVRCommands(
+ (*message_)[strings::msg_params][strings::choice_set]);
+ if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::MIXED) {
+ // this is an error
+ SendResponse(false,
+ Result::INVALID_DATA,
+ "Some choices don't contain VR commands. Either all or none "
+ "must have voice commands.");
+ return; // exit now, this is a bad set
+ } else if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ // everyone had a vr command, setup the grammar
+ uint32_t grammar_id = application_manager_.GenerateGrammarID();
+ (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
+ }
+ // continue on as usual
app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]);
- SendVRAddCommandRequests(app);
+
+ if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ // we have VR commands
+ SendVRAddCommandRequests(app);
+ } else {
+ // we have none, just return with success
+ SendResponse(true, Result::SUCCESS);
+ }
}
mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
@@ -155,7 +175,7 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
(*current_choice_set_it)[strings::choice_id].asInt());
if (!ins_res.second) {
LOG4CXX_ERROR(logger_,
- "Choise with ID "
+ "Choice with ID "
<< (*current_choice_set_it)[strings::choice_id].asInt()
<< " already exists");
return mobile_apis::Result::INVALID_ID;
@@ -179,12 +199,15 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
bool CreateInteractionChoiceSetRequest::compareSynonyms(
const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1,
const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) {
+ // only compare if they both have vr commands
+ if (!(choice1.keyExists(strings::vr_commands) &&
+ choice2.keyExists(strings::vr_commands))) {
+ return false; // clearly there isn't a duplicate if one of them is null
+ }
smart_objects::SmartArray* vr_cmds_1 =
choice1[strings::vr_commands].asArray();
- DCHECK(vr_cmds_1 != NULL);
smart_objects::SmartArray* vr_cmds_2 =
choice2[strings::vr_commands].asArray();
- DCHECK(vr_cmds_2 != NULL);
smart_objects::SmartArray::iterator it;
it = std::find_first_of(vr_cmds_1->begin(),
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 ec06f0bb31..42489fd8bd 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
@@ -186,7 +186,8 @@ void PerformInteractionRequest::Run() {
case mobile_apis::InteractionMode::BOTH: {
LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH");
if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) ||
- !CheckVrHelpItemPositions(app)) {
+ !CheckVrHelpItemPositions(app) ||
+ !CheckChoiceSetListVRCommands(app)) {
return;
}
break;
@@ -201,7 +202,8 @@ void PerformInteractionRequest::Run() {
}
case mobile_apis::InteractionMode::VR_ONLY: {
LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY");
- if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) {
+ if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) ||
+ !CheckChoiceSetListVRCommands(app)) {
return;
}
break;
@@ -542,7 +544,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
smart_objects::SmartObject* choice_set =
app->FindChoiceSet(choice_list[i].asInt());
if (!choice_set) {
- LOG4CXX_WARN(logger_, "Couldn't found choiset");
+ LOG4CXX_WARN(logger_, "Couldn't found choiceset");
continue;
}
msg_params[strings::grammar_id][grammar_id_index++] =
@@ -750,6 +752,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
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(
+ strings::vr_commands) &&
+ (*j_choice_set)[strings::choice_set][jj].keyExists(
+ strings::vr_commands))) {
+ LOG4CXX_DEBUG(logger_,
+ "One or both sets has missing vr commands, skipping "
+ "synonym check");
+ return true;
+ }
// choice_set pointer contains SmartObject msg_params
smart_objects::SmartObject& ii_vr_commands =
(*i_choice_set)[strings::choice_set][ii][strings::vr_commands];
@@ -946,6 +957,45 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse(
return false;
}
+bool PerformInteractionRequest::CheckChoiceSetListVRCommands(
+ ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ 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());
+
+ // this should never ever happen since this was already checked
+ if (choice_set == nullptr) {
+ LOG4CXX_ERROR(
+ logger_,
+ "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];
+ auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list);
+
+ // if not all choices have vr commands
+ if (vr_status != MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ LOG4CXX_ERROR(logger_,
+ "PerformInteraction has choice sets with "
+ "missing vrCommands, not in MANUAL_ONLY mode");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Some choices don't contain VR commands.");
+ return false;
+ }
+ }
+ return true;
+}
+
bool PerformInteractionRequest::CheckChoiceIDFromRequest(
ApplicationSharedPtr app,
const size_t choice_set_id_list_length,
@@ -962,9 +1012,10 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
if (!choice_set) {
LOG4CXX_ERROR(
logger_,
- "Couldn't find choiset_id = " << choice_set_id_list[i].asInt());
+ "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt());
return false;
}
+
choice_list_length = (*choice_set)[strings::choice_set].length();
const smart_objects::SmartObject& choices_list =
(*choice_set)[strings::choice_set];
@@ -973,7 +1024,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
choice_id_set.insert(choices_list[k][strings::choice_id].asInt());
if (!ins_res.second) {
LOG4CXX_ERROR(logger_,
- "Choise with ID "
+ "choice with ID "
<< choices_list[k][strings::choice_id].asInt()
<< " already exists");
return false;
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 ed264ff2ab..c42be48e57 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
@@ -199,6 +199,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
10;
(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] =
"menu_name";
+ (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands]
+ [0] = kVrCommands1;
(*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11;
std::shared_ptr<CreateInteractionChoiceSetRequest> req_vr =
CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr);
@@ -231,7 +233,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true));
-
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
req_vr->Run();
MessageSharedPtr vr_command_result;
@@ -436,6 +439,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -481,6 +487,79 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
command_->Run();
}
+TEST_F(CreateInteractionChoiceSetRequestTest, Run_WithoutVrCommands_SUCCESS) {
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::image][am::strings::value] = kImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::choice_id] = kChoiceId1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::secondary_image][am::strings::value] = kSecondImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::choice_id] = kChoiceId2;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
+ kChoiceSetId;
+
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+
+ EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::NONE));
+
+ smart_objects::SmartObject* choice_set_id = NULL;
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+
+ // No VR commands
+ EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
+
+ command_->Run();
+}
+
+TEST_F(CreateInteractionChoiceSetRequestTest,
+ Run_WithMixedVrCommands_UNSUCCESS) {
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::image][am::strings::value] = kImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::choice_id] = kChoiceId1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::secondary_image][am::strings::value] = kSecondImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::vr_commands][0] = kVrCommands1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::choice_id] = kChoiceId2;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
+ kChoiceSetId;
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+
+ EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::MIXED));
+
+ smart_objects::SmartObject* choice_set_id = NULL;
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+
+ EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(0);
+
+ command_->Run();
+}
+
TEST_F(CreateInteractionChoiceSetRequestTest,
OnEvent_InvalidEventId_UNSUCCESS) {
Event event(hmi_apis::FunctionID::INVALID_ENUM);
@@ -523,6 +602,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -557,6 +639,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -592,6 +677,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -640,6 +728,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -682,6 +773,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -723,6 +817,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
+
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
@@ -796,6 +893,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID())
.WillRepeatedly(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
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 052d619fcc..0ad86b5541 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -2690,6 +2690,40 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
return mobile_apis::Result::WARNINGS;
}
+MessageHelper::ChoiceSetVRCommandsStatus
+MessageHelper::CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set) {
+ // if this is false, someone doesn't have vrCommands
+ bool all_have = true;
+ // if this is false, someone has vrCommands
+ bool none_have = true;
+ smart_objects::SmartArray::const_iterator current_choice_set_it =
+ choice_set.asArray()->begin();
+ // Iterate through choices
+ for (; choice_set.asArray()->end() != current_choice_set_it;
+ ++current_choice_set_it) {
+ // if the vrCommands is present
+ if (current_choice_set_it->keyExists(
+ application_manager::strings::vr_commands)) {
+ // this one has the parameter
+ none_have = false;
+ } else {
+ // this one doesn't
+ all_have = false;
+ }
+ }
+ // everyone has it
+ if (all_have) {
+ return MessageHelper::ChoiceSetVRCommandsStatus::ALL;
+ }
+ // No one has it
+ if (none_have) {
+ return MessageHelper::ChoiceSetVRCommandsStatus::NONE;
+ }
+ // mix-and-match
+ return MessageHelper::ChoiceSetVRCommandsStatus::MIXED;
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 8641a3781e..8a06102e99 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -195,6 +195,9 @@ class MockMessageHelper {
mobile_apis::Result::eType(smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr));
+ MOCK_METHOD1(CheckChoiceSetVRCommands,
+ MessageHelper::ChoiceSetVRCommandsStatus(
+ const smart_objects::SmartObject&));
MOCK_METHOD6(GetBCActivateAppRequestToHMI,
smart_objects::SmartObjectSPtr(
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index 9e2eb75a55..0850361a20 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -340,6 +340,13 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
message, app, app_mngr);
}
+MessageHelper::ChoiceSetVRCommandsStatus
+MessageHelper::CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set) {
+ return MockMessageHelper::message_helper_mock()->CheckChoiceSetVRCommands(
+ choice_set);
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 4e2c9e5a52..fa4df2dd4a 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -983,7 +983,11 @@
<description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
<param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true"/>
<param name="menuName" type="String" maxlength="500" mandatory="true"/>
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="true"/>
+ <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="false" since="5.0">
+ <history>
+ <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="true" since="1.0" until="5.0"/>
+ </history>
+ </param>
<param name="image" type="Image" mandatory="false" since="2.0" />
<param name="secondaryText" maxlength="500" type="String" mandatory="false" since="3.0">
<description>Optional secondary text to display; e.g. address of POI in a search result entry</description>