summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2017-11-02 16:55:38 -0400
committerGitHub <noreply@github.com>2017-11-02 16:55:38 -0400
commit10b632f27b3e04ed1e75363d0674c44279f7ac1f (patch)
tree16393385d0f09033fce50c9c3ea8d002fb3eb6fe
parentf11b34a815db5a7cf903734dcbfd9114215c8035 (diff)
parent7b57748b3213b6739f9e700c751f7a3b63c7f027 (diff)
downloadsdl_core-10b632f27b3e04ed1e75363d0674c44279f7ac1f.tar.gz
Merge pull request #1627 from LuxoftAKutsan/fix/SDL_responds_GENERIC_ERROR_instead_of_INVALID_DATA_when_soft_button_has_Type_is_Image_or_Both
Fix issue with incorrect behaviour in AlertManeuver
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc32
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc6
2 files changed, 29 insertions, 9 deletions
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
index b151990289..78b05e452f 100644
--- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
@@ -216,23 +216,41 @@ bool AlertManeuverRequest::PrepareResponseParameters(
bool AlertManeuverRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
- const char* str = NULL;
+ using smart_objects::SmartArray;
if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
- const smart_objects::SmartArray* tc_array =
+ const SmartArray* tts_chunks_arr =
(*message_)[strings::msg_params][strings::tts_chunks].asArray();
- smart_objects::SmartArray::const_iterator it_tc = tc_array->begin();
- smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end();
+ SmartArray::const_iterator it_tts_chunk = tts_chunks_arr->begin();
- for (; it_tc != it_tc_end; ++it_tc) {
- str = (*it_tc)[strings::text].asCharArray();
- if (strlen(str) && !CheckSyntax(str)) {
+ for (; it_tts_chunk != tts_chunks_arr->end(); ++it_tts_chunk) {
+ const char* tts_chunk_text = (*it_tts_chunk)[strings::text].asCharArray();
+ if (strlen(tts_chunk_text) && !CheckSyntax(tts_chunk_text)) {
LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed");
return true;
}
}
}
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ DCHECK_OR_RETURN(
+ (*message_)[strings::msg_params][strings::soft_buttons].getType() ==
+ smart_objects::SmartType_Array,
+ true);
+ const smart_objects::SmartArray* soft_button_array =
+ (*message_)[strings::msg_params][strings::soft_buttons].asArray();
+
+ SmartArray::const_iterator it_soft_button = soft_button_array->begin();
+
+ for (; it_soft_button != soft_button_array->end(); ++it_soft_button) {
+ const char* soft_button_text = (*it_soft_button)[strings::text].asCharArray();
+ if (!CheckSyntax(soft_button_text)) {
+ LOG4CXX_ERROR(logger_, "Invalid soft_buttons syntax check failed");
+ return true;
+ }
+ }
+ }
+
return false;
}
diff --git a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
index 9a101e6352..fd577621cd 100644
--- a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
@@ -158,7 +158,8 @@ TEST_F(AlertManeuverRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_UNSUCCESS) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons][0]
+ [am::strings::text] = "text";
CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
@@ -208,7 +209,8 @@ TEST_F(AlertManeuverRequestTest, Run_IsWhiteSpaceExist_UNSUCCESS) {
TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_SUCCESS) {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons][0]
+ [am::strings::text] = "text";
CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));