diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc index 4981301e07..ffa7203f1f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc @@ -32,14 +32,13 @@ #include <string> -#include "gtest/gtest.h" -#include "mobile/on_system_request_notification.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" +#include "mobile/on_system_request_notification.h" namespace test { namespace components { @@ -49,20 +48,21 @@ namespace on_system_request_notification { namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; -using application_manager::commands::CommandImpl; using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; using test::components::policy_test::MockPolicyHandlerInterface; using namespace mobile_apis; -using testing::SaveArg; +using testing::_; using testing::Mock; using testing::Return; using testing::ReturnRef; -using testing::_; +using testing::SaveArg; namespace { const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "fake-app-id"; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class OnSystemRequestNotificationTest @@ -74,6 +74,7 @@ class OnSystemRequestNotificationTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); } protected: @@ -91,12 +92,14 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillRepeatedly(Return(true)); #ifdef PROPRIETARY_MODE @@ -131,10 +134,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) @@ -168,7 +174,7 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(MockAppPtr())); EXPECT_CALL(*mock_app_, policy_app_id()).Times(0); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _, _)).Times(0); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -188,10 +194,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(false)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -215,7 +224,7 @@ TEST_F( PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) @@ -242,7 +251,7 @@ TEST_F(OnSystemRequestNotificationTest, PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) |