summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2018-11-29 13:03:16 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2018-11-29 13:03:16 -0500
commite443110f744f0aa6ddc03e34a04d12cf556a10dd (patch)
tree3d36576e1c1d2c9ac5c147c3bfebb43c1b90ec89 /src/components/application_manager/src
parent90d1b24267a03cecbf43b7de5331c2d74a876538 (diff)
downloadsdl_core-e443110f744f0aa6ddc03e34a04d12cf556a10dd.tar.gz
Add tests for RegisterApplication and RetryConnection
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8fd7f9e455..d2d2458ac0 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -614,6 +614,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
PolicyAppIdPredicate finder(application->policy_app_id());
ApplicationSet::iterator it =
std::find_if(apps_to_register_.begin(), apps_to_register_.end(), finder);
+ bool is_mismatched_cloud_app = false;
if (apps_to_register_.end() == it) {
DevicePredicate finder(application->device());
@@ -621,24 +622,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
apps_to_register_.begin(), apps_to_register_.end(), finder);
bool found = apps_to_register_.end() != it;
- bool is_mismatched_cloud_app = found && (*it)->is_cloud_app() &&
- policy_app_id != (*it)->policy_app_id();
-
- // Reject registration request if a cloud app registers with the incorrect
- // appID
- if (is_mismatched_cloud_app) {
- std::shared_ptr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- connection_key,
- mobile_apis::FunctionID::RegisterAppInterfaceID,
- message[strings::params][strings::correlation_id].asUInt(),
- mobile_apis::Result::DISALLOWED));
- (*response)[strings::msg_params][strings::info] =
- "Cloud app registered with incorrect app id";
- rpc_service_->ManageMobileCommand(response,
- commands::Command::SOURCE_SDL);
- return ApplicationSharedPtr();
- }
+ is_mismatched_cloud_app = found && (*it)->is_cloud_app() &&
+ policy_app_id != (*it)->policy_app_id();
} else {
application->set_hmi_application_id((*it)->hmi_app_id());
@@ -653,6 +638,21 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
}
apps_to_register_list_lock_ptr_->Release();
+ // Reject registration request if a cloud app registers with the incorrect
+ // appID
+ if (is_mismatched_cloud_app) {
+ std::shared_ptr<smart_objects::SmartObject> response(
+ MessageHelper::CreateNegativeResponse(
+ connection_key,
+ mobile_apis::FunctionID::RegisterAppInterfaceID,
+ message[strings::params][strings::correlation_id].asUInt(),
+ mobile_apis::Result::DISALLOWED));
+ (*response)[strings::msg_params][strings::info] =
+ "Cloud app registered with incorrect app id";
+ rpc_service_->ManageMobileCommand(response, commands::Command::SOURCE_SDL);
+ return ApplicationSharedPtr();
+ }
+
if (!application->hmi_app_id()) {
const bool is_saved =
resume_controller().IsApplicationSaved(policy_app_id, device_mac);
@@ -3813,6 +3813,13 @@ void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) {
applications_list_lock_ptr_->Release();
}
+void ApplicationManagerImpl::AddMockPendingApplication(
+ ApplicationSharedPtr mock_app) {
+ apps_to_register_list_lock_ptr_->Acquire();
+ apps_to_register_.insert(mock_app);
+ apps_to_register_list_lock_ptr_->Release();
+}
+
void ApplicationManagerImpl::SetMockMediaManager(
media_manager::MediaManager* mock_media_manager) {
media_manager_ = mock_media_manager;