summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-05-15 16:21:50 +0300
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-27 18:20:28 +0300
commitd627885845eaf4b3f5097afbb46c142854839562 (patch)
tree1fb41fabae209026f2a4f8794dd3496eaf0ee324
parentfbb2bb87065d55e3815906649efafac5fbf20834 (diff)
downloadsdl_core-d627885845eaf4b3f5097afbb46c142854839562.tar.gz
Fix after rebase
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc24
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc6
7 files changed, 29 insertions, 11 deletions
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 9a3b55e278..efed4a85cc 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
@@ -13,7 +13,7 @@ bool RCRPCPlugin::Init(
application_manager::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handler) {
resource_allocation_manager_.reset(
- new ResourceAllocationManagerImpl(app_manager));
+ new ResourceAllocationManagerImpl(app_manager, rpc_service));
command_factory_.reset(
new rc_rpc_plugin::RCCommandFactory(app_manager,
rpc_service,
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 c0c2ce5412..e814a2e01e 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
@@ -184,6 +184,30 @@ void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) {
}
}
+void ResourceAllocationManagerImpl::SetResourceAquired(
+ const std::string& module_type, const uint32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ allocated_resources_[module_type] = app_id;
+}
+
+void ResourceAllocationManagerImpl::SetResourceFree(
+ const std::string& module_type, const uint32_t app_id) {
+ AllocatedResources::const_iterator allocation =
+ allocated_resources_.find(module_type);
+ if (allocated_resources_.end() == allocation) {
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is not allocated.");
+ return;
+ }
+ if (app_id != allocation->second) {
+ LOG4CXX_ERROR(logger_,
+ "Resource " << module_type
+ << " is allocated by different application "
+ << allocation->second);
+ }
+ allocated_resources_.erase(allocation);
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released.");
+}
+
std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources(
const uint32_t application_id) const {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
index 7ab4819002..5098f6472e 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
@@ -130,8 +130,6 @@ class ButtonPressRequestTest
CheckHMIType(kPolicyAppId,
mobile_apis::AppHMIType::eType::REMOTE_CONTROL,
nullptr)).WillByDefault(Return(true));
- ON_CALL(mock_allocation_manager_, is_rc_enabled())
- .WillByDefault(Return(true));
}
MessageSharedPtr CreateBasicMessage() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
index 594cf62c58..5aecb8664b 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
@@ -100,8 +100,6 @@ class GetInteriorVehicleDataRequestTest
CheckHMIType(
_, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr))
.WillByDefault(Return(true));
- ON_CALL(mock_allocation_manager_, is_rc_enabled())
- .WillByDefault(Return(true));
}
MessageSharedPtr CreateBasicMessage() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
index 00be1de397..1bbe66faf2 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
@@ -133,8 +133,6 @@ class RCGetInteriorVehicleDataConsentTest
CheckHMIType(
_, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr))
.WillByDefault(Return(true));
- ON_CALL(mock_allocation_manager_, is_rc_enabled())
- .WillByDefault(Return(true));
ON_CALL(mock_policy_handler_, CheckModule(_, _))
.WillByDefault(Return(true));
ON_CALL(app_mngr_, GetPluginManager())
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
index 1d5e63e2df..68985e5f94 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
@@ -89,8 +89,6 @@ class SetInteriorVehicleDataRequestTest
CheckHMIType(kPolicyAppId,
mobile_apis::AppHMIType::eType::REMOTE_CONTROL,
nullptr)).WillByDefault(Return(true));
- ON_CALL(mock_allocation_manager_, is_rc_enabled())
- .WillByDefault(Return(true));
}
MessageSharedPtr CreateBasicMessage() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
index a5079eaf86..8f58ac7eb7 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
@@ -36,6 +36,7 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_rpc_service.h"
#include "application_manager/policies/mock_policy_handler_interface.h"
#include "utils/shared_ptr.h"
#include "utils/make_shared.h"
@@ -44,6 +45,7 @@
using test::components::application_manager_test::MockApplication;
using test::components::application_manager_test::MockApplicationManager;
+using test::components::application_manager_test::MockRPCService;
using ::testing::_;
using ::testing::Mock;
@@ -88,8 +90,6 @@ class RAManagerTest : public ::testing::Test {
auto plugin_id = rc_rpc_plugin::RCRPCPlugin::kRCPluginID;
app_ext_ptr_ = utils::MakeShared<rc_rpc_plugin::RCAppExtension>(plugin_id);
ON_CALL(*mock_app_1_, app_id()).WillByDefault(Return(kAppId1));
-
- OnRCStatusNotoficationExpectations();
}
void CheckResultWithHMILevelAndAccessMode(
@@ -146,6 +146,8 @@ TEST_F(RAManagerTest, AcquireResource_NoAppRegistered_Expect_InUse) {
TEST_F(RAManagerTest,
AcquireResource_AppRegisteredAnyHmiLevelResourceFree_Expect_Allowed) {
// Arrange
+ EXPECT_CALL(mock_app_mngr_, application(kAppId1))
+ .WillOnce(Return(mock_app_1_));
ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_);
// Act & Assert
EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED,