diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin')
10 files changed, 453 insertions, 118 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h index 01f20a68e3..f9f780b84b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h @@ -123,11 +123,12 @@ class ChangeRegistrationRequest /** * @brief Check parameters (name, vr) for * coincidence with already known parameters of registered applications - * + * @param device_id device identifier * @return SUCCESS if there is no coincidence of app.name/VR synonyms, * otherwise appropriate error code returns */ - mobile_apis::Result::eType CheckCoincidence(); + mobile_apis::Result::eType CheckCoincidence( + const connection_handler::DeviceHandle& device_id); /** * @brief Checks if requested name is allowed by policy diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 8a80db9cdf..c894b355d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -215,9 +215,23 @@ class RegisterAppInterfaceRequest */ bool IsApplicationSwitched(); + /** + * @brief Information about given Connection Key. + * @param key Unique key used by other components as session identifier + * @param device_id device identifier. + * @param mac_address uniq address + * @return false in case of error or true in case of success + */ + bool GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id = nullptr, + std::string* mac_address = nullptr) const; + private: std::string response_info_; mobile_apis::Result::eType result_code_; + connection_handler::DeviceHandle device_handle_; + std::string device_id_; policy::PolicyHandlerInterface& GetPolicyHandler(); DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc index d9a7eccddf..82e0703da1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc @@ -61,12 +61,13 @@ void CancelInteractionRequest::Run() { auto function_id = static_cast<mobile_apis::FunctionID::eType>( (*message_)[strings::msg_params][strings::func_id].asInt()); - if (helpers::Compare<mobile_apis::FunctionID::eType, helpers::NEQ, helpers::ALL>( - function_id, - mobile_apis::FunctionID::PerformInteractionID, - mobile_apis::FunctionID::AlertID, - mobile_apis::FunctionID::ScrollableMessageID, - mobile_apis::FunctionID::SliderID)) { + if (helpers:: + Compare<mobile_apis::FunctionID::eType, helpers::NEQ, helpers::ALL>( + function_id, + mobile_apis::FunctionID::PerformInteractionID, + mobile_apis::FunctionID::AlertID, + mobile_apis::FunctionID::ScrollableMessageID, + mobile_apis::FunctionID::SliderID)) { LOG4CXX_ERROR(logger_, "Bad function ID" << function_id); SendResponse(false, mobile_apis::Result::INVALID_ID); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc index ef81babdd6..8940ea3f59 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -49,7 +49,7 @@ struct IsSameNickname { } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_id_; }; } // namespace @@ -160,7 +160,7 @@ void ChangeRegistrationRequest::Run() { return; } - if (mobile_apis::Result::SUCCESS != CheckCoincidence()) { + if (mobile_apis::Result::SUCCESS != CheckCoincidence(app->device())) { SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); return; } @@ -578,36 +578,46 @@ bool ChangeRegistrationRequest::IsWhiteSpaceExist() { return false; } -mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { +mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence( + const connection_handler::DeviceHandle& device_id) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; + + const auto& accessor = application_manager_.applications().GetData(); custom_str::CustomString app_name; - uint32_t app_id = connection_key(); + const uint32_t app_id = connection_key(); if (msg_params.keyExists(strings::app_name)) { app_name = msg_params[strings::app_name].asCustomString(); } - ApplicationSetConstIt it = accessor.begin(); - for (; accessor.end() != it; ++it) { - if (app_id == (*it)->app_id()) { + for (const auto& app : accessor) { + if (app->device() != device_id) { + continue; + } + + if (app->app_id() == app_id) { continue; } - const custom_str::CustomString& cur_name = (*it)->name(); + const auto& cur_name = app->name(); if (msg_params.keyExists(strings::app_name)) { if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); return mobile_apis::Result::DUPLICATE_NAME; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector<smart_objects::SmartObject>* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { @@ -617,18 +627,37 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector<smart_objects::SmartObject>* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); return mobile_apis::Result::DUPLICATE_NAME; } - } // end vr check - } // application for end + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check + + } // Application for end return mobile_apis::Result::SUCCESS; } 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 a85dec10bb..fc99bb323c 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 @@ -86,8 +86,8 @@ void OnSystemRequestNotification::Run() { 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->device(), app->policy_app_id(), request_type)) { LOG4CXX_WARN(logger_, "Request type " << stringified_request_type << " is not allowed by policies"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 701002ed65..f0da4ebbab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -164,7 +164,7 @@ struct IsSameNickname { } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_id_; }; } // namespace @@ -184,13 +184,14 @@ RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( rpc_service, hmi_capabilities, policy_handler) - , result_code_(mobile_apis::Result::INVALID_ENUM) {} + , result_code_(mobile_apis::Result::INVALID_ENUM) + , device_handle_(0) {} RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} bool RegisterAppInterfaceRequest::Init() { LOG4CXX_AUTO_TRACE(logger_); - return true; + return GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_); } void RegisterAppInterfaceRequest::Run() { @@ -224,20 +225,25 @@ void RegisterAppInterfaceRequest::Run() { return; } + LOG4CXX_DEBUG( + logger_, + "device_handle: " << device_handle_ << " device_id: " << device_id_); + if (IsApplicationSwitched()) { return; } + // Cache the original app ID (for legacy behavior) + const auto policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); + ApplicationSharedPtr application = - application_manager_.application(connection_key()); + application_manager_.application(device_id_, policy_app_id); if (application) { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } - // cache the original app ID (for legacy behavior) - const std::string policy_app_id = - application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -842,14 +848,15 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( - application->policy_app_id(), hmi_types); + application->mac_address(), application->policy_app_id(), hmi_types); response_params[strings::icon_resumed] = file_system::FileExists(application->app_icon_path()); SendResponse(true, result_code, add_info.c_str(), &response_params); if (msg_params.keyExists(strings::app_hmi_type)) { - GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), + GetPolicyHandler().SetDefaultHmiTypes(application->device(), + application->policy_app_id(), &(msg_params[strings::app_hmi_type])); } @@ -863,7 +870,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // Start PTU after successfull registration // Sends OnPermissionChange notification to mobile right after RAI response // and HMI level set-up - GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); + GetPolicyHandler().OnAppRegisteredOnMobile(application->mac_address(), + application->policy_app_id()); if (result_code != mobile_apis::Result::RESUME_FAILED) { resumer.StartResumption(application, hash_id); @@ -968,48 +976,72 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; - ApplicationSetConstIt it = accessor.begin(); - const custom_str::CustomString& app_name = - msg_params[strings::app_name].asCustomString(); + const auto& accessor = application_manager_.applications().GetData(); + const auto& app_name = msg_params[strings::app_name].asCustomString(); - for (; accessor.end() != it; ++it) { - // name check - const custom_str::CustomString& cur_name = (*it)->name(); + for (const auto& app : accessor) { + if (app->device() != device_handle_) { + continue; + } + // Name check + const auto& cur_name = app->name(); if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector<smart_objects::SmartObject>* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector<smart_objects::SmartObject>* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - } // end vr check + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check - } // application for end + } // Application for end if (!out_duplicate_apps.empty()) { return mobile_apis::Result::DUPLICATE_NAME; @@ -1138,14 +1170,19 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { const custom_string::CustomString mobile_app_id( application_manager_.GetCorrectMobileIDFromMessage(message_)); - const ApplicationSet& applications = - application_manager_.applications().GetData(); - - ApplicationSetConstIt it = applications.begin(); - ApplicationSetConstIt it_end = applications.end(); - - for (; it != it_end; ++it) { - if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) { + const auto& applications = application_manager_.applications().GetData(); + + for (const auto& app : applications) { + if (mobile_app_id.CompareIgnoreCase(app->policy_app_id().c_str())) { + if (app->device() != device_handle_) { + LOG4CXX_DEBUG(logger_, + "These policy_app_id equal, but applications have " + "different device id" + << " mobile_app_id: " << mobile_app_id.c_str() + << " device_handle: " << device_handle_ + << " device_handle: " << app->device()); + continue; + } return true; } } @@ -1330,7 +1367,7 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); - auto app = application_manager_.application_by_policy_id(policy_app_id); + auto app = application_manager_.application(device_id_, policy_app_id); if (!app) { LOG4CXX_DEBUG( @@ -1341,12 +1378,13 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { LOG4CXX_DEBUG(logger_, "Application with policy id " << policy_app_id << " is found."); - if (!application_manager_.IsAppInReconnectMode(policy_app_id)) { + if (!application_manager_.IsAppInReconnectMode(device_handle_, + policy_app_id)) { LOG4CXX_DEBUG( logger_, "Policy id " << policy_app_id << " is not found in reconnection list."); SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); - return false; + return true; } LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); @@ -1372,6 +1410,51 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { return true; } +bool RegisterAppInterfaceRequest::GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id, + std::string* mac_address) const { + LOG4CXX_AUTO_TRACE(logger_); + + if ((nullptr == mac_address) && (nullptr == device_id)) { + LOG4CXX_ERROR(logger_, + "Can't get data on session key because device id and mac " + "address are empty."); + return false; + } + + connection_handler::DeviceHandle device_handle = 0; + auto& connect_handler = application_manager_.connection_handler(); + + auto result = connect_handler.GetDataOnSessionKey( + connection_key(), nullptr, nullptr, &device_handle); + + if (result) { + LOG4CXX_DEBUG( + logger_, + "Failed to get device info for connection key: " << connection_key()); + return false; + } + + if (mac_address) { + result = connect_handler.get_session_observer().GetDataOnDeviceID( + device_handle, nullptr, nullptr, mac_address, nullptr); + } + + if (result) { + LOG4CXX_DEBUG(logger_, + "Failed get unique address info for connection key: " + << connection_key()); + return false; + } + + if (device_id) { + *device_id = device_handle; + } + + return true; +} + policy::PolicyHandlerInterface& RegisterAppInterfaceRequest::GetPolicyHandler() { return policy_handler_; 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 e70433f29b..9be5a270f5 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 @@ -470,8 +470,8 @@ void SystemRequest::Run() { static_cast<rpc::policy_table_interface_base::RequestType>( request_type)); - if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), - request_type)) { + if (!policy_handler.IsRequestTypeAllowed( + application->device(), application->policy_app_id(), request_type)) { LOG4CXX_ERROR(logger_, "RequestType " << stringified_request_type << " is DISALLOWED by policies"); 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 69ed8fb311..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 @@ -62,6 +62,7 @@ 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 @@ -73,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: @@ -90,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 @@ -130,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(_)) @@ -167,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); @@ -187,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); @@ -214,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)) @@ -241,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)) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 0e8374b75a..ac45e90d8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -67,6 +67,8 @@ using ::testing::_; using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; +using ::testing::SaveArg; +using ::testing::SetArgPointee; namespace am = ::application_manager; @@ -75,12 +77,15 @@ using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest; namespace { const uint32_t kConnectionKey = 1u; +const uint32_t kConnectionKey2 = 2u; const hmi_apis::Common_Language::eType kHmiLanguage = hmi_apis::Common_Language::EN_US; const mobile_apis::Language::eType kMobileLanguage = mobile_apis::Language::EN_US; -const std::string kMacAddress = "test_mac_address"; -const std::string kAppId = "test_app_id"; +const std::string kMacAddress1 = "test_mac_address1"; +const std::string kMacAddress2 = "test_mac_address2"; +const std::string kAppId1 = "test_app1_id"; +const std::string kAppId2 = "test_app2_id"; const std::string kFullAppId = "test_app_id_long"; const std::string kDummyString = "test_string"; const std::vector<uint32_t> kDummyDiagModes; @@ -94,6 +99,7 @@ class RegisterAppInterfaceRequestTest : msg_(CreateMessage()) , command_(CreateCommand<RegisterAppInterfaceRequest>(msg_)) , app_name_("test_app_name_") + , app2_name_("test_app2_name_") , lock_ptr_(std::make_shared<sync_primitives::Lock>()) , mock_application_helper_( application_manager_test::MockApplicationHelper:: @@ -112,7 +118,7 @@ class RegisterAppInterfaceRequestTest void InitBasicMessage() { (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; - (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId1; (*msg_)[am::strings::msg_params][am::strings::full_app_id] = kFullAppId; (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_; (*msg_)[am::strings::msg_params][am::strings::language_desired] = @@ -130,11 +136,11 @@ class RegisterAppInterfaceRequestTest MockAppPtr CreateBasicMockedApp() { MockAppPtr mock_app = CreateMockApp(); ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_)); - ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress1)); ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString)); ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); - ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId1)); ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); return mock_app; @@ -154,7 +160,7 @@ class RegisterAppInterfaceRequestTest void InitGetters() { ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) - .WillByDefault(Return(kAppId)); + .WillByDefault(Return(kAppId1)); ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); @@ -168,7 +174,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(ReturnRef(kDummyString)); ON_CALL(app_mngr_settings_, supported_diag_modes()) .WillByDefault(ReturnRef(kDummyDiagModes)); - ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) + ON_CALL(mock_policy_handler_, GetAppRequestTypes(_, _)) .WillByDefault(Return(std::vector<std::string>())); ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) .WillByDefault(Return(policy::RequestType::State::EMPTY)); @@ -180,7 +186,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); ON_CALL(app_mngr_, GetDeviceTransportType(_)) .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI)); - ON_CALL(app_mngr_, IsAppInReconnectMode(_)).WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAppInReconnectMode(_, _)).WillByDefault(Return(false)); ON_CALL(app_mngr_, application_by_policy_id(_)) .WillByDefault(Return(ApplicationSharedPtr())); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) @@ -201,7 +207,7 @@ class RegisterAppInterfaceRequestTest void SetCommonExpectionsOnSwitchedApplication( MockAppPtr mock_app, mobile_apis::Result::eType response_result_code) { - EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, AddApplication(_, _, _)).Times(0); EXPECT_CALL( mock_rpc_service_, @@ -250,6 +256,7 @@ class RegisterAppInterfaceRequestTest std::shared_ptr<RegisterAppInterfaceRequest> command_; const utils::custom_string::CustomString app_name_; + const utils::custom_string::CustomString app2_name_; std::shared_ptr<sync_primitives::Lock> lock_ptr_; am::ApplicationSet app_set_; @@ -280,7 +287,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) { TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { InitBasicMessage(); - (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1; EXPECT_CALL(app_mngr_, IsStopping()) .WillOnce(Return(false)) .WillOnce(Return(true)) @@ -289,20 +296,30 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(handle, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); ON_CALL(app_mngr_, applications()) .WillByDefault( Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared<utils::CallNothing>(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -323,6 +340,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -360,10 +378,19 @@ TEST_F(RegisterAppInterfaceRequestTest, EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(_, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + .WillOnce(Return(mock_app)); MessageSharedPtr expected_message = CreateMessage(smart_objects::SmartType_Map); @@ -401,11 +428,11 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault( Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared<utils::CallNothing>(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -444,7 +471,7 @@ TEST_F(RegisterAppInterfaceRequestTest, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -456,10 +483,23 @@ TEST_F(RegisterAppInterfaceRequestTest, (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + app_set_.insert(mock_app); + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) .WillRepeatedly(Return(mock_app)); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + ON_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillByDefault(Return(mock_app)); + + ON_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) + .WillByDefault(Return(true)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -482,6 +522,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::SUCCESS); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -492,11 +533,22 @@ TEST_F(RegisterAppInterfaceRequestTest, const std::string request_hash_id = "abc123"; (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) .WillRepeatedly(Return(mock_app)); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillOnce(Return(mock_app)); + ON_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) + .WillByDefault(Return(true)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -520,7 +572,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -528,11 +580,23 @@ TEST_F(RegisterAppInterfaceRequestTest, SwitchApplication_NoHash_ExpectCleanupResumeFailed) { InitBasicMessage(); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) .WillRepeatedly(Return(mock_app)); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) + .WillOnce(Return(true)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -550,6 +614,133 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_SameDeviceFailed) { + using namespace am; + + InitBasicMessage(); + + MockAppPtr mock_app1 = CreateBasicMockedApp(); + + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillOnce(Return(mock_app1)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs( + mobile_apis::Result::APPLICATION_REGISTERED_ALREADY), + am::commands::Command::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_DifferentDevicesSuccess) { + MockAppPtr mock_app1 = CreateBasicMockedApp(); + const connection_handler::DeviceHandle device_id1 = 1u; + ON_CALL(*mock_app1, device()).WillByDefault(Return(device_id1)); + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + InitBasicMessage(); + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2; + EXPECT_CALL(app_mngr_, IsStopping()) + .WillOnce(Return(false)) + .WillOnce(Return(true)) + .WillOnce(Return(false)); + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey2, _, _)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1)) + .WillOnce(Return(false)); + + connection_handler::DeviceHandle device_id2 = 2u; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey2, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id2), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id2, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress2), Return(0))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + ON_CALL(*mock_app2, device()).WillByDefault(Return(device_id2)); + ON_CALL(*mock_app2, mac_address()).WillByDefault(ReturnRef(kMacAddress2)); + EXPECT_CALL(app_mngr_, application(kMacAddress2, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + + EXPECT_CALL(app_mngr_, application(kConnectionKey2)) + .WillOnce(Return(mock_app2)); + + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) + .WillByDefault(Return(true)); + policy::StatusNotifier notify_upd_manager = + std::make_shared<utils::CallNothing>(); + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress2, kAppId1, _)) + .WillByDefault(Return(notify_upd_manager)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app2)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(2); + EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + + ASSERT_TRUE(command_->Init()); command_->Run(); } 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 7351cd67d3..211888d6be 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 @@ -74,6 +74,7 @@ const std::string kAppStorageFolder = "fake-storage"; const std::string kSystemFilesPath = "/fake/system/files"; const std::string kFileName = "Filename"; const uint32_t kHmiAppId = 3u; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class SystemRequestTest @@ -99,13 +100,15 @@ class SystemRequestTest ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); ON_CALL(app_mngr_settings_, system_files_path()) .WillByDefault(ReturnRef(kSystemFilesPath)); ON_CALL(app_mngr_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ON_CALL(mock_policy_handler_, IsRequestTypeAllowed(kAppPolicyId, _)) + ON_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kAppPolicyId, _)) .WillByDefault(Return(true)); } @@ -146,9 +149,10 @@ TEST_F(SystemRequestTest, PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -191,9 +195,10 @@ TEST_F( PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -216,9 +221,10 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); @@ -241,9 +247,9 @@ TEST_F(SystemRequestTest, Run_RequestType_IconURL_Success) { const std::vector<uint8_t> binary_data = {1u, 2u}; (*msg)[am::strings::params][am::strings::binary_data] = binary_data; - EXPECT_CALL( - mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, mobile_apis::RequestType::ICON_URL)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::ICON_URL)) .WillOnce(Return(true)); EXPECT_CALL(app_mngr_settings_, app_icons_folder()) .WillOnce(ReturnRef(kAppStorageFolder)); |