diff options
author | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-11 19:15:52 +0300 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-27 18:20:29 +0300 |
commit | 22359508681253d181ea920adf8f5101395be5f2 (patch) | |
tree | 98c917b501a526175ee6dd00045079fcc4f8514f | |
parent | b513f40eb94ebf6bd7399cd0b02bc57d81fc101c (diff) | |
download | sdl_core-22359508681253d181ea920adf8f5101395be5f2.tar.gz |
Fixes after rebase
9 files changed, 28 insertions, 41 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index fb41f05cb7..76e3105640 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1110,7 +1110,7 @@ class ApplicationManagerImpl app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE; -bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id, + bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id, const smart_objects::SmartObject& display_capabilities); /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt index d367b03136..11dd35d061 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt @@ -53,6 +53,7 @@ set(LIBRARIES v4_protocol_v1_2_no_extra SmartObjects Utils + Policy ) if(ENABLE_LOG) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h index 10f242ed00..b369ad38f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #include "application_manager/commands/command_notification_impl.h" +#include "policy/policy_table/enums.h" #include <vector> namespace sdl_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index bd025a103e..67e9275691 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -33,6 +33,7 @@ #include <cstring> #include <cstdio> #include <string> +#include <iostream> #include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" @@ -74,19 +75,15 @@ void OnSystemRequestNotification::Run() { << " is not registered."); return; } - const mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>( (*message_)[strings::msg_params][strings::request_type].asInt()); - const policy::PolicyHandlerInterface& policy_handler = - policy_handler_; const std::string stringified_request_type = rpc::policy_table_interface_base::EnumToJsonString( static_cast<rpc::policy_table_interface_base::RequestType>( request_type)); - - if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), - request_type)) { + if (!policy_handler_.IsRequestTypeAllowed(app->policy_app_id(), + request_type)) { LOG4CXX_WARN(logger_, "Request type " << stringified_request_type << " is not allowed by policies"); @@ -98,8 +95,8 @@ void OnSystemRequestNotification::Run() { if (request_subtype_present) { const std::string request_subtype = (*message_)[strings::msg_params][strings::request_subtype].asString(); - if (!policy_handler.IsRequestSubTypeAllowed(app->policy_app_id(), - request_subtype)) { + if (!policy_handler_.IsRequestSubTypeAllowed(app->policy_app_id(), + request_subtype)) { LOG4CXX_ERROR(logger_, "Request subtype: " << request_subtype << " is DISALLOWED by policies"); @@ -131,7 +128,7 @@ void OnSystemRequestNotification::Run() { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; if ((*message_)[strings::msg_params].keyExists(strings::url)) { (*message_)[strings::msg_params][strings::timeout] = - policy_handler.TimeoutExchangeSec(); + policy_handler_.TimeoutExchangeSec(); } } @@ -141,8 +138,7 @@ void OnSystemRequestNotification::Run() { #ifdef PROPRIETARY_MODE void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { LOG4CXX_AUTO_TRACE(logger_); - const uint32_t timeout = - policy_handler_.TimeoutExchangeSec(); + const uint32_t timeout = policy_handler_.TimeoutExchangeSec(); size_t content_length; char size_str[24]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index 972faed1d9..62eb2d59c5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -462,8 +462,7 @@ void SystemRequest::Run() { static_cast<mobile_apis::RequestType::eType>( (*message_)[strings::msg_params][strings::request_type].asInt()); - const policy::PolicyHandlerInterface& policy_handler = - policy_handler_; + const policy::PolicyHandlerInterface& policy_handler = policy_handler_; const std::string stringified_request_type = rpc::policy_table_interface_base::EnumToJsonString( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index da067cfe03..da51c3e4e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -30,6 +30,7 @@ set(LIBRARIES connectionHandler sdl_rpc_plugin jsoncpp + Policy ) create_cotired_test("sdl_commands_test" "${SOURCES}" "${LIBRARIES}" ) 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 1b9bf06589..d6e1b2fe52 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 @@ -73,15 +73,11 @@ class OnSystemRequestNotificationTest void PreConditions() { ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - - ON_CALL(app_mngr_, GetPolicyHandler()) - .WillByDefault(ReturnRef(mock_policy_handler_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); } protected: MockAppPtr mock_app_; - MockPolicyHandlerInterface mock_policy_handler_; }; TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { @@ -95,13 +91,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); - MockAppPtr mock_app = CreateMockApp(); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); - std::string policy_app_id; - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) - .WillOnce(Return(true)); + .WillRepeatedly(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillRepeatedly(Return(true)); #ifdef PROPRIETARY_MODE EXPECT_CALL(mock_policy_handler_, TimeoutExchangeSec()).WillOnce(Return(5u)); @@ -135,11 +131,9 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); - MockAppPtr mock_app = CreateMockApp(); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); - std::string policy_app_id; - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id)); + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) .WillOnce(Return(true)); @@ -171,10 +165,9 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); - MockAppPtr mock_app = CreateMockApp(); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(MockAppPtr())); - EXPECT_CALL(*mock_app, policy_app_id()).Times(0); + EXPECT_CALL(*mock_app_, policy_app_id()).Times(0); EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)).Times(0); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -195,18 +188,15 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); - MockAppPtr mock_app = CreateMockApp(); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); - std::string policy_app_id; - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id)); + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) .WillOnce(Return(false)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)).Times(0); - ; command->Run(); } @@ -231,7 +221,7 @@ TEST_F( IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) .WillOnce(Return(false)); - EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); auto command = CreateCommand<OnSystemRequestNotification>(msg); @@ -259,7 +249,7 @@ TEST_F(OnSystemRequestNotificationTest, .WillOnce(Return(true)); smart_objects::SmartObjectSPtr result; - EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)) + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)) .WillOnce((SaveArg<0>(&result))); auto command = CreateCommand<OnSystemRequestNotification>(msg); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc index ed11e48e46..7214e0eea4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc @@ -160,7 +160,7 @@ TEST_F(SystemRequestTest, .WillOnce(Return(mobile_apis::Result::SUCCESS)); smart_objects::SmartObjectSPtr result; - EXPECT_CALL(app_mngr_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); @@ -201,7 +201,7 @@ TEST_F( .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); ASSERT_TRUE(command->Init()); @@ -222,7 +222,7 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); ASSERT_TRUE(command->Init()); diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 78b6675d57..bd29b2942e 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -591,7 +591,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void set_access_remote( utils::SharedPtr<AccessRemote> access_remote) = 0; - /** * @brief Checks if there is existing URL in the EndpointUrls vector with * index saved in the policy manager and if not, it moves to the next |