From 05fdb9006ef9c337c49474d0996789124e2401d7 Mon Sep 17 00:00:00 2001 From: "Valerii Malkov (GitHub)" Date: Fri, 10 Jan 2020 21:20:59 +0200 Subject: SDL forwards `OnButtonEvent` notification of `CUSTOM_BUTTON` to `BACKGROUND` App. (#2365) * Bugfix `SDL forwards OnButtonEvent notification` Bugfix `SDL forwards OnButtonEvent notification of CUSTOM_BUTTON to BACKGROUND App.` Issue number #967 * Check that SDL forwards OnButtonEvent notification of CUSTOM_BUTTON to BACKGROUND App * fixup! Bugfix `SDL forwards OnButtonEvent notification` Co-authored-by: Ira Lytvynenko (GitHub) Co-authored-by: Igor Gapchuk (GitHub) <41586842+IGapchuk@users.noreply.github.com> --- .../mobile/on_button_event_notification.cc | 7 +++--- .../mobile/on_button_press_notification.cc | 7 +++--- .../mobile/on_button_notification_commands_test.cc | 29 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src/components') diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 0bf9b40cb6..bca3b20fe0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -105,11 +105,10 @@ void OnButtonEventNotification::Run() { const auto window_id = app->GetSoftButtonWindowID(custom_btn_id); (*message_)[strings::msg_params][strings::window_id] = window_id; const auto window_hmi_level = app->hmi_level(window_id); - if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && - (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { + if ((mobile_api::HMILevel::HMI_NONE == window_hmi_level)) { LOG4CXX_WARN(logger_, - "CUSTOM_BUTTON OnButtonEvent notification is allowed only " - << "in FULL or LIMITED hmi level"); + "CUSTOM_BUTTON OnButtonEvent notification is not allowed in " + "NONE hmi level"); return; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index 8c22844865..c51991742d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -108,11 +108,10 @@ void OnButtonPressNotification::Run() { app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); (*message_)[strings::msg_params][strings::window_id] = window_id; const auto window_hmi_level = app->hmi_level(window_id); - if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && - (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { + if ((mobile_api::HMILevel::HMI_NONE == window_hmi_level)) { LOG4CXX_WARN(logger_, - "CUSTOM_BUTTON OnButtonPress notification is allowed only " - << "in FULL or LIMITED hmi level"); + "CUSTOM_BUTTON OnButtonPress notification is not allowed in " + "NONE hmi level"); return; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc index c0305a15ca..aa48e8916b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc @@ -231,6 +231,35 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) { command->Run(); } +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_CustomButton_SUCCESS_BACKGROUND) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*notification_msg)[am::strings::msg_params] + [am::hmi_response::custom_button_id] = kCustomButtonId; + + std::shared_ptr command( + this->template CreateCommand(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + ON_CALL(*mock_app, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); + EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) + .WillOnce(Return(true)); + EXPECT_CALL(this->mock_rpc_service_, + SendMessageToMobile( + CheckNotificationMessage(TestFixture::kFunctionId), _)); + + command->Run(); +} + TYPED_TEST(OnButtonNotificationCommandsTest, Run_NoSubscribedApps_UNSUCCESS) { typedef typename TestFixture::Notification Notification; -- cgit v1.2.1