summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-03-17 15:19:23 -0400
committerJackLivio <jack@livio.io>2019-03-17 15:19:23 -0400
commitc6020f483bcd9739779ce4fa87c0065f0ae7cac8 (patch)
treeae033ddb1821cb6b0b8b0d85f884d0eba29c246a
parenta593ff38c4a5a01f1cbb467b955c12d44783e995 (diff)
parent6c6e363dc72338893dc8c577e9b59867a3215aa2 (diff)
downloadsdl_core-tests/cloud_app_disconnect+fix.tar.gz
Merge remote-tracking branch 'origin/develop' into tests/cloud_app_disconnecttests/cloud_app_disconnect+fix
# Conflicts: # src/components/application_manager/test/application_manager_impl_test.cc
-rw-r--r--.github/ISSUE_TEMPLATE.md4
-rw-r--r--src/components/application_manager/include/application_manager/app_service_manager.h181
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h6
-rw-r--r--src/components/application_manager/include/application_manager/rpc_passing_handler.h4
-rw-r--r--src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h3
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc31
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc11
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt38
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc151
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc135
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc30
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_db.cc2
-rw-r--r--src/components/application_manager/src/app_service_manager.cc60
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc18
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc4
-rw-r--r--src/components/application_manager/src/commands/request_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc4
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc2
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc2
-rw-r--r--src/components/application_manager/src/rpc_passing_handler.cc15
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc2
-rw-r--r--src/components/application_manager/src/system_time/system_time_handler_impl.cc2
-rwxr-xr-xsrc/components/application_manager/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/app_service_manager_test.cc439
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc12
-rw-r--r--src/components/application_manager/test/commands/command_impl_test.cc11
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_service_manager.h93
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc2
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc168
-rw-r--r--src/components/application_manager/test/sdl_pt_update.json8
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc2
-rw-r--r--src/components/include/application_manager/application_manager.h3
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h21
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_observer.h3
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h2
-rw-r--r--src/components/interfaces/HMI_API.xml15
-rw-r--r--src/components/interfaces/MOBILE_API.xml2
-rw-r--r--src/components/policy/policy_external/test/json/valid_sdl_pt_update.json8
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc31
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc31
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc39
-rw-r--r--src/components/policy/policy_regular/test/valid_sdl_pt_update.json8
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h3
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc5
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc222
-rw-r--r--src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h2
-rw-r--r--src/components/transport_manager/src/cloud/websocket_client_connection.cc3
75 files changed, 1674 insertions, 258 deletions
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 1b58b20e86..d62fd997a0 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,4 +1,4 @@
-[Delete any non-applicable sections, but we may ask for more information.]
+[Delete any non-applicable sections, but we may ask for more information. Please reference the [SmartDeviceLink GitHub Best Practices](https://d83tozu1c8tt6.cloudfront.net/media/resources/SDL_GitHub_BestPractices.pdf) for further instructions on how to enter an issue.]
### Bug Report
[Summary]
@@ -20,4 +20,4 @@
* Testing Against: [What you tested with to observe this behavior. Proxy, App, HMI etc.]
##### Test Case, Sample Code, and / or Example App
-[Paste a link to a PR, gist, or other code that exemplifies this behavior] \ No newline at end of file
+[Paste a link to a PR, gist, or other code that exemplifies this behavior]
diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h
index f7c46178c5..9690d7cd46 100644
--- a/src/components/application_manager/include/application_manager/app_service_manager.h
+++ b/src/components/application_manager/include/application_manager/app_service_manager.h
@@ -34,10 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_
#include "application_manager/application.h"
+#include "application_manager/rpc_passing_handler.h"
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/application.h"
-#include "application_manager/rpc_passing_handler.h"
namespace resumption {
class LastState;
@@ -52,6 +51,7 @@ struct AppService {
smart_objects::SmartObject record;
};
+class RPCPassingHandler;
class ApplicationManager;
/**
* @brief The AppServiceManager is TODO.
@@ -70,97 +70,153 @@ class AppServiceManager {
/**
* @brief Class destructor
*/
- ~AppServiceManager();
+ virtual ~AppServiceManager();
/**
- * @brief TODO
- * @param manifest
+ * @brief Publish an app service. This service will be activated if it is the
+ * default service for its type, or if it is the first service to register of
+ * its type.
+ * @param manifest - The app service manifest of the service to be published
+ * @param mobile_service - True, if the service is being published by a mobile
+ * app. False, if published by the embedded system.
+ * @param connection_key - If mobile_service is true, the connection key of
+ * the app publishing this service.
+ * @return The app service record of the published app service
*/
- smart_objects::SmartObject PublishAppService(
+ virtual smart_objects::SmartObject PublishAppService(
const smart_objects::SmartObject& manifest,
const bool mobile_service,
- const uint32_t connection_key);
+ const uint32_t connection_key = 0u);
/**
- * @brief TODO
- * @param service_id
+ * @brief Unpublish an existing app service
+ * @param service_id - The ID of the app service to be deleted.
+ * @return True on success, false otherwise
*/
- bool UnpublishAppService(const std::string service_id);
-
- void OnAppActivated(ApplicationConstSharedPtr app);
+ virtual bool UnpublishAppService(const std::string service_id);
/**
- * @brief TODO
- * @param connection_key
+ * @brief Callback for when an application is activated. Will activate all
+ * services which were published by this app.
+ * @param app - The application that was activated.
*/
- void UnpublishServices(const uint32_t connection_key);
+ virtual void OnAppActivated(ApplicationConstSharedPtr app);
/**
- * @brief TODO
- * @param service_id
+ * @brief Unpublish any published services for a given mobile application
+ * @param connection_key - The connection key of the application from which
+ * all published services should be deleted.
*/
- bool SetDefaultService(const std::string service_id);
+ virtual void UnpublishServices(const uint32_t connection_key);
/**
- * @brief TODO
- * @param service_id
+ * @brief Sets a service to the default service for its type
+ * @param service_id - The ID of the service to become the default
+ * @return True on success, false otherwise
*/
- bool RemoveDefaultService(const std::string service_id);
+ virtual bool SetDefaultService(const std::string service_id);
/**
- * @brief TODO
- * @param service_id
+ * @brief Removes a service from the list of default services.
+ * @param service_id - The ID of the existing default service.
+ * @return True on success, false otherwise
*/
- bool ActivateAppService(const std::string service_id);
+ virtual bool RemoveDefaultService(const std::string service_id);
/**
- * @brief TODO
- * @param service_id
+ * @brief Activate an existing service
+ * @param service_id - The ID of the service to be activated.
+ * @return True if the service is active, false otherwise
*/
- bool DeactivateAppService(const std::string service_id);
+ virtual bool ActivateAppService(const std::string service_id);
/**
- * @brief TODO
- * @param manifest
+ * @brief Deactivate an existing active service
+ * @param service_id - The ID of the service to be deactivated.
+ * @return True if the service was deactivated, false otherwise
*/
- std::vector<smart_objects::SmartObject> GetAllServices();
- std::vector<std::pair<std::string, AppService> > GetActiveServices();
+ virtual bool DeactivateAppService(const std::string service_id);
- void GetProviderByType(const std::string& service_type,
- bool mobile_consumer,
- ApplicationSharedPtr& app,
- bool& hmi_service);
-
- void GetProviderByID(const std::string& service_id,
- bool mobile_consumer,
- ApplicationSharedPtr& app,
- bool& hmi_service);
+ /**
+ * @brief Get a list of all published service records.
+ * @return A list of all all published service records.
+ */
+ virtual std::vector<smart_objects::SmartObject> GetAllServiceRecords();
- AppService* ActiveServiceByType(std::string service_type);
+ /**
+ * @brief Get a list of all active app services.
+ * @return A list of all all active app services.
+ */
+ virtual std::vector<AppService> GetActiveServices();
- AppService* EmbeddedServiceForType(std::string service_type);
+ /**
+ * @brief Retrieve the active service provider for a given service type
+ * @param service_type - The service type of the provider to be retrieved
+ * @param mobile_consumer - True, if the consumer trying to communicate with
+ * the provider is a mobile application
+ * @param app - Output parameter that will be filled with the application
+ * providing the requested service on success, unchanged on failure
+ * @param hmi_service - Output parameter set to true if the service
+ * provider is the HMI, unchanged on failure
+ */
+ virtual void GetProviderByType(const std::string& service_type,
+ const bool mobile_consumer,
+ ApplicationSharedPtr& app,
+ bool& hmi_service);
- AppService* FindServiceByName(std::string name);
+ /**
+ * @brief Retrieve the service provider with a given service ID
+ * @param service_type - The service type of the provider to be retrieved
+ * @param mobile_consumer - True, if the consumer trying to communicate with
+ * the provider is a mobile application
+ * @param app - Output parameter that will be filled with the application
+ * providing the requested service on success, unchanged on failure
+ * @param hmi_service - Output parameter set to true if the service
+ * provider is the HMI, unchanged on failure
+ */
+ virtual void GetProviderByID(const std::string& service_id,
+ const bool mobile_consumer,
+ ApplicationSharedPtr& app,
+ bool& hmi_service);
- AppService* FindServiceByID(std::string service_id);
+ /**
+ * @brief Get the active service for a given service type.
+ * @param service_type - The service type
+ * @return A pointer to the active service for the given service type on
+ * success, NULL on failure
+ */
+ virtual AppService* ActiveServiceForType(const std::string service_type);
- std::string DefaultServiceByType(std::string service_type);
+ /**
+ * @brief Get the embedded service for a given service type.
+ * @param service_type - The service type
+ * @return A pointer to the embedded service for the given service type on
+ * success, NULL on failure
+ */
+ virtual AppService* EmbeddedServiceForType(const std::string service_type);
/**
- * @brief TODO
- * @param service_id
- * @param service_published
+ * @brief Get the service with a given service ID.
+ * @param service_type - The service ID
+ * @return A pointer to requested service on success, NULL on failure
*/
- void SetServicePublished(const std::string service_id,
- bool service_published);
+ virtual AppService* FindServiceByID(const std::string service_id);
/**
- * @brief TODO
- * @param out_params
+ * @brief Update a navigation system capability struct with the capabilities
+ * of the active navigation service.
+ * @param out_params - The struct to be modified
+ * @return True on success, false otherwise (if there was no active NAVIGATION
+ * service)
*/
- bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params);
+ virtual bool UpdateNavigationCapabilities(
+ smart_objects::SmartObject& out_params);
- RPCPassingHandler& GetRPCPassingHandler();
+ /**
+ * @brief Get the RPCPassingHandler tied to this object
+ * @return The RPCPassingHandler tied to this object
+ */
+ virtual RPCPassingHandler& GetRPCPassingHandler();
private:
ApplicationManager& app_manager_;
@@ -170,16 +226,27 @@ class AppServiceManager {
std::map<std::string, AppService> published_services_;
RPCPassingHandler rpc_passing_handler_;
+ void SetServicePublished(const std::string service_id,
+ bool service_published);
void AppServiceUpdated(
const smart_objects::SmartObject& service_record,
const mobile_apis::ServiceUpdateReason::eType update_reason,
smart_objects::SmartObject& msg_params);
void GetProviderFromService(const AppService& service,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service);
- AppService* FindServiceByPolicyAppID(std::string policy_app_id,
- std::string type);
+
+ /**
+ * @brief Get the policy app ID of the default service provider for a given
+ * service type.
+ * @param service_type - The service type
+ * @return The policy app ID of the default service provider for the given
+ * service type on success, "" on failure
+ */
+ std::string DefaultServiceByType(const std::string service_type);
+ AppService* FindServiceByPolicyAppID(const std::string policy_app_id,
+ const std::string type);
std::string GetPolicyAppID(AppService service);
};
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 8668f10d2c..738458ef26 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
@@ -42,6 +42,7 @@
#include <memory>
#include "application_manager/application_manager.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/hmi_capabilities.h"
#include "application_manager/message.h"
#include "application_manager/message_helper.h"
@@ -1595,9 +1596,8 @@ class ApplicationManagerImpl
plugin_manager_.reset(plugin_manager.release());
}
- virtual void SetAppServiceManager(
- std::unique_ptr<AppServiceManager>& app_service_manager) {
- app_service_manager_.reset(app_service_manager.release());
+ virtual void SetAppServiceManager(AppServiceManager* app_service_manager) {
+ app_service_manager_.reset(app_service_manager);
}
private:
diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
index 3ed10ff1e6..ab85b1374f 100644
--- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h
+++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
@@ -33,11 +33,11 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_
+#include <deque>
#include "application_manager/application.h"
+#include "application_manager/commands/command.h"
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/app_service_manager.h"
-#include <deque>
#include "utils/timer.h"
namespace application_manager {
diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
index add440ad80..05565861f6 100644
--- a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
@@ -39,7 +39,7 @@
#include "utils/lock.h"
#include "utils/macro.h"
#include "utils/system_time_handler.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/event_engine/event_observer.h"
namespace application_manager {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt
index 2bdc150906..1e23aac8ee 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt
@@ -80,5 +80,5 @@ install(TARGETS app_service_rpc_plugin
)
if(BUILD_TESTS)
- # add_subdirectory(test)
+ add_subdirectory(test)
endif()
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
index 8295e855fa..7c80ec5e03 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
@@ -77,7 +77,8 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl {
virtual void on_event(const app_mngr::event_engine::MobileEvent& event);
private:
- AppServiceRpcPlugin* plugin_;
+ void HandleSubscribe();
+
DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h
index 1411b23e5a..7e2b26d8fb 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h
@@ -70,7 +70,6 @@ class GetAppServiceDataResponseFromMobile
virtual void Run();
private:
- AppServiceRpcPlugin* plugin_;
DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataResponseFromMobile);
};
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
index 63812056f1..6d8b0c08cc 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2018, Ford Motor Company
+ Copyright (c) 2019, Ford Motor Company, Livio
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
disclaimer in the documentation and/or other materials provided with the
distribution.
- Neither the name of the Ford Motor Company nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ Neither the name of the the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
index 7c32d9bbe1..fd7312ca98 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
@@ -32,6 +32,8 @@
#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h"
+#include "application_manager/app_service_manager.h"
+
namespace app_service_rpc_plugin {
using namespace application_manager;
namespace commands {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc
index 822cd0a29b..635cd7319a 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc
@@ -33,7 +33,6 @@
#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc
index 9ce6ffdb50..c0b1b274fb 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc
@@ -33,7 +33,7 @@
#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
#include "application_manager/message_helper.h"
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc
index 9e2289d39e..b489ec4765 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc
@@ -33,7 +33,6 @@
#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
index 1131448d2f..fa704c1995 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
@@ -32,6 +32,8 @@
#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h"
+#include "application_manager/app_service_manager.h"
+
namespace app_service_rpc_plugin {
using namespace application_manager;
namespace commands {
@@ -61,7 +63,7 @@ void ASGetAppServiceRecordsRequest::Run() {
smart_objects::SmartObject records =
smart_objects::SmartObject(smart_objects::SmartType_Array);
std::vector<smart_objects::SmartObject> service_records =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
int index = 0;
for (auto& record : service_records) {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
index 2b66993d8f..70a5a10be0 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
namespace app_service_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
index b816016fa7..637240666d 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
namespace app_service_rpc_plugin {
@@ -59,8 +61,8 @@ void ASPublishAppServiceRequest::Run() {
smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
smart_objects::SmartObject service_record =
- application_manager_.GetAppServiceManager().PublishAppService(
- manifest, false, UINT32_MAX);
+ application_manager_.GetAppServiceManager().PublishAppService(manifest,
+ false);
response_params[strings::app_service_record] = service_record;
SendResponse(true,
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
index 0d387785ee..7c2e62abe2 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
@@ -52,26 +52,24 @@ GetAppServiceDataRequest::GetAppServiceDataRequest(
application_manager,
rpc_service,
hmi_capabilities,
- policy_handler)
- , plugin_(NULL) {
- auto plugin = (application_manager.GetPluginManager().FindPluginToProcess(
- mobile_apis::FunctionID::GetAppServiceDataID,
- app_mngr::commands::Command::CommandSource::SOURCE_MOBILE));
- if (plugin) {
- plugin_ = dynamic_cast<AppServiceRpcPlugin*>(&(*plugin));
- }
-}
+ policy_handler) {}
GetAppServiceDataRequest::~GetAppServiceDataRequest() {}
void GetAppServiceDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID,
+ hmi_apis::FunctionID::AppService_GetAppServiceData,
+ &(*message_),
+ true);
+}
+
+void GetAppServiceDataRequest::HandleSubscribe() {
std::string service_type =
(*message_)[strings::msg_params][strings::service_type].asString();
-
ApplicationSharedPtr app = application_manager_.application(connection_key());
- if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) {
+ if (app && (*message_)[strings::msg_params].keyExists(strings::subscribe)) {
bool subscribe =
(*message_)[strings::msg_params][strings::subscribe].asBool();
auto& ext = AppServiceAppExtension::ExtractASExtension(*app);
@@ -81,11 +79,6 @@ void GetAppServiceDataRequest::Run() {
ext.UnsubscribeFromAppService(service_type);
}
}
-
- SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID,
- hmi_apis::FunctionID::AppService_GetAppServiceData,
- &(*message_),
- true);
}
void GetAppServiceDataRequest::on_event(
@@ -97,6 +90,9 @@ void GetAppServiceDataRequest::on_event(
mobile_apis::Result::eType result = static_cast<mobile_apis::Result::eType>(
msg_params[strings::result_code].asInt());
bool success = IsMobileResultSuccess(result);
+ if (success) {
+ HandleSubscribe();
+ }
const char* info = msg_params.keyExists(strings::info)
? msg_params[strings::info].asCharArray()
@@ -118,6 +114,9 @@ void GetAppServiceDataRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(hmi_result);
bool success = PrepareResultForMobileResponse(
hmi_result, HmiInterfaces::HMI_INTERFACE_AppService);
+ if (success) {
+ HandleSubscribe();
+ }
const char* info = msg_params.keyExists(strings::info)
? msg_params[strings::info].asCharArray()
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc
index 2bf81b3a2d..0af1a5436b 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc
@@ -33,7 +33,6 @@
#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc
index df7bbba2f7..32ad8e014d 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc
@@ -33,7 +33,6 @@
#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc
index f8c1f3892d..90fca04eb2 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc
@@ -50,15 +50,7 @@ GetAppServiceDataResponseFromMobile::GetAppServiceDataResponseFromMobile(
application_manager,
rpc_service,
hmi_capabilities,
- policy_handler)
- , plugin_(NULL) {
- auto plugin = (application_manager.GetPluginManager().FindPluginToProcess(
- mobile_apis::FunctionID::PublishAppServiceID,
- app_mngr::commands::Command::CommandSource::SOURCE_MOBILE));
- if (plugin) {
- plugin_ = dynamic_cast<AppServiceRpcPlugin*>(&(*plugin));
- }
-}
+ policy_handler) {}
GetAppServiceDataResponseFromMobile::~GetAppServiceDataResponseFromMobile() {}
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
index 2c6ba414e0..fd3891e0e8 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
@@ -31,7 +31,9 @@
*/
#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h"
+
#include "app_service_rpc_plugin/app_service_app_extension.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
index 9e262f0ca3..4046ac7379 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
@@ -73,6 +75,15 @@ void PerformAppServiceInteractionRequest::Run() {
return;
}
+ if (!service->record[strings::service_manifest][strings::allow_app_consumers]
+ .asBool()) {
+ SendResponse(
+ false,
+ mobile_apis::Result::REJECTED,
+ "The requested service ID does not allow mobile app consumers");
+ return;
+ }
+
bool request_service_active = false;
if (msg_params.keyExists(strings::request_service_active)) {
request_service_active =
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc
index 8d71174c8d..2a7b644cb3 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc
@@ -32,7 +32,6 @@
#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h"
#include "application_manager/application_impl.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc
index 774ec93720..5e84f42c34 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc
@@ -32,7 +32,6 @@
#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h"
#include "application_manager/application_impl.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
index 22d8e50c3a..171c10913e 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc
index b1136c79d0..d1bfc6e154 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc
@@ -34,7 +34,6 @@
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
-#include "interfaces/MOBILE_API.h"
namespace app_service_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt
new file mode 100644
index 0000000000..97d2efaf07
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt
@@ -0,0 +1,38 @@
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
+
+include_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin/include
+ ${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+ ${POLICY_MOCK_INCLUDE_PATH}/
+ ${CMAKE_SOURCE_DIR}/src
+)
+
+
+set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands)
+
+file(GLOB SOURCES
+ ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
+ ${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc
+ ${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc
+ ${COMMANDS_TEST_DIR}/hmi/*
+ ${COMMANDS_TEST_DIR}/mobile/*
+ ${COMPONENTS_DIR}/application_manager/src/message.cc
+ ${COMPONENTS_DIR}/application_manager/src/event_engine/*
+)
+
+set(LIBRARIES
+ gmock
+ Utils
+ SmartObjects
+ HMI_API
+ MOBILE_API
+ connectionHandler
+ app_service_rpc_plugin
+ sdl_rpc_plugin
+ jsoncpp
+ Policy
+)
+
+create_cotired_test("app_services_commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
new file mode 100644
index 0000000000..8ef87b6de9
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/command_request_test.h"
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+#include "gtest/gtest.h"
+
+#include "hmi/as_app_service_activation_request.h"
+#include "hmi/as_app_service_activation_response.h"
+#include "hmi/as_get_active_service_consent_request.h"
+#include "hmi/as_get_active_service_consent_response.h"
+#include "hmi/as_get_app_service_data_request_from_hmi.h"
+#include "hmi/as_get_app_service_data_request_to_hmi.h"
+#include "hmi/as_get_app_service_data_response_from_hmi.h"
+#include "hmi/as_get_app_service_data_response_to_hmi.h"
+#include "hmi/as_get_app_service_records_request.h"
+#include "hmi/as_get_app_service_records_response.h"
+#include "hmi/as_perform_app_service_interaction_request_from_hmi.h"
+#include "hmi/as_perform_app_service_interaction_request_to_hmi.h"
+#include "hmi/as_perform_app_service_interaction_response_from_hmi.h"
+#include "hmi/as_perform_app_service_interaction_response_to_hmi.h"
+#include "hmi/as_publish_app_service_request.h"
+#include "hmi/as_publish_app_service_response.h"
+#include "hmi/on_as_app_service_data_notification.h"
+#include "hmi/on_as_app_service_data_notification_from_hmi.h"
+
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_event_dispatcher.h"
+
+namespace am = application_manager;
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace dummy_hmi_commands_test {
+
+namespace commands = app_service_rpc_plugin::commands;
+
+using ::testing::_;
+using ::testing::NotNull;
+using ::testing::Types;
+using application_manager::commands::MessageSharedPtr;
+using ::test::components::event_engine_test::MockEventDispatcher;
+using ::test::components::application_manager_test::MockApplicationManager;
+using ::test::components::application_manager_test::
+ MockApplicationManagerSettings;
+using ::application_manager::ApplicationSharedPtr;
+using ::test::components::application_manager_test::MockApplication;
+
+template <class Command>
+class HMICommandsTest : public components::commands_test::CommandRequestTest<
+ CommandsTestMocks::kIsNice> {
+ public:
+ typedef Command CommandType;
+
+ void InitCommand(const uint32_t& timeout) OVERRIDE {
+ stream_retry_.first = 0;
+ stream_retry_.second = 0;
+ EXPECT_CALL(app_mngr_settings_, default_timeout())
+ .WillOnce(ReturnRef(timeout));
+ ON_CALL(app_mngr_, event_dispatcher())
+ .WillByDefault(ReturnRef(event_dispatcher_));
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, start_stream_retry_amount())
+ .WillByDefault(ReturnRef(stream_retry_));
+ }
+
+ protected:
+ std::pair<uint32_t, int32_t> stream_retry_;
+};
+
+template <class Command>
+class HMICommandsTestFirst : public HMICommandsTest<Command> {
+ public:
+ using typename HMICommandsTest<Command>::CommandType;
+};
+
+/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few
+ * TYPED_TEST_CASE for HMI and mobile commands
+ */
+
+typedef Types<commands::ASAppServiceActivationRequest,
+ commands::ASAppServiceActivationResponse,
+ commands::ASGetActiveServiceConsentRequest,
+ commands::ASGetActiveServiceConsentResponse,
+ commands::ASPerformAppServiceInteractionRequestFromHMI,
+ commands::ASGetAppServiceDataRequestToHMI,
+ commands::ASGetAppServiceDataResponseFromHMI,
+ commands::ASGetAppServiceDataResponseToHMI,
+ commands::ASGetAppServiceRecordsRequest,
+ commands::ASGetAppServiceRecordsResponse,
+ commands::ASPerformAppServiceInteractionRequestFromHMI,
+ commands::ASPerformAppServiceInteractionRequestToHMI,
+ commands::ASPerformAppServiceInteractionResponseFromHMI,
+ commands::ASPerformAppServiceInteractionResponseToHMI,
+ commands::ASPublishAppServiceRequest,
+ commands::ASPublishAppServiceResponse,
+ commands::OnASAppServiceDataNotification,
+ commands::OnASAppServiceDataNotificationFromHMI>
+ HMICommandsListFirst;
+
+TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst);
+
+TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) {
+ std::shared_ptr<typename TestFixture::CommandType> command =
+ this->template CreateCommand<typename TestFixture::CommandType>();
+ EXPECT_NE(command.use_count(), 0);
+}
+
+} // namespace dummy_hmi_commands_test
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
new file mode 100644
index 0000000000..3c8a780128
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/command_request_test.h"
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+#include "gtest/gtest.h"
+
+#include "mobile/get_app_service_data_request.h"
+#include "mobile/get_app_service_data_request_to_mobile.h"
+#include "mobile/get_app_service_data_response.h"
+#include "mobile/get_app_service_data_response_from_mobile.h"
+#include "mobile/on_app_service_data_notification.h"
+#include "mobile/on_app_service_data_notification_from_mobile.h"
+#include "mobile/perform_app_service_interaction_request.h"
+#include "mobile/perform_app_service_interaction_request_to_mobile.h"
+#include "mobile/perform_app_service_interaction_response.h"
+#include "mobile/perform_app_service_interaction_response_from_mobile.h"
+#include "mobile/publish_app_service_request.h"
+#include "mobile/publish_app_service_response.h"
+
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "test/application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_event_dispatcher.h"
+
+namespace am = application_manager;
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace dummy_mobile_commands_test {
+
+namespace commands = app_service_rpc_plugin::commands;
+using ::testing::_;
+using ::testing::NotNull;
+using ::testing::Types;
+using am::commands::MessageSharedPtr;
+using ::test::components::event_engine_test::MockEventDispatcher;
+using ::test::components::application_manager_test::MockApplicationManager;
+using ::test::components::application_manager_test::
+ MockApplicationManagerSettings;
+using ::application_manager::ApplicationSharedPtr;
+using ::test::components::application_manager_test::MockApplication;
+
+namespace {
+const std::string kEmptyString_ = "";
+} // namespace
+
+template <class Command>
+class MobileCommandsTest : public components::commands_test::CommandRequestTest<
+ CommandsTestMocks::kIsNice> {
+ public:
+ typedef Command CommandType;
+
+ void InitCommand(const uint32_t& timeout) OVERRIDE {
+ EXPECT_CALL(app_mngr_settings_, default_timeout())
+ .WillOnce(ReturnRef(timeout));
+ ON_CALL(app_mngr_, event_dispatcher())
+ .WillByDefault(ReturnRef(event_dispatcher_));
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, app_icons_folder())
+ .WillByDefault(ReturnRef(kEmptyString_));
+ }
+};
+
+template <class Command>
+class MobileCommandsTestFirst : public MobileCommandsTest<Command> {
+ public:
+ using typename MobileCommandsTest<Command>::CommandType;
+};
+
+/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few
+ * TYPED_TEST_CASE for HMI and mobile commands
+ */
+
+typedef Types<commands::GetAppServiceDataRequest,
+ commands::GetAppServiceDataRequestToMobile,
+ commands::GetAppServiceDataResponse,
+ commands::GetAppServiceDataResponseFromMobile,
+ commands::OnAppServiceDataNotification,
+ commands::OnAppServiceDataNotificationFromMobile,
+ commands::PerformAppServiceInteractionRequest,
+ commands::PerformAppServiceInteractionRequestToMobile,
+ commands::PerformAppServiceInteractionResponse,
+ commands::PerformAppServiceInteractionResponseFromMobile,
+ commands::PublishAppServiceRequest,
+ commands::PublishAppServiceResponse> MobileCommandsListFirst;
+
+TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst);
+
+TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) {
+ std::shared_ptr<typename TestFixture::CommandType> command =
+ this->template CreateCommand<typename TestFixture::CommandType>();
+ EXPECT_NE(command.use_count(), 0);
+}
+
+} // namespace dummy_mobile_commands_test
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
index 90160d9953..3a97ebdfb5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/response_from_hmi.h"
#include "utils/macro.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
index 0beba8dc6b..7cd8410d8e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
@@ -34,7 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_
#include "application_manager/commands/notification_from_hmi.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
index 73ec1137a8..0677c97db8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
@@ -31,6 +31,8 @@
*/
#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
@@ -120,7 +122,7 @@ void OnBCSystemCapabilityUpdatedNotification::Run() {
break;
case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
auto app_service_caps =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
index 2b3611fece..a582670426 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
@@ -31,11 +31,12 @@
*/
#include "sdl_rpc_plugin/commands/mobile/get_file_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
#include "interfaces/MOBILE_API.h"
#include "application_manager/message_helper.h"
-#include "application_manager/app_service_manager.h"
#include "utils/file_system.h"
#include <boost/crc.hpp>
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
index 63a4416139..2a25928b97 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
@@ -31,7 +31,9 @@
*/
#include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h"
+
#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
#include <set>
@@ -143,7 +145,7 @@ void GetSystemCapabilityRequest::Run() {
break;
case mobile_apis::SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
response_params
[strings::system_capability][strings::app_services_capabilities] =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
index b5e3a73ee4..a8544ae643 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
@@ -1,4 +1,6 @@
#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
@@ -86,7 +88,7 @@ void OnSystemCapabilityUpdatedNotification::Run() {
break;
case mobile_apis::SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
auto app_service_caps =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
index 3cfe4d7118..fb809e8834 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
@@ -248,6 +248,8 @@
namespace sdl_rpc_plugin {
using namespace application_manager;
+CREATE_LOGGERPTR_GLOBAL(logger_, "HMICommandFactory")
+
HMICommandFactory::HMICommandFactory(
ApplicationManager& application_manager,
rpc_service::RPCService& rpc_service,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
index a6497ca6e1..874d27b4b0 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
@@ -223,6 +223,8 @@
#include "hmi/on_tts_reset_timeout_notification.h"
#include "hmi/dial_number_request.h"
#include "hmi/dial_number_response.h"
+#include "hmi/bc_get_file_path_request.h"
+#include "hmi/bc_get_file_path_response.h"
#include "application_manager/commands/commands_test.h"
#include "application_manager/mock_application.h"
@@ -496,7 +498,9 @@ typedef Types<commands::hmi::OnButtonEventNotification,
typedef Types<commands::AllowAllAppsRequest,
commands::AllowAllAppsResponse,
commands::AllowAppRequest,
- commands::AllowAppResponse> HMICommandsListFifth;
+ commands::AllowAppResponse,
+ commands::BCGetFilePathRequest,
+ commands::BCGetFilePathResponse> HMICommandsListFifth;
TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst);
TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond);
@@ -507,30 +511,30 @@ TYPED_TEST_CASE(HMICommandsTestFifth, HMICommandsListFifth);
TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(HMICommandsTestSecond, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(HMICommandsTestThird, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(HMICommandsTestFourth, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(HMICommandsTestFifth, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
} // namespace dummy_hmi_commands_test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc
index a90c0c70fc..917de81fb3 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc
@@ -140,6 +140,8 @@ TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) {
std::shared_ptr<SDLActivateAppRequest> command(
CreateCommand<SDLActivateAppRequest>(msg));
+ EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID))
+ .WillOnce(Return(ApplicationSharedPtr()));
EXPECT_CALL(app_mngr_, state_controller())
.WillOnce(ReturnRef(mock_state_controller_));
EXPECT_CALL(mock_state_controller_,
@@ -446,8 +448,10 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) {
EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false));
EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(true));
+#ifndef EXTERNAL_PROPRIETARY_MODE
EXPECT_CALL(app_mngr_, application(kAppID))
.WillOnce(Return(ApplicationSharedPtr()));
+#endif
EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID))
.WillOnce(Return(mock_app));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
index 8589cbb6be..9c20143c39 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
@@ -62,6 +62,8 @@
#include "mobile/end_audio_pass_thru_request.h"
#include "mobile/end_audio_pass_thru_response.h"
#include "mobile/generic_response.h"
+#include "mobile/get_file_request.h"
+#include "mobile/get_file_response.h"
#include "mobile/get_way_points_request.h"
#include "mobile/get_way_points_response.h"
#include "mobile/list_files_request.h"
@@ -78,6 +80,7 @@
#include "mobile/on_keyboard_input_notification.h"
#include "mobile/on_language_change_notification.h"
#include "mobile/on_permissions_change_notification.h"
+#include "mobile/on_system_capability_updated_notification.h"
#include "mobile/on_system_request_notification.h"
#include "mobile/on_tbt_client_state_notification.h"
#include "mobile/on_touch_event_notification.h"
@@ -220,6 +223,8 @@ typedef Types<commands::AddCommandRequest,
commands::EndAudioPassThruRequest,
commands::EndAudioPassThruResponse,
commands::GenericResponse,
+ commands::GetFileRequest,
+ commands::GetFileResponse,
commands::GetWayPointsRequest,
commands::GetWayPointsResponse,
commands::ListFilesRequest,
@@ -236,12 +241,13 @@ typedef Types<commands::AddCommandRequest,
commands::mobile::OnKeyBoardInputNotification,
commands::OnLanguageChangeNotification,
commands::OnPermissionsChangeNotification,
- commands::mobile::OnSystemRequestNotification,
- commands::OnTBTClientStateNotification,
- commands::mobile::OnTouchEventNotification>
+ commands::mobile::OnSystemCapabilityUpdatedNotification>
MobileCommandsListFirst;
-typedef Types<commands::OnWayPointChangeNotification,
+typedef Types<commands::mobile::OnSystemRequestNotification,
+ commands::OnTBTClientStateNotification,
+ commands::mobile::OnTouchEventNotification,
+ commands::OnWayPointChangeNotification,
commands::PerformAudioPassThruRequest,
commands::PerformAudioPassThruResponse,
commands::PerformInteractionRequest,
@@ -277,12 +283,12 @@ typedef Types<commands::OnWayPointChangeNotification,
commands::SubscribeWayPointsRequest,
commands::SubscribeWayPointsResponse,
commands::SystemResponse,
- commands::UnregisterAppInterfaceRequest,
- commands::UnregisterAppInterfaceResponse,
- commands::UnsubscribeButtonRequest,
- commands::UnsubscribeButtonResponse> MobileCommandsListSecond;
+ commands::UnregisterAppInterfaceRequest> MobileCommandsListSecond;
-typedef Types<commands::UnsubscribeWayPointsRequest,
+typedef Types<commands::UnregisterAppInterfaceResponse,
+ commands::UnsubscribeButtonRequest,
+ commands::UnsubscribeButtonResponse,
+ commands::UnsubscribeWayPointsRequest,
commands::UnsubscribeWayPointsResponse,
commands::UpdateTurnListRequest,
commands::UpdateTurnListResponse> MobileCommandsListThird;
@@ -294,18 +300,18 @@ TYPED_TEST_CASE(MobileCommandsTestThird, MobileCommandsListThird);
TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(MobileCommandsTestSecond, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
TYPED_TEST(MobileCommandsTestThird, CtorAndDtorCall) {
std::shared_ptr<typename TestFixture::CommandType> command =
this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
+ EXPECT_NE(command.use_count(), 0);
}
} // namespace dummy_mobile_commands_test
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
index 393b01c952..22d2790183 100644
--- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc
+++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
@@ -33,7 +33,7 @@
#include <unistd.h>
#include "application_manager/app_launch/app_launch_data_db.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/app_launch/app_launch_sql_queries.h"
#include "application_manager/smart_object_keys.h"
#include "application_manager/message_helper.h"
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index d148e4ef61..1711180980 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/help_prompt_manager_impl.h"
+#include "application_manager/app_service_manager.h"
#include <algorithm>
#include <iterator>
@@ -103,7 +103,8 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
}
}
}
- app_service.default_service = GetPolicyAppID(app_service) == default_app_id;
+ app_service.default_service =
+ !default_app_id.empty() && GetPolicyAppID(app_service) == default_app_id;
auto ret = published_services_.insert(
std::pair<std::string, AppService>(service_id, app_service));
@@ -120,7 +121,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
// Activate the new service if it is the default for its service type, or if
// no service is active of its service type
- AppService* active_service = ActiveServiceByType(service_type);
+ AppService* active_service = ActiveServiceForType(service_type);
if (!active_service || app_service.default_service) {
ActivateAppService(service_id);
}
@@ -189,7 +190,8 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) {
}
}
-std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
+std::vector<smart_objects::SmartObject>
+AppServiceManager::GetAllServiceRecords() {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<smart_objects::SmartObject> services;
sync_primitives::AutoLock lock(published_services_lock_);
@@ -201,11 +203,11 @@ std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
}
void AppServiceManager::GetProviderByType(const std::string& service_type,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
- auto active_service = ActiveServiceByType(service_type);
+ auto active_service = ActiveServiceForType(service_type);
if (!active_service) {
LOG4CXX_ERROR(logger_,
"There is no active service for the given service type: "
@@ -218,7 +220,7 @@ void AppServiceManager::GetProviderByType(const std::string& service_type,
}
void AppServiceManager::GetProviderByID(const std::string& service_id,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -234,7 +236,7 @@ void AppServiceManager::GetProviderByID(const std::string& service_id,
}
void AppServiceManager::GetProviderFromService(const AppService& service,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -327,7 +329,7 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) {
const std::string service_type =
service[strings::service_manifest][strings::service_type].asString();
- auto active_service = ActiveServiceByType(service_type);
+ auto active_service = ActiveServiceForType(service_type);
if (active_service) {
active_service->record[strings::service_active] = false;
AppServiceUpdated(active_service->record,
@@ -374,7 +376,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) {
const std::string service_type =
service[strings::service_manifest][strings::service_type].asString();
auto embedded_service = EmbeddedServiceForType(service_type);
- if (embedded_service) {
+ if (embedded_service &&
+ embedded_service->record[strings::service_id].asString() !=
+ service[strings::service_id].asString()) {
embedded_service->record[strings::service_active] = true;
AppServiceUpdated(embedded_service->record,
mobile_apis::ServiceUpdateReason::ACTIVATED,
@@ -391,7 +395,8 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) {
return true;
}
-AppService* AppServiceManager::ActiveServiceByType(std::string service_type) {
+AppService* AppServiceManager::ActiveServiceForType(
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -407,7 +412,7 @@ AppService* AppServiceManager::ActiveServiceByType(std::string service_type) {
}
AppService* AppServiceManager::EmbeddedServiceForType(
- std::string service_type) {
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -421,21 +426,8 @@ AppService* AppServiceManager::EmbeddedServiceForType(
return NULL;
}
-AppService* AppServiceManager::FindServiceByName(std::string name) {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock lock(published_services_lock_);
- for (auto it = published_services_.begin(); it != published_services_.end();
- ++it) {
- if (it->second.record[strings::service_manifest][strings::service_name]
- .asString() == name) {
- return &(it->second);
- }
- }
- return NULL;
-}
-
AppService* AppServiceManager::FindServiceByPolicyAppID(
- std::string policy_app_id, std::string type) {
+ const std::string policy_app_id, const std::string type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -452,7 +444,7 @@ AppService* AppServiceManager::FindServiceByPolicyAppID(
return NULL;
}
-AppService* AppServiceManager::FindServiceByID(std::string service_id) {
+AppService* AppServiceManager::FindServiceByID(const std::string service_id) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
@@ -464,7 +456,8 @@ AppService* AppServiceManager::FindServiceByID(std::string service_id) {
return &(it->second);
}
-std::string AppServiceManager::DefaultServiceByType(std::string service_type) {
+std::string AppServiceManager::DefaultServiceByType(
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
Json::Value& dictionary = last_state_.get_dictionary();
if (dictionary[kAppServiceSection][kDefaults].isMember(service_type)) {
@@ -474,7 +467,7 @@ std::string AppServiceManager::DefaultServiceByType(std::string service_type) {
}
void AppServiceManager::SetServicePublished(const std::string service_id,
- bool service_published) {
+ const bool service_published) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
auto it = published_services_.find(service_id);
@@ -500,7 +493,7 @@ bool AppServiceManager::UpdateNavigationCapabilities(
ns_smart_device_link::ns_smart_objects::
EnumConversionHelper<mobile_apis::AppServiceType::eType>::EnumToString(
mobile_apis::AppServiceType::NAVIGATION, &navi_service_type);
- auto service = ActiveServiceByType(navi_service_type);
+ auto service = ActiveServiceForType(navi_service_type);
if (!service) {
return false;
}
@@ -544,13 +537,12 @@ void AppServiceManager::AppServiceUpdated(
services[-1] = service;
}
-std::vector<std::pair<std::string, AppService> >
-AppServiceManager::GetActiveServices() {
- std::vector<std::pair<std::string, AppService> > active_services;
+std::vector<AppService> AppServiceManager::GetActiveServices() {
+ std::vector<AppService> active_services;
for (auto it = published_services_.begin(); it != published_services_.end();
++it) {
if (it->second.record[strings::service_active].asBool()) {
- active_services.push_back(*it);
+ active_services.push_back(it->second);
}
}
return active_services;
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 735741814a..8a8671c167 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -933,6 +933,9 @@ void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) {
void ApplicationManagerImpl::RefreshCloudAppInformation() {
LOG4CXX_AUTO_TRACE(logger_);
+ if (is_stopping()) {
+ return;
+ }
std::vector<std::string> enabled_apps;
GetPolicyHandler().GetEnabledCloudApps(enabled_apps);
std::vector<std::string>::iterator enabled_it = enabled_apps.begin();
@@ -2825,6 +2828,21 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
it = accessor.GetData().begin();
}
}
+
+ bool send_pending_update_app_list = false;
+ {
+ sync_primitives::AutoLock auto_lock(apps_to_register_list_lock_ptr_);
+ if (!apps_to_register_.empty()) {
+ send_pending_update_app_list = true;
+ apps_to_register_.clear();
+ }
+ }
+
+ // Only send update app list if pending apps were removed.
+ if (send_pending_update_app_list) {
+ SendUpdateAppList();
+ }
+
if (is_ignition_off) {
resume_controller().OnIgnitionOff();
}
diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc
index 344831f882..2d875db387 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -36,9 +36,11 @@
#include "utils/macro.h"
#include "application_manager/commands/command_request_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
-#include "application_manager/rpc_service.h"
#include "application_manager/message_helper.h"
+#include "application_manager/rpc_service.h"
#include "smart_objects/smart_object.h"
#include "smart_objects/enum_schema_item.h"
diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc
index 0adb389e76..5581f027c0 100644
--- a/src/components/application_manager/src/commands/request_from_hmi.cc
+++ b/src/components/application_manager/src/commands/request_from_hmi.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/commands/request_from_hmi.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/request_info.h"
#include "application_manager/rpc_service.h"
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 6cd6747e99..060eaf011c 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -34,7 +34,7 @@
#include "utils/logger.h"
#include "application_manager/hmi_capabilities_impl.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "smart_objects/smart_object.h"
#include "application_manager/message_helper.h"
#include "application_manager/smart_object_keys.h"
@@ -46,6 +46,8 @@
namespace application_manager {
namespace formatters = ns_smart_device_link::ns_json_handler::formatters;
+CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities")
+
namespace {
std::map<std::string, hmi_apis::Common_VrCapabilities::eType>
vr_enum_capabilities;
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index c8e9032dfa..584fb4e697 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/resumption/resumption_data_json.h"
#include "smart_objects/smart_object.h"
#include "json/json.h"
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 2574da5fb5..6205e028d0 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/rpc_handler_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/plugin_manager/plugin_keys.h"
namespace application_manager {
diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc
index 8d93659a27..37b01a92f6 100644
--- a/src/components/application_manager/src/rpc_passing_handler.cc
+++ b/src/components/application_manager/src/rpc_passing_handler.cc
@@ -35,12 +35,13 @@
#include <algorithm>
#include <iterator>
+#include "application_manager/app_service_manager.h"
#include "application_manager/application.h"
#include "application_manager/application_manager.h"
-#include "application_manager/rpc_passing_handler.h"
-#include "application_manager/rpc_handler.h"
#include "application_manager/commands/command_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/rpc_handler.h"
+#include "application_manager/rpc_passing_handler.h"
#include "application_manager/smart_object_keys.h"
#include "encryption/hashing.h"
#include "resumption/last_state.h"
@@ -82,7 +83,7 @@ bool RPCPassingHandler::CanHandleFunctionID(int32_t function_id) {
auto services = app_service_manager_.GetActiveServices();
for (auto it = services.begin(); it != services.end(); ++it) {
auto handled_rpcs =
- it->second.record[strings::service_manifest][strings::handled_rpcs];
+ it->record[strings::service_manifest][strings::handled_rpcs];
for (size_t i = 0; i < handled_rpcs.length(); i++) {
if (handled_rpcs[i].asInt() == function_id) {
return true;
@@ -186,13 +187,13 @@ void RPCPassingHandler::PopulateRPCRequestQueue(
for (auto services_it = services.begin(); services_it != services.end();
++services_it) {
auto handled_rpcs =
- services_it->second
- .record[strings::service_manifest][strings::handled_rpcs];
+ services_it->record[strings::service_manifest][strings::handled_rpcs];
for (size_t i = 0; i < handled_rpcs.length(); i++) {
if (handled_rpcs[i].asInt() == function_id) {
// Add requests to queue
- ServiceInfo service_info{services_it->first,
- services_it->second.connection_key};
+ ServiceInfo service_info{
+ services_it->record[strings::service_id].asString(),
+ services_it->connection_key};
entry.second.push_back(service_info);
app_manager_.IncreaseForwardedRequestTimeout(origin_connection_key,
correlation_id);
diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index dfb5839764..96882d472f 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/rpc_service_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/plugin_manager/plugin_keys.h"
namespace application_manager {
diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc
index 06343af5a3..f5d08a8ebf 100644
--- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc
+++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc
@@ -41,6 +41,8 @@
namespace application_manager {
+CREATE_LOGGERPTR_GLOBAL(logger_, "SystemTimeHandler")
+
SystemTimeHandlerImpl::SystemTimeHandlerImpl(
ApplicationManager& application_manager)
: event_engine::EventObserver(application_manager.event_dispatcher())
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 02cf58485a..4851a6b37e 100755
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -63,6 +63,7 @@ set(testSources
${AM_TEST_DIR}/application_state_test.cc
${AM_TEST_DIR}/usage_statistics_test.cc
${AM_TEST_DIR}/policy_handler_test.cc
+ ${AM_TEST_DIR}/app_service_manager_test.cc
${AM_TEST_DIR}/application_manager_impl_test.cc
${AM_TEST_DIR}/application_helper_test.cc
${AM_TEST_DIR}/command_holder_test.cc
diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc
new file mode 100644
index 0000000000..960e8e31f6
--- /dev/null
+++ b/src/components/application_manager/test/app_service_manager_test.cc
@@ -0,0 +1,439 @@
+/*
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gmock/gmock.h>
+
+#include "application_manager/commands/command.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/smart_object_keys.h"
+#include "resumption/mock_last_state.h"
+#include "smart_objects/smart_object.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+using testing::_;
+using ::testing::DoAll;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+
+namespace am = application_manager;
+
+const char* kAppServiceSection = "AppServices";
+const char* kDefaults = "defaults";
+const std::string kServiceType = "MEDIA";
+const std::string kServiceName = "service_name";
+const std::string kServiceId = "service_id";
+const std::string kPolicyAppId = "p_app_id";
+const uint32_t kConnectionKey = 43629;
+const uint32_t kHMIConnectionKey = 0;
+
+MATCHER_P(CapabilityUpdateMatcher, reason, "") {
+ smart_objects::SmartObject& services_updated =
+ arg[am::strings::system_capability]
+ [am::strings::app_services_capabilities][am::strings::app_services];
+ if (smart_objects::SmartType_Array != services_updated.getType()) {
+ return false;
+ }
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (reason == service_cap[am::strings::update_reason].asInt()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+class AppServiceManagerTest : public testing::Test {
+ public:
+ AppServiceManagerTest()
+ : mock_app_ptr_(new MockApplication)
+ , app_service_manager_(mock_app_manager_, mock_last_state_)
+ , mock_message_helper_(
+ application_manager::MockMessageHelper::message_helper_mock()) {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+ ~AppServiceManagerTest() {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(*mock_message_helper_, BroadcastCapabilityUpdate(_, _))
+ .WillByDefault(Return());
+ ON_CALL(mock_settings_, embedded_services())
+ .WillByDefault(ReturnRef(embedded_services_));
+ ON_CALL(mock_app_manager_, get_settings())
+ .WillByDefault(ReturnRef(mock_settings_));
+ ON_CALL(*mock_app_ptr_, policy_app_id())
+ .WillByDefault(Return(kPolicyAppId));
+ ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_));
+ auto app_ptr = std::static_pointer_cast<am::Application>(mock_app_ptr_);
+ ON_CALL(mock_app_manager_, application(kConnectionKey))
+ .WillByDefault(Return(app_ptr));
+ }
+
+ protected:
+ smart_objects::SmartObject GenerateMediaManifest(
+ bool allow_app_consumers, std::string app_service_name = kServiceName) {
+ smart_objects::SmartObject manifest(smart_objects::SmartType_Map);
+ manifest[am::strings::service_type] = "MEDIA";
+ manifest[am::strings::service_name] = app_service_name;
+ manifest[am::strings::allow_app_consumers] = allow_app_consumers;
+ manifest[am::strings::media_service_manifest] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ return manifest;
+ }
+
+ smart_objects::SmartObject PublishService(
+ uint32_t connection_key = kConnectionKey, bool first_run = true) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(Return());
+ if (first_run) {
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(Return());
+ }
+ bool mobile_service = connection_key != kHMIConnectionKey;
+ return app_service_manager_.PublishAppService(
+ manifest, mobile_service, connection_key);
+ }
+
+ void CheckCapabilityUpdate(smart_objects::SmartObject& msg_params,
+ size_t length,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ smart_objects::SmartObject& services_updated = msg_params
+ [am::strings::system_capability][am::strings::app_services_capabilities]
+ [am::strings::app_services];
+ ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType());
+ EXPECT_EQ(length, services_updated.length());
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (service_id ==
+ service_cap[am::strings::updated_app_service_record]
+ [am::strings::service_id].asString()) {
+ CheckCapability(service_cap, service_id, reason, published, active);
+ return;
+ }
+ }
+ FAIL() << "Unable to find service in capability update with service_id: "
+ << service_id;
+ }
+
+ void CheckCapability(smart_objects::SmartObject& app_service_capability,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ EXPECT_EQ(reason,
+ app_service_capability[am::strings::update_reason].asInt());
+ smart_objects::SmartObject& updated_record =
+ app_service_capability[am::strings::updated_app_service_record];
+ EXPECT_EQ(service_id, updated_record[am::strings::service_id].asString());
+ EXPECT_EQ(published,
+ updated_record[am::strings::service_published].asBool());
+ EXPECT_EQ(active, updated_record[am::strings::service_active].asBool());
+ }
+
+ Json::Value dict_;
+ std::vector<std::string> embedded_services_;
+ std::shared_ptr<MockApplication> mock_app_ptr_;
+ MockApplicationManager mock_app_manager_;
+ resumption_test::MockLastState mock_last_state_;
+ MockApplicationManagerSettings mock_settings_;
+ application_manager::AppServiceManager app_service_manager_;
+ application_manager::MockMessageHelper* mock_message_helper_;
+};
+
+TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record =
+ app_service_manager_.PublishAppService(manifest, true, kConnectionKey);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record = app_service_manager_.PublishAppService(manifest, false);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_unpublished;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id));
+
+ // Check removed capability update
+ CheckCapabilityUpdate(syscap_update_unpublished,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::REMOVED,
+ false,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) {
+ auto record = PublishService();
+
+ // No capability update
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).Times(0);
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id));
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) {
+ // Register two services with the same service type, the first is activated
+ // automatically
+ auto record = PublishService();
+ auto record2 = PublishService(kConnectionKey + 1, false);
+
+ // No capability update
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+ std::string service_id2 = record2[am::strings::service_id].asString();
+
+ // Activate the second service
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id2));
+
+ // Check that the first service is deactivated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+
+ // Check that the second service is activated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id2,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_deactivated;
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::DEACTIVATED),
+ _))
+ .WillOnce(DoAll(SaveArg<0>(&syscap_update_deactivated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.DeactivateAppService(service_id));
+
+ // Check deactivated capability update
+ CheckCapabilityUpdate(syscap_update_deactivated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) {
+ auto record = PublishService();
+
+ auto service = app_service_manager_.ActiveServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) {
+ auto record = PublishService(kHMIConnectionKey);
+
+ auto service = app_service_manager_.EmbeddedServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_FALSE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) {
+ auto record = PublishService();
+
+ std::string service_id = record[am::strings::service_id].asString();
+ auto service = app_service_manager_.FindServiceByID(service_id);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, GetAllServiceRecords_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto records = app_service_manager_.GetAllServiceRecords();
+
+ ASSERT_EQ(1u, records.size());
+ EXPECT_EQ(record, records[0]);
+}
+
+TEST_F(AppServiceManagerTest, GetActiveServices_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto services = app_service_manager_.GetActiveServices();
+
+ ASSERT_EQ(1u, services.size());
+ EXPECT_EQ(record, services[0].record);
+ EXPECT_EQ(kConnectionKey, services[0].connection_key);
+ EXPECT_TRUE(services[0].mobile_service);
+}
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test \ No newline at end of file
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index 36ae9b0b48..c4ce498595 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -42,6 +42,7 @@
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager_settings.h"
#include "application_manager/mock_resumption_data.h"
+#include "application_manager/mock_app_service_manager.h"
#include "application_manager/mock_rpc_plugin_manager.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/policies/mock_policy_handler_interface.h"
@@ -122,6 +123,8 @@ class ApplicationManagerImplTest : public ::testing::Test {
, mock_rpc_service_(new MockRPCService)
, mock_policy_handler_(
new test::components::policy_test::MockPolicyHandlerInterface)
+ , mock_app_service_manager_(
+ new MockAppServiceManager(mock_app_mngr_, mock_last_state_))
, mock_message_helper_(
application_manager::MockMessageHelper::message_helper_mock())
@@ -146,11 +149,13 @@ class ApplicationManagerImplTest : public ::testing::Test {
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
app_manager_impl_->set_connection_handler(&mock_connection_handler_);
+ ON_CALL(*mock_app_service_manager_, UnpublishServices(_))
+ .WillByDefault(Return());
+ ON_CALL(*mock_app_service_manager_, OnAppActivated(_))
+ .WillByDefault(Return());
+ app_manager_impl_->SetAppServiceManager(mock_app_service_manager_);
Json::Value empty;
ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty));
- std::unique_ptr<AppServiceManager> app_service_manager_ptr(
- new AppServiceManager(*app_manager_impl_, mock_last_state_));
- app_manager_impl_->SetAppServiceManager(app_service_manager_ptr);
}
void CreateAppManager() {
@@ -232,6 +237,7 @@ class ApplicationManagerImplTest : public ::testing::Test {
mock_policy_handler_;
application_manager_test::MockApplicationManager mock_app_mngr_;
std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_;
+ MockAppServiceManager* mock_app_service_manager_;
application_manager::MockMessageHelper* mock_message_helper_;
std::shared_ptr<MockApplication> mock_app_ptr_;
diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc
index 222f16ef46..53e8534c2b 100644
--- a/src/components/application_manager/test/commands/command_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_impl_test.cc
@@ -85,11 +85,12 @@ class CommandImplTest : public CommandsTest<CommandsTestMocks::kIsNice> {
using CommandImpl::ReplaceMobileWithHMIAppId;
using CommandImpl::ReplaceHMIWithMobileAppId;
- UnwrappedCommandImpl(const MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ UnwrappedCommandImpl(
+ const MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ application_manager::rpc_service::RPCService& rpc_service,
+ application_manager::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
: CommandImpl(message,
application_manager,
rpc_service,
diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
new file mode 100644
index 0000000000..311268689a
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
@@ -0,0 +1,93 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+
+#include <gmock/gmock.h>
+#include "application_manager/app_service_manager.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+class MockAppServiceManager : public application_manager::AppServiceManager {
+ public:
+ MockAppServiceManager(application_manager::ApplicationManager& app_manager,
+ resumption::LastState& last_state)
+ : application_manager::AppServiceManager(app_manager, last_state) {}
+ MOCK_METHOD3(
+ PublishAppService,
+ smart_objects::SmartObject(const smart_objects::SmartObject& manifest,
+ const bool mobile_service,
+ const uint32_t connection_key));
+ MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id));
+ MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key));
+ MOCK_METHOD1(OnAppActivated,
+ void(application_manager::ApplicationConstSharedPtr app));
+ MOCK_METHOD1(SetDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(RemoveDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(ActivateAppService, bool(const std::string service_id));
+ MOCK_METHOD1(DeactivateAppService, bool(const std::string service_id));
+ MOCK_METHOD0(GetAllServiceRecords, std::vector<smart_objects::SmartObject>());
+ MOCK_METHOD0(GetActiveServices,
+ std::vector<application_manager::AppService>());
+ MOCK_METHOD4(GetProviderByType,
+ void(const std::string& service_type,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD4(GetProviderByID,
+ void(const std::string& service_id,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD1(
+ ActiveServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(
+ EmbeddedServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(FindServiceByID,
+ application_manager::AppService*(const std::string service_id));
+ MOCK_METHOD2(SetServicePublished,
+ void(const std::string service_id,
+ const bool service_published));
+ MOCK_METHOD1(UpdateNavigationCapabilities,
+ bool(smart_objects::SmartObject& out_params));
+};
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index f43062dc53..92be221ec9 100644
--- a/src/components/application_manager/test/message_helper/message_helper_test.cc
+++ b/src/components/application_manager/test/message_helper/message_helper_test.cc
@@ -42,7 +42,7 @@
#include "utils/custom_string.h"
#include "utils/lock.h"
#include "policy/mock_policy_settings.h"
-#include "application_manager/policies/policy_handler.h"
+#include "application_manager/commands/command_impl.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/event_engine/event_dispatcher.h"
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index a1471eff36..af21a705bf 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -81,15 +81,13 @@ using namespace application_manager;
using namespace policy;
using namespace utils::custom_string;
using testing::_;
+using ::testing::DoAll;
using ::testing::Mock;
+using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnRef;
-using ::testing::NiceMock;
-using ::testing::SetArgReferee;
using ::testing::SetArgPointee;
-using ::testing::DoAll;
using ::testing::SetArgReferee;
-using ::testing::Mock;
typedef NiceMock<application_manager_test::MockRPCService> MockRPCService;
@@ -380,6 +378,70 @@ TEST_F(PolicyHandlerTest, ClearUserConsent) {
policy_handler_.ClearUserConsent();
}
+TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) {
+ // Arrange
+ EnablePolicy();
+ EXPECT_TRUE(policy_handler_.LoadPolicyLibrary());
+ // Check
+ EXPECT_TRUE(policy_handler_.InitPolicyTable());
+ ChangePolicyManagerToMock();
+ std::string file_name("sdl_pt_update.json");
+ std::ifstream ifile(file_name);
+ Json::Reader reader;
+ std::string json;
+ Json::Value root(Json::objectValue);
+ if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ json = root.toStyledString();
+ }
+ ifile.close();
+ BinaryMessage msg(json.begin(), json.end());
+ // Checks
+ EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true));
+ policy_handler_.ReceiveMessageFromSDK("", msg);
+
+ policy_table::AppServiceParameters app_service_params =
+ policy_table::AppServiceParameters();
+ std::string kServiceType = "MEDIA";
+ std::string as_app_id = "1010101010";
+ std::string service_name1 = "SDL Music";
+ std::string service_name2 = "SDL App";
+ (app_service_params)[kServiceType] = policy_table::AppServiceInfo();
+ (app_service_params)[kServiceType].service_names->push_back(service_name2);
+ (app_service_params)[kServiceType].service_names->push_back(service_name1);
+ (app_service_params)[kServiceType].service_names->mark_initialized();
+ policy_table::AppServiceHandledRpc handled_rpc;
+ handled_rpc.function_id = 41;
+ (app_service_params)[kServiceType].handled_rpcs.push_back(handled_rpc);
+ EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_, _))
+ .WillRepeatedly(SetArgPointee<1>(app_service_params));
+
+ ns_smart_device_link::ns_smart_objects::SmartArray requested_handled_rpcs;
+ ns_smart_device_link::ns_smart_objects::SmartObject rpc_id(41);
+ requested_handled_rpcs.push_back(rpc_id);
+
+ ns_smart_device_link::ns_smart_objects::SmartArray fake_handled_rpcs;
+ ns_smart_device_link::ns_smart_objects::SmartObject fake_rpc_id(40);
+ fake_handled_rpcs.push_back(fake_rpc_id);
+
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name1, kServiceType, &requested_handled_rpcs));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, &requested_handled_rpcs));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, NULL));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, "", kServiceType, NULL));
+
+ EXPECT_FALSE(
+ policy_handler_.CheckAppServiceParameters(as_app_id, "", "", NULL));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, "NAVIGATION", &requested_handled_rpcs));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, "MUSIC", kServiceType, &requested_handled_rpcs));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, &fake_handled_rpcs));
+}
+
TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) {
// Arrange
EnablePolicy();
@@ -2536,6 +2598,104 @@ TEST_F(PolicyHandlerTest, RemoteAppsUrl_SUCCESS) {
EXPECT_EQ(url, policy_handler_.RemoteAppsUrl());
}
+TEST_F(PolicyHandlerTest, OnSetCloudAppProperties_AllProperties_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ bool enabled = true;
+ std::string app_name = "anAppName";
+ std::string auth_token = "anAuthToken";
+ std::string cloud_transport_type = "aTransportType";
+ mobile_apis::HybridAppPreference::eType hybrid_app_preference =
+ mobile_apis::HybridAppPreference::CLOUD;
+ std::string hybrid_app_preference_str = "CLOUD";
+ std::string endpoint = "anEndpoint";
+
+ StringArray nicknames_vec;
+ nicknames_vec.push_back(app_name);
+
+ smart_objects::SmartObject message(smart_objects::SmartType_Map);
+ smart_objects::SmartObject properties(smart_objects::SmartType_Map);
+ smart_objects::SmartObject nicknames(smart_objects::SmartType_Array);
+
+ properties[strings::app_id] = kPolicyAppId_;
+ nicknames[0] = app_name;
+ properties[strings::nicknames] = nicknames;
+ properties[strings::enabled] = enabled;
+ properties[strings::auth_token] = auth_token;
+ properties[strings::cloud_transport_type] = cloud_transport_type;
+ properties[strings::hybrid_app_preference] = hybrid_app_preference;
+ properties[strings::endpoint] = endpoint;
+ message[strings::msg_params][strings::properties] = properties;
+
+ application_manager_test::MockPolicyHandlerObserver policy_handler_observer;
+ policy_handler_.add_listener(&policy_handler_observer);
+
+ EXPECT_CALL(*mock_policy_manager_, InitCloudApp(kPolicyAppId_));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetCloudAppEnabled(kPolicyAppId_, enabled));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppNicknames(kPolicyAppId_, nicknames_vec));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppAuthToken(kPolicyAppId_, auth_token));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppCloudTransportType(kPolicyAppId_, cloud_transport_type));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetHybridAppPreference(kPolicyAppId_, hybrid_app_preference_str));
+ EXPECT_CALL(*mock_policy_manager_, SetAppEndpoint(kPolicyAppId_, endpoint));
+ EXPECT_CALL(*mock_policy_manager_,
+ GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<4>(auth_token), Return(true)));
+ EXPECT_CALL(app_manager_, RefreshCloudAppInformation());
+ EXPECT_CALL(policy_handler_observer,
+ OnAuthTokenUpdated(kPolicyAppId_, auth_token));
+
+ policy_handler_.OnSetCloudAppProperties(message);
+}
+
+TEST_F(PolicyHandlerTest, GetCloudAppParameters_AllProperties_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ bool enabled = true;
+ std::string certificate = "aCertificate";
+ std::string auth_token = "anAuthToken";
+ std::string cloud_transport_type = "aTransportType";
+ std::string hybrid_app_preference_str = "CLOUD";
+ std::string endpoint = "anEndpoint";
+
+ application_manager_test::MockPolicyHandlerObserver policy_handler_observer;
+ policy_handler_.add_listener(&policy_handler_observer);
+
+ EXPECT_CALL(*mock_policy_manager_,
+ GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<1>(enabled),
+ SetArgReferee<2>(endpoint),
+ SetArgReferee<3>(certificate),
+ SetArgReferee<4>(auth_token),
+ SetArgReferee<5>(cloud_transport_type),
+ SetArgReferee<6>(hybrid_app_preference_str),
+ Return(true)));
+
+ bool enabled_out;
+ std::string endpoint_out;
+ std::string cert_out;
+ std::string auth_token_out;
+ std::string ctt_out;
+ std::string hap_out;
+ EXPECT_TRUE(policy_handler_.GetCloudAppParameters(kPolicyAppId_,
+ enabled_out,
+ endpoint_out,
+ cert_out,
+ auth_token_out,
+ ctt_out,
+ hap_out));
+ EXPECT_EQ(enabled, enabled_out);
+ EXPECT_EQ(endpoint, endpoint_out);
+ EXPECT_EQ(certificate, cert_out);
+ EXPECT_EQ(auth_token, auth_token_out);
+ EXPECT_EQ(cloud_transport_type, ctt_out);
+ EXPECT_EQ(hybrid_app_preference_str, hap_out);
+}
+
} // namespace policy_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json
index 17b07f797f..aea3f7700b 100644
--- a/src/components/application_manager/test/sdl_pt_update.json
+++ b/src/components/application_manager/test/sdl_pt_update.json
@@ -20,7 +20,13 @@
"nicknames" : [ "SyncProxyTester" ],
"priority" : "EMERGENCY",
"steal_focus" : true,
- "watchdog_timer_ms" : 20000
+ "watchdog_timer_ms" : 20000,
+ "app_services": {
+ "MEDIA": {
+ "service_names" : ["SDL App", "SDL Music"],
+ "handled_rpcs" : [{"function_id": 41}]
+ }
+ }
},
"default" : {
"default_hmi" : "NONE",
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index 7e93e04047..c412c9c637 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -888,6 +888,8 @@ ConnectionHandlerImpl::TransportTypeProfileStringFromDeviceHandle(
return std::string("IAP_USB_DEVICE_MODE");
} else if (connection_type == "CARPLAY_WIRELESS_IOS") {
return std::string("IAP_CARPLAY");
+ } else if (connection_type == "CLOUD_WEBSOCKET") {
+ return std::string("WEBSOCKET");
#ifdef BUILD_TESTS
} else if (connection_type == "BTMAC") {
return std::string("BTMAC");
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 97140a18f1..e8f646c1e5 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -51,7 +51,7 @@
#include "application_manager/hmi_interfaces.h"
#include "policy/policy_types.h"
#include "application_manager/plugin_manager/rpc_plugin_manager.h"
-#include "application_manager/app_service_manager.h"
+
namespace resumption {
class LastState;
}
@@ -90,6 +90,7 @@ class RPCHandler;
}
class Application;
+class AppServiceManager;
class StateControllerImpl;
struct CommandParametersPermissions;
using policy::RPCParams;
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 4f09d2c2f9..679e6ccfb3 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -39,21 +39,24 @@
#include "gmock/gmock.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager_settings.h"
+#include "application_manager/command_factory.h"
#include "application_manager/commands/command.h"
+#include "application_manager/event_engine/event_dispatcher.h"
#include "application_manager/hmi_capabilities.h"
-#include "application_manager/state_controller.h"
#include "application_manager/message.h"
-#include "resumption/last_state.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/app_launch/app_launch_ctrl.h"
-#include "application_manager/event_engine/event_dispatcher.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/plugin_manager/rpc_plugin_manager.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/rpc_handler.h"
+#include "application_manager/rpc_service.h"
#include "application_manager/state_controller.h"
+#include "interfaces/HMI_API.h"
+#include "interfaces/MOBILE_API.h"
+#include "resumption/last_state.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/plugin_manager/rpc_plugin_manager.h"
-#include "application_manager/command_factory.h"
namespace test {
namespace components {
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h
index e8ed0e90e2..bd8c83d897 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h
@@ -49,6 +49,9 @@ class MockPolicyHandlerObserver : public ::policy::PolicyHandlerObserver {
MOCK_METHOD1(OnUpdateHMIAppType,
void(std::map<std::string, std::vector<std::string> >));
MOCK_METHOD1(OnCertificateUpdated, bool(const std::string&));
+ MOCK_METHOD2(OnAuthTokenUpdated,
+ void(const std::string& policy_app_id,
+ const std::string& auth_token));
MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result));
};
} // namespace application_manager_test
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index 3f594ff6df..0ec4883448 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -188,7 +188,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD7(GetCloudAppParameters,
- void(const std::string& policy_app_id,
+ bool(const std::string& policy_app_id,
bool& enabled,
std::string& endpoint,
std::string& certificate,
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 004e0301c7..e0ca4d6d18 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -3302,6 +3302,15 @@
</param>
</struct>
+ <struct name="SystemCapabilities">
+ <param name="navigationCapability" type="NavigationCapability" mandatory="false">
+ </param>
+ <param name="phoneCapability" type="PhoneCapability" mandatory="false">
+ </param>
+ <param name="videoStreamingCapability" type="VideoStreamingCapability" mandatory="false">
+ </param>
+ </struct>
+
<struct name="RemoteControlCapabilities">
<param name="climateControlCapabilities" type="ClimateControlCapabilities" mandatory="false" minsize="1" maxsize="100" array="true">
<description>If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported.</description >
@@ -3546,7 +3555,7 @@
<description> In km </description>
</param>
- <param name="weatherIconImageName" type="String" mandatory="false"/>
+ <param name="weatherIcon" type="Common.Image" mandatory="false"/>
</struct>
<struct name="WeatherServiceData">
@@ -3773,7 +3782,7 @@
<element name="APP_SERVICES" />
</enum>
- <struct name="SystemCapabilities">
+ <struct name="SystemCapability">
<description>The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist</description>
<param name="systemCapabilityType" type="Common.SystemCapabilityType" mandatory="true">
<description>Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included.</description>
@@ -4249,7 +4258,7 @@
</function>
<function name="OnSystemCapabilityUpdated" messagetype="notification">
<description>A notification to inform the connected device that a specific system capability has changed.</description>
- <param name="systemCapability" type="Common.SystemCapabilities" mandatory="true">
+ <param name="systemCapability" type="Common.SystemCapability" mandatory="true">
<description>The system capability that has been updated</description>
</param>
</function>
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 3b9614ab76..a0345ada29 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -3899,7 +3899,7 @@
<description> In km </description>
</param>
- <param name="weatherIconImageName" type="String" mandatory="false"/>
+ <param name="weatherIcon" type="Image" mandatory="false"/>
</struct>
<struct name="WeatherServiceData" since="5.1">
diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
index 35e6b1d1a6..acf18c5706 100644
--- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
+++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
@@ -20,7 +20,13 @@
"nicknames" : [ "SyncProxyTester" ],
"priority" : "EMERGENCY",
"steal_focus" : true,
- "heart_beat_timeout_ms": 5000
+ "heart_beat_timeout_ms": 5000,
+ "app_services": {
+ "MEDIA": {
+ "service_names" : ["SDL App", "SDL Music"],
+ "handled_rpcs" : [{"function_id": 41}]
+ }
+ }
},
"default" : {
"default_hmi" : "NONE",
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
index 6521db7c36..1916e09efc 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
@@ -345,6 +345,37 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) {
EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_));
}
+TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) {
+ // Arrange
+ std::string kServiceType = "MEDIA";
+ CreateLocalPT(preloaded_pt_filename_);
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+ GetPTU("json/valid_sdl_pt_update.json");
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+ // Try to add existing app
+ policy_table::AppServiceParameters app_service_parameters =
+ policy_table::AppServiceParameters();
+ policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters);
+
+ ASSERT_FALSE(app_service_parameters.find(kServiceType) ==
+ app_service_parameters.end());
+
+ auto service_names = *(app_service_parameters[kServiceType].service_names);
+
+ ASSERT_TRUE(service_names.is_initialized());
+ ASSERT_EQ(service_names.size(), 2u);
+ EXPECT_EQ(static_cast<std::string>(service_names[0]), "SDL App");
+ EXPECT_EQ(static_cast<std::string>(service_names[1]), "SDL Music");
+
+ auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs;
+
+ ASSERT_TRUE(handled_rpcs.is_initialized());
+ EXPECT_EQ(handled_rpcs[0].function_id, 41);
+
+ // Check no update required
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+}
+
TEST_F(
PolicyManagerImplTest_ExternalConsent,
ExternalConsent_SetExternalConsentStatusWhileAppExists_ExpectUserConsentsUpdateForApp) {
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index ff054b3cc4..97b1768666 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -834,6 +834,37 @@ TEST_F(
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
}
+TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) {
+ std::string kServiceType = "MEDIA";
+ // Arrange
+ CreateLocalPT("sdl_preloaded_pt.json");
+ EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+ GetPTU("valid_sdl_pt_update.json");
+ EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+ // Try to add existing app
+ policy_table::AppServiceParameters app_service_parameters =
+ policy_table::AppServiceParameters();
+ manager->GetAppServiceParameters(app_id2, &app_service_parameters);
+
+ ASSERT_FALSE(app_service_parameters.find(kServiceType) ==
+ app_service_parameters.end());
+
+ auto service_names = *(app_service_parameters[kServiceType].service_names);
+
+ ASSERT_TRUE(service_names.is_initialized());
+ ASSERT_EQ(service_names.size(), 2u);
+ EXPECT_EQ(static_cast<std::string>(service_names[0]), "SDL App");
+ EXPECT_EQ(static_cast<std::string>(service_names[1]), "SDL Music");
+
+ auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs;
+
+ ASSERT_TRUE(handled_rpcs.is_initialized());
+ EXPECT_EQ(handled_rpcs[0].function_id, 41);
+
+ // Check no update required
+ EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+}
+
TEST_F(PolicyManagerImplTest2,
PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) {
// Arrange
diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
index 6448a47b42..675d708843 100644
--- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
@@ -124,6 +124,13 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
policy_table::ApplicationPoliciesSection* policies) const {
return ::SQLPTRepresentation::GatherApplicationPoliciesSection(policies);
}
+
+ bool GatherAppServiceParameters(
+ const std::string& app_id,
+ policy_table::AppServiceParameters* policies) const {
+ return ::SQLPTRepresentation::GatherAppServiceParameters(app_id, policies);
+ }
+
virtual void GatherDeviceData(policy_table::DeviceData* data) const {
::SQLPTRepresentation::GatherDeviceData(data);
}
@@ -314,6 +321,21 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
app_policies["1234"]["keep_context"] = Json::Value(false);
app_policies["1234"]["steal_focus"] = Json::Value(false);
app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue);
+ app_policies["1234"]["app_services"] = Json::Value(Json::objectValue);
+ app_policies["1234"]["app_services"]["MEDIA"] =
+ Json::Value(Json::objectValue);
+ app_policies["1234"]["app_services"]["MEDIA"]["service_names"] =
+ Json::Value(Json::arrayValue);
+ app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] =
+ Json::Value("SDL App");
+ app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] =
+ Json::Value("SDL Music");
+ app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] =
+ Json::Value(Json::arrayValue);
+ app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] =
+ Json::Value(Json::objectValue);
+ app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0]
+ ["function_id"] = Json::Value(41);
app_policies["device"] = Json::Value(Json::objectValue);
app_policies["device"]["groups"] = Json::Value(Json::arrayValue);
@@ -1706,6 +1728,23 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) {
GatherDeviceData(&devices);
EXPECT_EQ(3u, devices.size());
+
+ const std::string kAppId = "1234";
+ const std::string kServiceType = "MEDIA";
+ policy_table::AppServiceParameters app_service_parameters;
+ GatherAppServiceParameters(kAppId, &app_service_parameters);
+ ASSERT_FALSE(app_service_parameters.find(kServiceType) ==
+ app_service_parameters.end());
+ auto service_names = *(app_service_parameters[kServiceType].service_names);
+ EXPECT_TRUE(service_names.is_initialized());
+ ASSERT_EQ(service_names.size(), 2u);
+ EXPECT_EQ(static_cast<std::string>(service_names[0]), "SDL App");
+ EXPECT_EQ(static_cast<std::string>(service_names[1]), "SDL Music");
+
+ auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs;
+
+ EXPECT_TRUE(handled_rpcs.is_initialized());
+ EXPECT_EQ(handled_rpcs[0].function_id, 41);
}
} // namespace policy_test
diff --git a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
index 35e6b1d1a6..acf18c5706 100644
--- a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
+++ b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
@@ -20,7 +20,13 @@
"nicknames" : [ "SyncProxyTester" ],
"priority" : "EMERGENCY",
"steal_focus" : true,
- "heart_beat_timeout_ms": 5000
+ "heart_beat_timeout_ms": 5000,
+ "app_services": {
+ "MEDIA": {
+ "service_names" : ["SDL App", "SDL Music"],
+ "handled_rpcs" : [{"function_id": 41}]
+ }
+ }
},
"default" : {
"default_hmi" : "NONE",
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index 89800037b5..7c2b411dcb 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -141,7 +141,8 @@ typedef enum {
TT_NONE = -1,
TT_USB = 0,
TT_BLUETOOTH = 1,
- TT_WIFI = 2
+ TT_WIFI = 2,
+ TT_WEBSOCKET = 3
} TransportType;
struct TransportDescription {
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 27b06af424..d5837a0470 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -2274,7 +2274,10 @@ const impl::TransportTypes transportTypes = {
impl::TransportDescription(impl::TransportType::TT_USB, true, false)),
std::make_pair(
std::string("IAP_CARPLAY"),
- impl::TransportDescription(impl::TransportType::TT_WIFI, true, false))};
+ impl::TransportDescription(impl::TransportType::TT_WIFI, true, false)),
+ std::make_pair(std::string("WEBSOCKET"),
+ impl::TransportDescription(
+ impl::TransportType::TT_WEBSOCKET, false, false))};
const impl::TransportDescription
ProtocolHandlerImpl::GetTransportTypeFromConnectionType(
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 51284dfcda..e1149fefb2 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -29,19 +29,19 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "gtest/gtest.h"
#include <string>
-#include "protocol_handler/protocol_handler.h"
-#include "protocol_handler/protocol_handler_impl.h"
+#include "connection_handler/connection_handler_impl.h"
+#include "connection_handler/mock_connection_handler.h"
+#include "gtest/gtest.h"
#include "protocol/bson_object_keys.h"
#include "protocol/common.h"
#include "protocol_handler/control_message_matcher.h"
#include "protocol_handler/mock_protocol_handler.h"
-#include "protocol_handler/mock_protocol_observer.h"
#include "protocol_handler/mock_protocol_handler_settings.h"
+#include "protocol_handler/mock_protocol_observer.h"
#include "protocol_handler/mock_session_observer.h"
-#include "connection_handler/mock_connection_handler.h"
-#include "connection_handler/connection_handler_impl.h"
+#include "protocol_handler/protocol_handler.h"
+#include "protocol_handler/protocol_handler_impl.h"
#ifdef ENABLE_SECURITY
#include "security_manager/mock_security_manager.h"
#include "security_manager/mock_ssl_context.h"
@@ -50,8 +50,8 @@
#include "utils/mock_system_time_handler.h"
#include "utils/semantic_version.h"
-#include "utils/test_async_waiter.h"
#include <bson_object.h>
+#include "utils/test_async_waiter.h"
namespace transport_manager {
namespace transport_adapter {
@@ -59,8 +59,8 @@ namespace transport_adapter {
const char* tc_enabled = "enabled";
const char* tc_tcp_port = "tcp_port";
const char* tc_tcp_ip_address = "tcp_ip_address";
-}
-}
+} // namespace transport_adapter
+} // namespace transport_manager
namespace test {
namespace components {
@@ -70,50 +70,50 @@ namespace protocol_handler_test {
#define NEW_SESSION_ID 0u
#define SESSION_START_REJECT 0u
// Protocol Handler Entities
-using protocol_handler::ProtocolHandlerImpl;
-using protocol_handler::ServiceType;
-using protocol_handler::RawMessage;
-using protocol_handler::RawMessagePtr;
-using protocol_handler::PROTECTION_ON;
-using protocol_handler::PROTECTION_OFF;
-using protocol_handler::PROTOCOL_VERSION_1;
-using protocol_handler::PROTOCOL_VERSION_2;
-using protocol_handler::PROTOCOL_VERSION_3;
-using protocol_handler::PROTOCOL_VERSION_4;
-using protocol_handler::PROTOCOL_VERSION_5;
-using protocol_handler::PROTOCOL_VERSION_MAX;
-using protocol_handler::FRAME_TYPE_CONTROL;
-using protocol_handler::FRAME_TYPE_SINGLE;
-using protocol_handler::FRAME_TYPE_FIRST;
-using protocol_handler::FRAME_TYPE_CONSECUTIVE;
-using protocol_handler::FRAME_TYPE_MAX_VALUE;
-using protocol_handler::MAXIMUM_FRAME_DATA_V2_SIZE;
-using protocol_handler::FRAME_DATA_START_SERVICE;
-using protocol_handler::FRAME_DATA_START_SERVICE_ACK;
-using protocol_handler::FRAME_DATA_END_SERVICE_NACK;
-using protocol_handler::FRAME_DATA_END_SERVICE_ACK;
using protocol_handler::FRAME_DATA_END_SERVICE;
+using protocol_handler::FRAME_DATA_END_SERVICE_ACK;
+using protocol_handler::FRAME_DATA_END_SERVICE_NACK;
+using protocol_handler::FRAME_DATA_FIRST;
using protocol_handler::FRAME_DATA_HEART_BEAT;
using protocol_handler::FRAME_DATA_HEART_BEAT_ACK;
-using protocol_handler::FRAME_DATA_SERVICE_DATA_ACK;
-using protocol_handler::FRAME_DATA_SINGLE;
-using protocol_handler::FRAME_DATA_FIRST;
using protocol_handler::FRAME_DATA_LAST_CONSECUTIVE;
using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT;
using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT_ACK;
using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT_NACK;
+using protocol_handler::FRAME_DATA_SERVICE_DATA_ACK;
+using protocol_handler::FRAME_DATA_SINGLE;
+using protocol_handler::FRAME_DATA_START_SERVICE;
+using protocol_handler::FRAME_DATA_START_SERVICE_ACK;
using protocol_handler::FRAME_DATA_TRANSPORT_EVENT_UPDATE;
-using protocol_handler::kRpc;
-using protocol_handler::kControl;
+using protocol_handler::FRAME_TYPE_CONSECUTIVE;
+using protocol_handler::FRAME_TYPE_CONTROL;
+using protocol_handler::FRAME_TYPE_FIRST;
+using protocol_handler::FRAME_TYPE_MAX_VALUE;
+using protocol_handler::FRAME_TYPE_SINGLE;
using protocol_handler::kAudio;
-using protocol_handler::kMobileNav;
using protocol_handler::kBulk;
+using protocol_handler::kControl;
using protocol_handler::kInvalidServiceType;
+using protocol_handler::kMobileNav;
+using protocol_handler::kRpc;
+using protocol_handler::MAXIMUM_FRAME_DATA_V2_SIZE;
+using protocol_handler::PROTECTION_OFF;
+using protocol_handler::PROTECTION_ON;
+using protocol_handler::PROTOCOL_VERSION_1;
+using protocol_handler::PROTOCOL_VERSION_2;
+using protocol_handler::PROTOCOL_VERSION_3;
+using protocol_handler::PROTOCOL_VERSION_4;
+using protocol_handler::PROTOCOL_VERSION_5;
+using protocol_handler::PROTOCOL_VERSION_MAX;
+using protocol_handler::ProtocolHandlerImpl;
+using protocol_handler::RawMessage;
+using protocol_handler::RawMessagePtr;
+using protocol_handler::ServiceType;
// For TM states
-using transport_manager::TransportManagerListener;
using test::components::security_manager_test::MockSystemTimeHandler;
-using transport_manager::E_SUCCESS;
using transport_manager::DeviceInfo;
+using transport_manager::E_SUCCESS;
+using transport_manager::TransportManagerListener;
#ifdef ENABLE_SECURITY
// For security
using ContextCreationStrategy =
@@ -122,21 +122,21 @@ using ContextCreationStrategy =
// For CH entities
using connection_handler::DeviceHandle;
// Google Testing Framework Entities
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::ReturnRefOfCopy;
-using ::testing::ReturnNull;
+using ::testing::_;
using ::testing::An;
using ::testing::AnyOf;
using ::testing::AtLeast;
using ::testing::ByRef;
using ::testing::DoAll;
-using ::testing::SaveArg;
using ::testing::Eq;
-using ::testing::_;
using ::testing::Invoke;
-using ::testing::SetArgReferee;
+using ::testing::Return;
+using ::testing::ReturnNull;
+using ::testing::ReturnRef;
+using ::testing::ReturnRefOfCopy;
+using ::testing::SaveArg;
using ::testing::SetArgPointee;
+using ::testing::SetArgReferee;
typedef std::vector<uint8_t> UCharDataVector;
@@ -149,7 +149,7 @@ namespace {
const uint32_t kAsyncExpectationsTimeout = 10000u;
const uint32_t kMicrosecondsInMillisecond = 1000u;
const uint32_t kAddSessionWaitTimeMs = 100u;
-}
+} // namespace
class ProtocolHandlerImplTest : public ::testing::Test {
protected:
@@ -383,6 +383,9 @@ class ProtocolHandlerImplTest : public ::testing::Test {
const std::vector<int32_t>& expected_audio_service_transports,
const std::vector<int32_t>& expected_video_service_transports);
+ void VerifyCloudAppParamsInStartSessionAck(const std::string& policy_app_id,
+ char* auth_token);
+
testing::NiceMock<MockProtocolHandlerSettings> protocol_handler_settings_mock;
std::shared_ptr<ProtocolHandlerImpl> protocol_handler_impl;
TransportManagerListener* tm_listener;
@@ -1920,6 +1923,117 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck(
bson_object_deinitialize(&expected_obj);
+ EXPECT_CALL(
+ transport_manager_mock,
+ SendMessageToDevice(ControlMessage(
+ FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, connection_id, _)))
+ .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS)));
+ times++;
+
+#ifdef ENABLE_SECURITY
+ AddSecurityManager();
+
+ EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id))
+ .WillOnce(Return(connection_key));
+
+ EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc))
+ .WillOnce(ReturnNull());
+#endif // ENABLE_SECURITY
+
+ protocol_handler_impl->SendStartSessionAck(connection_id,
+ session_id,
+ input_protocol_version,
+ hash_id,
+ protocol_handler::SERVICE_TYPE_RPC,
+ false /* protection */,
+ full_version);
+
+ EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout));
+}
+
+void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck(
+ const std::string& policy_app_id, char* auth_token) {
+ const size_t maximum_rpc_payload_size = 1500;
+ EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size())
+ .WillRepeatedly(Return(maximum_rpc_payload_size));
+ InitProtocolHandlerImpl(0u, 0u);
+
+ TestAsyncWaiter waiter;
+ uint32_t times = 0;
+
+ const uint8_t input_protocol_version = 5;
+ const uint32_t hash_id = 123456;
+ utils::SemanticVersion full_version(5, 2, 0);
+ char full_version_string[] = "5.2.0";
+
+ // configuration setup
+ EXPECT_CALL(protocol_handler_settings_mock, max_supported_protocol_version())
+ .WillRepeatedly(Return(PROTOCOL_VERSION_5));
+ EXPECT_CALL(connection_handler_mock, GetCloudAppID(connection_id))
+ .WillOnce(Return(policy_app_id));
+ connection_handler::SessionTransports dummy_st = {0, 0};
+ EXPECT_CALL(connection_handler_mock,
+ SetSecondaryTransportID(_, kDisabledSecondary))
+ .WillOnce(Return(dummy_st));
+ EXPECT_CALL(protocol_handler_settings_mock, multiple_transports_enabled())
+ .WillRepeatedly(Return(false));
+ std::vector<std::string> empty_vec;
+ EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports())
+ .WillRepeatedly(ReturnRef(empty_vec));
+ EXPECT_CALL(protocol_handler_settings_mock, video_service_transports())
+ .WillRepeatedly(ReturnRef(empty_vec));
+ EXPECT_CALL(session_observer_mock,
+ TransportTypeProfileStringFromConnHandle(connection_id))
+ .WillRepeatedly(Return("WEBSOCKET"));
+
+ // Prepare expected BSON parameters. When we add another param in Start
+ // Service ACK frame in future, it should be also added here.
+ BsonObject expected_obj;
+ bson_object_initialize_default(&expected_obj);
+
+ // mtu
+ bson_object_put_int64(&expected_obj,
+ protocol_handler::strings::mtu,
+ static_cast<int64_t>(maximum_rpc_payload_size));
+ // hashId
+ bson_object_put_int32(&expected_obj,
+ protocol_handler::strings::hash_id,
+ static_cast<int32_t>(hash_id));
+ // protocolVersion
+ bson_object_put_string(&expected_obj,
+ protocol_handler::strings::protocol_version,
+ full_version_string);
+
+ // secondaryTransports
+ BsonArray secondary_transports;
+ bson_array_initialize(&secondary_transports, 0);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::secondary_transports,
+ &secondary_transports);
+
+ BsonArray audio_service_transports;
+ bson_array_initialize(&audio_service_transports, 1);
+ bson_array_add_int32(&audio_service_transports, 1);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::audio_service_transports,
+ &audio_service_transports);
+
+ BsonArray video_service_transports;
+ bson_array_initialize(&video_service_transports, 1);
+ bson_array_add_int32(&video_service_transports, 1);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::video_service_transports,
+ &video_service_transports);
+
+ // authToken
+ bson_object_put_string(
+ &expected_obj, protocol_handler::strings::auth_token, auth_token);
+
+ std::vector<uint8_t> expected_param =
+ CreateVectorFromBsonObject(&expected_obj);
+
+ bson_object_deinitialize(&expected_obj);
+
EXPECT_CALL(transport_manager_mock,
SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK,
PROTECTION_OFF,
@@ -1938,6 +2052,8 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck(
.WillOnce(ReturnNull());
#endif // ENABLE_SECURITY
+ protocol_handler_impl->OnAuthTokenUpdated(policy_app_id,
+ std::string(auth_token));
protocol_handler_impl->SendStartSessionAck(connection_id,
session_id,
input_protocol_version,
@@ -2468,6 +2584,18 @@ TEST_F(ProtocolHandlerImplTest, StartSessionAck_PrimaryTransportUSBHostMode) {
expected_video_service_transports);
}
+TEST_F(ProtocolHandlerImplTest, StartSessionAck_CloudAppAuthTokenAvailable) {
+ std::string policy_id = "policy_id";
+ char auth_token[] = "Sample auth token";
+
+ // A TransportUpdateEvent is also issued after Start Service ACK. We don't
+ // check it in this test case.
+ EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, _))
+ .WillRepeatedly(Return(false));
+
+ VerifyCloudAppParamsInStartSessionAck(policy_id, auth_token);
+}
+
TEST_F(ProtocolHandlerImplTest,
TransportEventUpdate_afterVersionNegotiation_TCPEnabled) {
TestAsyncWaiter waiter;
diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
index ff7b9da9d6..0d31573d8e 100644
--- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
+++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
@@ -40,7 +40,7 @@
#include "utils/threads/thread_delegate.h"
#include "telemetry_monitor/metric_wrapper.h"
#include "telemetry_monitor/application_manager_observer.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "telemetry_monitor/transport_manager_observer.h"
#include "transport_manager/transport_manager_impl.h"
#include "protocol_handler_observer.h"
diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
index 5c9553a970..057e3d7208 100644
--- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc
+++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
@@ -267,6 +267,9 @@ void WebsocketClientConnection::Shutdown() {
thread_delegate_->SetShutdown();
write_thread_->join();
delete thread_delegate_;
+ thread_delegate_ = NULL;
+ threads::DeleteThread(write_thread_);
+ write_thread_ = NULL;
}
if (buffer_.size()) {
buffer_.consume(buffer_.size());