summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Levchenko (GitHub) <slevchenko.work@gmail.com>2016-11-10 14:24:06 +0200
committerSergey Levchenko (GitHub) <slevchenko.work@gmail.com>2016-11-21 11:53:51 +0200
commite0a812a4ef741a8e2ece4854951165056b6954c3 (patch)
tree44862ba8e89c7d2e9a6156f9741fda4cd27862ac
parent6ceafb31852c96d693a2adc7775e3612e824ff46 (diff)
downloadsdl_core-e0a812a4ef741a8e2ece4854951165056b6954c3.tar.gz
Fix issues with OnButtonNotificationCommands
Obtaining of `app_id` value moved after checking of its existence. Related to: APPLINK-29755
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_event_notification.cc6
-rw-r--r--[-rwxr-xr-x]src/components/application_manager/src/commands/mobile/on_button_press_notification.cc6
-rw-r--r--src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc4
3 files changed, 12 insertions, 4 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
index 64043d2a88..82836717a3 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
@@ -56,8 +56,7 @@ void OnButtonEventNotification::Run() {
const bool is_app_id_exists =
(*message_)[strings::msg_params].keyExists(strings::app_id);
- const ApplicationSharedPtr app = application_manager_.application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
+ ApplicationSharedPtr app;
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
@@ -67,6 +66,9 @@ void OnButtonEventNotification::Run() {
return;
}
+ app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
+
// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false ==
(*message_)[strings::msg_params].keyExists(
diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
index b789b7c7e9..c77cd9fbba 100755..100644
--- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
@@ -56,8 +56,7 @@ void OnButtonPressNotification::Run() {
const bool is_app_id_exists =
(*message_)[strings::msg_params].keyExists(strings::app_id);
- const ApplicationSharedPtr app = application_manager_.application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
+ ApplicationSharedPtr app;
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
@@ -67,6 +66,9 @@ void OnButtonPressNotification::Run() {
return;
}
+ app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
+
// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false ==
(*message_)[strings::msg_params].keyExists(
diff --git a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
index 1520ab4288..793f379286 100644
--- a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
@@ -152,6 +152,9 @@ TYPED_TEST(OnButtonNotificationCommandsTest,
SharedPtr<Notification> command(
this->template CreateCommand<Notification>(notification_msg));
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
command->Run();
@@ -318,6 +321,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) {
MessageSharedPtr notification_msg(
this->CreateMessage(smart_objects::SmartType_Map));
+ (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
(*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
kButtonName;