diff options
author | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2018-02-16 13:55:01 +0200 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:45 +0300 |
commit | 29df63b5296a71f263952d4075522d019e804fec (patch) | |
tree | d49647351fd3c71752ac0bc0838ab18db8adb0ab | |
parent | 44bb162a73480bfc45f2675897baae456ffcd932 (diff) | |
download | sdl_core-29df63b5296a71f263952d4075522d019e804fec.tar.gz |
Move GetRCApplications function to RCRPCPlugin
Delete logger initialization from UT
Delete logger initialization from UT
9 files changed, 30 insertions, 53 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 7a97b113c8..be79d9e8d1 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -172,8 +172,6 @@ class CommandImpl : public Command { */ void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message); - std::vector<ApplicationSharedPtr> GetApplications(AppExtensionUID uid); - MessageSharedPtr message_; uint32_t default_timeout_; bool allowed_to_terminate_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index e102dc597d..b3f8eef10e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -56,6 +56,9 @@ class RCRPCPlugin : public plugins::RPCPlugin { static const uint32_t kRCPluginID = 153; + typedef std::vector<application_manager::ApplicationSharedPtr> Apps; + static Apps GetRCApplications(application_manager::ApplicationManager& app_mngr); + private: std::unique_ptr<application_manager::CommandFactory> command_factory_; std::unique_ptr<ResourceAllocationManager> resource_allocation_manager_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h index c99b47c5f8..23cf5aa2d0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h @@ -8,8 +8,7 @@ namespace rc_rpc_plugin { -// typedef rc_event_engine::EventDispatcher<application_manager::MessagePtr, -// std::string> RCEventDispatcher; +typedef std::vector<application_manager::ApplicationSharedPtr> Apps; class ResourceAllocationManagerImpl : public ResourceAllocationManager { public: @@ -65,9 +64,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { application_manager::ApplicationSharedPtr application) FINAL; private: - typedef std::vector<application_manager::ApplicationSharedPtr> Apps; - - Apps GetRCApplications(); /** * @brief IsModuleTypeRejected check if current resource was rejected by @@ -136,6 +132,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { hmi_apis::Common_RCAccessMode::eType current_access_mode_; application_manager::ApplicationManager& app_mngr_; + }; } // rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 2069773970..1ed872f273 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -61,7 +61,7 @@ void UnsubscribeFromInteriorVehicleDataForAllModules( void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { LOG4CXX_AUTO_TRACE(logger_); typedef std::vector<application_manager::ApplicationSharedPtr> Apps; - Apps apps = GetApplications(RCRPCPlugin::kRCPluginID); + Apps apps = RCRPCPlugin::GetRCApplications(application_manager_); for (Apps::iterator it = apps.begin(); it != apps.end(); ++it) { application_manager::ApplicationSharedPtr app = *it; DCHECK(app); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 3c306f65ec..d1f11e80f9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -29,7 +29,7 @@ void OnInteriorVehicleDataNotification::Run() { (*message_)[app_mngr::strings::msg_params][message_params::kModuleType].asString(); typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs; - AppPtrs apps = GetApplications(RCRPCPlugin::kRCPluginID); + AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { DCHECK(*it); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index de10dc843a..4d978f2fcc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -81,6 +81,26 @@ void RCRPCPlugin::OnApplicationEvent( } } +RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications(application_manager::ApplicationManager& app_mngr){ + using application_manager::ApplicationSharedPtr; + using application_manager::ApplicationSet; + ApplicationSet accessor = app_mngr.applications().GetData(); + + auto predicate = [](const ApplicationSharedPtr& app) { + auto uid = RCRPCPlugin::kRCPluginID; + return app ? app->QueryInterface(uid).valid() : false; + }; + + auto it = std::find_if(accessor.begin(), accessor.end(), predicate); + + std::vector<ApplicationSharedPtr> result; + while (it != accessor.end()) { + result.push_back(*it); + it = std::find_if(++it, accessor.end(), predicate); + } + return result; +} + } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc index 7116ecd6a5..c5f5dd2aac 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc @@ -125,14 +125,12 @@ void ResourceAllocationManagerImpl::ReleaseResource( } void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { - typedef std::vector<application_manager::ApplicationSharedPtr> Apps; LOG4CXX_AUTO_TRACE(logger_); - Apps app_list = GetRCApplications(); + Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_); Apps::const_iterator app = app_list.begin(); for (; app_list.end() != app; ++app) { - application_manager::ApplicationSharedPtr app_ptr = *app; - const uint32_t application_id = app_ptr->app_id(); + application_manager::ApplicationSharedPtr app_ptr = *app; const uint32_t application_id = app_ptr->app_id(); Resources acquired_modules = GetAcquiredResources(application_id); std::sort(acquired_modules.begin(), acquired_modules.end()); @@ -355,7 +353,7 @@ void ResourceAllocationManagerImpl::OnPolicyEvent( if (PolicyEvent::kApplicationsDisabled == event) { ResetAllAllocations(); - Apps app_list = GetRCApplications(); + Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_); RemoveAppsSubscriptions(app_list); return; } @@ -377,26 +375,4 @@ void ResourceAllocationManagerImpl::ResetAllAllocations() { } } -ResourceAllocationManagerImpl::Apps -ResourceAllocationManagerImpl::GetRCApplications() { - LOG4CXX_AUTO_TRACE(logger_); - using application_manager::ApplicationSharedPtr; - using application_manager::ApplicationSet; - ApplicationSet accessor = app_mngr_.applications().GetData(); - - auto predicate = [](const ApplicationSharedPtr& app) { - auto uid = RCRPCPlugin::kRCPluginID; - return app ? app->QueryInterface(uid).valid() : false; - }; - - auto it = std::find_if(accessor.begin(), accessor.end(), predicate); - - std::vector<ApplicationSharedPtr> result; - while (it != accessor.end()) { - result.push_back(*it); - it = std::find_if(++it, accessor.end(), predicate); - } - return result; -} - } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 593b8ee398..dbe89b8881 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -214,21 +214,5 @@ DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId( } } -std::vector<ApplicationSharedPtr> CommandImpl::GetApplications( - AppExtensionUID uid) { - ApplicationSet accessor = application_manager_.applications().GetData(); - AppExtensionPredicate predicate; - predicate.uid = uid; - - std::vector<ApplicationSharedPtr> result; - ApplicationSetConstIt it = - std::find_if(accessor.begin(), accessor.end(), predicate); - while (it != accessor.end()) { - result.push_back(*it); - it = std::find_if(++it, accessor.end(), predicate); - } - return result; -} - } // namespace commands } // namespace application_manager diff --git a/src/components/test_main.cc b/src/components/test_main.cc index 9688d1e9ac..61606756fe 100644 --- a/src/components/test_main.cc +++ b/src/components/test_main.cc @@ -6,7 +6,6 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "SDLMain")
int main(int argc, char** argv) {
namespace custom_str = utils::custom_string;
- INIT_LOGGER("./log4cxx.properties", true);
testing::InitGoogleMock(&argc, argv);
::testing::DefaultValue<custom_str::CustomString>::Set(
custom_str::CustomString(""));
|