diff options
author | okozlovlux <okozlov@luxoft.com> | 2017-03-15 12:38:31 +0200 |
---|---|---|
committer | Alex Kutsan <akutsan@luxoft.com> | 2017-06-19 17:09:11 +0300 |
commit | ffeb333e71101adb26fccc3721881b438f60c80d (patch) | |
tree | fa754540541f5512ace3c1cc3fc4fbe4d6be6d30 | |
parent | 22a014b3746b28d2b8a3a4049c60bb76db6a0861 (diff) | |
download | sdl_core-ffeb333e71101adb26fccc3721881b438f60c80d.tar.gz |
Fix issue with incorrect behaviour in AlertManeuver
- fixed issue when in AlertManeuver SDL responds GENERIC_ERROR instead of
INVALID_DATA when soft button has Type is Image or Both and Text is
whitespace or \t or \n or empty
- fixed failed UTs
- added DCHECK condition
- used local variable
Related to Issue-980
-rw-r--r-- | src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc | 23 | ||||
-rw-r--r-- | src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc | 6 |
2 files changed, 25 insertions, 4 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..3d8faad8d1 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,7 +216,6 @@ bool AlertManeuverRequest::PrepareResponseParameters( bool AlertManeuverRequest::IsWhiteSpaceExist() { LOG4CXX_AUTO_TRACE(logger_); - const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { const smart_objects::SmartArray* tc_array = @@ -226,13 +225,33 @@ bool AlertManeuverRequest::IsWhiteSpaceExist() { smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end(); for (; it_tc != it_tc_end; ++it_tc) { - str = (*it_tc)[strings::text].asCharArray(); + const char* str = (*it_tc)[strings::text].asCharArray(); if (strlen(str) && !CheckSyntax(str)) { 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* sb_array = + (*message_)[strings::msg_params][strings::soft_buttons].asArray(); + + smart_objects::SmartArray::const_iterator it_sb = sb_array->begin(); + smart_objects::SmartArray::const_iterator it_sb_end = sb_array->end(); + + for (; it_sb != it_sb_end; ++it_sb) { + const char* str = (*it_sb)[strings::text].asCharArray(); + if (!CheckSyntax(str)) { + 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 a835239a90..66e74e484f 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 @@ -149,7 +149,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)); @@ -199,7 +200,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)); |