summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2016-10-26 17:17:51 -0400
committerGitHub <noreply@github.com>2016-10-26 17:17:51 -0400
commita6c32b45832653d6b851be9b19355fa35f377e07 (patch)
tree234118d7fc3a151d1755434c007317de53d5cc33
parentd4568910cc45e4af0c3b06c67359ea1fe577da54 (diff)
parentfc832c7a7ae24bf0c9336cace69b25194b81c9e3 (diff)
downloadsdl_core-a6c32b45832653d6b851be9b19355fa35f377e07.tar.gz
Merge pull request #907 from smartdevicelink/release/4.2.04.2.0
Release 4.2.0
-rw-r--r--src/appMain/life_cycle.cc2
-rw-r--r--src/appMain/smartDeviceLink.ini17
-rw-r--r--src/components/application_manager/CMakeLists.txt481
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h74
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h86
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_data.h103
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h168
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h136
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h156
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_sql_queries.h51
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/apps_launcher.h86
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h46
-rw-r--r--src/components/application_manager/include/application_manager/application.h8
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h10
-rw-r--r--src/components/application_manager/include/application_manager/application_manager.h21
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h34
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h117
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h10
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h21
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h20
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h20
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h20
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h21
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h22
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h13
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/alert_request.h17
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h29
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h27
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h12
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h14
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h40
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h38
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h17
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h13
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h20
-rw-r--r--src/components/application_manager/include/application_manager/hmi_capabilities_impl.h (renamed from src/components/application_manager/include/application_manager/hmi_capabilities.h)306
-rw-r--r--src/components/application_manager/include/application_manager/hmi_interfaces.h102
-rw-r--r--src/components/application_manager/include/application_manager/hmi_interfaces_impl.h77
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h2
-rw-r--r--src/components/application_manager/include/application_manager/request_controller.h13
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h369
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h500
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h6
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc116
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_db.cc396
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_impl.cc83
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_json.cc283
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_sql_queries.cc78
-rw-r--r--src/components/application_manager/src/app_launch/apps_launcher.cc139
-rw-r--r--src/components/application_manager/src/app_launch/device_apps_launcher.cc208
-rw-r--r--src/components/application_manager/src/application_impl.cc16
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc101
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc245
-rw-r--r--src/components/application_manager/src/commands/hmi/close_popup_request.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc24
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc30
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc13
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc24
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/request_to_hmi.cc24
-rw-r--r--src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc54
-rw-r--r--src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc14
-rw-r--r--src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc120
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc118
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_request.cc114
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_request.cc171
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc103
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc93
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc19
-rw-r--r--src/components/application_manager/src/commands/mobile/get_dtcs_request.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc31
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc161
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_request.cc199
-rw-r--r--src/components/application_manager/src/commands/mobile/read_did_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc274
-rw-r--r--src/components/application_manager/src/commands/mobile/scrollable_message_request.cc26
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc26
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc21
-rw-r--r--src/components/application_manager/src/commands/mobile/set_display_layout_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_request.cc91
-rw-r--r--src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc29
-rw-r--r--src/components/application_manager/src/commands/mobile/show_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_request.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/speak_request.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc255
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc28
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_request.cc21
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc (renamed from src/components/application_manager/src/hmi_capabilities.cc)760
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc274
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc45
-rw-r--r--src/components/application_manager/src/request_controller.cc40
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc (renamed from src/components/application_manager/src/resumption/resume_ctrl.cc)180
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc10
-rw-r--r--src/components/application_manager/test/CMakeLists.txt9
-rw-r--r--src/components/application_manager/test/app_launch/CMakeLists.txt62
-rw-r--r--src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc354
-rw-r--r--src/components/application_manager/test/app_launch/app_launch_data_db_test.cc345
-rw-r--r--src/components/application_manager/test/app_launch/app_launch_data_json_test.cc344
-rw-r--r--src/components/application_manager/test/application_impl_test.cc44
-rw-r--r--src/components/application_manager/test/commands/CMakeLists.txt63
-rw-r--r--src/components/application_manager/test/commands/command_impl_test.cc279
-rw-r--r--src/components/application_manager/test/commands/command_request_impl_test.cc519
-rw-r--r--src/components/application_manager/test/commands/command_response_impl_test.cc184
-rw-r--r--src/components/application_manager/test/commands/hmi/CMakeLists.txt59
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc121
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc139
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc121
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc103
-rw-r--r--src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc209
-rw-r--r--src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc175
-rw-r--r--src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc193
-rw-r--r--src/components/application_manager/test/commands/mobile/CMakeLists.txt75
-rw-r--r--src/components/application_manager/test/commands/mobile/add_command_request_test.cc343
-rw-r--r--src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc138
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc277
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc211
-rw-r--r--src/components/application_manager/test/commands/mobile/change_registration_test.cc539
-rw-r--r--src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc211
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_command_request_test.cc265
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc145
-rw-r--r--src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc182
-rw-r--r--src/components/application_manager/test/commands/mobile/dial_number_request_test.cc185
-rw-r--r--src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc132
-rw-r--r--src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc (renamed from src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc)95
-rw-r--r--src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc252
-rw-r--r--src/components/application_manager/test/commands/mobile/list_files_request_test.cc128
-rw-r--r--src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc346
-rw-r--r--src/components/application_manager/test/commands/mobile/on_command_notification_test.cc135
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc126
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc278
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc213
-rw-r--r--src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc171
-rw-r--r--src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc215
-rw-r--r--src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc138
-rw-r--r--src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc135
-rw-r--r--src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc146
-rw-r--r--src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc114
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc210
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_interaction_test.cc276
-rw-r--r--src/components/application_manager/test/commands/mobile/read_did_request_test.cc159
-rw-r--r--src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc336
-rw-r--r--src/components/application_manager/test/commands/mobile/scrollable_message_test.cc167
-rw-r--r--src/components/application_manager/test/commands/mobile/set_app_icon_test.cc164
-rw-r--r--src/components/application_manager/test/commands/mobile/set_display_layout_test.cc178
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc280
-rw-r--r--src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc145
-rw-r--r--src/components/application_manager/test/commands/mobile/show_test.cc158
-rw-r--r--src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc95
-rw-r--r--src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc105
-rw-r--r--src/components/application_manager/test/commands/mobile/slider_test.cc156
-rw-r--r--src/components/application_manager/test/commands/mobile/speak_request_test.cc189
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc202
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc14
-rw-r--r--src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc116
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc103
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc291
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc109
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc~ff89c63... Cover UnsubscribeWayPoints and UpdateTurnList by Unit Tests.169
-rw-r--r--src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc314
-rw-r--r--src/components/application_manager/test/hmi_capabilities_test.cc152
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/command_request_test.h141
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/commands_test.h150
-rw-r--r--src/components/application_manager/test/include/application_manager/hmi_capabilities_for_testing.h14
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_launch_ctrl.h47
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_launch_data.h57
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h7
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application_manager.h11
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h180
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_hmi_interface.h56
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h76
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h104
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc144
-rw-r--r--src/components/application_manager/test/resumption/resume_ctrl_test.cc29
-rw-r--r--src/components/application_manager/test/smartDeviceLink_test.ini16
-rw-r--r--src/components/config_profile/include/config_profile/profile.h57
-rw-r--r--src/components/config_profile/src/profile.cc122
-rw-r--r--src/components/config_profile/test/smartDeviceLink.ini16
-rw-r--r--src/components/config_profile/test/smartDeviceLink_invalid_boolean.ini16
-rw-r--r--src/components/config_profile/test/smartDeviceLink_invalid_int.ini16
-rw-r--r--src/components/config_profile/test/smartDeviceLink_invalid_pairs.ini16
-rw-r--r--src/components/config_profile/test/smartDeviceLink_invalid_string.ini16
-rw-r--r--src/components/config_profile/test/smartDeviceLink_test.ini16
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler.h14
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_impl.h14
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc14
-rw-r--r--src/components/connection_handler/test/connection_handler_impl_test.cc66
-rw-r--r--src/components/include/application_manager/app_launch_settings.h22
-rw-r--r--src/components/include/application_manager/application_manager_settings.h9
-rw-r--r--src/components/include/application_manager/hmi_capabilities.h448
-rw-r--r--src/components/include/security_manager/crypto_manager.h2
-rw-r--r--src/components/include/test/application_manager/mock_app_launch_settings.h61
-rw-r--r--src/components/include/test/application_manager/mock_application_manager_settings.h11
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler.h2
-rw-r--r--src/components/include/test/transport_manager/mock_transport_manager.h3
-rw-r--r--src/components/include/transport_manager/transport_adapter/device.h12
-rw-r--r--src/components/include/transport_manager/transport_adapter/transport_adapter.h14
-rw-r--r--src/components/include/transport_manager/transport_manager.h14
-rw-r--r--src/components/interfaces/MOBILE_API.xml25
-rw-r--r--src/components/policy/src/policy_manager_impl.cc4
-rw-r--r--src/components/policy/src/usage_statistics/counter.cc3
-rw-r--r--src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h14
-rw-r--r--src/components/transport_manager/include/transport_manager/transport_manager_impl.h14
-rw-r--r--src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc15
-rw-r--r--src/components/transport_manager/src/transport_manager_impl.cc28
-rw-r--r--src/components/transport_manager/test/include/transport_manager/device_mock.h1
-rw-r--r--src/components/transport_manager/test/include/transport_manager/transport_adapter_mock.h9
-rw-r--r--src/components/transport_manager/test/smartDeviceLink_test.ini15
-rw-r--r--src/components/transport_manager/test/transport_adapter_test.cc34
-rw-r--r--src/components/transport_manager/test/transport_manager_impl_test.cc35
-rw-r--r--src/components/utils/include/utils/helpers.h9
-rw-r--r--src/components/utils/include/utils/timer.h21
-rw-r--r--src/components/utils/src/timer.cc15
-rw-r--r--src/components/utils/test/test_generator/MOBILE_API.xml25
-rw-r--r--src/components/utils/test/timer_test.cc33
231 files changed, 21069 insertions, 2712 deletions
diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc
index 1d8e92210e..3c3895d02f 100644
--- a/src/appMain/life_cycle.cc
+++ b/src/appMain/life_cycle.cc
@@ -128,6 +128,7 @@ bool LifeCycle::StartComponents() {
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_);
media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_);
+ app_manager_->set_connection_handler(connection_handler_);
if (!app_manager_->Init(*last_state_, media_manager_)) {
LOG4CXX_ERROR(logger_, "Application manager init failed.");
return false;
@@ -177,7 +178,6 @@ bool LifeCycle::StartComponents() {
// It's important to initialise TM after setting up listener chain
// [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere
app_manager_->set_protocol_handler(protocol_handler_);
- app_manager_->set_connection_handler(connection_handler_);
app_manager_->set_hmi_message_handler(hmi_handler_);
transport_manager_->Init(*last_state_);
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index a9baf8c45a..c5cd4dab8e 100644
--- a/src/appMain/smartDeviceLink.ini
+++ b/src/appMain/smartDeviceLink.ini
@@ -238,3 +238,20 @@ UseDBForResumption = false
AttemptsToOpenResumptionDB = 5
; Timeout between attempts during opening DB in milliseconds
OpenAttemptTimeoutMsResumptionDB = 500
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true
+
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt
index d44cf6c69e..32848b1c6d 100644
--- a/src/components/application_manager/CMakeLists.txt
+++ b/src/components/application_manager/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014, Ford Motor Company
+# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,7 @@ include_directories (
${COMPONENTS_DIR}/config_profile/include/
${COMPONENTS_DIR}/request_watchdog/include/
${COMPONENTS_DIR}/resumption/include/
+ ${COMPONENTS_DIR}/app_launch/include/
${COMPONENTS_DIR}/rpc_base/include/
${COMPONENTS_DIR}/interfaces
${CMAKE_BINARY_DIR}/src/components/
@@ -95,249 +96,258 @@ file (GLOB RESUMPTION
${AM_SOURCE_DIR}/src/resumption/*
)
+file (GLOB APP_LAUNCH
+ ${AM_SOURCE_DIR}/src/app_launch/*
+)
+
+set (COMMANDS_SOURCE_DIR
+ ${AM_SOURCE_DIR}/src/commands
+)
+
file (GLOB MOBILE_COMMANDS_SOURCES
- ${AM_SOURCE_DIR}/src/commands/*
- ${AM_SOURCE_DIR}/src/commands/mobile/*
+ ${COMMANDS_SOURCE_DIR}/*
+ ${COMMANDS_SOURCE_DIR}/mobile/*
)
+
set (HMI_COMMANDS_SOURCES
- ${AM_SOURCE_DIR}/src/commands/hmi/request_to_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/response_from_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/request_from_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/response_to_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/notification_to_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/notification_from_hmi.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/allow_all_apps_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/allow_all_apps_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/allow_app_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/allow_app_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_sdl_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_sdl_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/activate_app_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/activate_app_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/get_system_info_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/get_system_info_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_list_of_permissions_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_list_of_permissions_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_user_friendly_message_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_user_friendly_message_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_status_update_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_get_status_update_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_status_update_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_activate_app_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_activate_app_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/mixing_audio_supported_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/mixing_audio_supported_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_app_list_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_app_list_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_update_device_list.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_device_list_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/update_device_list_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_audio_data_streaming_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_video_data_streaming_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_sdl_consent_needed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_sdl_persistence_complete_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_exit_all_applications_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_exit_application_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_navi_way_point_change_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_start_device_discovery.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/close_popup_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/close_popup_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_activated_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/button_get_capabilities_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/button_get_capabilities_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_is_ready_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_is_ready_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_add_command_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_add_command_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_delete_command_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_delete_command_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_change_registration_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_change_registration_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_supported_languages_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_supported_languages_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_language_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_language_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_capabilities_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_get_capabilities_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_is_ready_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_is_ready_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_change_registration_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_change_registration_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_language_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_language_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_supported_languages_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_supported_languages_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_stop_speaking_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_stop_speaking_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_speak_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_speak_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_set_global_properties_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_set_global_properties_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_capabilities_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/tts_get_capabilities_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_perform_interaction_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vr_perform_interaction_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_add_command_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_add_command_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_delete_command_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_delete_command_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_add_submenu_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_add_submenu_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_delete_submenu_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_delete_submenu_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_supported_languages_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_supported_languages_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_language_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_language_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_capabilities_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_get_capabilities_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_change_registration_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_change_registration_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_show_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_show_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_alert_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_alert_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_slider_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_scrollable_message_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_scrollable_message_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_global_properties_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_global_properties_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_slider_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_is_ready_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_is_ready_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_perform_audio_pass_thru_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_perform_audio_pass_thru_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_end_audio_pass_thru_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_end_audio_pass_thru_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_perform_interaction_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_perform_interaction_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_app_icon_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_app_icon_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_media_clock_timer_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_media_clock_timer_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_show_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_show_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_is_ready_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_is_ready_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_read_did_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_read_did_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_dtcs_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_dtcs_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_diagnostic_message_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_diagnostic_message_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_vehicle_type_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_vehicle_type_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_is_ready_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_is_ready_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_alert_maneuver_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_alert_maneuver_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_update_turn_list_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_update_turn_list_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_show_constant_tbt_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_show_constant_tbt_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_send_location_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_send_location_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_subscribe_way_points_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_subscribe_way_points_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_unsubscribe_way_points_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_unsubscribe_way_points_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ready_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_system_context_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_device_chosen_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_allow_sdl_functionality_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_permission_consent_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_registered_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_permission_changed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_unregistered_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_driver_distraction_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ignition_cycle_over_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_system_info_changed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_file_removed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_tts_started_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_tts_stopped_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vr_started_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vr_stopped_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vr_command_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ui_command_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_navi_tbt_client_state_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_app_deactivated_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_tts_language_change_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vr_language_change_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ui_language_change_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_button_event_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_button_press_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_button_subscription_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_find_applications.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ui_keyboard_input_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ui_touch_event_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_ui_reset_timeout_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_start_stream_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_start_stream_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_stop_stream_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_stop_stream_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_audio_start_stream_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_audio_start_stream_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_audio_stop_stream_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_audio_stop_stream_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_get_way_points_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/navi_get_way_points_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_system_request_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_put_file_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_resume_audio_source_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_sdl_close_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_display_layout_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/ui_set_display_layout_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_record_start_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/add_statistics_info_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_system_error_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/basic_communication_system_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/basic_communication_system_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_policy_update.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/sdl_policy_update_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_received_policy_update.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_policy_update.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/get_urls.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/get_urls_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_device_state_changed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_tts_reset_timeout_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/dial_number_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/dial_number_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_event_changed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/request_to_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/response_from_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/request_from_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/response_to_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/notification_to_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/notification_from_hmi.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/allow_all_apps_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/allow_all_apps_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/allow_app_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/allow_app_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_sdl_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_sdl_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/activate_app_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/activate_app_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/get_system_info_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/get_system_info_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_list_of_permissions_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_list_of_permissions_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_user_friendly_message_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_user_friendly_message_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_status_update_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_status_update_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_status_update_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_activate_app_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_activate_app_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/mixing_audio_supported_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/mixing_audio_supported_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_app_list_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_app_list_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_update_device_list.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_device_list_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/update_device_list_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_audio_data_streaming_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_video_data_streaming_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_sdl_consent_needed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_sdl_persistence_complete_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_exit_all_applications_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_exit_application_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_navi_way_point_change_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_start_device_discovery.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/close_popup_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/close_popup_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_activated_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/button_get_capabilities_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/button_get_capabilities_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_add_command_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_add_command_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_delete_command_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_delete_command_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_change_registration_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_change_registration_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_supported_languages_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_supported_languages_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_language_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_language_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_capabilities_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_get_capabilities_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_change_registration_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_change_registration_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_language_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_language_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_supported_languages_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_supported_languages_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_stop_speaking_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_stop_speaking_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_speak_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_speak_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_set_global_properties_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_set_global_properties_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_capabilities_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/tts_get_capabilities_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_perform_interaction_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vr_perform_interaction_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_add_command_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_add_command_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_delete_command_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_delete_command_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_add_submenu_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_add_submenu_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_delete_submenu_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_delete_submenu_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_supported_languages_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_supported_languages_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_language_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_language_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_capabilities_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_get_capabilities_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_change_registration_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_change_registration_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_show_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_show_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_alert_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_alert_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_slider_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_scrollable_message_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_scrollable_message_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_global_properties_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_global_properties_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_slider_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_perform_audio_pass_thru_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_perform_audio_pass_thru_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_end_audio_pass_thru_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_end_audio_pass_thru_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_perform_interaction_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_perform_interaction_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_app_icon_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_app_icon_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_media_clock_timer_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_media_clock_timer_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_show_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_show_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_read_did_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_read_did_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_dtcs_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_dtcs_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_diagnostic_message_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_diagnostic_message_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_vehicle_type_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_vehicle_type_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_alert_maneuver_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_alert_maneuver_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_update_turn_list_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_update_turn_list_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_show_constant_tbt_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_show_constant_tbt_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_send_location_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_send_location_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_subscribe_way_points_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_subscribe_way_points_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_unsubscribe_way_points_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_unsubscribe_way_points_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ready_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_system_context_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_device_chosen_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_allow_sdl_functionality_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_permission_consent_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_registered_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_permission_changed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_unregistered_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_driver_distraction_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ignition_cycle_over_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_system_info_changed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_file_removed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_tts_started_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_tts_stopped_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vr_started_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vr_stopped_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vr_command_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ui_command_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_navi_tbt_client_state_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_app_deactivated_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_tts_language_change_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vr_language_change_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ui_language_change_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_button_event_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_button_press_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_button_subscription_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_find_applications.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ui_keyboard_input_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ui_touch_event_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_ui_reset_timeout_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_start_stream_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_start_stream_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_stop_stream_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_stop_stream_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_audio_start_stream_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_audio_start_stream_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_audio_stop_stream_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_audio_stop_stream_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_get_way_points_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_get_way_points_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_system_request_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_put_file_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_resume_audio_source_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_sdl_close_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_display_layout_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_set_display_layout_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_record_start_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/add_statistics_info_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_system_error_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/basic_communication_system_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/basic_communication_system_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_policy_update.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/sdl_policy_update_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_received_policy_update.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_policy_update.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/get_urls.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/get_urls_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_device_state_changed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_tts_reset_timeout_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/dial_number_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/dial_number_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_event_changed_notification.cc
)
set (HMI_COMMANDS_SOURCES_JSON
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_vehicle_data_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_get_vehicle_data_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_subscribe_vehicle_data_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_subscribe_vehicle_data_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_vehicle_data_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_vehicle_data_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_get_vehicle_data_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_subscribe_vehicle_data_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_subscribe_vehicle_data_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_unsubscribe_vehicle_data_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/vi_unsubscribe_vehicle_data_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_vehicle_data_notification.cc
)
set (HMI_COMMANDS_SOURCES_DBUS
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_gps_data_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_speed_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_rpm_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_fuel_level_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_fuel_level_state_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_external_temperature_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_vin_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_prndl_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_tire_pressure_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_odometer_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_belt_status_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_body_information_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_device_status_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_driver_braking_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_wiper_status_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_head_lamp_status_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_engine_torque_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_acc_pedal_position_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc
- ${AM_SOURCE_DIR}/src/commands/hmi/on_vi_my_key_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_gps_data_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_speed_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_rpm_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_fuel_level_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_fuel_level_state_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_instant_fuel_consumption_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_external_temperature_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_vin_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_prndl_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_tire_pressure_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_odometer_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_belt_status_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_body_information_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_device_status_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_driver_braking_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_wiper_status_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_head_lamp_status_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_engine_torque_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_acc_pedal_position_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_steering_wheel_angle_notification.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/on_vi_my_key_notification.cc
)
if (${HMI_JSON_API})
@@ -382,7 +392,8 @@ add_library("MessageHelper" ${MESSAGE_HELPER_SOURCES})
add_library("AMMobileCommandsLibrary" ${MOBILE_COMMANDS_SOURCES} )
target_link_libraries("AMMobileCommandsLibrary" ${LIBRARIES} AMEventEngine)
-add_library("ApplicationManager" ${SOURCES} ${RESUMPTION})
+add_library("ApplicationManager" ${SOURCES} ${RESUMPTION} ${APP_LAUNCH})
+
target_link_libraries("ApplicationManager" ${LIBRARIES} AMHMICommandsLibrary
AMMobileCommandsLibrary
AMEventEngine
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
new file mode 100644
index 0000000000..9fc85db38c
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_
+#include <string>
+#include "utils/shared_ptr.h"
+
+namespace application_manager {
+class Application;
+typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr;
+} // namespace application_manager
+
+namespace app_launch {
+
+/**
+ * @brief The AppLaunchCtrl class manage logic of AppLaunch feature
+ * It launches all known applications on newly connected device
+ */
+class AppLaunchCtrl {
+ public:
+ /**
+ * @brief OnAppRegistered should be called when application registered
+ * Save application parameters to database
+ * @param app application to save
+ */
+ virtual void OnAppRegistered(const application_manager::Application& app) = 0;
+
+ /**
+ * @brief OnDeviceConnected shoudl be called on device connected event
+ * Start launching saaved applications on ios device
+ * @param device_mac
+ */
+ virtual void OnDeviceConnected(const std::string& device_mac) = 0;
+
+ /**
+ * @brief OnMasterReset clear database of saved applications
+ */
+ virtual void OnMasterReset() = 0;
+ virtual ~AppLaunchCtrl() {}
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
new file mode 100644
index 0000000000..1f508eebe5
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_IMPL_H_
+
+#include "application_manager/app_launch/app_launch_ctrl.h"
+#include "application_manager/app_launch/app_launch_data.h"
+#include "application_manager/app_launch/apps_launcher.h"
+#include "application_manager/app_launch/device_apps_launcher.h"
+#include "application_manager/app_launch_settings.h"
+
+namespace connection_handler {
+class ConnectionHandler;
+} // connection_handler
+
+namespace resumption {
+class ResumeCtrl;
+} // resumption
+
+namespace app_launch {
+// TODO(AK) Use unique pointer
+typedef utils::SharedPtr<timer::Timer> TimerPtr;
+class MultipleAppsLauncherFactoryImpl;
+
+class AppLaunchCtrlImpl : public AppLaunchCtrl {
+ public:
+ /**
+ * @brief allows to create AppLaunchCtrlImpl object
+ */
+ AppLaunchCtrlImpl(AppLaunchData& data,
+ application_manager::ApplicationManager& app_mngr,
+ const AppLaunchSettings& settings);
+
+ /**
+ * @brief allows to destroy AppLaunchCtrlImpl object
+ */
+ ~AppLaunchCtrlImpl() {}
+
+ void OnAppRegistered(const application_manager::Application& app) OVERRIDE;
+ void OnDeviceConnected(const std::string& device_mac) OVERRIDE;
+ void OnMasterReset() OVERRIDE;
+
+ private:
+ const AppLaunchSettings& settings_;
+ AppLaunchData& app_launch_data_;
+ resumption::ResumeCtrl& resume_ctrl_;
+
+ AppsLauncher apps_launcher_;
+ DeviceAppsLauncher device_apps_launcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppLaunchCtrlImpl);
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h
new file mode 100644
index 0000000000..0d52384018
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_
+
+#include <stdint.h>
+#include <vector>
+#include <string>
+#include "utils/shared_ptr.h"
+
+namespace app_launch {
+
+/**
+ * @brief struct holds AppLaunch data
+ */
+struct ApplicationData {
+ ApplicationData(const std::string& mobile_app_id,
+ const std::string& bundle_id,
+ const std::string& device_id)
+ : mobile_app_id_(mobile_app_id)
+ , bundle_id_(bundle_id)
+ , device_mac_(device_id) {}
+
+ std::string mobile_app_id_;
+ std::string bundle_id_;
+ std::string device_mac_;
+ bool operator==(const ApplicationData& app_data) const {
+ return mobile_app_id_ == app_data.mobile_app_id_ &&
+ bundle_id_ == app_data.bundle_id_ && device_mac_ == device_mac_;
+ }
+};
+typedef utils::SharedPtr<ApplicationData> ApplicationDataPtr;
+
+/**
+ * @brief class contains interfaces to AppLaunchDataDB and AppLaunchDataJson
+ */
+class AppLaunchData {
+ public:
+ /**
+ * @brief allows correct delete heir object
+ */
+ virtual ~AppLaunchData() {}
+
+ /**
+ * @brief insert new data to DB
+ * @param app_data - data to inserting
+ * @return true in success cases and false othrewise
+ */
+ virtual bool AddApplicationData(const ApplicationData& app_data) = 0;
+
+ /**
+ * @brief select from DB all records with this dev_mac
+ * @param app_data - data to inserting
+ * @param dev_apps -
+ * @return vector of pointers on results of select
+ */
+ virtual std::vector<ApplicationDataPtr> GetApplicationDataByDevice(
+ const std::string& dev_mac) = 0;
+ /**
+ * @brief delete App_launch table in DB, after calling this
+ * one, it should again call init
+ * @return true in success cases and false othrewise
+ */
+ virtual bool Clear() = 0;
+
+ /**
+ * @brief Persist saves resumption data on file system
+ */
+ virtual bool Persist() = 0;
+};
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h
new file mode 100644
index 0000000000..92d6bbd9ef
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_DB_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_DB_H_
+#include <memory>
+#include "application_manager/app_launch/app_launch_data_impl.h"
+#include "application_manager/app_launch_settings.h"
+#include "utils/macro.h"
+#ifdef __QNX__
+#include "utils/qdb_wrapper/sql_database.h"
+#include "utils/qdb_wrapper/sql_query.h"
+#else // linux
+#include "utils/sqlite_wrapper/sql_database.h"
+#include "utils/sqlite_wrapper/sql_query.h"
+#endif
+
+namespace app_launch {
+
+const std::string kDatabaseName = "resumption";
+
+/**
+ * @brief Show should database be saved in a disk file or in memory
+ */
+enum DbStorage { In_Memory_Storage = 0, In_File_Storage };
+
+/**
+ * @brief class contains logic for representation application
+ * launch_app data in data base
+ */
+class AppLaunchDataDB : public AppLaunchDataImpl {
+ public:
+ /**
+ * @brief Constructor of AppLaunchDataDB
+ * @param settings - setting of AppLaunch
+ */
+ AppLaunchDataDB(const AppLaunchSettings& settings,
+ DbStorage db_storage = In_File_Storage);
+
+ /**
+ * @brief allows to destroy AppLaunchDataDB object
+ */
+ ~AppLaunchDataDB();
+
+ /**
+ * @brief Creates or opens DB and initialize it
+ * @return false if DB doesn't initialize
+ * otherwise returns true
+ */
+ bool Init();
+
+ /**
+ * @brief delete App_launch table in DB, after calling this
+ * one, it should again call init
+ * @return true in success cases and false othrewise
+ */
+ bool Clear() OVERRIDE;
+
+ /**
+ * @brief Write database to file system
+ */
+ bool Persist() OVERRIDE;
+
+ /**
+ * @return current count of records
+ * AppLaunch in DB
+ */
+ uint32_t GetCurentNumberOfAppData() const;
+
+ /**
+ * @param app_data - searching fields in object
+ * @return true in case application data already existed
+ * and false othrewise
+ */
+ bool IsAppDataAlreadyExisted(const ApplicationData& app_data) const OVERRIDE;
+
+ /**
+ * @brief returns pointer to data base
+ */
+ utils::dbms::SQLDatabase* db() const;
+
+ enum ApplicationDataDBIndexes {
+ result_query = 0,
+ device_mac_index = 0,
+ application_id_index,
+ bundle_id_index,
+ timestamp_index
+ };
+
+ private:
+ /**
+ * @brief update time stamp
+ * @param app_data - data to update
+ * @return true in success cases and false othrewise
+ */
+ bool RefreshAppSessionTime(const ApplicationData& app_data) OVERRIDE;
+
+ /**
+ * @brief insert new data to DB
+ * @param app_data - data to inserting
+ * @return true in success cases and false othrewise
+ */
+ bool AddNewAppData(const ApplicationData& app_data) OVERRIDE;
+
+ /**
+ * @brief select from DB all records with this dev_mac
+ * @param app_data - data to inserting
+ * @return vector of ponter on founded records
+ */
+ std::vector<ApplicationDataPtr> GetAppDataByDevMac(
+ const std::string& dev_mac) const OVERRIDE;
+ /**
+ * @brief delete record with oldest timestamp
+ * @return true in success cases and false othrewise
+ */
+ bool DeleteOldestAppData() OVERRIDE;
+
+ /**
+ * @brief write DB to file
+ * @return true in success cases and false othrewise
+ */
+ bool WriteDb();
+
+ /**
+ * @brief returns pointer to data base
+ */
+ std::auto_ptr<utils::dbms::SQLDatabase> db_;
+
+ /**
+ * @brief indicate initializing status of DB
+ */
+ bool init_successeful_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppLaunchDataDB);
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_DB_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h
new file mode 100644
index 0000000000..111ff25ab2
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_
+
+#include "application_manager/app_launch/app_launch_data.h"
+#include "application_manager/app_launch_settings.h"
+
+namespace app_launch {
+
+class AppLaunchDataImpl : public AppLaunchData {
+ public:
+ /**
+ * @brief Constructor of AppLaunchDataImpl
+ * @param settings - setting of AppLaunch
+ */
+ AppLaunchDataImpl(const AppLaunchSettings& settings);
+
+ /**
+ * @brief allows to destroy AppLaunchDataImpl object
+ */
+ virtual ~AppLaunchDataImpl();
+
+ /**
+ * @brief insert new data to DB
+ * @param app_data - data to inserting
+ * @return true in success cases and false othrewise
+ */
+ virtual bool AddApplicationData(const ApplicationData& app_data);
+
+ /**
+ * @brief select from DB all records with this dev_mac
+ * @param app_data - data to inserting
+ * @return return vector of pointers on founded records
+ */
+ std::vector<ApplicationDataPtr> GetApplicationDataByDevice(
+ const std::string& dev_mac) OVERRIDE;
+
+ /**
+ * @brief Persist saves resumption data on file system
+ */
+ virtual bool Persist() = 0;
+
+ /**
+ * @return max count of iOS device that can be connected
+ */
+ virtual uint32_t get_max_number_iOS_devs() const {
+ return kMaxNumberOfiOSdevice;
+ }
+
+ /**
+ * @brief all AppLaunch settings
+ */
+ const AppLaunchSettings& settings_;
+
+ private:
+ /**
+ * @param app_data - searching filled in object
+ * @return true in case application data already existed
+ * and false othrewise
+ */
+ virtual bool IsAppDataAlreadyExisted(
+ const ApplicationData& app_data) const = 0;
+
+ /**
+ * @brief update time stamp
+ * @param app_data - data to update
+ * @return true in success cases and false othrewise
+ */
+ virtual bool RefreshAppSessionTime(const ApplicationData& app_data) = 0;
+
+ /**
+ * @brief insert new data to DB
+ * @param app_data - data to inserting
+ * @return true in success cases and false othrewise
+ */
+ virtual bool AddNewAppData(const ApplicationData& app_data) = 0;
+
+ /**
+ * @brief select from DB all records with this dev_mac
+ * @param app_data - data to inserting
+ * @return vector of ponter on founded records
+ */
+ virtual std::vector<ApplicationDataPtr> GetAppDataByDevMac(
+ const std::string& dev_mac) const = 0;
+
+ /**
+ * @brief delete record with oldest timestamp
+ * @return true in success cases and false othrewise
+ */
+ virtual bool DeleteOldestAppData() = 0;
+
+ /**
+ * @return current count of records
+ * AppLaunch in DB
+ */
+ virtual uint32_t GetCurentNumberOfAppData() const = 0;
+
+ /**
+ * @brief max count of iOS device that can be connected
+ */
+ const uint32_t kMaxNumberOfiOSdevice;
+};
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h
new file mode 100644
index 0000000000..61117e552b
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_
+
+#include "application_manager/app_launch/app_launch_data_impl.h"
+#include "smart_objects/smart_object.h"
+#include "resumption/last_state.h"
+#include "utils/lock.h"
+#include "utils/macro.h"
+
+namespace app_launch {
+
+enum { NotFound = -1 };
+/**
+ * @brief class contains logic for representation application launch_app data in
+ * json file
+ */
+class AppLaunchDataJson : public AppLaunchDataImpl {
+ public:
+ /**
+ * @brief Constructor of AppLaunchDataJson object
+ */
+ AppLaunchDataJson(const AppLaunchSettings& settings,
+ resumption::LastState& last_state);
+ /**
+ * @brief allows to destroy AppLaunchDataJson object
+ */
+ ~AppLaunchDataJson();
+
+ /**
+ * @brief Write Json to file system
+ */
+ bool Persist() OVERRIDE;
+
+ /**
+ * @brief delete App_launch table in DB, after calling this
+ * one, it should again call init
+ * @return true in success cases and false othrewise
+ */
+ virtual bool Clear();
+
+ /**
+ * @return current count of records
+ * AppLaunch in DB
+ */
+ uint32_t GetCurentNumberOfAppData() const;
+
+ /**
+ * @param app_data - searching filled in object
+ * @return true in case application data already existed
+ * and false othrewise
+ */
+ virtual bool IsAppDataAlreadyExisted(const ApplicationData& app_data) const;
+
+ /**
+ * @param app_data - searching filled in object
+ * @param founded_index - referenceto index of founded record
+ * in case it wasn't found it'll be -1
+ * @return pointer to json list object
+ */
+ Json::Value& GetApplicationListAndIndex(const ApplicationData& app_data,
+ int32_t& founded_index) const;
+
+ private:
+ /**
+ * @brief update time stamp
+ * @param app_data - data to update
+ * @return true in success cases and false othrewise
+ */
+ virtual bool RefreshAppSessionTime(const ApplicationData& app_data);
+
+ /**
+ * @brief insert new data to DB
+ * @param app_data - data to inserting
+ * @return true in success cases and false othrewise
+ */
+ virtual bool AddNewAppData(const ApplicationData& app_data);
+
+ /**
+ * @brief select from DB all records with this dev_mac
+ * @param app_data - data to inserting
+ * @return vector of pointer on founded records
+ */
+ std::vector<ApplicationDataPtr> GetAppDataByDevMac(
+ const std::string& dev_mac) const OVERRIDE;
+
+ /**
+ * @return pointer to LastState functionality
+ */
+ resumption::LastState& last_state() const {
+ return last_state_;
+ }
+
+ /**
+ * @brief delete record with oldest timestamp
+ * @return true in success cases and false othrewise
+ */
+ bool DeleteOldestAppData();
+
+ /**
+ * @return pointer to AppLaunch data block in Json file
+ */
+ Json::Value& GetSavedApplicationDataList() const;
+
+ /**
+ * @return pointer to AppLaunch records block in Json file
+ */
+ Json::Value& GetApplicationData() const;
+
+ /**
+ * @brief lock to protected common data
+ */
+ mutable sync_primitives::Lock app_launch_json_lock_;
+
+ /**
+ * @brief ponter to Last State object
+ */
+ resumption::LastState& last_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppLaunchDataJson);
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_sql_queries.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_sql_queries.h
new file mode 100644
index 0000000000..4539b49002
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_sql_queries.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_SQL_QUERIES_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_SQL_QUERIES_H_
+
+#include <string>
+
+namespace app_launch {
+
+extern const std::string kCreateSchema;
+extern const std::string kDropSchema;
+extern const std::string kFindApplicationData;
+extern const std::string kDeleteOldestAppData;
+extern const std::string kGetNumberOfApplicationData;
+extern const std::string kGetApplicationDataByDevID;
+extern const std::string kAddApplicationData;
+extern const std::string kRefreshApplicationDataSessionTime;
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_SQL_QUERIES_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h
new file mode 100644
index 0000000000..751e04bada
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h
@@ -0,0 +1,86 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_
+#include "application_manager/app_launch/app_launch_data.h"
+#include "connection_handler/connection_handler.h"
+#include "utils/timer.h"
+
+namespace app_launch {
+class AppLaunchCtrlImpl;
+/**
+ * @brief The AppLauncher struct will manage Launching app and relaunching app
+ * in case application wasn't Registered.
+ * When application registered instance of this structure should be deleted to
+ * stop relaunch timer
+ */
+class AppsLauncher {
+ public:
+ AppsLauncher(connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t max_number_of_ios_device,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time);
+
+ /**
+ * @brief StartLaunching start launching process of applicaiton
+ * @param app_data applicaiton to launch
+ */
+ void StartLaunching(ApplicationDataPtr app_data);
+
+ /**
+ * @brief OnLaunched callback for application registration
+ * @param app_data registered application
+ */
+ void OnLaunched(ApplicationDataPtr app_data);
+
+ /**
+ * @brief OnRetryAttemptsExhausted callback for retry attempt exhausting
+ * @param app_data applicaiton that was exhausted launch attempts
+ */
+ void OnRetryAttemptsExhausted(ApplicationDataPtr app_data);
+
+ struct Launcher {
+ public:
+ Launcher(AppsLauncher& parent,
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time);
+
+ /**
+ * @brief PosponedLaunch launch application after cpecial timeout
+ * Will manage launch retrying in case of application wasn't registered
+ * @param app_data applicaiton to launch
+ */
+ void PosponedLaunch(const ApplicationDataPtr& app_data);
+
+ /**
+ * @brief Stops launching timers and remove information about launching
+ * application
+ */
+ void Clear();
+
+ /**
+ * @brief LaunchNow send Launch to device request now
+ */
+ void LaunchNow();
+ ApplicationDataPtr app_data_;
+ size_t retry_index_;
+ timer::Timer retry_timer_;
+ const uint16_t app_launch_max_retry_attempt_;
+ const uint16_t app_launch_retry_wait_time_;
+ connection_handler::ConnectionHandler& connection_handler_;
+ AppsLauncher& parent_;
+ };
+ typedef utils::SharedPtr<Launcher> LauncherPtr;
+ typedef std::vector<LauncherPtr> AppLaunchers;
+
+ private:
+ sync_primitives::Lock launchers_lock_;
+ AppLaunchers free_launchers_;
+ AppLaunchers works_launchers_;
+ friend class Launcher;
+ void StopLaunching(ApplicationDataPtr app_data);
+ DISALLOW_COPY_AND_ASSIGN(AppsLauncher);
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_
diff --git a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
new file mode 100644
index 0000000000..f1f29471e6
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
@@ -0,0 +1,46 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_
+#include <stdint.h>
+#include <vector>
+#include <string>
+#include <memory>
+#include "application_manager/app_launch/app_launch_data.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/app_launch_settings.h"
+
+namespace app_launch {
+class AppLaunchCtrlImpl;
+class DeviceAppsLauncherImpl;
+class AppsLauncher;
+class AppLaunchSettings;
+/**
+ * @brief The MultipleAppsLauncher struct
+ * should manage launching applications and gaps between launching application
+ * on one device
+ * When all apps launched it will notify AppLaunchCtrlImpl that all apps
+ * launched
+ */
+class DeviceAppsLauncher {
+ public:
+ DeviceAppsLauncher(application_manager::ApplicationManager& app_mngr,
+ app_launch::AppsLauncher& apps_launcher,
+ const AppLaunchSettings& settings);
+
+ bool LaunchAppsOnDevice(
+ const std::string& device_mac,
+ const std::vector<ApplicationDataPtr>& applications_to_launch);
+ bool StopLaunchingAppsOnDevice(const std::string& device_mac);
+
+ const AppLaunchSettings& settings() const;
+
+ private:
+ application_manager::ApplicationManager& app_mngr_;
+ const AppLaunchSettings& settings_;
+ std::auto_ptr<DeviceAppsLauncherImpl> impl_;
+ friend class DeviceAppsLauncherImpl;
+ DISALLOW_COPY_AND_ASSIGN(DeviceAppsLauncher);
+};
+
+} // namespace app_launch
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index 612db6be03..3ec667d911 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,6 +109,8 @@ class InitialApplicationData {
virtual const smart_objects::SmartObject* app_types() const = 0;
virtual const smart_objects::SmartObject* vr_synonyms() const = 0;
virtual const std::string& mac_address() const = 0;
+ virtual const std::string& bundle_id() const = 0;
+ virtual void set_bundle_id(const std::string& bundle_id) = 0;
virtual std::string policy_app_id() const = 0;
virtual const smart_objects::SmartObject* tts_name() const = 0;
virtual const smart_objects::SmartObject* ngn_media_screen_name() const = 0;
@@ -578,8 +580,8 @@ class Application : public virtual InitialApplicationData,
* @param source Limits source, e.g. policy table, config file etc.
* @return true, if - excedeed, otherwise - false
*/
- virtual bool IsCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
- TLimitSource source) = 0;
+ virtual bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
+ TLimitSource source) = 0;
/**
* Returns object for recording statistics
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h
index 75496b2761..8658963aef 100644
--- a/src/components/application_manager/include/application_manager/application_impl.h
+++ b/src/components/application_manager/include/application_manager/application_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -139,6 +139,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
const std::string& app_icon_path() const;
connection_handler::DeviceHandle device() const;
const std::string& mac_address() const OVERRIDE;
+ const std::string& bundle_id() const OVERRIDE;
+ void set_bundle_id(const std::string& bundle_id) OVERRIDE;
void set_tts_properties_in_none(bool active);
bool tts_properties_in_none();
void set_tts_properties_in_full(bool active);
@@ -199,8 +201,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
UsageStatistics& usage_report();
- bool IsCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
- TLimitSource source);
+ bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
+ TLimitSource source);
virtual void SubscribeToSoftButtons(int32_t cmd_id,
const SoftButtonID& softbuttons_id);
virtual bool IsSubscribedToSoftButton(const uint32_t softbutton_id);
@@ -357,7 +359,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
std::string app_icon_path_;
connection_handler::DeviceHandle device_;
const std::string mac_address_;
-
+ std::string bundle_id_;
AppFilesMap app_files_;
std::set<mobile_apis::ButtonName::eType> subscribed_buttons_;
VehicleInfoSubscriptions subscribed_vehicle_info_;
diff --git a/src/components/application_manager/include/application_manager/application_manager.h b/src/components/application_manager/include/application_manager/application_manager.h
index 97c38cd134..e67864b9b1 100644
--- a/src/components/application_manager/include/application_manager/application_manager.h
+++ b/src/components/application_manager/include/application_manager/application_manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,11 +47,15 @@
#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/application_manager_settings.h"
#include "application_manager/state_controller.h"
+#include "application_manager/hmi_interfaces.h"
namespace resumption {
class LastState;
}
+namespace app_launch {
+class AppLaunchCtrl;
+} // namespace app_launch
namespace media_manager {
class MediaManager;
}
@@ -408,8 +412,11 @@ class ApplicationManager {
* @brief TerminateRequest forces termination of request
* @param connection_key - application id of request
* @param corr_id correlation id of request
+ * @param function_id function id of request
*/
- virtual void TerminateRequest(uint32_t connection_key, uint32_t corr_id) = 0;
+ virtual void TerminateRequest(const uint32_t connection_key,
+ const uint32_t corr_id,
+ const int32_t function_id) = 0;
/*
* @brief Closes application by id
@@ -490,6 +497,16 @@ class ApplicationManager {
uint32_t connection_key, const std::string& policy_app_id) const = 0;
virtual resumption::ResumeCtrl& resume_controller() = 0;
+
+ /**
+ * @brief hmi_interfaces getter for hmi_interfaces component, that handle
+ * hmi_instrfaces state
+ * @return reference to hmi_interfaces component
+ */
+ virtual HmiInterfaces& hmi_interfaces() = 0;
+
+ virtual app_launch::AppLaunchCtrl& app_launch_ctrl() = 0;
+
/*
* @brief Converts connection string transport type representation
* to HMI Common_TransportType
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 dda192f8b0..be52046888 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
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_H_
#include <stdint.h>
#include <vector>
@@ -39,6 +39,7 @@
#include <set>
#include <deque>
#include <algorithm>
+#include <memory>
#include "application_manager/hmi_command_factory.h"
#include "application_manager/application_manager.h"
@@ -49,8 +50,10 @@
#include "application_manager/resumption/resume_ctrl.h"
#include "application_manager/vehicle_info_data.h"
#include "application_manager/state_controller_impl.h"
+#include "application_manager/app_launch/app_launch_data.h"
#include "application_manager/application_manager_settings.h"
#include "application_manager/event_engine/event_dispatcher_impl.h"
+#include "application_manager/hmi_interfaces_impl.h"
#include "protocol_handler/protocol_observer.h"
#include "protocol_handler/protocol_handler.h"
@@ -317,8 +320,8 @@ class ApplicationManagerImpl
void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE;
- HMICapabilities& hmi_capabilities();
- const HMICapabilities& hmi_capabilities() const;
+ HMICapabilities& hmi_capabilities() OVERRIDE;
+ const HMICapabilities& hmi_capabilities() const OVERRIDE;
/**
* @brief ProcessQueryApp executes logic related to QUERY_APP system request.
@@ -708,8 +711,11 @@ class ApplicationManagerImpl
* @brief TerminateRequest forces termination of request
* @param connection_key - application id of request
* @param corr_id correlation id of request
+ * @param function_id function id of request
*/
- void TerminateRequest(uint32_t connection_key, uint32_t corr_id) OVERRIDE;
+ void TerminateRequest(const uint32_t connection_key,
+ const uint32_t corr_id,
+ const int32_t function_id) OVERRIDE;
// Overriden ProtocolObserver method
void OnMessageReceived(
const ::protocol_handler::RawMessagePtr message) OVERRIDE;
@@ -839,7 +845,11 @@ class ApplicationManagerImpl
* @return Resume Controller
*/
resumption::ResumeCtrl& resume_controller() OVERRIDE {
- return resume_ctrl_;
+ return *resume_ctrl_.get();
+ }
+
+ HmiInterfaces& hmi_interfaces() OVERRIDE {
+ return hmi_interfaces_;
}
/**
@@ -1102,6 +1112,8 @@ class ApplicationManagerImpl
const ApplicationManagerSettings& get_settings() const OVERRIDE;
virtual event_engine::EventDispatcher& event_dispatcher() OVERRIDE;
+ app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE;
+
private:
/**
* @brief PullLanguagesInfo allows to pull information about languages.
@@ -1409,7 +1421,7 @@ class ApplicationManagerImpl
// Thread that pumps messages audio pass thru to mobile.
impl::AudioPassThruQueue audio_pass_thru_messages_;
- HMICapabilities hmi_capabilities_;
+ std::auto_ptr<HMICapabilities> hmi_capabilities_;
// The reason of HU shutdown
mobile_api::AppInterfaceUnregisteredReason::eType unregister_reason_;
@@ -1418,7 +1430,9 @@ class ApplicationManagerImpl
* about persistent application data on disk, and save session ID for resuming
* application in case INGITION_OFF or MASTER_RESSET
*/
- resumption::ResumeCtrl resume_ctrl_;
+ std::auto_ptr<resumption::ResumeCtrl> resume_ctrl_;
+
+ HmiInterfacesImpl hmi_interfaces_;
NaviServiceStatusMap navi_service_status_;
std::deque<uint32_t> navi_app_to_stop_;
@@ -1430,6 +1444,8 @@ class ApplicationManagerImpl
sync_primitives::Lock timer_pool_lock_;
sync_primitives::Lock stopping_application_mng_lock_;
StateControllerImpl state_ctrl_;
+ std::auto_ptr<app_launch::AppLaunchData> app_launch_dto_;
+ std::auto_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_;
#ifdef TELEMETRY_MONITOR
AMTelemetryObserver* metric_observer_;
@@ -1460,4 +1476,4 @@ inline bool ApplicationManagerImpl::all_apps_allowed() const {
} // namespace application_manager
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
index c5f45e2095..5b86bfa851 100644
--- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2014, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -47,8 +47,71 @@ class SmartObject;
namespace application_manager {
namespace commands {
+struct ResponseInfo {
+ ResponseInfo()
+ : result_code(hmi_apis::Common_Result::INVALID_ENUM)
+ , interface(HmiInterfaces::HMI_INTERFACE_INVALID_ENUM)
+ , interface_state(HmiInterfaces::STATE_NOT_RESPONSE)
+ , is_ok(false)
+ , is_unsupported_resource(false)
+ , is_invalid_enum(false) {}
+ ResponseInfo(hmi_apis::Common_Result::eType result,
+ HmiInterfaces::InterfaceID interface)
+ : result_code(result)
+ , interface(interface)
+ , interface_state(HmiInterfaces::STATE_NOT_RESPONSE)
+ , is_ok(false)
+ , is_unsupported_resource(false)
+ , is_invalid_enum(false) {}
+ hmi_apis::Common_Result::eType result_code;
+ HmiInterfaces::InterfaceID interface;
+ HmiInterfaces::InterfaceState interface_state;
+ bool is_ok;
+ bool is_unsupported_resource;
+ bool is_invalid_enum;
+};
+
namespace NsSmart = NsSmartDeviceLink::NsSmartObjects;
+/**
+ * @brief MergeInfos merge 2 infos in one string
+ * @param first - info string that should be first in result info
+ * @param second - info string that should be second in result info
+ * @return if first is empty return second
+ * if second is empty return first
+ * if both are empty return empty string
+ * if both are not empty return empty first +", " + second
+ */
+std::string MergeInfos(const std::string& first, const std::string& second);
+
+/**
+ * @brief MergeInfos merge 2 infos into one string with info
+ * @param first_info -contains result_code from HMI response and
+ * interface that returns response
+ * @param first_str - info string that should be first in result info
+ * @param second_info -contains result_code from HMI response and
+ * interface that returns response
+ * @param second_str - info string that should be second in result info
+ * @return if first_info is not available and second_str not empty return second
+ * if second_info is not available and first_str not empty return first
+ * other cases return result MergeInfos for 2 params
+ */
+std::string MergeInfos(const ResponseInfo& first_info,
+ const std::string& first_str,
+ const ResponseInfo& second_info,
+ const std::string& second_str);
+
+/**
+ * @brief MergeInfos merge 3 infos in one string
+ * @param first - info string that should be first in result info
+ * @param second - info string that should be second in result info
+ * @param third - info string that should be second in result info
+ * @return resulting string contain merge all incoming parameters
+ */
+std::string MergeInfos(const std::string& first,
+ const std::string& second,
+ const std::string& third);
+
class CommandRequestImpl : public CommandImpl,
public event_engine::EventObserver {
public:
@@ -153,6 +216,54 @@ class CommandRequestImpl : public CommandImpl,
*/
bool HasDisallowedParams() const;
+ /**
+ * @brief Checks result code from HMI for single RPC
+ * and returns parameter for sending to mobile app.
+ * @param result_code contains result code from HMI response
+ * @param interface contains interface for which HMI sent response
+ * @return true if result code complies successful result cods
+ * otherwise returns false.
+ */
+ bool PrepareResultForMobileResponse(
+ hmi_apis::Common_Result::eType result_code,
+ HmiInterfaces::InterfaceID interface) const;
+
+ /**
+ * @brief Checks result code from HMI for splitted RPC
+ * and returns parameter for sending to mobile app.
+ * @param first contains result_code from HMI response and
+ * interface that returns response
+ * @param second contains result_code from HMI response and
+ * interface that returns response
+ * @return true if result code complies successful result code
+ * otherwise returns false
+ */
+ bool PrepareResultForMobileResponse(ResponseInfo& out_first,
+ ResponseInfo& out_second) const;
+
+ /**
+ * @brief If message from HMI contains returns this info
+ * or process result code from HMI and checks state of interface
+ * and create info.
+ * @param interface contains interface for which HMI sent response
+ * @param result_code contains result code from HMI
+ * @param response_from_hmi contains response from HMI
+ * @param out_info contain info for sending to application
+ */
+ void GetInfo(const smart_objects::SmartObject& response_from_hmi,
+ std::string& out_info);
+
+ /**
+ * @brief Prepare result code for sending to mobile application
+ * @param first contains result_code from HMI response and
+ * interface that returns response
+ * @param second contains result_code from HMI response and
+ * interface that returns response.
+ * @return resulting code for sending to mobile application.
+ */
+ mobile_apis::Result::eType PrepareResultCodeForResponse(
+ const ResponseInfo& first, const ResponseInfo& second);
+
protected:
/**
* @brief Returns policy parameters permissions
@@ -182,6 +293,10 @@ class CommandRequestImpl : public CommandImpl,
*/
void AddDisallowedParametersToInfo(
smart_objects::SmartObject& response) const;
+
+ bool ProcessHMIInterfacesAvailability(
+ const uint32_t hmi_correlation_id,
+ const hmi_apis::FunctionID::eType& function_id);
};
} // namespace commands
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h
index 9f1adaeee0..77ce48a2cc 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h
@@ -42,7 +42,8 @@ namespace commands {
/**
* @brief NaviIsReadyRequest command class
**/
-class NaviIsReadyRequest : public RequestToHMI {
+class NaviIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
public:
/**
* @brief NaviIsReadyRequest class constructor
@@ -60,7 +61,12 @@ class NaviIsReadyRequest : public RequestToHMI {
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(NaviIsReadyRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h b/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h
index e512279e79..b30044fd26 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h
@@ -40,6 +40,27 @@ namespace application_manager {
namespace commands {
+/**
+ * @brief Check if HMI's interface is available.
+ * @param application_manager contains application manager component
+ * @param interface contains name of HMI's interface
+ * @return true if interface is available otherwise return fasle.
+ */
+bool CheckAvailabilityHMIInterfaces(ApplicationManager& application_manager,
+ HmiInterfaces::InterfaceID interface);
+
+/**
+ * @brief Change interface state
+ * @param application_manager contains ApplicationManager instance
+ * @param response_from_hmi contains response from HMI
+ * @param interface contanins InterfaceID whose state is changed.
+ * @return true if field available exist and contains true in response params
+ * otherwise return false.
+ */
+bool ChangeInterfaceState(ApplicationManager& application_manager,
+ const smart_objects::SmartObject& response_from_hmi,
+ HmiInterfaces::InterfaceID interface);
+
class RequestToHMI : public CommandImpl {
public:
RequestToHMI(const MessageSharedPtr& message,
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h
index 81bd8eb27b..340a00d294 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h
@@ -42,7 +42,8 @@ namespace commands {
/**
* @brief TTSIsReadyRequest command class
**/
-class TTSIsReadyRequest : public RequestToHMI {
+class TTSIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
public:
/**
* @brief TTSIsReadyRequest class constructor
@@ -60,7 +61,22 @@ class TTSIsReadyRequest : public RequestToHMI {
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut from requrst Controller
+ */
+ void onTimeOut() OVERRIDE;
+
+ /**
+ * @brief Send request to HMI for fetching of cappabilities
+ */
+ void SendMessageToHMI();
private:
DISALLOW_COPY_AND_ASSIGN(TTSIsReadyRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h
index a505df6de4..49942d81a7 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h
@@ -42,7 +42,8 @@ namespace commands {
/**
* @brief UIIsReadyRequest command class
**/
-class UIIsReadyRequest : public RequestToHMI {
+class UIIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
public:
/**
* @brief UIIsReadyRequest class constructor
@@ -60,7 +61,22 @@ class UIIsReadyRequest : public RequestToHMI {
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut from requrst Controller
+ */
+ virtual void onTimeOut() OVERRIDE;
+
+ /**
+ * @brief Send request to HMI for fetching of cappabilities
+ */
+ void SendMessageToHMI();
private:
DISALLOW_COPY_AND_ASSIGN(UIIsReadyRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h
index 9049db4d24..07ab9df605 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h
@@ -42,7 +42,8 @@ namespace commands {
/**
* @brief VIIsReadyRequest command class
**/
-class VIIsReadyRequest : public RequestToHMI {
+class VIIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
public:
/**
* @brief VIIsReadyRequest class constructor
@@ -60,7 +61,22 @@ class VIIsReadyRequest : public RequestToHMI {
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut from requrst Controller
+ */
+ void onTimeOut() OVERRIDE;
+
+ /**
+ * @brief Send request to HMI for fetching of cappabilities
+ */
+ void SendMessageToHMI();
private:
DISALLOW_COPY_AND_ASSIGN(VIIsReadyRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h
index 9fc4ccd2f3..55a2101e1a 100644
--- a/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h
+++ b/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_VR_IS_READY_REQUEST_H_
#include "application_manager/commands/hmi/request_to_hmi.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -42,7 +43,8 @@ namespace commands {
/**
* @brief VRIsReadyRequest command class
**/
-class VRIsReadyRequest : public RequestToHMI {
+class VRIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
public:
/**
* @brief VRIsReadyRequest class constructor
@@ -60,7 +62,22 @@ class VRIsReadyRequest : public RequestToHMI {
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut from requrst Controller
+ */
+ void onTimeOut() OVERRIDE;
+
+ /**
+ * @brief Send request to HMI for fetching of cappabilities
+ */
+ void SendMessageToHMI();
private:
DISALLOW_COPY_AND_ASSIGN(VRIsReadyRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h b/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
index 22a0c7e85f..17758d66fc 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
@@ -33,6 +33,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_ADD_COMMAND_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_ADD_COMMAND_REQUEST_H_
+#include <string>
#include "application_manager/application.h"
#include "application_manager/commands/command_request_impl.h"
@@ -72,6 +73,12 @@ class AddCommandRequest : public CommandRequestImpl {
*/
void on_event(const event_engine::Event& event);
+ /**
+ * @brief Function is called by RequestController when request execution time
+ * has exceed it's limit
+ */
+ virtual void onTimeOut();
+
private:
/*
* @brief Check if command name doesn't exist in application
@@ -103,12 +110,6 @@ class AddCommandRequest : public CommandRequestImpl {
bool CheckCommandParentId(ApplicationConstSharedPtr app);
/**
- * @brief Function is called by RequestController when request execution time
- * has exceed it's limit
- */
- virtual void onTimeOut();
-
- /**
* @brief Removes command from list when HMI sends negative response or
* HMI does not answer on addCommand request.
*/
@@ -133,12 +134,21 @@ class AddCommandRequest : public CommandRequestImpl {
inline bool BothSend() const;
+ /**
+ * @brief GenerateMobileResponseInfo generated info for mobile response
+ * depends from UI and VR responses
+ * @return info for mobile response
+ */
+ const std::string GenerateMobileResponseInfo();
bool send_ui_;
bool send_vr_;
bool is_ui_received_;
bool is_vr_received_;
+ std::string ui_info_;
+ std::string vr_info_;
+
hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType vr_result_;
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h
index 472ff45551..92211b54a2 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h
@@ -75,6 +75,15 @@ class AlertManeuverRequest : public CommandRequestImpl {
private:
/**
+ * @brief Prepare parameters for sending to mobile application
+ * @param result_code contains result code for sending to mobile application
+ * @param return_info contains resulting info for sending to mobile
+ * application
+ * @return result for sending to mobile application.
+ */
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& return_info);
+ /**
* @brief Checks alert maneuver params(ttsChunks, ...).
* When type is String there is a check on the contents \t\n \\t \\n
* @return if alert maneuver contains \t\n \\t \\n return TRUE,
@@ -82,8 +91,8 @@ class AlertManeuverRequest : public CommandRequestImpl {
*/
bool IsWhiteSpaceExist();
- mobile_apis::Result::eType tts_speak_result_code_;
- mobile_apis::Result::eType navi_alert_maneuver_result_code_;
+ hmi_apis::Common_Result::eType tts_speak_result_code_;
+ hmi_apis::Common_Result::eType navi_alert_maneuver_result_code_;
std::string info_navi_;
std::string info_tts_;
Pending pending_requests_;
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h b/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h
index bc99665d82..84241f8f80 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/alert_request.h
@@ -34,6 +34,8 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_ALERT_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_ALERT_REQUEST_H_
+#include <string>
+
#include "application_manager/commands/command_request_impl.h"
#include "interfaces/MOBILE_API.h"
#include "utils/macro.h"
@@ -126,14 +128,25 @@ class AlertRequest : public CommandRequestImpl {
*/
bool CheckStringsOfAlertRequest();
+ /*
+ * @brief Prepare result code and result for sending to mobile application
+ * @param result_code contains result code for sending to mobile application
+ * @param info contains info for mobile app.
+ * @return result for sending to mobile application.
+ */
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& info);
+
bool awaiting_ui_alert_response_;
bool awaiting_tts_speak_response_;
bool awaiting_tts_stop_speaking_response_;
bool is_alert_succeeded_;
bool is_ui_alert_sent_;
- mobile_apis::Result::eType alert_result_;
+ hmi_apis::Common_Result::eType alert_result_;
smart_objects::SmartObject alert_response_params_;
- mobile_apis::Result::eType tts_speak_result_;
+ hmi_apis::Common_Result::eType tts_speak_result_;
+ std::string ui_response_info_;
+ std::string tts_response_info_;
DISALLOW_COPY_AND_ASSIGN(AlertRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h
index c81ed0b5d3..f783af12b3 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h
@@ -106,15 +106,6 @@ class ChangeRegistrationRequest : public CommandRequestImpl {
*/
bool IsPendingResponseExist();
- /*
- * @brief Checks result codes
- *
- * @return true if all of result codes is success
- */
- bool AllHmiResponsesSuccess(const hmi_apis::Common_Result::eType ui,
- const hmi_apis::Common_Result::eType vr,
- const hmi_apis::Common_Result::eType tts);
-
/**
* @brief Checks change_registration params(ttsName, appname,
* ngnMediaScreenAppName, vrSynonyms) on invalid characters.
@@ -141,11 +132,20 @@ class ChangeRegistrationRequest : public CommandRequestImpl {
bool IsNicknameAllowed(const custom_str::CustomString& app_name) const;
/**
- * @brief Predicate for using with CheckCoincidence method to compare with VR
- * synonym SO
- *
- * @return TRUE if there is coincidence of VR, otherwise FALSE
+ * @brief Prepare result code and result for sending to mobile application
+ * @param result_code contains result code for sending to mobile application
+ * @param response_info contains info for sending to mobile application
+ * @return result for sending to mobile application.
*/
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& ResponseInfo);
+
+ /**
+ * @brief Predicate for using with CheckCoincidence method to compare with VR
+ * synonym SO
+ *
+ * @return TRUE if there is coincidence of VR, otherwise FALSE
+ */
struct CoincidencePredicateVR {
CoincidencePredicateVR(const custom_str::CustomString& newItem)
: newItem_(newItem){};
@@ -163,6 +163,9 @@ class ChangeRegistrationRequest : public CommandRequestImpl {
hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType vr_result_;
hmi_apis::Common_Result::eType tts_result_;
+ std::string ui_response_info_;
+ std::string vr_response_info_;
+ std::string tts_response_info_;
DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
index 2a6e55f312..fffbab567f 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
@@ -71,7 +71,6 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
**/
virtual void Run();
- private:
/**
* @brief Interface method that is called whenever new event received
*
@@ -88,6 +87,8 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
* @brief DeleteChoices allows to walk through the sent commands collection
* in order to sent appropriate DeleteCommand request.
*/
+
+ private:
void DeleteChoices();
/**
@@ -231,6 +232,30 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
*/
bool IsWhiteSpaceExist(const smart_objects::SmartObject& choice_set);
+ /**
+ * @brief ProcessHmiError process received error from HMI.
+ * This function id not thread safe. It should be protected with
+ * vr_commands_lock_
+ * @param vr_result ERROR type
+ */
+ void ProcessHmiError(const hmi_apis::Common_Result::eType vr_result);
+
+ /**
+ * @brief ProcessSuccesfulHMIResponse process succesful response from HMI\
+ * This function id not thread safe. It should be protected with
+ * vr_commands_lock_
+ * @param corr_id correlation id of received response
+ * @return true if resuest with corr_itd was sent on HMI, false otherwise
+ */
+ bool ProcessSuccesfulHMIResponse(const uint32_t corr_id);
+
+ /**
+ * @brief CountReceivedVRResponses counts received HMI responses. Updated
+ * request timeout if not all responses received
+ * Send response to mobile if all responses received.
+ */
+ void CountReceivedVRResponses();
+
DISALLOW_COPY_AND_ASSIGN(CreateInteractionChoiceSetRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h b/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
index 6a19014c96..4e392f3857 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
@@ -33,6 +33,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_DELETE_COMMAND_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_DELETE_COMMAND_REQUEST_H_
+#include <string>
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
@@ -81,6 +82,15 @@ class DeleteCommandRequest : public CommandRequestImpl {
*/
bool IsPendingResponseExist();
+ /*
+ * @brief Prepare result code and result for sending to mobile application
+ * @param result_code contains result code for sending to mobile application
+ * @param info contains info for mobile app.
+ * @return result for sending to mobile application.
+ */
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& info);
+
bool is_ui_send_;
bool is_vr_send_;
@@ -89,6 +99,8 @@ class DeleteCommandRequest : public CommandRequestImpl {
hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType vr_result_;
+ std::string ui_info_;
+ std::string vr_info_;
};
} // namespace commands
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
index 7c48de5d8e..20342ba5c1 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
@@ -65,6 +65,13 @@ class DeleteSubMenuRequest : public CommandRequestImpl {
**/
virtual void Run();
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void on_event(const event_engine::Event& event);
+
private:
/*
* @brief Deletes VR commands from SDL for corresponding submenu ID
@@ -84,13 +91,6 @@ class DeleteSubMenuRequest : public CommandRequestImpl {
*/
void DeleteSubMenuUICommands(ApplicationSharedPtr const app);
- /**
- * @brief Interface method that is called whenever new event received
- *
- * @param event The received event
- */
- void on_event(const event_engine::Event& event);
-
DISALLOW_COPY_AND_ASSIGN(DeleteSubMenuRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h
index b69cb969e1..aff7430c6a 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/perform_audio_pass_thru_request.h
@@ -85,23 +85,31 @@ class PerformAudioPassThruRequest : public CommandRequestImpl {
void on_event(const event_engine::Event& event);
private:
- /*
+ /**
+ * @brief Prepare result code, result and info for sending to mobile
+ * application
+ * @param result_code contains result code for sending to mobile application
+ * @return result for sending to mobile application.
+ */
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& info);
+ /**
* @brief Sends TTS Speak request
*/
void SendSpeakRequest();
- /*
+ /**
* @brief Sends UI PerformAudioPassThru request
*/
void SendPerformAudioPassThruRequest();
- /*
+ /**
* @brief Sends UI RecordStart notification after TTS Speak response received.
* Indicates that capturing mic data should be started
*/
void SendRecordStartNotification();
- /*
+ /**
* @brief Starts microphone recording
*/
void StartMicrophoneRecording();
@@ -115,21 +123,25 @@ class PerformAudioPassThruRequest : public CommandRequestImpl {
bool IsWhiteSpaceExist();
/**
- * @brief Waiting for TTS.Speak response, after default timeout send
- * GENERIC_ERROR response
- * @return if receive TTS.Speak return TRUE, FALSE otherwise
- */
- bool WaitTTSSpeak();
-
- /**
* @brief If is_active_tts_speak_ TRUE - set up to FALSE and send request
* TTS_StopSpeaking to HMI
*/
void FinishTTSSpeak();
- // flag display state of speak during perform audio pass thru
- bool is_active_tts_speak_;
- mobile_apis::Result::eType result_tts_speak_;
+ /*
+ * @brief Tells if there are sent requests without responses
+ */
+ bool IsWaitingHMIResponse();
+
+ /* flag display state of speak and ui perform audio
+ during perform audio pass thru*/
+ bool awaiting_tts_speak_response_;
+ bool awaiting_ui_response_;
+
+ hmi_apis::Common_Result::eType result_tts_speak_;
+ hmi_apis::Common_Result::eType result_ui_;
+ std::string ui_info_;
+ std::string tts_info_;
DISALLOW_COPY_AND_ASSIGN(PerformAudioPassThruRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h
index f64b2ab334..5ba85b0cb7 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h
@@ -33,6 +33,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_PERFORM_INTERACTION_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_PERFORM_INTERACTION_REQUEST_H_
+#include <string>
#include "application_manager/commands/command_request_impl.h"
#include "application_manager/application.h"
@@ -79,7 +80,6 @@ class PerformInteractionRequest : public CommandRequestImpl {
*/
virtual void on_event(const event_engine::Event& event);
- private:
/*
* @brief Function is called by RequestController when request execution time
* has exceed it's limit
@@ -87,25 +87,23 @@ class PerformInteractionRequest : public CommandRequestImpl {
*/
virtual void onTimeOut();
- /*
+ private:
+ /**
* @brief Function will be called when VR_OnCommand event
* comes
- *
* @param message which should send to mobile side
- *
+ * @return true if send response to mobile application otherwise
+ * return false.
*/
- void ProcessVRResponse(const smart_objects::SmartObject& message,
+ bool ProcessVRResponse(const smart_objects::SmartObject& message,
smart_objects::SmartObject& msg_params);
- /*
+ /**
* @brief Sends PerformInteraction response to mobile side
- *
* @param message which should send to mobile side
- *
*/
- void ProcessPerformInteractionResponse(
- const smart_objects::SmartObject& message,
- smart_objects::SmartObject& msg_params);
+ void ProcessUIResponse(const smart_objects::SmartObject& message,
+ smart_objects::SmartObject& msg_params);
/*
* @brief Sends UI PerformInteraction request to HMI
@@ -218,26 +216,20 @@ class PerformInteractionRequest : public CommandRequestImpl {
const bool HasHMIResponsesToWait() const;
/**
- * @brief Check VR response result code, in case GENERIC_ERROR, REJECTED,
- * send resultCode FALSE, in case WARNINGS send resultCode TRUE
- */
- void CheckResponseResultCode();
-
- /**
* @brief Check UI & VR result codes, send response to mobile
* @param msg_param Message params to send
*/
void SendBothModeResponse(const smart_objects::SmartObject& msg_param);
mobile_apis::InteractionMode::eType interaction_mode_;
- bool ui_response_recived_;
- bool vr_response_recived_;
- bool ui_result_;
- bool vr_result_;
+ bool ui_response_received_;
+ bool vr_response_received_;
bool app_pi_was_active_before_;
static uint32_t pi_requests_count_;
- mobile_apis::Result::eType vr_resultCode_;
- mobile_apis::Result::eType ui_resultCode_;
+ hmi_apis::Common_Result::eType vr_result_code_;
+ hmi_apis::Common_Result::eType ui_result_code_;
+ std::string ui_info_;
+ std::string vr_info_;
DISALLOW_COPY_AND_ASSIGN(PerformInteractionRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h
index dc7f9fb755..cc3d5b685c 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h
@@ -90,6 +90,23 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl {
const uint32_t connection_key, ApplicationSharedPtr app);
/**
+ * @brief SendChangeRegistration send ChangeRegistration on HMI
+ * @param function_id interface specific ChangeRegistration
+ * @param language language of registration
+ * @param app_id application to change registration
+ */
+ void SendChangeRegistration(const hmi_apis::FunctionID::eType function_id,
+ const int32_t language,
+ const uint32_t app_id);
+
+ /**
+ * @brief SendChangeRegistrationOnHMI send required SendChangeRegistration
+ * HMI
+ * @param app application to change registration
+ */
+ void SendChangeRegistrationOnHMI(ApplicationConstSharedPtr app);
+
+ /**
* @brief Sends OnAppRegistered notification to HMI
*
*@param application_impl application with changed HMI status
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h b/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
index aa26a70393..0300245af8 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
@@ -32,7 +32,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_
-
+#include <string>
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
#include "application_manager/application.h"
@@ -125,6 +125,15 @@ class SetGlobalPropertiesRequest : public CommandRequestImpl {
*/
bool IsWhiteSpaceExist();
+ /*
+ * @brief Prepare result code and result for sending to mobile application
+ * @param result_code contains result code for sending to mobile application
+ * @param info contains info for sending to mobile applicaion
+ * @return result for sending to mobile application.
+ */
+ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code,
+ std::string& info);
+
bool is_ui_send_;
bool is_tts_send_;
@@ -133,6 +142,8 @@ class SetGlobalPropertiesRequest : public CommandRequestImpl {
hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType tts_result_;
+ std::string ui_response_info_;
+ std::string tts_response_info_;
DISALLOW_COPY_AND_ASSIGN(SetGlobalPropertiesRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
index 6b2c2bb616..fb21823b3a 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
@@ -113,6 +113,26 @@ class SubscribeVehicleDataRequest : public CommandRequestImpl {
const smart_objects::SmartObject& msg_params) const;
/**
+ * @brief Checks if current application and other applications
+ * were subscribed to VI, prepare data that need to send to mobile app
+ * or HMI.
+ * @param app contains application
+ * @param out_info contains resulting info for sending to mobile app
+ * @param out_result_code contains result code for sending to mobile app
+ * @param out_response_params contains parameters that SDL sends to
+ * mobile application
+ * @param out_request_params contains parameters that SDL sends to
+ * HMI
+ * @param result contains result that SDL sends to mobile app.
+ */
+ void CheckVISubscribtions(ApplicationSharedPtr app,
+ std::string& out_info,
+ mobile_apis::Result::eType& out_result_code,
+ smart_objects::SmartObject& out_response_params,
+ smart_objects::SmartObject& out_request_params,
+ bool& out_result);
+
+ /**
* @brief VI parameters which had been already subscribed by another apps
* befor particular app subscribed for these parameters
*/
diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
index f94c8125c8..ec7bbcebbd 100644
--- a/src/components/application_manager/include/application_manager/hmi_capabilities.h
+++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
@@ -30,9 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_IMPL_H_
+#include "application_manager/hmi_capabilities.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
#include "json/json.h"
@@ -42,38 +43,32 @@
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
class SmartObject;
-}
-}
+} // namespace NsSmartObjects
+} // namespace NsSmartDeviceLink
+
namespace resumption {
class LastState;
-}
+} // namespace resumption
namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
namespace application_manager {
class ApplicationManager;
-class HMICapabilities {
+class HMICapabilitiesImpl : public HMICapabilities {
public:
/*
* @ Class constructor
*
* @param app_mngr Application manager pointer
*/
- explicit HMICapabilities(ApplicationManager& app_mngr);
+ explicit HMICapabilitiesImpl(ApplicationManager& app_mngr);
/*
* @brief Class destructor
*
*/
- virtual ~HMICapabilities();
-
- /**
- * @brief Checks if all HMI capabilities received
- *
- * @return TRUE if all information received, otherwise FALSE
- */
- bool is_hmi_capabilities_initialized() const;
+ virtual ~HMICapabilitiesImpl();
/*
* @brief Checks is image type(Static/Dynamic) requested by
@@ -81,27 +76,42 @@ class HMICapabilities {
* @param image_type recieved type of image from Enum.
* @return Bool true if supported
*/
- bool VerifyImageType(int32_t image_type) const;
+ bool VerifyImageType(const int32_t image_type) const OVERRIDE;
/**
* @brief Checks if all HMI capabilities received
*
* @return TRUE if all information received, otherwise FALSE
*/
- inline bool is_vr_cooperating() const;
- void set_is_vr_cooperating(bool value);
+ bool is_vr_cooperating() const OVERRIDE;
+ void set_is_vr_cooperating(const bool value) OVERRIDE;
+
+ bool is_tts_cooperating() const OVERRIDE;
+ void set_is_tts_cooperating(const bool value) OVERRIDE;
+
+ bool is_ui_cooperating() const OVERRIDE;
+ void set_is_ui_cooperating(const bool value) OVERRIDE;
- inline bool is_tts_cooperating() const;
- void set_is_tts_cooperating(bool value);
+ bool is_navi_cooperating() const OVERRIDE;
+ void set_is_navi_cooperating(const bool value) OVERRIDE;
- inline bool is_ui_cooperating() const;
- void set_is_ui_cooperating(bool value);
+ bool is_ivi_cooperating() const OVERRIDE;
+ void set_is_ivi_cooperating(const bool value) OVERRIDE;
- inline bool is_navi_cooperating() const;
- void set_is_navi_cooperating(bool value);
+ /*
+ * @brief Interface used to store information about software version of the
+ *target
+ *
+ * @param ccpu_version Received system/hmi software version
+ */
+ void set_ccpu_version(const std::string& ccpu_version) OVERRIDE;
- inline bool is_ivi_cooperating() const;
- void set_is_ivi_cooperating(bool value);
+ /*
+ * @brief Returns software version of the target
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ const std::string& ccpu_version() const OVERRIDE;
/*
* @brief Retrieves if mixing audio is supported by HMI
@@ -109,35 +119,36 @@ class HMICapabilities {
*
* @return Current state of the mixing audio flag
*/
- inline bool attenuated_supported() const;
+ bool attenuated_supported() const OVERRIDE;
/*
* @brief Sets state for mixing audio
*
* @param state New state to be set
*/
- void set_attenuated_supported(bool state);
+ void set_attenuated_supported(const bool state) OVERRIDE;
/*
* @brief Retrieves currently active UI language
*
* @return Currently active UI language
*/
- const hmi_apis::Common_Language::eType active_ui_language() const;
+ const hmi_apis::Common_Language::eType active_ui_language() const OVERRIDE;
/*
* @brief Sets currently active UI language
*
* @param language Currently active UI language
*/
- void set_active_ui_language(const hmi_apis::Common_Language::eType& language);
+ void set_active_ui_language(
+ const hmi_apis::Common_Language::eType language) OVERRIDE;
/*
* @brief Retrieves UI supported languages
*
* @return Currently supported UI languages
*/
- inline const smart_objects::SmartObject* ui_supported_languages() const;
+ const smart_objects::SmartObject* ui_supported_languages() const OVERRIDE;
/*
* @brief Sets supported UI languages
@@ -145,28 +156,29 @@ class HMICapabilities {
* @param supported_languages Supported UI languages
*/
void set_ui_supported_languages(
- const smart_objects::SmartObject& supported_languages);
+ const smart_objects::SmartObject& supported_languages) OVERRIDE;
/*
* @brief Retrieves currently active VR language
*
* @return Currently active VR language
*/
- const hmi_apis::Common_Language::eType active_vr_language() const;
+ const hmi_apis::Common_Language::eType active_vr_language() const OVERRIDE;
/*
* @brief Sets currently active VR language
*
* @param language Currently active VR language
*/
- void set_active_vr_language(const hmi_apis::Common_Language::eType& language);
+ void set_active_vr_language(
+ const hmi_apis::Common_Language::eType language) OVERRIDE;
/*
* @brief Retrieves VR supported languages
*
* @return Currently supported VR languages
*/
- inline const smart_objects::SmartObject* vr_supported_languages() const;
+ const smart_objects::SmartObject* vr_supported_languages() const OVERRIDE;
/*
* @brief Sets supported VR languages
@@ -174,14 +186,14 @@ class HMICapabilities {
* @param supported_languages Supported VR languages
*/
void set_vr_supported_languages(
- const smart_objects::SmartObject& supported_languages);
+ const smart_objects::SmartObject& supported_languages) OVERRIDE;
/*
* @brief Retrieves currently active TTS language
*
* @return Currently active TTS language
*/
- const hmi_apis::Common_Language::eType active_tts_language() const;
+ const hmi_apis::Common_Language::eType active_tts_language() const OVERRIDE;
/*
* @brief Sets currently active TTS language
@@ -189,14 +201,14 @@ class HMICapabilities {
* @param language Currently active TTS language
*/
void set_active_tts_language(
- const hmi_apis::Common_Language::eType& language);
+ const hmi_apis::Common_Language::eType language) OVERRIDE;
/*
* @brief Retrieves TTS supported languages
*
* @return Currently supported TTS languages
*/
- inline const smart_objects::SmartObject* tts_supported_languages() const;
+ const smart_objects::SmartObject* tts_supported_languages() const OVERRIDE;
/*
* @brief Sets supported TTS languages
@@ -204,14 +216,14 @@ class HMICapabilities {
* @param supported_languages Supported TTS languages
*/
void set_tts_supported_languages(
- const smart_objects::SmartObject& supported_languages);
+ const smart_objects::SmartObject& supported_languages) OVERRIDE;
/*
* @brief Retrieves information about the display capabilities
*
* @return Currently supported display capabilities
*/
- inline const smart_objects::SmartObject* display_capabilities() const;
+ const smart_objects::SmartObject* display_capabilities() const OVERRIDE;
/*
* @brief Sets supported display capabilities
@@ -219,14 +231,14 @@ class HMICapabilities {
* @param display_capabilities supported display capabilities
*/
void set_display_capabilities(
- const smart_objects::SmartObject& display_capabilities);
+ const smart_objects::SmartObject& display_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the HMI zone capabilities
*
* @return Currently supported HMI zone capabilities
*/
- inline const smart_objects::SmartObject* hmi_zone_capabilities() const;
+ const smart_objects::SmartObject* hmi_zone_capabilities() const OVERRIDE;
/*
* @brief Sets supported HMI zone capabilities
@@ -234,14 +246,14 @@ class HMICapabilities {
* @param hmi_zone_capabilities supported HMI zone capabilities
*/
void set_hmi_zone_capabilities(
- const smart_objects::SmartObject& hmi_zone_capabilities);
+ const smart_objects::SmartObject& hmi_zone_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the SoftButton's capabilities
*
* @return Currently supported SoftButton's capabilities
*/
- inline const smart_objects::SmartObject* soft_button_capabilities() const;
+ const smart_objects::SmartObject* soft_button_capabilities() const OVERRIDE;
/*
* @brief Sets supported SoftButton's capabilities
@@ -249,14 +261,14 @@ class HMICapabilities {
* @param soft_button_capabilities supported SoftButton's capabilities
*/
void set_soft_button_capabilities(
- const smart_objects::SmartObject& soft_button_capabilities);
+ const smart_objects::SmartObject& soft_button_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the Button's capabilities
*
* @return Currently supported Button's capabilities
*/
- inline const smart_objects::SmartObject* button_capabilities() const;
+ const smart_objects::SmartObject* button_capabilities() const OVERRIDE;
/*
* @brief Sets supported Button's capabilities
@@ -264,7 +276,7 @@ class HMICapabilities {
* @param soft_button_capabilities supported Button's capabilities
*/
void set_button_capabilities(
- const smart_objects::SmartObject& button_capabilities);
+ const smart_objects::SmartObject& button_capabilities) OVERRIDE;
/*
* @brief Sets supported speech capabilities
@@ -272,28 +284,29 @@ class HMICapabilities {
* @param speech_capabilities supported speech capabilities
*/
void set_speech_capabilities(
- const smart_objects::SmartObject& speech_capabilities);
+ const smart_objects::SmartObject& speech_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the speech capabilities
*
* @return Currently supported speech capabilities
*/
- inline const smart_objects::SmartObject* speech_capabilities() const;
+ const smart_objects::SmartObject* speech_capabilities() const OVERRIDE;
/*
* @brief Sets supported VR capabilities
*
* @param vr_capabilities supported VR capabilities
*/
- void set_vr_capabilities(const smart_objects::SmartObject& vr_capabilities);
+ void set_vr_capabilities(
+ const smart_objects::SmartObject& vr_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the VR capabilities
*
* @return Currently supported VR capabilities
*/
- inline const smart_objects::SmartObject* vr_capabilities() const;
+ const smart_objects::SmartObject* vr_capabilities() const OVERRIDE;
/*
* @brief Sets supported audio_pass_thru capabilities
@@ -301,36 +314,37 @@ class HMICapabilities {
* @param vr_capabilities supported audio_pass_thru capabilities
*/
void set_audio_pass_thru_capabilities(
- const smart_objects::SmartObject& audio_pass_thru_capabilities);
+ const smart_objects::SmartObject& audio_pass_thru_capabilities) OVERRIDE;
/*
- * @brief Sets supported pcm_stream capabilities
+ * @brief Retrieves information about the audio_pass_thru capabilities
*
- * @param supported pcm stream capabilities
+ * @return Currently supported audio_pass_thru capabilities
*/
- void set_pcm_stream_capabilities(
- const smart_objects::SmartObject& pcm_stream_capabilities);
+ const smart_objects::SmartObject* audio_pass_thru_capabilities()
+ const OVERRIDE;
/*
- * @brief Retrieves information about the audio_pass_thru capabilities
+ * @brief Sets supported pcm_stream capabilities
*
- * @return Currently supported audio_pass_thru capabilities
+ * @param supported pcm_stream capabilities
*/
- inline const smart_objects::SmartObject* audio_pass_thru_capabilities() const;
+ void set_pcm_stream_capabilities(
+ const smart_objects::SmartObject& pcm_stream_capabilities) OVERRIDE;
/*
* @brief Retrieves information about the pcm_stream capabilities
*
* @return Currently supported pcm_streaming capabilities
*/
- inline const smart_objects::SmartObject* pcm_stream_capabilities() const;
+ const smart_objects::SmartObject* pcm_stream_capabilities() const OVERRIDE;
/*
* @brief Retrieves information about the preset bank capabilities
*
* @return Currently supported preset bank capabilities
*/
- inline const smart_objects::SmartObject* preset_bank_capabilities() const;
+ const smart_objects::SmartObject* preset_bank_capabilities() const OVERRIDE;
/*
* @brief Sets supported preset bank capabilities
@@ -338,28 +352,29 @@ class HMICapabilities {
* @param soft_button_capabilities supported preset bank capabilities
*/
void set_preset_bank_capabilities(
- const smart_objects::SmartObject& preset_bank_capabilities);
+ const smart_objects::SmartObject& preset_bank_capabilities) OVERRIDE;
/*
* @brief Sets vehicle information(make, model, modelYear)
*
* @param vehicle_type Cuurent vehicle information
*/
- void set_vehicle_type(const smart_objects::SmartObject& vehicle_type);
+ void set_vehicle_type(
+ const smart_objects::SmartObject& vehicle_type) OVERRIDE;
/*
* @brief Retrieves vehicle information(make, model, modelYear)
*
* @param vehicle_type Cuurent vehicle information
*/
- inline const smart_objects::SmartObject* vehicle_type() const;
+ const smart_objects::SmartObject* vehicle_type() const OVERRIDE;
/*
* @brief Retrieves information about the prerecorded speech
*
* @return Currently supported prerecorded speech
*/
- inline const smart_objects::SmartObject* prerecorded_speech() const;
+ const smart_objects::SmartObject* prerecorded_speech() const OVERRIDE;
/*
* @brief Sets supported prerecorded speech
@@ -367,7 +382,7 @@ class HMICapabilities {
* @param prerecorded_speech supported prerecorded speech
*/
void set_prerecorded_speech(
- const smart_objects::SmartObject& prerecorded_speech);
+ const smart_objects::SmartObject& prerecorded_speech) OVERRIDE;
/*
* @brief Interface used to store information if navigation
@@ -375,14 +390,14 @@ class HMICapabilities {
*
* @param supported Indicates if navigation supported by the system
*/
- void set_navigation_supported(bool supported);
+ void set_navigation_supported(const bool supported) OVERRIDE;
/*
* @brief Retrieves information if navi supported by the system
*
* @return TRUE if it supported, otherwise FALSE
*/
- inline bool navigation_supported() const;
+ bool navigation_supported() const OVERRIDE;
/*
* @brief Interface used to store information if phone call
@@ -390,40 +405,30 @@ class HMICapabilities {
*
* @param supported Indicates if navigation supported by the sustem
*/
- void set_phone_call_supported(bool supported);
+ void set_phone_call_supported(const bool supported) OVERRIDE;
/*
* @brief Retrieves information if phone call supported by the system
*
* @return TRUE if it supported, otherwise FALSE
*/
- inline bool phone_call_supported() const;
+ bool phone_call_supported() const OVERRIDE;
- /*
- * @brief Interface used to store information about software version of the
- *target
- *
- * @param ccpu_version Received system/hmi software version
- */
- void set_ccpu_version(const std::string& ccpu_version);
+ void Init(resumption::LastState* last_state) OVERRIDE;
/*
- * @brief Returns software version of the target
- *
- * @return TRUE if it supported, otherwise FALSE
- */
- inline const std::string& ccpu_version() const;
-
- void Init(resumption::LastState* last_state);
-
- /**
* @brief return component which follows for correctness of
* languages
* @return HMI language handler
*/
- HMILanguageHandler& get_hmi_language_handler() {
- return hmi_language_handler_;
- }
+ HMILanguageHandler& get_hmi_language_handler() OVERRIDE;
+
+ /**
+ * @brief Trigger waiting for response
+ * @param request Request object
+ */
+ void set_handle_response_for(
+ const smart_objects::SmartObject& request) OVERRIDE;
protected:
/*
@@ -445,7 +450,7 @@ class HMICapabilities {
* member does not exist.
*/
bool check_existing_json_member(const Json::Value& json_member,
- const char* name_of_member);
+ const char* name_of_member) const OVERRIDE;
/*
* @brief function converts json object "languages" to smart object
@@ -454,8 +459,9 @@ class HMICapabilities {
* @param languages - the converted object
*
*/
- void convert_json_languages_to_obj(Json::Value& json_languages,
- smart_objects::SmartObject& languages);
+ void convert_json_languages_to_obj(
+ const Json::Value& json_languages,
+ smart_objects::SmartObject& languages) const OVERRIDE;
private:
bool is_vr_cooperating_;
@@ -464,13 +470,6 @@ class HMICapabilities {
bool is_navi_cooperating_;
bool is_ivi_cooperating_;
- // to check if IsReady response for corresponding interface received
- bool is_vr_ready_response_recieved_;
- bool is_tts_ready_response_recieved_;
- bool is_ui_ready_response_recieved_;
- bool is_navi_ready_response_recieved_;
- bool is_ivi_ready_response_recieved_;
-
bool attenuated_supported_;
hmi_apis::Common_Language::eType ui_language_;
hmi_apis::Common_Language::eType vr_language_;
@@ -489,117 +488,16 @@ class HMICapabilities {
smart_objects::SmartObject* audio_pass_thru_capabilities_;
smart_objects::SmartObject* pcm_stream_capabilities_;
smart_objects::SmartObject* prerecorded_speech_;
- std::string ccpu_version_;
bool is_navigation_supported_;
bool is_phone_call_supported_;
+ std::string ccpu_version_;
ApplicationManager& app_mngr_;
HMILanguageHandler hmi_language_handler_;
- DISALLOW_COPY_AND_ASSIGN(HMICapabilities);
+ DISALLOW_COPY_AND_ASSIGN(HMICapabilitiesImpl);
};
-bool HMICapabilities::is_ui_cooperating() const {
- return is_ui_cooperating_;
-}
-
-bool HMICapabilities::is_vr_cooperating() const {
- return is_vr_cooperating_;
-}
-
-bool HMICapabilities::is_tts_cooperating() const {
- return is_tts_cooperating_;
-}
-
-bool HMICapabilities::is_navi_cooperating() const {
- return is_navi_cooperating_;
-}
-
-bool HMICapabilities::is_ivi_cooperating() const {
- return is_ivi_cooperating_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::ui_supported_languages()
- const {
- return ui_supported_languages_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::vr_supported_languages()
- const {
- return vr_supported_languages_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::tts_supported_languages()
- const {
- return tts_supported_languages_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::display_capabilities()
- const {
- return display_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::hmi_zone_capabilities()
- const {
- return hmi_zone_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::soft_button_capabilities()
- const {
- return soft_buttons_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::button_capabilities() const {
- return button_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::speech_capabilities() const {
- return speech_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::vr_capabilities() const {
- return vr_capabilities_;
-}
-
-const smart_objects::SmartObject*
-HMICapabilities::audio_pass_thru_capabilities() const {
- return audio_pass_thru_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::pcm_stream_capabilities()
- const {
- return pcm_stream_capabilities_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::preset_bank_capabilities()
- const {
- return preset_bank_capabilities_;
-}
-
-bool HMICapabilities::attenuated_supported() const {
- return attenuated_supported_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::vehicle_type() const {
- return vehicle_type_;
-}
-
-const smart_objects::SmartObject* HMICapabilities::prerecorded_speech() const {
- return prerecorded_speech_;
-}
-
-const std::string& HMICapabilities::ccpu_version() const {
- return ccpu_version_;
-}
-
-bool HMICapabilities::navigation_supported() const {
- return is_navigation_supported_;
-}
-
-bool HMICapabilities::phone_call_supported() const {
- return is_phone_call_supported_;
-}
-
} // namespace application_manager
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces.h b/src/components/application_manager/include/application_manager/hmi_interfaces.h
new file mode 100644
index 0000000000..df1e2a9067
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/hmi_interfaces.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+/**
+ * @brief The class contains information about state HMI's interfaces
+ * (Buttons, BasicCommunication, VR, TTS, UI, Navigation,VehicleInfo,
+ * SDL) and provides this information through public interfaces.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_H_
+
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+/**
+ * @brief The class contains information about state HMI's interfaces
+ * (Buttons, BasicCommunication, VR, TTS, UI, Navigation,VehicleInfo,
+ * SDL) and provides this information through public interfaces.
+ */
+class HmiInterfaces {
+ public:
+ enum InterfaceID {
+ HMI_INTERFACE_INVALID_ENUM,
+ HMI_INTERFACE_Buttons,
+ HMI_INTERFACE_BasicCommunication,
+ HMI_INTERFACE_VR,
+ HMI_INTERFACE_TTS,
+ HMI_INTERFACE_UI,
+ HMI_INTERFACE_Navigation,
+ HMI_INTERFACE_VehicleInfo,
+ HMI_INTERFACE_SDL
+ };
+
+ /**
+ * @brief The InterfaceState enum handle possible states of HMI interfaces
+ * STATE_NOT_RESPONSE - HMI didn't not responsed IsReady on Inerface
+ * STATE_AVAILABLE - Hmi responsed IsReady(avaliable = true)
+ * STATE_NOT_AVAILABLE - Hmi responsed IsReady(avaliable = false)
+ */
+ enum InterfaceState {
+ STATE_NOT_RESPONSE,
+ STATE_AVAILABLE,
+ STATE_NOT_AVAILABLE
+ };
+
+ /**
+ * @brief GetInterfaceState return currecnt state of hmi interface
+ * @param interface to get state
+ * @return state of interface
+ */
+ virtual InterfaceState GetInterfaceState(InterfaceID interface) const = 0;
+
+ /**
+ * @brief SetInterfaceState set interface to some state
+ * @param interface interface to set state
+ * @param state to setup
+ */
+ virtual InterfaceID GetInterfaceFromFunction(
+ hmi_apis::FunctionID::eType function) const = 0;
+
+ /**
+ * @brief GetInterfaceFromFunction extract interface name fron function id
+ * @param function to extract interface name
+ * @return extracted interface name
+ */
+ virtual void SetInterfaceState(InterfaceID interface,
+ InterfaceState state) = 0;
+ virtual ~HmiInterfaces() {}
+};
+} // namespace application_manager
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_H_
diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h
new file mode 100644
index 0000000000..2b2d1e1361
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_IMPL_H_
+#include <map>
+#include "application_manager/hmi_interfaces.h"
+#include "utils/macro.h"
+#include "utils/lock.h"
+/**
+ * @brief The HmiInterfacesImpl class handles
+ * hmi interfaces states
+ */
+namespace application_manager {
+
+class HmiInterfacesImpl : public HmiInterfaces {
+ public:
+ HmiInterfacesImpl();
+
+ /**
+ * @brief GetInterfaceState return currecnt state of hmi interface
+ * @param interface to get state
+ * @return state of interface
+ */
+ InterfaceState GetInterfaceState(InterfaceID interface) const OVERRIDE;
+
+ /**
+ * @brief SetInterfaceState set interface to some state
+ * @param interface interface to set state
+ * @param state to setup
+ */
+ void SetInterfaceState(InterfaceID interface, InterfaceState state) OVERRIDE;
+
+ /**
+ * @brief GetInterfaceFromFunction extract interface name fron function id
+ * @param function to extract interface name
+ * @return extracted interface name
+ */
+ InterfaceID GetInterfaceFromFunction(
+ hmi_apis::FunctionID::eType function) const OVERRIDE;
+
+ private:
+ typedef std::map<InterfaceID, InterfaceState> InterfaceStatesMap;
+ InterfaceStatesMap interfaces_states_;
+ mutable sync_primitives::Lock interfaces_states_lock_;
+};
+} // namespace application_manager
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index ab89883ad2..a423ea7507 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -269,8 +269,6 @@ class MessageHelper {
*/
static void SendUIChangeRegistrationRequestToHMI(
ApplicationConstSharedPtr app, ApplicationManager& app_mngr);
- static void SendChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app,
- ApplicationManager& app_mngr);
static void SendAddVRCommandToHMI(
uint32_t cmd_id,
const smart_objects::SmartObject& vr_commands,
diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h
index 6de5253ac0..479ebb217e 100644
--- a/src/components/application_manager/include/application_manager/request_controller.h
+++ b/src/components/application_manager/include/application_manager/request_controller.h
@@ -139,11 +139,13 @@ class RequestController {
*
* @param correlation_id Active request correlation ID,
* @param connection_key Active request connection key (0 for HMI requersts)
+ * @param function_id Active request function id
* @param force_terminate if true, request controller will terminate
* even if not allowed by request
*/
- void terminateRequest(const uint32_t& correlation_id,
- const uint32_t& connection_key,
+ void TerminateRequest(const uint32_t correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id,
bool force_terminate = false);
/**
@@ -152,8 +154,9 @@ class RequestController {
* @param mobile_correlation_id Active mobile request correlation ID
*
*/
- void OnMobileResponse(const uint32_t& mobile_correlation_id,
- const uint32_t& connection_key);
+ void OnMobileResponse(const uint32_t mobile_correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id);
/**
* @brief Removes request from queue
@@ -161,7 +164,7 @@ class RequestController {
* @param mobile_correlation_id Active mobile request correlation ID
*
*/
- void OnHMIResponse(const uint32_t& correlation_id);
+ void OnHMIResponse(const uint32_t correlation_id, const int32_t function_id);
/**
* @ Add notification to collection
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
index 853f91ff23..26b1739a38 100644
--- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,28 +30,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_RESUME_CTRL_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_RESUME_CTRL_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_
#include <stdint.h>
-#include <vector>
-#include <map>
-#include <set>
-#include <list>
-
-#include "interfaces/HMI_API.h"
-#include "interfaces/HMI_API_schema.h"
-#include "interfaces/MOBILE_API_schema.h"
-#include "application_manager/event_engine/event_observer.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/application.h"
+#include "utils/shared_ptr.h"
#include "application_manager/resumption/resumption_data.h"
-#include "utils/timer.h"
namespace application_manager {
class ApplicationManager;
class Application;
+typedef utils::SharedPtr<Application> ApplicationSharedPtr;
+typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr;
}
+namespace app_mngr = application_manager;
namespace resumption {
@@ -61,50 +53,40 @@ class LastState;
* @brief Contains logic for storage/restore data of applications.
*/
-class ResumeCtrl : public application_manager::event_engine::EventObserver {
+class ResumeCtrl {
public:
/**
- * @brief allows to create ResumeCtrl object
- */
- ResumeCtrl(application_manager::ApplicationManager& application_manager);
-
- /**
* @brief allows to destroy ResumeCtrl object
*/
- ~ResumeCtrl();
-
- /**
- * @brief Event, that raised if application get resumption response from HMI
- * @param event : event object, that contains smart_object with HMI message
- */
- virtual void on_event(const application_manager::event_engine::Event& event);
+ virtual ~ResumeCtrl() {}
/**
* @brief Save all applications info to the file system
*/
- void SaveAllApplications();
+ virtual void SaveAllApplications() = 0;
/**
* @brief Save application persistent info for future resuming
* @param application is application witch need to be saved
*/
- void SaveApplication(application_manager::ApplicationSharedPtr application);
+ virtual void SaveApplication(
+ application_manager::ApplicationSharedPtr application) = 0;
/**
* @brief Set application HMI Level and ausio_state as saved
* @param application is application witch HMI Level is need to restore
* @return true if success, otherwise return false
*/
- bool RestoreAppHMIState(
- application_manager::ApplicationSharedPtr application);
+ virtual bool RestoreAppHMIState(
+ application_manager::ApplicationSharedPtr application) = 0;
/**
* @brief Set application HMI Level as stored in policy
* @param application is application witch HMI Level is need to setup
* @return true if success, otherwise return false
*/
- bool SetupDefaultHMILevel(
- application_manager::ApplicationSharedPtr application);
+ virtual bool SetupDefaultHMILevel(
+ application_manager::ApplicationSharedPtr application) = 0;
/**
* @brief Setup HmiLevel for application
@@ -115,55 +97,34 @@ class ResumeCtrl : public application_manager::event_engine::EventObserver {
* @param check_policy indicate if policy data consent must be verified
* @return true if success, otherwise return false
*/
- bool SetAppHMIState(application_manager::ApplicationSharedPtr application,
- const mobile_apis::HMILevel::eType hmi_level,
- bool check_policy = true);
-
- /**
- * @brief Check if Resume controller have saved instance of application
- * @param application is application witch need to be checked
- * @return true if exist, false otherwise
- */
- bool ApplicationIsSaved(
- application_manager::ApplicationConstSharedPtr application);
+ virtual bool SetAppHMIState(
+ application_manager::ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
+ bool check_policy = true) = 0;
/**
* @brief Remove application from list of saved applications
* @param application is application which need to be removed
* @return return true, if success, otherwise return false
*/
- bool RemoveApplicationFromSaved(
- application_manager::ApplicationConstSharedPtr application);
-
- /**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
- */
- void OnSuspend();
-
+ virtual bool RemoveApplicationFromSaved(
+ app_mngr::ApplicationConstSharedPtr application) = 0;
/**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
+ * @brief Processes resumption data after receiving signal "Suspend"
*/
- void OnAwake();
+ virtual void OnSuspend() = 0;
/**
- * @brief Method starts timer "RsmCtrlPercist" when
- * SDL receives onAwakeSDL notification
+ * @brief Processes resumption data after receiving signal "Awake"
*/
- void StartSavePersistentDataTimer();
+ virtual void OnAwake() = 0;
/**
* @brief Method stops timer "RsmCtrlPercist" when SDL
* receives OnExitAllApplication notification
* with reason "SUSPEND"
*/
- void StopSavePersistentDataTimer();
-
- /**
- * @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend()
- */
- void StopRestoreHmiLevelTimer();
+ virtual void StopSavePersistentDataTimer() = 0;
/**
* @brief Start timer for resumption applications
@@ -171,41 +132,39 @@ class ResumeCtrl : public application_manager::event_engine::EventObserver {
* @param application that is need to be restored
* @return true if it was saved, otherwise return false
*/
- bool StartResumption(application_manager::ApplicationSharedPtr application,
- const std::string& hash);
-
+ virtual bool StartResumption(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash) = 0;
/**
* @brief Start timer for resumption applications
* Does not restore D1-D5 data
* @param application that is need to be restored
* @return true if it was saved, otherwise return false
*/
- bool StartResumptionOnlyHMILevel(
- application_manager::ApplicationSharedPtr application);
+ virtual bool StartResumptionOnlyHMILevel(
+ app_mngr::ApplicationSharedPtr application) = 0;
/**
* @brief Check if there are all files need for resumption
* @param application that is need to be restored
* @return true if it all files exist, otherwise return false
*/
- bool CheckPersistenceFilesForResumption(
- application_manager::ApplicationSharedPtr application);
+ virtual bool CheckPersistenceFilesForResumption(
+ app_mngr::ApplicationSharedPtr application) = 0;
/**
* @brief Check application hash
* @param application that is need to be restored
* @return true if it was saved, otherwise return false
*/
- bool CheckApplicationHash(
- application_manager::ApplicationSharedPtr application,
- const std::string& hash);
+ virtual bool CheckApplicationHash(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash) = 0;
/**
* @brief Checks if Resume controller have saved application with hmi app id
* @param hmi_app_id - hmi application id
* @return true if exist, false otherwise
*/
- bool IsHMIApplicationIdExist(uint32_t hmi_app_id);
+ virtual bool IsHMIApplicationIdExist(uint32_t hmi_app_id) = 0;
/**
* @brief Check if Resume controller have saved instance of application
@@ -213,8 +172,8 @@ class ResumeCtrl : public application_manager::event_engine::EventObserver {
* @param device_id - id of device where application is run
* @return true if exist, false otherwise
*/
- bool IsApplicationSaved(const std::string& policy_app_id,
- const std::string& device_id);
+ virtual bool IsApplicationSaved(const std::string& policy_app_id,
+ const std::string& device_id) = 0;
/**
* @brief Function is used for application resume. HMI app ID must be
@@ -224,283 +183,75 @@ class ResumeCtrl : public application_manager::event_engine::EventObserver {
* @param device_id - id of device where application is run
* @return HMI app ID
*/
- uint32_t GetHMIApplicationID(const std::string& policy_app_id,
- const std::string& device_id) const;
- /**
- * @brief SaveDataOnTimer :
- * Timer callback for persisting ResumptionData each N seconds
- * N gets from property
- */
- void SaveDataOnTimer();
+ virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id,
+ const std::string& device_id) const = 0;
/**
* @brief Updates flag for saving application data
*/
- void ApplicationsDataUpdated() {
- is_data_saved_ = false;
- }
+ virtual void ApplicationsDataUpdated() = 0;
/**
* @brief Resume HMI Level and audio streaming state if needed
* @param application - application to restore hmi level
* and audio streaming state
*/
- void StartAppHmiStateResumption(
- application_manager::ApplicationSharedPtr application);
+ virtual void StartAppHmiStateResumption(
+ application_manager::ApplicationSharedPtr application) = 0;
/**
* @brief Update launch_time_ to current
*/
- void ResetLaunchTime();
-
- /**
- * @brief Timer callback for restoring HMI Level
- *
- */
- void ApplicationResumptiOnTimer();
+ virtual void ResetLaunchTime() = 0;
/**
* @brief Removes activated application from resumption list
*
* @param application application witch need to be removed from resumption
*/
- void OnAppActivated(application_manager::ApplicationSharedPtr application);
+ virtual void OnAppActivated(app_mngr::ApplicationSharedPtr application) = 0;
/**
* @brief Removes app from resumption list
*
* app_id Application to remove
*/
- void RemoveFromResumption(uint32_t app_id);
+ virtual void RemoveFromResumption(uint32_t app_id) = 0;
/**
* @brief Initialization data for Resume controller
* @return true if initialization is success otherwise
* returns false
*/
- bool Init(LastState& last_state);
+ virtual bool Init(LastState& last_state) = 0;
/**
* @brief Notify resume controller about new application
* @param policy_app_id - mobile application id
* @param device_id - id of device where application is run
*/
- void OnAppRegistrationStart(const std::string& policy_app_id,
- const std::string& device_id);
+ virtual void OnAppRegistrationStart(const std::string& policy_app_id,
+ const std::string& device_id) = 0;
/**
* @brief Notify resume controller about delete new application
*/
- void OnAppRegistrationEnd();
-
-#ifdef BUILD_TESTS
- void set_resumption_storage(utils::SharedPtr<ResumptionData> mock_storage);
-#endif // BUILD_TESTS
- private:
- /**
- * @brief restores saved data of application
- * @param application contains application for which restores data
- * @return true if success, otherwise return false
- */
- bool RestoreApplicationData(
- application_manager::ApplicationSharedPtr application);
-
- /**
- * @brief AddFiles allows to add files for the application
- * which should be resumed
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddFiles(application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief AddSubmenues allows to add sub menues for the application
- * which should be resumed
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddSubmenues(application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief AddCommands allows to add commands for the application
- * which should be resumed
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddCommands(application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief AddChoicesets allows to add choice sets for the application
- * which should be resumed
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddChoicesets(application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief SetGlobalProperties allows to restore global properties.
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void SetGlobalProperties(
- application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief AddSubscriptions allows to restore subscriptions
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddSubscriptions(application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief AddWayPointsSubscription allows to restore subscription
- * for WayPoints
- * @param application application which will be resumed
- * @param saved_app application specific section from backup file
- */
- void AddWayPointsSubscription(
- application_manager::ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app);
-
- bool DisconnectedJustBeforeIgnOff(
- const smart_objects::SmartObject& saved_app);
-
- bool CheckAppRestrictions(
- application_manager::ApplicationConstSharedPtr application,
- const smart_objects::SmartObject& saved_app);
-
- /**
- * @brief CheckIcons allows to check application icons
- * @param application application under resumtion application
- * @param json_object
- * @return true in case icons exists, false otherwise
- */
- bool CheckIcons(application_manager::ApplicationSharedPtr application,
- smart_objects::SmartObject& obj);
-
- /**
- * @brief CheckDelayAfterIgnOn should check if SDL was started less
- * then N secconds ago. N will be readed from profile.
- * @return true if SDL started N secconds ago, otherwise return false
- */
- bool CheckDelayAfterIgnOn();
-
- typedef std::pair<uint32_t, uint32_t> ApplicationTimestamp;
-
- std::set<application_manager::ApplicationSharedPtr> retrieve_application();
+ virtual void OnAppRegistrationEnd() = 0;
/**
- * @brief This struct need to map
- * timestamp and application from correlationID
+ * @brief GetSavedHMILevels get saved apps hmi levels
+ * @return mapping of mobile application id and saved hmi_level
*/
- struct ResumingApp {
- uint32_t old_session_key; // session key is the same as app_id
- application_manager::ApplicationSharedPtr app;
- };
-
- struct TimeStampComparator {
- bool operator()(const ApplicationTimestamp& lhs,
- const ApplicationTimestamp& rhs) const {
- return lhs.second < rhs.second;
- }
- };
+ virtual int32_t GetSavedAppHmiLevel(const std::string& app_id,
+ const std::string& device_id) const = 0;
- /**
- * @brief geter for launch_time_
- * @return value of launch_time_
- */
- time_t launch_time() const;
-
- /**
- * @brief Check device MAC address
- * @param application that is need to be restored
- * @param saved_device_mac Saved device MAC address
- * @return TRUE on success, otherwise FALSE
- */
- bool IsDeviceMacAddressEqual(
- application_manager::ApplicationSharedPtr application,
- const std::string& saved_device_mac);
-
- /**
- * @brief Get the last ignition off time from LastState
- * @return the last ignition off time from LastState
- */
- time_t GetIgnOffTime();
+ virtual time_t LaunchTime() const = 0;
- /**
- * @brief Setup IgnOff time to LastState
- * @param ign_off_time - igition off time
- */
- void SetLastIgnOffTime(time_t ign_off_time);
-
- /**
- * @brief Process specified HMI request
- * @param request Request to process
- * @param use_events Process request events or not flag
- * @return TRUE on success, otherwise FALSE
- */
- bool ProcessHMIRequest(smart_objects::SmartObjectSPtr request = NULL,
- bool use_events = false);
-
- /**
- * @brief Process list of HMI requests using ProcessHMIRequest method
- * @param requests List of requests to process
- */
- void ProcessHMIRequests(const smart_objects::SmartObjectList& requests);
-
- void InsertToTimerQueue(uint32_t app_id, uint32_t time_stamp);
-
- void AddToResumptionTimerQueue(const uint32_t app_id);
-
- void LoadResumeData();
-
- /**
- * @brief Checks, if application data needs to be resumed
- * @param application Application data from storage
- * @return true, if data resumption must be skipped, otherwise - false
- */
- bool IsAppDataResumptionExpired(
- const smart_objects::SmartObject& application) const;
- /**
- * @brief Checks from resume data, if application has been disconnected
- * unexpectedly
- * @param app Application section from resume data
- * @return true, if it has been unexpectedly disconnected, otherwise - false
- */
- bool IsUnexpectedlyDisconnected(const smart_objects::SmartObject& app) const;
-
- /**
- * @brief Checks, if application can be resumed
- * @param application Application
- * @return true, if no restrictions currently, otherwise - false
- */
- bool IsResumeAllowed(
- const application_manager::ApplicationSharedPtr application) const;
-
- /**
- *@brief Mapping applications to time_stamps
- * wait for timer to resume HMI Level
- *
- */
- mutable sync_primitives::Lock queue_lock_;
- timer::Timer restore_hmi_level_timer_;
- timer::Timer save_persistent_data_timer_;
- typedef std::list<uint32_t> WaitingForTimerList;
- WaitingForTimerList waiting_for_timer_;
- bool is_resumption_active_;
- bool is_data_saved_;
- time_t launch_time_;
- utils::SharedPtr<ResumptionData> resumption_storage_;
- application_manager::ApplicationManager& application_manager_;
+#ifdef BUILD_TESTS
+ virtual void set_resumption_storage(
+ utils::SharedPtr<ResumptionData> mock_storage) = 0;
+#endif // BUILD_TESTS
};
} // namespace resumption
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_RESUME_CTRL_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
new file mode 100644
index 0000000000..b7512df28b
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
+
+#include <stdint.h>
+#include <vector>
+#include <map>
+#include <set>
+#include <list>
+
+#include "interfaces/HMI_API.h"
+#include "interfaces/HMI_API_schema.h"
+#include "interfaces/MOBILE_API_schema.h"
+#include "application_manager/event_engine/event_observer.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/application.h"
+#include "application_manager/resumption/resumption_data.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "utils/timer.h"
+
+namespace resumption {
+
+class LastState;
+
+/**
+ * @brief Contains logic for storage/restore data of applications.
+ */
+
+class ResumeCtrlImpl : public ResumeCtrl,
+ public app_mngr::event_engine::EventObserver {
+ public:
+ /**
+ * @brief allows to create ResumeCtrlImpl object
+ */
+ ResumeCtrlImpl(application_manager::ApplicationManager& application_manager);
+
+ /**
+ * @brief allows to destroy ResumeCtrlImpl object
+ */
+ ~ResumeCtrlImpl();
+
+ /**
+ * @brief Event, that raised if application get resumption response from HMI
+ * @param event : event object, that contains smart_object with HMI message
+ */
+ void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief Save all applications info to the file system
+ */
+ void SaveAllApplications() OVERRIDE;
+
+ /**
+ * @brief Save application persistent info for future resuming
+ * @param application is application witch need to be saved
+ */
+ void SaveApplication(app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Set application HMI Level and ausio_state as saved
+ * @param application is application witch HMI Level is need to restore
+ * @return true if success, otherwise return false
+ */
+ bool RestoreAppHMIState(app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Set application HMI Level as stored in policy
+ * @param application is application witch HMI Level is need to setup
+ * @return true if success, otherwise return false
+ */
+ bool SetupDefaultHMILevel(
+ app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Setup HmiLevel for application
+ * Do routine of setting up hmi_level
+ * @param application is application witch HMI Level is need to setup
+ * @param hmi_level HMI Level is needed to setup
+ * @param hmi_level AudioStreamingState is needed to setup
+ * @param check_policy indicate if policy data consent must be verified
+ * @return true if success, otherwise return false
+ */
+ bool SetAppHMIState(app_mngr::ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
+ bool check_policy = true) OVERRIDE;
+
+ /**
+ * @brief Remove application from list of saved applications
+ * @param application is application which need to be removed
+ * @return return true, if success, otherwise return false
+ */
+ bool RemoveApplicationFromSaved(
+ app_mngr::ApplicationConstSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Processes resumption data after receiving signal "Suspend"
+ */
+ void OnSuspend() OVERRIDE;
+
+ /**
+ * @brief Processes resumption data after receiving signal "Awake"
+ */
+ void OnAwake() OVERRIDE;
+
+ /**
+ * @brief Method stops timer "RsmCtrlPercist" when SDL
+ * receives OnExitAllApplication notification
+ * with reason "SUSPEND"
+ */
+ void StopSavePersistentDataTimer() OVERRIDE;
+
+ /**
+ * @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend()
+ */
+ void StopRestoreHmiLevelTimer();
+
+ /**
+ * @brief Start timer for resumption applications
+ * Restore D1-D5 data
+ * @param application that is need to be restored
+ * @return true if it was saved, otherwise return false
+ */
+ bool StartResumption(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash) OVERRIDE;
+
+ /**
+ * @brief Start timer for resumption applications
+ * Does not restore D1-D5 data
+ * @param application that is need to be restored
+ * @return true if it was saved, otherwise return false
+ */
+ bool StartResumptionOnlyHMILevel(
+ app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Check if there are all files need for resumption
+ * @param application that is need to be restored
+ * @return true if it all files exist, otherwise return false
+ */
+ bool CheckPersistenceFilesForResumption(
+ app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Check application hash
+ * @param application that is need to be restored
+ * @return true if it was saved, otherwise return false
+ */
+ bool CheckApplicationHash(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash) OVERRIDE;
+
+ /**
+ * @brief Checks if Resume controller have saved application with hmi app id
+ * @param hmi_app_id - hmi application id
+ * @return true if exist, false otherwise
+ */
+ bool IsHMIApplicationIdExist(uint32_t hmi_app_id) OVERRIDE;
+
+ /**
+ * @brief Check if Resume controller have saved instance of application
+ * @param policy_app_id - mobile application id
+ * @param device_id - id of device where application is run
+ * @return true if exist, false otherwise
+ */
+ bool IsApplicationSaved(const std::string& policy_app_id,
+ const std::string& device_id) OVERRIDE;
+
+ /**
+ * @brief Function is used for application resume. HMI app ID must be
+ * the same(PASA VCA module use it for stored app info).
+ * Retrieves HMI app ID for the given policy app ID from stored information.
+ * @param policy_app_id - mobile application id
+ * @param device_id - id of device where application is run
+ * @return HMI app ID
+ */
+ uint32_t GetHMIApplicationID(const std::string& policy_app_id,
+ const std::string& device_id) const OVERRIDE;
+
+ /**
+ * @brief Updates flag for saving application data
+ */
+ void ApplicationsDataUpdated() OVERRIDE {
+ is_data_saved_ = false;
+ }
+
+ /**
+ * @brief Resume HMI Level and audio streaming state if needed
+ * @param application - application to restore hmi level
+ * and audio streaming state
+ */
+ void StartAppHmiStateResumption(
+ app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Update launch_time_ to current
+ */
+ void ResetLaunchTime() OVERRIDE;
+
+ /**
+ * @brief Removes activated application from resumption list
+ *
+ * @param application application witch need to be removed from resumption
+ */
+ void OnAppActivated(app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ /**
+ * @brief Removes app from resumption list
+ *
+ * app_id Application to remove
+ */
+ void RemoveFromResumption(uint32_t app_id) OVERRIDE;
+
+ /**
+ * @brief Initialization data for Resume controller
+ * @return true if initialization is success otherwise
+ * returns false
+ */
+ bool Init(LastState& last_state) OVERRIDE;
+
+ /**
+ * @brief Notify resume controller about new application
+ * @param policy_app_id - mobile application id
+ * @param device_id - id of device where application is run
+ */
+ void OnAppRegistrationStart(const std::string& policy_app_id,
+ const std::string& device_id) OVERRIDE;
+
+ /**
+ * @brief Notify resume controller about delete new application
+ */
+ void OnAppRegistrationEnd() OVERRIDE;
+
+ int32_t GetSavedAppHmiLevel(const std::string& app_id,
+ const std::string& device_id) const OVERRIDE;
+
+ /**
+ * @brief geter for launch_time_
+ * @return value of launch_time_
+ */
+ time_t LaunchTime() const OVERRIDE;
+
+ /**
+ * @brief Timer callback for restoring HMI Level
+ *
+ */
+ void ApplicationResumptiOnTimer();
+
+ /**
+ * @brief Method starts timer "RsmCtrlPercist" when
+ * SDL receives onAwakeSDL notification
+ */
+ void StartSavePersistentDataTimer();
+
+#ifdef BUILD_TESTS
+ void set_resumption_storage(
+ utils::SharedPtr<ResumptionData> mock_storage) OVERRIDE;
+#endif // BUILD_TESTS
+ private:
+ /**
+ * @brief restores saved data of application
+ * @param application contains application for which restores data
+ * @return true if success, otherwise return false
+ */
+ bool RestoreApplicationData(app_mngr::ApplicationSharedPtr application);
+
+ /**
+ * @brief SaveDataOnTimer :
+ * Timer callback for persisting ResumptionData each N seconds
+ * N gets from property
+ */
+ void SaveDataOnTimer();
+
+ /**
+ * @brief AddFiles allows to add files for the application
+ * which should be resumed
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddFiles(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief AddSubmenues allows to add sub menues for the application
+ * which should be resumed
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddSubmenues(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief AddCommands allows to add commands for the application
+ * which should be resumed
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddCommands(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief AddChoicesets allows to add choice sets for the application
+ * which should be resumed
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddChoicesets(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief SetGlobalProperties allows to restore global properties.
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void SetGlobalProperties(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief AddSubscriptions allows to restore subscriptions
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddSubscriptions(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief AddWayPointsSubscription allows to restore subscription
+ * for WayPoints
+ * @param application application which will be resumed
+ * @param saved_app application specific section from backup file
+ */
+ void AddWayPointsSubscription(app_mngr::ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app);
+
+ bool DisconnectedJustBeforeIgnOff(
+ const smart_objects::SmartObject& saved_app);
+
+ bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application,
+ const smart_objects::SmartObject& saved_app);
+
+ /**
+ * @brief CheckIcons allows to check application icons
+ * @param application application under resumtion application
+ * @param json_object
+ * @return true in case icons exists, false otherwise
+ */
+ bool CheckIcons(app_mngr::ApplicationSharedPtr application,
+ smart_objects::SmartObject& obj);
+
+ /**
+ * @brief CheckDelayAfterIgnOn should check if SDL was started less
+ * then N secconds ago. N will be readed from profile.
+ * @return true if SDL started N secconds ago, otherwise return false
+ */
+ bool CheckDelayAfterIgnOn();
+
+ typedef std::pair<uint32_t, uint32_t> application_timestamp;
+
+ std::set<app_mngr::ApplicationSharedPtr> retrieve_application();
+
+ /**
+ * @brief This struct need to map
+ * timestamp and application from correlationID
+ */
+ struct ResumingApp {
+ uint32_t old_session_key; // session key is the same as app_id
+ app_mngr::ApplicationSharedPtr app;
+ };
+
+ struct TimeStampComparator {
+ bool operator()(const application_timestamp& lhs,
+ const application_timestamp& rhs) const {
+ return lhs.second < rhs.second;
+ }
+ };
+
+ /**
+ * @brief Check device MAC address
+ * @param application that is need to be restored
+ * @param saved_device_mac Saved device MAC address
+ * @return TRUE on success, otherwise FALSE
+ */
+ bool IsDeviceMacAddressEqual(app_mngr::ApplicationSharedPtr application,
+ const std::string& saved_device_mac);
+
+ /**
+ * @brief Get the last ignition off time from LastState
+ * @return the last ignition off time from LastState
+ */
+ time_t GetIgnOffTime();
+
+ /**
+ * @brief Setup IgnOff time to LastState
+ * @param ign_off_time - igition off time
+ */
+ void SetLastIgnOffTime(time_t ign_off_time);
+
+ /**
+ * @brief Process specified HMI request
+ * @param request Request to process
+ * @param use_events Process request events or not flag
+ * @return TRUE on success, otherwise FALSE
+ */
+ bool ProcessHMIRequest(smart_objects::SmartObjectSPtr request = NULL,
+ bool use_events = false);
+
+ /**
+ * @brief Process list of HMI requests using ProcessHMIRequest method
+ * @param requests List of requests to process
+ */
+ void ProcessHMIRequests(const smart_objects::SmartObjectList& requests);
+
+ void InsertToTimerQueue(uint32_t app_id, uint32_t time_stamp);
+
+ /**
+ * @brief Add application to queue to restore HMI level
+ * @param time_stamp contains time when application was stored to resumption
+ * data
+ * @param app_id contains id of application
+ */
+ void AddToResumptionTimerQueue(const uint32_t app_id);
+
+ void LoadResumeData();
+
+ /**
+ * @brief Checks, if application data needs to be resumed
+ * @param application Application data from storage
+ * @return true, if data resumption must be skipped, otherwise - false
+ */
+ bool IsAppDataResumptionExpired(
+ const smart_objects::SmartObject& application) const;
+
+ /**
+ * @brief Checks from resume data, if application has been disconnected
+ * unexpectedly
+ * @param app Application section from resume data
+ * @return true, if it has been unexpectedly disconnected, otherwise - false
+ */
+ bool IsUnexpectedlyDisconnected(const smart_objects::SmartObject& app) const;
+
+ /**
+ * @brief Checks, if application can be resumed
+ * @param application Application
+ * @param time_stamp contain time when application was stored to resumption
+ * data
+ * @return true, if no restrictions currently, otherwise - false
+ */
+ bool IsResumeAllowed(
+ const application_manager::ApplicationSharedPtr application) const;
+
+ /**
+ *@brief Mapping applications to time_stamps
+ * wait for timer to resume HMI Level
+ *
+ */
+ mutable sync_primitives::Lock queue_lock_;
+ timer::Timer restore_hmi_level_timer_;
+ timer::Timer save_persistent_data_timer_;
+ typedef std::list<uint32_t> WaitingForTimerList;
+ WaitingForTimerList waiting_for_timer_;
+ bool is_resumption_active_;
+ bool is_data_saved_;
+ time_t launch_time_;
+ utils::SharedPtr<ResumptionData> resumption_storage_;
+ application_manager::ApplicationManager& application_manager_;
+};
+
+} // namespace resumption
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index 1fda170c34..a1639eebd8 100644
--- a/src/components/application_manager/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/include/application_manager/smart_object_keys.h
@@ -51,6 +51,12 @@ extern const char* msg_params;
extern const char* method_name;
extern const char* info;
extern const char* app_id;
+extern const char* bundle_id;
+extern const char* app_info;
+extern const char* app_launch;
+extern const char* app_launch_list;
+extern const char* app_launch_last_session;
+extern const char* policy_app_id;
extern const char* hmi_app_id;
extern const char* device_id;
extern const char* subscribed_for_way_points;
diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
new file mode 100644
index 0000000000..481635d8e6
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2016, 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 <iterator>
+#include <algorithm>
+#include <utility>
+#include <vector>
+#include "application_manager/app_launch/app_launch_ctrl_impl.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "connection_handler/connection_handler.h"
+#include "application_manager/application.h"
+#include "utils/timer_task_impl.h"
+#include "utils/make_shared.h"
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchCtrlImpl::AppLaunchCtrlImpl(
+ AppLaunchData& data,
+ application_manager::ApplicationManager& app_mngr,
+ const AppLaunchSettings& settings)
+ : settings_(settings)
+ , app_launch_data_(data)
+ , resume_ctrl_(app_mngr.resume_controller())
+ , apps_launcher_(app_mngr.connection_handler(),
+ settings.max_number_of_ios_device(),
+ settings.app_launch_max_retry_attempt(),
+ settings.app_launch_retry_wait_time())
+ , device_apps_launcher_(app_mngr, apps_launcher_, settings) {}
+
+void AppLaunchCtrlImpl::OnAppRegistered(
+ const application_manager::Application& app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ // TODO (AKutsan) : get device mac
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ app.policy_app_id(), app.bundle_id(), app.mac_address());
+ apps_launcher_.OnLaunched(app_data);
+ app_launch_data_.AddApplicationData(*app_data);
+}
+
+ApplicationDataPtr GetAppFromHmiLevelPair(
+ const std::pair<int32_t, ApplicationDataPtr>& pair) {
+ return pair.second;
+}
+
+bool HmiLevelSorter(const std::pair<int32_t, ApplicationDataPtr>& lval,
+ const std::pair<int32_t, ApplicationDataPtr>& rval) {
+ if (lval.first == -1) {
+ return false;
+ }
+ if (rval.first == -1) {
+ return true;
+ }
+ return lval.first < rval.first;
+}
+
+void AppLaunchCtrlImpl::OnDeviceConnected(const std::string& device_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> apps_on_device =
+ app_launch_data_.GetApplicationDataByDevice(device_mac);
+ std::vector<std::pair<int32_t, ApplicationDataPtr> > apps_hmi_levels;
+ std::vector<ApplicationDataPtr>::iterator it = apps_on_device.begin();
+ for (; it != apps_on_device.end(); ++it) {
+ const ApplicationDataPtr& app_data = *it;
+ const int32_t hmi_level = resume_ctrl_.GetSavedAppHmiLevel(
+ app_data->mobile_app_id_, app_data->device_mac_);
+ const std::pair<int32_t, ApplicationDataPtr> hmi_level_app(hmi_level,
+ app_data);
+ apps_hmi_levels.push_back(hmi_level_app);
+ }
+ std::sort(apps_hmi_levels.begin(), apps_hmi_levels.end(), HmiLevelSorter);
+ apps_on_device.clear();
+ std::transform(apps_hmi_levels.begin(),
+ apps_hmi_levels.end(),
+ std::back_inserter(apps_on_device),
+ GetAppFromHmiLevelPair);
+ if (apps_on_device.size() > 0) {
+ device_apps_launcher_.LaunchAppsOnDevice(device_mac, apps_on_device);
+ } else {
+ LOG4CXX_DEBUG(logger_, "No apps in saved for device " << device_mac);
+ }
+}
+
+void AppLaunchCtrlImpl::OnMasterReset() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ app_launch_data_.Clear();
+}
+} // namespace app_launch
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
new file mode 100644
index 0000000000..f3adfc749b
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2016, 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 <string>
+#include <unistd.h>
+
+#include "application_manager/app_launch/app_launch_data_db.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/app_launch/app_launch_sql_queries.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/message_helper.h"
+#include "utils/make_shared.h"
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataDB::AppLaunchDataDB(const AppLaunchSettings& settings,
+ DbStorage db_storage)
+ : AppLaunchDataImpl(settings) {
+ if (db_storage == In_File_Storage) {
+ db_.reset(new utils::dbms::SQLDatabase(kDatabaseName));
+#ifndef __QNX__
+ std::string path = settings_.app_storage_folder();
+ if (!path.empty()) {
+ db()->set_path(path + "/");
+ }
+ } else if (db_storage == In_Memory_Storage) {
+ db_.reset(new utils::dbms::SQLDatabase());
+#endif // __QNX__
+ DCHECK(db_.get());
+ } else {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_ERROR(logger_, "Get not existed type of database storage");
+ }
+
+ // Connect to resumption DB
+ init_successeful_ = Init();
+}
+
+AppLaunchDataDB::~AppLaunchDataDB() {
+ db()->Close();
+}
+
+bool AppLaunchDataDB::Init() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!db()->Open()) {
+ LOG4CXX_ERROR(logger_, "Failed opening database.");
+ LOG4CXX_INFO(logger_, "Starting opening retries.");
+ const uint16_t attempts = settings_.app_launch_max_retry_attempt();
+ LOG4CXX_DEBUG(logger_, "Total attempts number is: " << attempts);
+ bool is_opened = false;
+ const uint16_t open_attempt_timeout_ms =
+ settings_.app_launch_retry_wait_time();
+ const useconds_t sleep_interval_mcsec = open_attempt_timeout_ms * 1000u;
+ LOG4CXX_DEBUG(logger_,
+ "Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
+ for (size_t i = 0u; i < attempts; ++i) {
+ usleep(sleep_interval_mcsec);
+ LOG4CXX_INFO(logger_, "Attempt: " << i + 1);
+ if (db()->Open()) {
+ LOG4CXX_INFO(logger_, "Database opened.");
+ is_opened = true;
+ break;
+ }
+ }
+ if (!is_opened) {
+ LOG4CXX_ERROR(logger_,
+ "Open retry sequence failed. Tried "
+ << attempts << " attempts with "
+ << open_attempt_timeout_ms
+ << " open timeout(ms) for each.");
+ return false;
+ }
+ }
+#ifndef __QNX__
+ if (!db()->IsReadWrite()) {
+ LOG4CXX_ERROR(logger_, "There are no read/write permissions for database");
+ return false;
+ }
+#endif // __QNX__
+
+ utils::dbms::SQLQuery query(db());
+ if (!query.Exec(kCreateSchema)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed creating schema of database: " << query.LastError().text());
+ return false;
+ }
+
+ return true;
+}
+
+bool AppLaunchDataDB::Persist() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ if ((retVal = WriteDb())) {
+ LOG4CXX_DEBUG(logger_, "App_lauch had been successfully saved.");
+ } else {
+ LOG4CXX_WARN(logger_, "Fail to save app_launch data.");
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::IsAppDataAlreadyExisted(
+ const ApplicationData& app_data) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kFindApplicationData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kFindApplicationData'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ if (query.Exec()) {
+ retVal = query.GetBoolean(result_query);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::RefreshAppSessionTime(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kRefreshApplicationDataSessionTime)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries "
+ "'kRefreshApplicationDataSessionTime'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ if (query.Exec()) {
+ LOG4CXX_DEBUG(logger_, "Dare&time last session were updated successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::AddNewAppData(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kAddApplicationData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kAddApplicationData'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ retVal = query.Exec();
+ if (retVal) {
+ LOG4CXX_DEBUG(logger_, "New application data was added successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac(
+ const std::string& dev_mac) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> dev_apps;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return dev_apps;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kGetApplicationDataByDevID)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification queries 'kGetApplicationDataByDevID'");
+ return dev_apps;
+ }
+
+ query.Bind(device_mac_index, dev_mac);
+ const bool retVal = query.Exec();
+ if (retVal) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+ do {
+ const std::string device_mac = query.GetString(device_mac_index);
+ const std::string mobile_app_id = query.GetString(application_id_index);
+ const std::string bundle_id = query.GetString(bundle_id_index);
+ dev_apps.push_back(utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac));
+ } while (query.Next());
+ LOG4CXX_DEBUG(logger_, "All application data has been successfully loaded");
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return dev_apps;
+}
+
+bool AppLaunchDataDB::Clear() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ utils::dbms::SQLQuery query(db());
+ retVal = query.Exec(kDropSchema);
+
+ if (retVal) {
+ LOG4CXX_INFO(logger_, "App_Launch table had been cleared successfully");
+ retVal = WriteDb();
+ init_successeful_ = false;
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed dropping database: " << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+uint32_t AppLaunchDataDB::GetCurentNumberOfAppData() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ uint32_t number_of_app_data = 0u;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return number_of_app_data;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kGetNumberOfApplicationData)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification queries 'kGetNumberOfApplicationData'");
+ return number_of_app_data;
+ }
+
+ if (query.Exec()) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+
+ number_of_app_data = query.GetInteger(result_query);
+ LOG4CXX_DEBUG(logger_,
+ "Total cout saved mobile applications is "
+ << number_of_app_data);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return number_of_app_data;
+}
+
+bool AppLaunchDataDB::DeleteOldestAppData() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kDeleteOldestAppData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kDeleteOldestAppData'");
+ return retVal;
+ }
+
+ if ((retVal = query.Exec())) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::WriteDb() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return db_->Backup();
+}
+
+utils::dbms::SQLDatabase* AppLaunchDataDB::db() const {
+#ifdef __QNX__
+ std::auto_ptr<utils::dbms::SQLDatabase> db_qnx(
+ new utils::dbms::SQLDatabase(kDatabaseName));
+ db_qnx.get()->Open();
+ return db_qnx.get();
+#else
+ return db_.get();
+#endif // __QNX__
+}
+
+} // namespace resumption
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_impl.cc b/src/components/application_manager/src/app_launch/app_launch_data_impl.cc
new file mode 100644
index 0000000000..c095cc9d94
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_impl.cc
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, 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/app_launch/app_launch_data_impl.h"
+#include "utils/logger.h"
+
+namespace app_launch {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataImpl::AppLaunchDataImpl(const AppLaunchSettings& settings)
+ : settings_(settings)
+ , kMaxNumberOfiOSdevice(settings.max_number_of_ios_device()) {}
+
+AppLaunchDataImpl::~AppLaunchDataImpl() {}
+
+bool AppLaunchDataImpl::AddApplicationData(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = true;
+
+ if (app_data.device_mac_.empty() == false &&
+ app_data.mobile_app_id_.empty() == false &&
+ app_data.bundle_id_.empty() == false) {
+ if (IsAppDataAlreadyExisted(app_data)) {
+ LOG4CXX_INFO(logger_, "This application data already existed");
+ retVal &= RefreshAppSessionTime(app_data);
+ } else {
+ if (GetCurentNumberOfAppData() >= get_max_number_iOS_devs()) {
+ LOG4CXX_INFO(logger_,
+ "Max number of application data have. It will be deleted "
+ "the oldest one");
+ retVal &= DeleteOldestAppData();
+ }
+ retVal &= AddNewAppData(app_data);
+ LOG4CXX_INFO(logger_, "Added new application data to DB");
+ }
+ } else {
+ retVal = false;
+ }
+ return retVal;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataImpl::GetApplicationDataByDevice(
+ const std::string& dev_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> apps = GetAppDataByDevMac(dev_mac);
+
+ if (apps.empty()) {
+ LOG4CXX_DEBUG(logger_, "No application founded by mac" << dev_mac);
+ }
+
+ return apps;
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_json.cc b/src/components/application_manager/src/app_launch/app_launch_data_json.cc
new file mode 100644
index 0000000000..260dde7205
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_json.cc
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2016, 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 <algorithm>
+#include "application_manager/app_launch/app_launch_data_json.h"
+#include "application_manager/smart_object_keys.h"
+#include "smart_objects/smart_object.h"
+#include "utils/make_shared.h"
+#include "utils/date_time.h"
+#include "json/json.h"
+
+namespace app_launch {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataJson::AppLaunchDataJson(const AppLaunchSettings& settings,
+ resumption::LastState& last_state)
+ : AppLaunchDataImpl(settings)
+ , app_launch_json_lock_(true)
+ , last_state_(last_state) {}
+
+AppLaunchDataJson::~AppLaunchDataJson() {}
+
+Json::Value& AppLaunchDataJson::GetSavedApplicationDataList() const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ Json::Value& app_launch = GetApplicationData();
+ if (!app_launch.isMember(strings::app_launch_list)) {
+ app_launch[strings::app_launch_list] = Json::Value(Json::arrayValue);
+ LOG4CXX_WARN(logger_, "app_list section is missed");
+ }
+ Json::Value& app_launch_list = app_launch[strings::app_launch_list];
+ if (!app_launch_list.isArray()) {
+ LOG4CXX_ERROR(logger_, "app_launch_list type INVALID rewrite");
+ app_launch_list = Json::Value(Json::arrayValue);
+ }
+ return app_launch_list;
+}
+
+Json::Value& AppLaunchDataJson::GetApplicationData() const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ Json::Value& dictionary = last_state().dictionary;
+ if (!dictionary.isMember(strings::app_launch)) {
+ last_state().dictionary[strings::app_launch] =
+ Json::Value(Json::objectValue);
+ LOG4CXX_WARN(logger_, "app_launch section is missed");
+ }
+ Json::Value& app_launch = dictionary[strings::app_launch];
+ if (!app_launch.isObject()) {
+ LOG4CXX_ERROR(logger_, "resumption type INVALID rewrite");
+ app_launch = Json::Value(Json::objectValue);
+ }
+ return app_launch;
+}
+
+Json::Value& AppLaunchDataJson::GetApplicationListAndIndex(
+ const ApplicationData& app_data, int32_t& founded_index) const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+
+ Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ const std::string deviceID =
+ apps_list[idx][strings::device_id].asString();
+ const std::string bundleID =
+ apps_list[idx][strings::bundle_id].asString();
+ const std::string appID = apps_list[idx][strings::app_id].asString();
+
+ if (deviceID == app_data.device_mac_ && bundleID == app_data.bundle_id_ &&
+ appID == app_data.mobile_app_id_) {
+ founded_index = idx;
+ }
+ }
+ }
+
+ return apps_list;
+}
+
+bool AppLaunchDataJson::IsAppDataAlreadyExisted(
+ const ApplicationData& app_data) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ int32_t index = NotFound;
+ GetApplicationListAndIndex(app_data, index);
+ return index == NotFound ? false : true;
+}
+
+bool AppLaunchDataJson::RefreshAppSessionTime(const ApplicationData& app_data) {
+ using namespace application_manager;
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ int32_t index = NotFound;
+ Json::Value& json_data_list = GetApplicationListAndIndex(app_data, index);
+ if (index != NotFound) {
+ if (json_data_list.empty() == false) {
+ json_data_list[index][strings::app_launch_last_session] =
+ static_cast<Json::Value::UInt64>(DateTime::getCurrentTime().tv_sec);
+ retVal = true;
+ }
+ }
+ return retVal;
+}
+
+bool AppLaunchDataJson::AddNewAppData(const ApplicationData& app_data) {
+ using namespace application_manager;
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+
+ Json::Value& json_app_data =
+ GetSavedApplicationDataList().append(Json::Value());
+ json_app_data[strings::device_id] = app_data.device_mac_;
+ json_app_data[strings::app_id] = app_data.mobile_app_id_;
+ json_app_data[strings::bundle_id] = app_data.bundle_id_;
+ json_app_data[strings::app_launch_last_session] =
+ static_cast<Json::Value::UInt64>(DateTime::getCurrentTime().tv_sec);
+
+ LOG4CXX_DEBUG(logger_,
+ "New application data saved. Detatils device_id: "
+ << app_data.device_mac_
+ << ", app_id: " << app_data.mobile_app_id_
+ << ", bundle_id: " << app_data.bundle_id_ << ".");
+
+ return true;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataJson::GetAppDataByDevMac(
+ const std::string& dev_mac) const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ std::vector<ApplicationDataPtr> dev_apps;
+ const Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ const std::string deviceMac =
+ apps_list[idx][strings::device_id].asString();
+ const std::string bundleID =
+ apps_list[idx][strings::bundle_id].asString();
+ const std::string appID = apps_list[idx][strings::app_id].asString();
+
+ if (deviceMac == dev_mac) {
+ dev_apps.push_back(
+ utils::MakeShared<ApplicationData>(appID, bundleID, deviceMac));
+ }
+ }
+ }
+
+ return dev_apps;
+}
+
+bool AppLaunchDataJson::Clear() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ GetSavedApplicationDataList().clear();
+
+ LOG4CXX_DEBUG(logger_,
+ "Application launch JSON section successfully cleared.");
+
+ return true;
+}
+
+uint32_t AppLaunchDataJson::GetCurentNumberOfAppData() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ uint32_t list_size = GetSavedApplicationDataList().size();
+
+ LOG4CXX_DEBUG(logger_,
+ "Successfully was gotten app_launch list. Size: " << list_size);
+
+ return list_size;
+}
+
+bool AppLaunchDataJson::DeleteOldestAppData() {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ std::vector<uint64_t> temp_array;
+ std::vector<Json::Value> temp_json_list;
+ Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ // Search oldest record in Json
+ // for it collect all timestaps in vector
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ temp_array.push_back(
+ apps_list[idx][strings::app_launch_last_session].asUInt64());
+ }
+ }
+
+ // Calc oldest one and found index of it in Json
+ const int32_t oldest_index =
+ (std::min_element(temp_array.begin(), temp_array.end()) -
+ temp_array.begin());
+
+ // Copy in temporary vector Json list without oldest record
+ int32_t i = 0;
+ for (Json::Value::iterator it = GetSavedApplicationDataList().begin();
+ it != GetSavedApplicationDataList().end();
+ ++it, i++) {
+ if ((*it).isMember(strings::device_id) &&
+ (*it).isMember(strings::bundle_id) && (*it).isMember(strings::app_id) &&
+ (*it).isMember(strings::app_launch_last_session)) {
+ if (i == oldest_index) {
+ continue;
+ }
+ temp_json_list.push_back((*it));
+ }
+ }
+
+ // Clear Json list
+ GetSavedApplicationDataList().clear();
+
+ // Copy to Json new list without oldest one
+ for (std::vector<Json::Value>::iterator it = temp_json_list.begin();
+ it != temp_json_list.end();
+ ++it) {
+ GetSavedApplicationDataList().append((*it));
+ }
+
+ LOG4CXX_DEBUG(
+ logger_, "Oldest application launch data had been successfully deleted.");
+
+ return true;
+}
+
+bool AppLaunchDataJson::Persist() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ last_state().SaveToFileSystem();
+ return true;
+}
+
+} // app_launch
diff --git a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc
new file mode 100644
index 0000000000..950bcd44fa
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2016, 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/app_launch/app_launch_sql_queries.h"
+
+namespace app_launch {
+
+const std::string kCreateSchema =
+ "CREATE TABLE IF NOT EXISTS `app_launch`( "
+ " `deviceMac` TEXT, "
+ " `appID` TEXT,"
+ " `bundleID` TEXT,"
+ " `last_session` DATETIME, "
+ " PRIMARY KEY(`deviceMac`, `appID`, `bundleID`)"
+ " ); ";
+
+const std::string kDropSchema = "DROP TABLE IF EXISTS `app_launch`; ";
+
+const std::string kAddApplicationData =
+ "INSERT INTO `app_launch`"
+ "(`deviceMac`, `appID`, `bundleID`, `last_session`)"
+ "VALUES "
+ "(?, ?, ?, STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW'));";
+
+const std::string kFindApplicationData =
+ " SELECT COUNT(*)"
+ "FROM `app_launch`"
+ "WHERE `deviceMac` = ? AND `appID` = ? AND `bundleID` = ?;";
+
+const std::string kDeleteOldestAppData =
+ "DELETE FROM `app_launch`"
+ "WHERE `last_session` IN ("
+ "SELECT MIN(`last_session`)"
+ "FROM `app_launch`);";
+
+const std::string kGetNumberOfApplicationData =
+ "SELECT COUNT (*)"
+ "FROM `app_launch` ;";
+
+const std::string kGetApplicationDataByDevID =
+ "SELECT *"
+ "FROM `app_launch`"
+ "WHERE `deviceMac` = ?;";
+
+const std::string kRefreshApplicationDataSessionTime =
+ "UPDATE `app_launch`"
+ "SET `last_session` = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')"
+ "WHERE `deviceMac` = ? AND appID = ? AND bundleID = ?;";
+
+} // namespace resumption
diff --git a/src/components/application_manager/src/app_launch/apps_launcher.cc b/src/components/application_manager/src/app_launch/apps_launcher.cc
new file mode 100644
index 0000000000..41465ae985
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/apps_launcher.cc
@@ -0,0 +1,139 @@
+#include <algorithm>
+#include "application_manager/app_launch/apps_launcher.h"
+#include "utils/make_shared.h"
+#include "utils/timer_task_impl.h"
+#include <iostream>
+
+namespace app_launch {
+struct LauncherGenerator {
+ LauncherGenerator(AppsLauncher& apps_laucnher,
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time)
+ : apps_laucnher_(apps_laucnher)
+ , connection_handler_(connection_handler)
+ , app_launch_max_retry_attempt_(app_launch_max_retry_attempt)
+ , app_launch_retry_wait_time_(app_launch_retry_wait_time) {}
+ AppsLauncher::LauncherPtr operator()() {
+ return utils::MakeShared<AppsLauncher::Launcher>(
+ apps_laucnher_,
+ connection_handler_,
+ app_launch_max_retry_attempt_,
+ app_launch_retry_wait_time_);
+ }
+
+ AppsLauncher& apps_laucnher_;
+ connection_handler::ConnectionHandler& connection_handler_;
+ const uint16_t app_launch_max_retry_attempt_;
+ const uint16_t app_launch_retry_wait_time_;
+};
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+AppsLauncher::AppsLauncher(
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t max_number_of_ios_device,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ free_launchers_.resize(max_number_of_ios_device);
+ std::generate(free_launchers_.begin(),
+ free_launchers_.end(),
+ LauncherGenerator(*this,
+ connection_handler,
+ app_launch_max_retry_attempt,
+ app_launch_retry_wait_time));
+}
+
+void AppsLauncher::StartLaunching(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ DCHECK_OR_RETURN_VOID(!free_launchers_.empty())
+ const AppLaunchers::iterator it = free_launchers_.begin();
+ LauncherPtr app_launcher = *it;
+ works_launchers_.push_back(app_launcher);
+ free_launchers_.erase(it);
+ app_launcher->PosponedLaunch(app_data);
+}
+
+struct AppLauncherFinder {
+ AppLauncherFinder(const ApplicationDataPtr& app_data) : app_data_(app_data) {}
+ bool operator()(const AppsLauncher::LauncherPtr& launcher) const {
+ DCHECK_OR_RETURN(launcher->app_data_ && app_data_, false)
+ return *launcher->app_data_ == *app_data_;
+ }
+ const ApplicationDataPtr& app_data_;
+};
+
+void AppsLauncher::StopLaunching(ApplicationDataPtr app_data) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ const AppLaunchers::iterator it = std::find_if(works_launchers_.begin(),
+ works_launchers_.end(),
+ AppLauncherFinder(app_data));
+ if (it != works_launchers_.end()) {
+ LauncherPtr launcher = *it;
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+ works_launchers_.erase(it);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Unable to StopLaunching" << app_data->mobile_app_id_);
+ }
+}
+
+void AppsLauncher::OnLaunched(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopLaunching(app_data);
+}
+
+void AppsLauncher::OnRetryAttemptsExhausted(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopLaunching(app_data);
+}
+
+AppsLauncher::Launcher::Launcher(
+ AppsLauncher& parent,
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time)
+ : retry_timer_(
+ "AppsLauncherTimer",
+ new timer::TimerTaskImpl<Launcher>(this, &Launcher::LaunchNow))
+ , app_launch_max_retry_attempt_(app_launch_max_retry_attempt)
+ , app_launch_retry_wait_time_(app_launch_retry_wait_time)
+ , connection_handler_(connection_handler)
+ , parent_(parent) {}
+
+void AppsLauncher::Launcher::PosponedLaunch(
+ const app_launch::ApplicationDataPtr& app_data) {
+ DCHECK(!app_data_);
+ app_data_ = app_data;
+ retry_index_ = 0;
+ retry_timer_.Start(app_launch_retry_wait_time_, timer::kPeriodic);
+ LOG4CXX_DEBUG(logger_,
+ "Applicaiton " << app_data->mobile_app_id_ << " on device "
+ << app_data->device_mac_
+ << " will be launched in "
+ << app_launch_retry_wait_time_ << " ms");
+}
+
+void AppsLauncher::Launcher::Clear() {
+ retry_timer_.Stop();
+ app_data_.reset();
+ retry_index_ = 0;
+}
+
+void AppsLauncher::Launcher::LaunchNow() {
+ if (retry_index_++ < app_launch_max_retry_attempt_) {
+ LOG4CXX_DEBUG(logger_,
+ "Run App " << app_data_->mobile_app_id_ << "with bundle "
+ << app_data_->bundle_id_ << " On Device "
+ << app_data_->device_mac_);
+
+ connection_handler_.RunAppOnDevice(app_data_->device_mac_,
+ app_data_->bundle_id_);
+ } else {
+ parent_.OnRetryAttemptsExhausted(app_data_);
+ }
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
new file mode 100644
index 0000000000..0eb9245cf8
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
@@ -0,0 +1,208 @@
+#include <string>
+#include <vector>
+#include <algorithm>
+
+#include "application_manager/app_launch/device_apps_launcher.h"
+#include "application_manager/app_launch/app_launch_data.h"
+#include "application_manager/app_launch/apps_launcher.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+#include "utils/timer.h"
+#include "utils/timer_task_impl.h"
+#include <iostream>
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+typedef std::pair<std::string, std::vector<ApplicationDataPtr> > AppsOnDevice;
+typedef utils::SharedPtr<AppsOnDevice> AppsOnDevicePtr;
+
+class Launcher {
+ public:
+ Launcher(const resumption::ResumeCtrl& resume_ctrl,
+ DeviceAppsLauncher& device_launcher,
+ AppsLauncher& apps_launcher)
+ : device_launcher_(device_launcher)
+ , apps_launcher_(apps_launcher)
+ , resume_ctrl_(resume_ctrl)
+ , gap_between_app_timer_("GapBetweenLaunchTimer",
+ new timer::TimerTaskImpl<Launcher>(
+ this, &Launcher::OnGapBetweenLaunchExpired))
+ , wait_before_launch_timer_(
+ "WaitBeforeLainchTimer",
+ new timer::TimerTaskImpl<Launcher>(this, &Launcher::LaunchNext)) {}
+
+ void Start(const AppsOnDevicePtr& apps_on_device) {
+ DCHECK(!apps_on_device_);
+ apps_on_device_ = apps_on_device;
+ const time_t curr_time = time(NULL);
+ const time_t sdl_launch_time = resume_ctrl_.LaunchTime();
+ const double seconds_from_sdl_start = difftime(curr_time, sdl_launch_time);
+ const uint32_t wait_time =
+ device_launcher_.settings().resumption_delay_after_ign();
+ const uint32_t wait_before_launch_timeout =
+ seconds_from_sdl_start < wait_time
+ ? wait_time - seconds_from_sdl_start
+ : device_launcher_.settings().app_launch_wait_time();
+ wait_before_launch_timer_.Start(wait_before_launch_timeout,
+ timer::kSingleShot);
+ }
+
+ void LaunchNext() {
+ std::vector<ApplicationDataPtr>& apps = apps_on_device_->second;
+ std::vector<ApplicationDataPtr>::iterator it = apps.begin();
+ if (it != apps.end()) {
+ apps_launcher_.StartLaunching(*it);
+ apps.erase(it);
+ gap_between_app_timer_.Start(
+ device_launcher_.settings().wait_time_between_apps(),
+ timer::kSingleShot);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "All Apps on " << apps_on_device_->first
+ << " posponed launched");
+ device_launcher_.StopLaunchingAppsOnDevice(apps_on_device_->first);
+ }
+ }
+
+ void OnGapBetweenLaunchExpired() {
+ LaunchNext();
+ }
+
+ void OnAppRegistered(const ApplicationDataPtr& app_data) {
+ std::vector<ApplicationDataPtr>& apps = apps_on_device_->second;
+ std::vector<ApplicationDataPtr>::iterator it =
+ std::find(apps.begin(), apps.end(), app_data);
+ if (it != apps.end()) {
+ apps.erase(it);
+ }
+ }
+
+ void Clear() {
+ gap_between_app_timer_.Stop();
+ wait_before_launch_timer_.Stop();
+ apps_on_device_.reset();
+ }
+
+ DeviceAppsLauncher& device_launcher_;
+ AppsLauncher& apps_launcher_;
+ const resumption::ResumeCtrl& resume_ctrl_;
+
+ timer::Timer gap_between_app_timer_;
+ timer::Timer wait_before_launch_timer_;
+
+ AppsOnDevicePtr apps_on_device_;
+};
+
+typedef utils::SharedPtr<Launcher> LauncherPtr;
+typedef std::vector<LauncherPtr> Launchers;
+
+struct LauncherGenerator {
+ LauncherGenerator(resumption::ResumeCtrl& resume_ctrl,
+ DeviceAppsLauncher& interface,
+ AppsLauncher& apps_launcher)
+ : resume_ctrl_(resume_ctrl)
+ , interface_(interface)
+ , apps_launcher_(apps_launcher) {}
+
+ LauncherPtr operator()() const {
+ return utils::MakeShared<Launcher>(
+ resume_ctrl_, interface_, apps_launcher_);
+ }
+
+ resumption::ResumeCtrl& resume_ctrl_;
+ DeviceAppsLauncher& interface_;
+ AppsLauncher& apps_launcher_;
+};
+
+class DeviceAppsLauncherImpl {
+ public:
+ DeviceAppsLauncherImpl(DeviceAppsLauncher& interface,
+ AppsLauncher& apps_launcher)
+ : interface_(interface) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ LauncherGenerator generate(
+ interface.app_mngr_.resume_controller(), interface, apps_launcher);
+ free_launchers_.reserve(interface.settings_.max_number_of_ios_device());
+ std::generate_n(std::back_inserter(free_launchers_),
+ interface.settings_.max_number_of_ios_device(),
+ generate);
+ }
+
+ bool LaunchAppsOnDevice(
+ const std::string& device_mac,
+ const std::vector<ApplicationDataPtr>& applications_to_launch) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_,
+ "On Device " << device_mac << " will be launched "
+ << applications_to_launch.size() << " apps");
+ AppsOnDevicePtr apps_on_device =
+ utils::MakeShared<AppsOnDevice>(device_mac, applications_to_launch);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ DCHECK_OR_RETURN(!free_launchers_.empty(), false)
+ const Launchers::iterator it = free_launchers_.begin();
+ LauncherPtr launcher = *it;
+ works_launchers_.push_back(launcher);
+ free_launchers_.erase(it);
+ launcher->Start(apps_on_device);
+ return true;
+ }
+
+ struct LauncherFinder {
+ LauncherFinder(const std::string& device_mac) : device_mac_(device_mac) {}
+
+ bool operator()(const LauncherPtr& launcher) const {
+ return device_mac_ == launcher->apps_on_device_->first;
+ }
+
+ std::string device_mac_;
+ };
+
+ bool StopLaunchingAppsOnDevice(const std::string& device_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ const Launchers::iterator it = std::find_if(works_launchers_.begin(),
+ works_launchers_.end(),
+ LauncherFinder(device_mac));
+ if (it == works_launchers_.end()) {
+ return false;
+ }
+ LauncherPtr launcher = *it;
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+ works_launchers_.erase(it);
+ return true;
+ }
+
+ private:
+ sync_primitives::Lock launchers_lock_;
+ Launchers free_launchers_;
+ Launchers works_launchers_;
+ DeviceAppsLauncher& interface_;
+};
+
+bool DeviceAppsLauncher::LaunchAppsOnDevice(
+ const std::string& device_mac,
+ const std::vector<ApplicationDataPtr>& applications_to_launch) {
+ return impl_->LaunchAppsOnDevice(device_mac, applications_to_launch);
+}
+
+DeviceAppsLauncher::DeviceAppsLauncher(
+ application_manager::ApplicationManager& app_mngr,
+ app_launch::AppsLauncher& apps_launcher,
+ const AppLaunchSettings& settings)
+ : app_mngr_(app_mngr)
+ , settings_(settings)
+ , impl_(new DeviceAppsLauncherImpl(*this, apps_launcher)) {}
+
+bool DeviceAppsLauncher::StopLaunchingAppsOnDevice(
+ const std::string& device_mac) {
+ return impl_->StopLaunchingAppsOnDevice(device_mac);
+}
+
+const AppLaunchSettings& DeviceAppsLauncher::settings() const {
+ return settings_;
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 61451e3602..e06497f1da 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -318,6 +318,10 @@ const std::string& ApplicationImpl::app_icon_path() const {
return app_icon_path_;
}
+const std::string& ApplicationImpl::bundle_id() const {
+ return bundle_id_;
+}
+
connection_handler::DeviceHandle ApplicationImpl::device() const {
return device_;
}
@@ -489,7 +493,8 @@ void ApplicationImpl::WakeUpStreaming(
ServiceType::kMobileNav, true, application_manager_);
video_streaming_suspended_ = false;
}
- video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, false);
+ video_stream_suspend_timer_.Start(video_stream_suspend_timeout_,
+ timer::kPeriodic);
} else if (ServiceType::kAudio == service_type) {
sync_primitives::AutoLock lock(audio_streaming_suspended_lock_);
if (audio_streaming_suspended_) {
@@ -498,7 +503,8 @@ void ApplicationImpl::WakeUpStreaming(
ServiceType::kAudio, true, application_manager_);
audio_streaming_suspended_ = false;
}
- audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, false);
+ audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_,
+ timer::kPeriodic);
}
}
@@ -570,6 +576,10 @@ void ApplicationImpl::set_grammar_id(uint32_t value) {
grammar_id_ = value;
}
+void ApplicationImpl::set_bundle_id(const std::string& bundle_id) {
+ bundle_id_ = bundle_id;
+}
+
void ApplicationImpl::ResetDataInNone() {
put_file_in_none_count_ = 0;
delete_file_in_none_count_ = 0;
@@ -688,7 +698,7 @@ UsageStatistics& ApplicationImpl::usage_report() {
return usage_report_;
}
-bool ApplicationImpl::IsCommandLimitsExceeded(
+bool ApplicationImpl::AreCommandLimitsExceeded(
mobile_apis::FunctionID::eType cmd_id, TLimitSource source) {
TimevalStruct current = date_time::DateTime::getCurrentTime();
switch (source) {
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index fcacf28942..97dcce10bf 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -44,6 +44,11 @@
#include "application_manager/message_helper.h"
#include "application_manager/mobile_message_handler.h"
#include "application_manager/policies/policy_handler.h"
+#include "application_manager/hmi_capabilities_impl.h"
+#include "application_manager/resumption/resume_ctrl_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl_impl.h"
+#include "application_manager/app_launch/app_launch_data_db.h"
+#include "application_manager/app_launch/app_launch_data_json.h"
#include "protocol_handler/protocol_handler.h"
#include "hmi_message_handler/hmi_message_handler.h"
#include "connection_handler/connection_handler_impl.h"
@@ -114,10 +119,10 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, messages_from_hmi_("AM FromHMI", this)
, messages_to_hmi_("AM ToHMI", this)
, audio_pass_thru_messages_("AudioPassThru", this)
- , hmi_capabilities_(*this)
+ , hmi_capabilities_(new HMICapabilitiesImpl(*this))
, unregister_reason_(
mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM)
- , resume_ctrl_(*this)
+ , resume_ctrl_(new resumption::ResumeCtrlImpl(*this))
, navi_close_app_timeout_(am_settings.stop_streaming_timeout())
, navi_end_stream_timeout_(am_settings.stop_streaming_timeout())
, stopping_application_mng_lock_(true)
@@ -148,7 +153,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::ClearTimerPool)));
const uint32_t timeout_ms = 10000u;
- clearing_timer->Start(timeout_ms, false);
+ clearing_timer->Start(timeout_ms, timer::kSingleShot);
timer_pool_.push_back(clearing_timer);
}
@@ -427,7 +432,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
LOG4CXX_DEBUG(logger_, "Restarting application list update timer");
GetPolicyHandler().OnAppsSearchStarted();
uint32_t timeout = get_settings().application_list_update_timeout();
- application_list_update_timer_.Start(timeout, true);
+ application_list_update_timer_.Start(timeout, timer::kSingleShot);
if (!is_all_apps_allowed_) {
LOG4CXX_WARN(logger_,
@@ -534,16 +539,23 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
if (!application->hmi_app_id()) {
const bool is_saved =
- resume_ctrl_.IsApplicationSaved(policy_app_id, device_mac);
+ resume_controller().IsApplicationSaved(policy_app_id, device_mac);
application->set_hmi_application_id(
- is_saved ? resume_ctrl_.GetHMIApplicationID(policy_app_id, device_mac)
- : GenerateNewHMIAppID());
+ is_saved
+ ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac)
+ : GenerateNewHMIAppID());
}
+ if (params.keyExists(strings::app_info)) {
+ const smart_objects::SmartObject& app_info = params[strings::app_info];
+ const std::string& bundle_id = app_info[strings::bundle_id].asString();
+ application->set_bundle_id(bundle_id);
+ }
// Stops timer of saving data to resumption in order to
// doesn't erase data from resumption storage.
// Timer will be started after hmi level resumption.
- resume_ctrl_.OnAppRegistrationStart(policy_app_id, device_mac);
+ resume_controller().OnAppRegistrationStart(policy_app_id, device_mac);
+
// Add application to registered app list and set appropriate mark.
// Lock has to be released before adding app to policy DB to avoid possible
// deadlock with simultaneous PTU processing
@@ -913,6 +925,7 @@ void ApplicationManagerImpl::OnDeviceListUpdated(
GetPolicyHandler().AddDevice(dev_params.device_mac_address,
device_info.connection_type);
+ app_launch_ctrl().OnDeviceConnected(dev_params.device_mac_address);
}
smart_objects::SmartObjectSPtr msg_params =
@@ -939,7 +952,7 @@ void ApplicationManagerImpl::OnFindNewApplicationsRequest() {
connection_handler().ConnectToAllDevices();
LOG4CXX_DEBUG(logger_, "Starting application list update timer");
uint32_t timeout = get_settings().application_list_update_timeout();
- application_list_update_timer_.Start(timeout, true);
+ application_list_update_timer_.Start(timeout, timer::kSingleShot);
GetPolicyHandler().OnAppsSearchStarted();
}
@@ -1009,7 +1022,7 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() {
uint32_t hmi_app_id = get_rand_from_range(1);
LOG4CXX_DEBUG(logger_, "GenerateNewHMIAppID value is: " << hmi_app_id);
- while (resume_ctrl_.IsHMIApplicationIdExist(hmi_app_id)) {
+ while (resume_controller().IsHMIApplicationIdExist(hmi_app_id)) {
LOG4CXX_DEBUG(logger_, "HMI appID " << hmi_app_id << " is exists.");
hmi_app_id = get_rand_from_range(1);
LOG4CXX_DEBUG(logger_, "Trying new value: " << hmi_app_id);
@@ -1374,8 +1387,9 @@ void ApplicationManagerImpl::SendMessageToMobile(
// checked against policy permissions
if (msg_to_mobile[strings::params].keyExists(strings::correlation_id)) {
request_ctrl_.OnMobileResponse(
- msg_to_mobile[strings::params][strings::correlation_id].asInt(),
- msg_to_mobile[strings::params][strings::connection_key].asInt());
+ msg_to_mobile[strings::params][strings::correlation_id].asUInt(),
+ msg_to_mobile[strings::params][strings::connection_key].asUInt(),
+ msg_to_mobile[strings::params][strings::function_id].asInt());
} else if (app) {
mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
@@ -1415,9 +1429,10 @@ void ApplicationManagerImpl::SendMessageToMobile(
impl::MessageToMobile(message_to_send, final_message));
}
-void ApplicationManagerImpl::TerminateRequest(uint32_t connection_key,
- uint32_t corr_id) {
- request_ctrl_.terminateRequest(corr_id, connection_key, true);
+void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key,
+ const uint32_t corr_id,
+ const int32_t function_id) {
+ request_ctrl_.TerminateRequest(corr_id, connection_key, function_id, true);
}
bool ApplicationManagerImpl::ManageMobileCommand(
@@ -1670,8 +1685,10 @@ bool ApplicationManagerImpl::ManageHMICommand(
command->Run();
if (kResponse == message_type) {
const uint32_t correlation_id =
- (*(message.get()))[strings::params][strings::correlation_id].asInt();
- request_ctrl_.OnHMIResponse(correlation_id);
+ (*(message.get()))[strings::params][strings::correlation_id].asUInt();
+ const int32_t function_id =
+ (*(message.get()))[strings::params][strings::function_id].asInt();
+ request_ctrl_.OnHMIResponse(correlation_id, function_id);
}
return true;
}
@@ -1686,11 +1703,11 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
!IsReadWriteAllowed(app_storage_folder, TYPE_STORAGE)) {
return false;
}
- if (!resume_ctrl_.Init(last_state)) {
+ if (!resume_controller().Init(last_state)) {
LOG4CXX_ERROR(logger_, "Problem with initialization of resume controller");
return false;
}
- hmi_capabilities_.Init(&last_state);
+ hmi_capabilities_->Init(&last_state);
if (!(file_system::IsWritingAllowed(app_storage_folder) &&
file_system::IsReadingAllowed(app_storage_folder))) {
@@ -1727,6 +1744,16 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
"System is configured to work without policy functionality.");
}
media_manager_ = media_manager;
+
+ if (settings_.use_db_for_resumption()) {
+ app_launch_dto_.reset(new app_launch::AppLaunchDataDB(settings_));
+ } else {
+ app_launch_dto_.reset(
+ new app_launch::AppLaunchDataJson(settings_, last_state));
+ }
+ app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl(
+ *app_launch_dto_.get(), *this, settings_));
+
return true;
}
@@ -2112,11 +2139,11 @@ mobile_apis::MOBILE_API& ApplicationManagerImpl::mobile_so_factory() {
}
HMICapabilities& ApplicationManagerImpl::hmi_capabilities() {
- return hmi_capabilities_;
+ return *hmi_capabilities_;
}
const HMICapabilities& ApplicationManagerImpl::hmi_capabilities() const {
- return hmi_capabilities_;
+ return *hmi_capabilities_;
}
void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data,
@@ -2247,8 +2274,8 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
device_id, NULL, NULL, &device_mac, NULL);
const uint32_t hmi_app_id =
- resume_ctrl_.IsApplicationSaved(policy_app_id, device_mac)
- ? resume_ctrl_.GetHMIApplicationID(policy_app_id, device_mac)
+ resume_controller().IsApplicationSaved(policy_app_id, device_mac)
+ ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac)
: GenerateNewHMIAppID();
// AppId = 0 because this is query_app(provided by hmi for download, but not
@@ -2593,12 +2620,12 @@ void ApplicationManagerImpl::UnregisterApplication(
return;
}
if (is_resuming) {
- resume_ctrl_.SaveApplication(app_to_remove);
+ resume_controller().SaveApplication(app_to_remove);
} else {
- resume_ctrl_.RemoveApplicationFromSaved(app_to_remove);
+ resume_controller().RemoveApplicationFromSaved(app_to_remove);
}
applications_.erase(app_to_remove);
- (hmi_capabilities_.get_hmi_language_handler())
+ (hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
AppV4DevicePredicate finder(handle);
ApplicationSharedPtr app = FindApp(accessor, finder);
@@ -2961,7 +2988,7 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
"CloseNaviAppTimer",
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::CloseNaviApp)));
- close_timer->Start(navi_close_app_timeout_, true);
+ close_timer->Start(navi_close_app_timeout_, timer::kPeriodic);
sync_primitives::AutoLock lock(timer_pool_lock_);
timer_pool_.push_back(close_timer);
@@ -3002,7 +3029,7 @@ void ApplicationManagerImpl::OnHMILevelChanged(
"AppShouldFinishStreaming",
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::EndNaviStreaming)));
- end_stream_timer->Start(navi_end_stream_timeout_, true);
+ end_stream_timer->Start(navi_end_stream_timeout_, timer::kPeriodic);
sync_primitives::AutoLock lock(timer_pool_lock_);
timer_pool_.push_back(end_stream_timer);
@@ -3089,12 +3116,14 @@ void ApplicationManagerImpl::EndNaviStreaming() {
using namespace mobile_apis::AppInterfaceUnregisteredReason;
using namespace mobile_apis::Result;
- uint32_t app_id = navi_app_to_end_stream_.front();
- navi_app_to_end_stream_.pop_front();
+ if (!navi_app_to_end_stream_.empty()) {
+ const uint32_t app_id = navi_app_to_end_stream_.front();
+ navi_app_to_end_stream_.pop_front();
- if (navi_app_to_stop_.end() ==
- std::find(navi_app_to_stop_.begin(), navi_app_to_stop_.end(), app_id)) {
- DisallowStreaming(app_id);
+ if (navi_app_to_stop_.end() ==
+ std::find(navi_app_to_stop_.begin(), navi_app_to_stop_.end(), app_id)) {
+ DisallowStreaming(app_id);
+ }
}
}
@@ -3288,7 +3317,7 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList(
LOG4CXX_INFO(logger_, "Start tts_global_properties_timer_");
tts_global_properties_app_list_lock_.Release();
const uint32_t timeout_ms = 1000;
- tts_global_properties_timer_.Start(timeout_ms, false);
+ tts_global_properties_timer_.Start(timeout_ms, timer::kSingleShot);
return;
}
tts_global_properties_app_list_lock_.Release();
@@ -3449,6 +3478,10 @@ event_engine::EventDispatcher& ApplicationManagerImpl::event_dispatcher() {
return event_dispatcher_;
}
+app_launch::AppLaunchCtrl& ApplicationManagerImpl::app_launch_ctrl() {
+ return *app_launch_ctrl_;
+}
+
const std::string ApplicationManagerImpl::DirectoryTypeToString(
ApplicationManagerImpl::DirectoryType type) const {
DirectoryTypeMap::const_iterator it = dir_type_to_string_map_.find(type);
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 b3b463328f..d8f14fa844 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,15 +32,92 @@
#include <algorithm>
#include <string>
+#include "utils/macro.h"
#include "application_manager/commands/command_request_impl.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
#include "smart_objects/smart_object.h"
-
namespace application_manager {
namespace commands {
+std::string MergeInfos(const ResponseInfo& first_info,
+ const std::string& first_str,
+ const ResponseInfo& second_info,
+ const std::string& second_str) {
+ if ((first_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !second_str.empty()) {
+ return second_str;
+ }
+
+ if ((second_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !first_str.empty()) {
+ return first_str;
+ }
+
+ return MergeInfos(first_str, second_str);
+}
+
+std::string MergeInfos(const std::string& first, const std::string& second) {
+ return first + ((!first.empty() && !second.empty()) ? ", " : "") + second;
+}
+
+std::string MergeInfos(const std::string& first,
+ const std::string& second,
+ const std::string& third) {
+ std::string result = MergeInfos(first, second);
+ return MergeInfos(result, third);
+}
+
+const std::string CreateInfoForUnsupportedResult(
+ HmiInterfaces::InterfaceID interface) {
+ switch (interface) {
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VR): {
+ return "VR is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS): {
+ return "TTS is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_UI): {
+ return "UI is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_Navigation): {
+ return "Navi is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo): {
+ return "VehicleInfo is not supported by system";
+ }
+ default:
+#ifdef ENABLE_LOG
+ CREATE_LOGGERPTR_LOCAL(logger, "Commands");
+ LOG4CXX_WARN(logger,
+ "Could not create info because"
+ " interface isn't valid. Interface is:"
+ << static_cast<int32_t>(interface));
+#endif // ENABLE_LOG
+ return "";
+ }
+}
+
+bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) {
+ if (first.is_ok && second.is_unsupported_resource &&
+ second.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) {
+ return true;
+ }
+ return false;
+}
+
+bool IsResultCodeUnsupported(const ResponseInfo& first,
+ const ResponseInfo& second) {
+ return ((first.is_ok || first.is_invalid_enum) &&
+ second.is_unsupported_resource) ||
+ ((second.is_ok || second.is_invalid_enum) &&
+ first.is_unsupported_resource) ||
+ (first.is_unsupported_resource && second.is_unsupported_resource);
+}
+
struct DisallowedParamsInserter {
DisallowedParamsInserter(smart_objects::SmartObject& response,
mobile_apis::VehicleDataResultCode::eType code)
@@ -194,6 +271,43 @@ bool CommandRequestImpl::CheckSyntax(const std::string& str,
return true;
}
+smart_objects::SmartObject CreateUnsupportedResourceResponse(
+ const hmi_apis::FunctionID::eType function_id,
+ const uint32_t hmi_correlation_id,
+ HmiInterfaces::InterfaceID interface) {
+ smart_objects::SmartObject response(smart_objects::SmartType_Map);
+ smart_objects::SmartObject& params = response[strings::params];
+ params[strings::message_type] = MessageType::kResponse;
+ params[strings::correlation_id] = hmi_correlation_id;
+ params[strings::protocol_type] = CommandImpl::hmi_protocol_type_;
+ params[strings::protocol_version] = CommandImpl::protocol_version_;
+ params[strings::function_id] = function_id;
+ params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ smart_objects::SmartObject& msg_params = response[strings::msg_params];
+ msg_params[strings::info] = CreateInfoForUnsupportedResult(interface);
+ return response;
+}
+
+bool CommandRequestImpl::ProcessHMIInterfacesAvailability(
+ const uint32_t hmi_correlation_id,
+ const hmi_apis::FunctionID::eType& function_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ HmiInterfaces::InterfaceID interface =
+ hmi_interfaces.GetInterfaceFromFunction(function_id);
+ DCHECK(interface != HmiInterfaces::HMI_INTERFACE_INVALID_ENUM);
+ const HmiInterfaces::InterfaceState state =
+ hmi_interfaces.GetInterfaceState(interface);
+ if (HmiInterfaces::STATE_NOT_AVAILABLE == state) {
+ event_engine::Event event(function_id);
+ event.set_smart_object(CreateUnsupportedResourceResponse(
+ function_id, hmi_correlation_id, interface));
+ event.raise(application_manager_.event_dispatcher());
+ return false;
+ }
+ return true;
+}
+
uint32_t CommandRequestImpl::SendHMIRequest(
const hmi_apis::FunctionID::eType& function_id,
const smart_objects::SmartObject* msg_params,
@@ -202,12 +316,6 @@ uint32_t CommandRequestImpl::SendHMIRequest(
const uint32_t hmi_correlation_id =
application_manager_.GetNextHMICorrelationID();
- if (use_events) {
- LOG4CXX_DEBUG(logger_,
- "subscribe_on_event " << function_id << " "
- << hmi_correlation_id);
- subscribe_on_event(function_id, hmi_correlation_id);
- }
smart_objects::SmartObject& request = *result;
request[strings::params][strings::message_type] = MessageType::kRequest;
@@ -222,9 +330,19 @@ uint32_t CommandRequestImpl::SendHMIRequest(
request[strings::msg_params] = *msg_params;
}
- if (!application_manager_.ManageHMICommand(result)) {
- LOG4CXX_ERROR(logger_, "Unable to send request");
- SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY);
+ if (use_events) {
+ LOG4CXX_DEBUG(logger_,
+ "subscribe_on_event " << function_id << " "
+ << hmi_correlation_id);
+ subscribe_on_event(function_id, hmi_correlation_id);
+ }
+ if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) {
+ if (!application_manager_.ManageHMICommand(result)) {
+ LOG4CXX_ERROR(logger_, "Unable to send request");
+ SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY);
+ }
+ } else {
+ LOG4CXX_DEBUG(logger_, "Interface is not available");
}
return hmi_correlation_id;
}
@@ -548,6 +666,111 @@ bool CommandRequestImpl::HasDisallowedParams() const {
(!removed_parameters_permissions_.undefined_params.empty()));
}
+bool CommandRequestImpl::PrepareResultForMobileResponse(
+ hmi_apis::Common_Result::eType result_code,
+ HmiInterfaces::InterfaceID interface) const {
+ using namespace helpers;
+ if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED)) {
+ return true;
+ }
+
+ const HmiInterfaces::InterfaceState state =
+ application_manager_.hmi_interfaces().GetInterfaceState(interface);
+ if ((hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code) &&
+ (HmiInterfaces::STATE_NOT_AVAILABLE != state)) {
+ return true;
+ }
+ return false;
+}
+
+bool CommandRequestImpl::PrepareResultForMobileResponse(
+ ResponseInfo& out_first, ResponseInfo& out_second) const {
+ using namespace helpers;
+
+ out_first.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ out_first.result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED);
+
+ out_second.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ out_second.result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED);
+
+ out_first.is_invalid_enum =
+ hmi_apis::Common_Result::INVALID_ENUM == out_first.result_code;
+
+ out_second.is_invalid_enum =
+ hmi_apis::Common_Result::INVALID_ENUM == out_second.result_code;
+
+ out_first.is_unsupported_resource =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_first.result_code;
+
+ out_second.is_unsupported_resource =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_second.result_code;
+
+ out_first.interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ out_first.interface);
+ out_second.interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ out_second.interface);
+
+ bool result = (out_first.is_ok && out_second.is_ok) ||
+ (out_second.is_invalid_enum && out_first.is_ok) ||
+ (out_first.is_invalid_enum && out_second.is_ok);
+ result = result || CheckResultCode(out_first, out_second);
+ result = result || CheckResultCode(out_second, out_first);
+ return result;
+}
+
+void CommandRequestImpl::GetInfo(
+ const smart_objects::SmartObject& response_from_hmi,
+ std::string& out_info) {
+ if (response_from_hmi[strings::msg_params].keyExists(strings::info)) {
+ if (!response_from_hmi[strings::msg_params][strings::info].empty()) {
+ out_info =
+ response_from_hmi[strings::msg_params][strings::info].asString();
+ }
+ }
+}
+
+mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse(
+ const ResponseInfo& first, const ResponseInfo& second) {
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ if (IsResultCodeUnsupported(first, second)) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ } else {
+ // If response contains erroneous result code SDL need return erroneus
+ // result code.
+ hmi_apis::Common_Result::eType first_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType second_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ if (!first.is_unsupported_resource) {
+ first_result = first.result_code;
+ }
+ if (!second.is_unsupported_resource) {
+ second_result = second.result_code;
+ }
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(first_result, second_result));
+ }
+ return result_code;
+}
+
const CommandParametersPermissions& CommandRequestImpl::parameters_permissions()
const {
return parameters_permissions_;
diff --git a/src/components/application_manager/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/src/commands/hmi/close_popup_request.cc
index b0ab48dd96..d628475438 100644
--- a/src/components/application_manager/src/commands/hmi/close_popup_request.cc
+++ b/src/components/application_manager/src/commands/hmi/close_popup_request.cc
@@ -44,7 +44,6 @@ ClosePopupRequest::~ClosePopupRequest() {}
void ClosePopupRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
index 920c6fbdf9..1e46eab52e 100644
--- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
@@ -58,21 +58,24 @@ AudioStartStreamRequest::~AudioStartStreamRequest() {}
void AudioStartStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
- SetAllowedToTerminate(false);
- subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream,
- correlation_id());
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
- if (app) {
- app->set_audio_streaming_allowed(true);
- SendRequest();
- } else {
+ if (!app) {
LOG4CXX_ERROR(logger_,
"Applcation with hmi_app_id " << application_id()
<< " does not exist");
+ return;
}
+ SetAllowedToTerminate(false);
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream,
+ correlation_id());
+ app->set_audio_streaming_allowed(true);
+ SendRequest();
}
void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
@@ -124,7 +127,8 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
void AudioStartStreamRequest::onTimeOut() {
RetryStartSession();
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void AudioStartStreamRequest::RetryStartSession() {
diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
index d0f1a96282..f86ee8302a 100644
--- a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
@@ -43,7 +43,11 @@ AudioStopStreamRequest::~AudioStopStreamRequest() {}
void AudioStopStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
index 92e972e8f4..4392258a31 100644
--- a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
@@ -38,16 +38,42 @@ namespace commands {
NaviIsReadyRequest::NaviIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
NaviIsReadyRequest::~NaviIsReadyRequest() {}
void NaviIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_IsReady,
+ correlation_id());
SendRequest();
}
+void NaviIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received Navigation_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::Navigation_IsReady);
+ const bool is_available =
+ ChangeInterfaceState(application_manager_,
+ message,
+ HmiInterfaces::HMI_INTERFACE_Navigation);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_navi_cooperating(is_available);
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
index 129900c60f..7daba4258b 100644
--- a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
@@ -43,16 +43,9 @@ NaviIsReadyResponse::~NaviIsReadyResponse() {}
void NaviIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
-
- hmi_capabilities.set_is_navi_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::Navigation_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
index f0104cbaee..9f1c4b7902 100644
--- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
@@ -58,21 +58,24 @@ NaviStartStreamRequest::~NaviStartStreamRequest() {}
void NaviStartStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
- SetAllowedToTerminate(false);
- subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream,
- correlation_id());
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
- if (app) {
- app->set_video_streaming_allowed(true);
- SendRequest();
- } else {
+ if (!app) {
LOG4CXX_ERROR(logger_,
"Applcation with hmi_app_id " << application_id()
<< "does not exist");
+ return;
}
+ SetAllowedToTerminate(false);
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream,
+ correlation_id());
+ app->set_video_streaming_allowed(true);
+ SendRequest();
}
void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
@@ -124,7 +127,8 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
void NaviStartStreamRequest::onTimeOut() {
RetryStartSession();
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void NaviStartStreamRequest::RetryStartSession() {
diff --git a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
index 4b72ff28b4..a40ee13b68 100644
--- a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
@@ -12,7 +12,11 @@ NaviStopStreamRequest::~NaviStopStreamRequest() {}
void NaviStopStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
index 2e7d7e9df1..39d549ac72 100644
--- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
@@ -36,6 +36,29 @@ namespace application_manager {
namespace commands {
+bool CheckAvailabilityHMIInterfaces(ApplicationManager& application_manager,
+ HmiInterfaces::InterfaceID interface) {
+ const HmiInterfaces::InterfaceState state =
+ application_manager.hmi_interfaces().GetInterfaceState(interface);
+ return HmiInterfaces::STATE_NOT_AVAILABLE != state;
+}
+
+bool ChangeInterfaceState(ApplicationManager& application_manager,
+ const smart_objects::SmartObject& response_from_hmi,
+ HmiInterfaces::InterfaceID interface) {
+ if (response_from_hmi[strings::msg_params].keyExists(strings::available)) {
+ const bool is_available =
+ response_from_hmi[strings::msg_params][strings::available].asBool();
+ const HmiInterfaces::InterfaceState interface_state =
+ is_available ? HmiInterfaces::STATE_AVAILABLE
+ : HmiInterfaces::STATE_NOT_AVAILABLE;
+ application_manager.hmi_interfaces().SetInterfaceState(interface,
+ interface_state);
+ return is_available;
+ }
+ return false;
+}
+
RequestToHMI::RequestToHMI(const MessageSharedPtr& message,
ApplicationManager& application_manager)
: CommandImpl(message, application_manager) {
@@ -58,7 +81,6 @@ void RequestToHMI::Run() {}
void RequestToHMI::SendRequest() {
(*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_;
(*message_)[strings::params][strings::protocol_version] = protocol_version_;
-
application_manager_.SendMessageToHMI(message_);
}
diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
index e7fd335808..71e89dd9b9 100644
--- a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/tts_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,68 @@ namespace commands {
TTSIsReadyRequest::TTSIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
TTSIsReadyRequest::~TTSIsReadyRequest() {}
void TTSIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::TTS_IsReady, correlation_id());
SendRequest();
}
+void TTSIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::TTS_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received TTS_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::TTS_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_TTS);
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_tts_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_TTS isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void TTSIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void TTSIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::TTS_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::TTS_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
index 91efb293c9..30e2f4816b 100644
--- a/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
@@ -43,15 +43,9 @@ TTSIsReadyResponse::~TTSIsReadyResponse() {}
void TTSIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_tts_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::TTS_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
index 463ae9d41d..9e27e23d34 100644
--- a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/ui_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,68 @@ namespace commands {
UIIsReadyRequest::UIIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
UIIsReadyRequest::~UIIsReadyRequest() {}
void UIIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::UI_IsReady, correlation_id());
SendRequest();
}
+void UIIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received UI_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_UI);
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_ui_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_UI)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_UI isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void UIIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void UIIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::UI_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::UI_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
index e7fca943bc..088baeb8b2 100644
--- a/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
@@ -43,16 +43,10 @@ UIIsReadyResponse::~UIIsReadyResponse() {}
void UIIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
-
- hmi_capabilities.set_is_ui_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::UI_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
index 3ecc2ffe90..ddd08695a0 100644
--- a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/vi_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,65 @@ namespace commands {
VIIsReadyRequest::VIIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
VIIsReadyRequest::~VIIsReadyRequest() {}
void VIIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::VehicleInfo_IsReady,
+ correlation_id());
SendRequest();
}
+void VIIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_IsReady: {
+ LOG4CXX_DEBUG(logger_, "VehicleInfo_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ const bool is_available =
+ ChangeInterfaceState(application_manager_,
+ message,
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_ivi_cooperating(is_available);
+ application_manager_.GetPolicyHandler().OnVIIsReady();
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
+ LOG4CXX_INFO(
+ logger_,
+ "HmiInterfaces::HMI_INTERFACE_VehicleInfo isn't available");
+ return;
+ }
+ SendMessageToHMI();
+
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void VIIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void VIIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_type(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleType,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_type);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
index 91dae226b6..2f84190494 100644
--- a/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
@@ -43,17 +43,9 @@ VIIsReadyResponse::~VIIsReadyResponse() {}
void VIIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_ivi_cooperating(is_available);
-
- application_manager_.GetPolicyHandler().OnVIIsReady();
+ event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
index 8c5e8bd49b..086b5d4490 100644
--- a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
@@ -38,16 +38,69 @@ namespace commands {
VRIsReadyRequest::VRIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
VRIsReadyRequest::~VRIsReadyRequest() {}
void VRIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::VR_IsReady, correlation_id());
SendRequest();
}
+void VRIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VR_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received VR_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::VR_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_VR);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_vr_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_VR)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_VR isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void VRIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void VRIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VR_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VR_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
index 617742a28c..78e2dae23b 100644
--- a/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
@@ -43,15 +43,9 @@ VRIsReadyResponse::~VRIsReadyResponse() {}
void VRIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_vr_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::VR_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc
index 03bdfadd66..a76f537a24 100644
--- a/src/components/application_manager/src/commands/mobile/add_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -289,6 +289,7 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
return true;
}
+// TODO(AKUTSAN) APPLINK-26973: Refactor AddCommandRequest
void AddCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace helpers;
@@ -314,7 +315,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
+ GetInfo(message, ui_info_);
if (hmi_apis::Common_Result::SUCCESS != ui_result_) {
(*message_)[strings::msg_params].erase(strings::menu_params);
}
@@ -325,7 +326,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
is_vr_received_ = true;
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
+ GetInfo(message, vr_info_);
if (hmi_apis::Common_Result::SUCCESS != vr_result_) {
(*message_)[strings::msg_params].erase(strings::vr_commands);
}
@@ -341,10 +342,6 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
return;
}
- if (hmi_apis::Common_Result::REJECTED == ui_result_) {
- RemoveCommand();
- }
-
smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
@@ -358,37 +355,73 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
- const bool is_ui_ivalid_unsupported =
+ const bool is_ui_invalid_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+ const bool is_vr_unsupported =
+ vr_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ const bool is_ui_unsupported =
+ ui_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
vr_result_,
hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
bool result = (is_no_ui_error && is_no_vr_error) ||
(is_no_ui_error && is_vr_invalid_unsupported) ||
- (is_no_vr_error && is_ui_ivalid_unsupported);
+ (is_no_vr_error && is_ui_invalid_unsupported);
+ LOG4CXX_DEBUG(logger_,
+ "calculated result " << ui_result_ << " " << is_no_ui_error
+ << " " << is_no_vr_error);
const bool is_vr_or_ui_warning =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+ const bool is_vr_or_ui_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ ui_result_,
+ vr_result_);
+
+ const bool is_vr_and_ui_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ ui_result_,
+ vr_result_);
+
if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
result_code = MessageHelper::HMIToMobileResult(ui_result_);
+ } else if (result && is_vr_or_ui_unsupported) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
} else if (is_vr_or_ui_warning) {
result_code = mobile_apis::Result::WARNINGS;
} else {
result_code =
MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) {
+ result_code = MessageHelper::HMIToMobileResult(vr_result_);
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_) {
+ result_code = MessageHelper::HMIToMobileResult(ui_result_);
+ }
+ LOG4CXX_DEBUG(logger_, "HMIToMobileResult " << result_code);
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) {
@@ -410,11 +443,13 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
+ LOG4CXX_DEBUG(logger_, "Result " << result);
}
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ &&
- !is_no_vr_error) {
+ !is_no_vr_error &&
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) {
result_code = vr_result_ == hmi_apis::Common_Result::REJECTED
? mobile_apis::Result::REJECTED
: mobile_apis::Result::GENERIC_ERROR;
@@ -424,9 +459,39 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
+ LOG4CXX_DEBUG(logger_, "Result " << result);
+ }
+
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
+ HmiInterfaces::InterfaceState vr_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VR);
+
+ if (!BothSend() &&
+ ((is_vr_unsupported &&
+ HmiInterfaces::STATE_NOT_AVAILABLE == vr_interface_state) ||
+ (is_ui_unsupported &&
+ HmiInterfaces::STATE_NOT_AVAILABLE == ui_interface_state))) {
+ LOG4CXX_DEBUG(logger_, "!BothSend() && is_vr_or_ui_unsupported");
+ result = false;
+ }
+
+ if (is_vr_and_ui_unsupported) {
+ LOG4CXX_DEBUG(logger_, "UI and VR interface both unsupported");
+ result = false;
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ if (!result) {
+ RemoveCommand();
+ }
+
+ const std::string info = GenerateMobileResponseInfo();
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
@@ -479,6 +544,35 @@ bool AddCommandRequest::BothSend() const {
return send_vr_ && send_ui_;
}
+const std::string AddCommandRequest::GenerateMobileResponseInfo() {
+ // In case if vr_result_ is UNSUPPORTED_RESOURCE vr_info should be on the
+ // first place
+ // In case if ui_result_ is UNSUPPORTED_RESOURCE ui_info should be on the
+ // first place
+ // Other way order is doesn't matter
+
+ HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ HmiInterfaces::InterfaceState ui_interface_state =
+ hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_UI);
+
+ HmiInterfaces::InterfaceState vr_interface_state =
+ hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_VR);
+
+ if ((ui_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (vr_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !vr_info_.empty()) {
+ return vr_info_;
+ }
+
+ if ((vr_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (ui_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !ui_info_.empty()) {
+ return ui_info_;
+ }
+
+ return MergeInfos(ui_info_, vr_info_);
+}
+
void AddCommandRequest::RemoveCommand() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application_manager_.application(connection_key());
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
index 83f137ac19..6838d1af7d 100644
--- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/add_sub_menu_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application.h"
#include "utils/helpers.h"
@@ -98,19 +99,17 @@ void AddSubMenuRequest::Run() {
void AddSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_AddSubMenu: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
ApplicationSharedPtr application =
application_manager_.application(connection_key());
@@ -125,7 +124,10 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
(*message_)[strings::msg_params][strings::menu_id].asInt(),
(*message_)[strings::msg_params]);
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
index ea00bc8d70..b151990289 100644
--- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
@@ -1,22 +1,17 @@
/*
Copyright (c) 2016, 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
@@ -33,11 +28,9 @@
#include <cstring>
#include <string>
#include "application_manager/commands/mobile/alert_maneuver_request.h"
-
#include "application_manager/application_impl.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/message_helper.h"
-#include "utils/helpers.h"
namespace application_manager {
@@ -46,8 +39,8 @@ namespace commands {
AlertManeuverRequest::AlertManeuverRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM)
- , navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) {
+ , tts_speak_result_code_(hmi_apis::Common_Result::INVALID_ENUM)
+ , navi_alert_maneuver_result_code_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -136,66 +129,24 @@ void AlertManeuverRequest::Run() {
void AlertManeuverRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
- bool is_tts_ok;
- bool is_no_navi_error;
- hmi_apis::Common_Result::eType tts_result;
- hmi_apis::Common_Result::eType navi_result;
hmi_apis::FunctionID::eType event_id = event.id();
switch (event_id) {
case hmi_apis::FunctionID::Navigation_AlertManeuver: {
LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event");
-
pending_requests_.Remove(event_id);
-
navi_alert_maneuver_result_code_ =
- static_cast<mobile_apis::Result::eType>(
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- navi_result =
- MessageHelper::MobileToHMIResult(navi_alert_maneuver_result_code_);
- is_no_navi_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- navi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_navi_success =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- navi_result, hmi_apis::Common_Result::SUCCESS);
- if (is_navi_success) {
- info_navi_ =
- message[strings::msg_params][hmi_response::message].asString();
- } else {
- info_navi_ = message[strings::msg_params][strings::info].asString();
- }
+ GetInfo(message, info_navi_);
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
-
pending_requests_.Remove(event_id);
-
- tts_speak_result_code_ = static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- tts_result = MessageHelper::MobileToHMIResult(tts_speak_result_code_);
-
- is_tts_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_tts_success =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result, hmi_apis::Common_Result::SUCCESS);
- if (is_tts_success) {
- info_tts_ =
- message[strings::msg_params][hmi_response::message].asString();
- } else {
- info_tts_ = message[strings::msg_params][strings::info].asString();
- }
+ GetInfo(message, info_tts_);
break;
}
case hmi_apis::FunctionID::TTS_OnResetTimeout: {
@@ -219,32 +170,9 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
"AlertManeuverRequest still waiting.");
return;
}
-
- const bool result =
- (is_tts_ok && is_no_navi_error) ||
- (hmi_apis::Common_Result::SUCCESS == tts_result &&
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == navi_result);
-
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- std::max(tts_speak_result_code_, navi_alert_maneuver_result_code_));
-
std::string return_info;
-
- const bool is_tts_or_navi_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, tts_result, navi_result);
-
- if (result && (is_tts_or_navi_warning ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = std::string("Unsupported phoneme type sent in a prompt");
- }
-
- if (!info_tts_.empty() && !info_navi_.empty()) {
- info_tts_ += ". ";
- }
- return_info = info_tts_ + info_navi_;
+ mobile_apis::Result::eType result_code;
+ const bool result = PrepareResponseParameters(result_code, return_info);
bool must_be_empty_info = false;
if (return_info.find("\n") != std::string::npos ||
return_info.find("\t") != std::string::npos) {
@@ -256,6 +184,36 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
&(message[strings::msg_params]));
}
+bool AlertManeuverRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& return_info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ application_manager::commands::ResponseInfo navigation_alert_info(
+ navi_alert_maneuver_result_code_,
+ HmiInterfaces::HMI_INTERFACE_Navigation);
+
+ application_manager::commands::ResponseInfo tts_alert_info(
+ tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info);
+
+ if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ tts_speak_result_code_ &&
+ (HmiInterfaces::STATE_AVAILABLE ==
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)))) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt");
+ return result;
+ }
+ result_code =
+ PrepareResultCodeForResponse(navigation_alert_info, tts_alert_info);
+ return_info =
+ MergeInfos(navigation_alert_info, info_navi_, tts_alert_info, info_tts_);
+ return result;
+}
+
bool AlertManeuverRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc
index 53910a05b7..48eb45f9ce 100644
--- a/src/components/application_manager/src/commands/mobile/alert_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_request.cc
@@ -55,8 +55,8 @@ AlertRequest::AlertRequest(const MessageSharedPtr& message,
, awaiting_tts_stop_speaking_response_(false)
, is_alert_succeeded_(false)
, is_ui_alert_sent_(false)
- , alert_result_(mobile_apis::Result::INVALID_ENUM)
- , tts_speak_result_(mobile_apis::Result::INVALID_ENUM) {
+ , alert_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -131,8 +131,6 @@ void AlertRequest::onTimeOut() {
void AlertRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
-
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -153,26 +151,21 @@ void AlertRequest::on_event(const event_engine::Event& event) {
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert);
awaiting_ui_alert_response_ = false;
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
- if (awaiting_tts_speak_response_) {
+ if (awaiting_tts_speak_response_ &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) {
awaiting_tts_stop_speaking_response_ = true;
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true);
}
+ alert_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
// Mobile Alert request is successful when UI_Alert is successful
-
- const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::WARNINGS);
-
- is_alert_succeeded_ = is_alert_ok;
- alert_result_ = result_code;
alert_response_params_ = message[strings::msg_params];
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
@@ -180,8 +173,9 @@ void AlertRequest::on_event(const event_engine::Event& event) {
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak);
awaiting_tts_speak_response_ = false;
- tts_speak_result_ = static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_StopSpeaking: {
@@ -200,56 +194,44 @@ void AlertRequest::on_event(const event_engine::Event& event) {
if (HasHmiResponsesToWait()) {
return;
}
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string info;
+ const bool result = PrepareResponseParameters(result_code, info);
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ &alert_response_params_);
+}
- const bool is_tts_alert_unsupported =
- Compare<mobile_api::Result::eType, EQ, ALL>(
- mobile_api::Result::UNSUPPORTED_RESOURCE,
- tts_speak_result_,
- alert_result_);
-
- const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- alert_result_, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
-
- std::string response_info;
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
- !is_ui_alert_sent_) {
- is_alert_succeeded_ = false;
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if (is_tts_alert_unsupported) {
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info =
- "Unsupported phoneme type sent in a prompt and "
- "unsupported image sent in soft buttons";
- } else if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
- is_alert_ok) {
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if (mobile_apis::Result::SUCCESS == tts_speak_result_ &&
- (mobile_apis::Result::INVALID_ENUM == alert_result_ &&
- !is_ui_alert_sent_)) {
- alert_result_ = mobile_apis::Result::SUCCESS;
- is_alert_succeeded_ = true;
- }
-
- const bool is_tts_not_ok =
- Compare<mobile_api::Result::eType, EQ, ONE>(tts_speak_result_,
- mobile_api::Result::ABORTED,
- mobile_api::Result::REJECTED);
-
- if (is_tts_not_ok && !is_ui_alert_sent_) {
- is_alert_succeeded_ = false;
- alert_result_ = tts_speak_result_;
+bool AlertRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ ResponseInfo ui_alert_info(alert_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo tts_alert_info(tts_speak_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info);
+
+ /* result=false if UI interface is ok and TTS interface = UNSUPPORTED_RESOURCE
+ * and sdl receive TTS.IsReady=true or SDL doesn't receive responce for
+ * TTS.IsReady.
+ */
+ if (result && ui_alert_info.is_ok && tts_alert_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != tts_alert_info.interface_state) {
+ result = false;
}
-
- if (mobile_apis::Result::WARNINGS == tts_speak_result_) {
- alert_result_ = mobile_apis::Result::WARNINGS;
+ result_code = mobile_apis::Result::WARNINGS;
+ if ((ui_alert_info.is_ok || ui_alert_info.is_invalid_enum) &&
+ tts_alert_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) {
+ tts_response_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(
+ ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_);
+ return result;
}
-
- SendResponse(is_alert_succeeded_,
- alert_result_,
- response_info.empty() ? NULL : response_info.c_str(),
- &alert_response_params_);
+ result_code = PrepareResultCodeForResponse(ui_alert_info, tts_alert_info);
+ info = MergeInfos(
+ ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_);
+ return result;
}
bool AlertRequest::Validate(uint32_t app_id) {
@@ -263,7 +245,7 @@ bool AlertRequest::Validate(uint32_t app_id) {
}
if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() &&
- app->IsCommandLimitsExceeded(
+ app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::POLICY_TABLE)) {
LOG4CXX_ERROR(logger_, "Alert frequency is too high.");
diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
index 63339fdc33..f1f3b93e24 100644
--- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc
+++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
@@ -38,6 +38,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace {
namespace custom_str = utils::custom_string;
@@ -69,9 +70,6 @@ void ChangeRegistrationRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace smart_objects;
- const HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -91,18 +89,6 @@ void ChangeRegistrationRequest::Run() {
return;
}
- if (!hmi_capabilities.is_ui_cooperating()) {
- ui_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
- if (!hmi_capabilities.is_vr_cooperating()) {
- vr_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
- if (!hmi_capabilities.is_tts_cooperating()) {
- tts_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
SmartObject& msg_params = (*message_)[strings::msg_params];
const int32_t hmi_language =
@@ -174,15 +160,6 @@ void ChangeRegistrationRequest::Run() {
hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true);
}
-bool ChangeRegistrationRequest::AllHmiResponsesSuccess(
- const hmi_apis::Common_Result::eType ui,
- const hmi_apis::Common_Result::eType vr,
- const hmi_apis::Common_Result::eType tts) {
- return hmi_apis::Common_Result::SUCCESS == ui &&
- hmi_apis::Common_Result::SUCCESS == vr &&
- hmi_apis::Common_Result::SUCCESS == tts;
-}
-
void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
@@ -195,6 +172,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::VR_ChangeRegistration: {
@@ -202,6 +180,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, vr_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_ChangeRegistration: {
@@ -209,6 +188,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
default: {
@@ -237,16 +217,16 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
application->set_language(static_cast<mobile_api::Language::eType>(
(*message_)[strings::msg_params][strings::language].asInt()));
}
-
- int32_t greates_result_code =
- std::max(std::max(ui_result_, vr_result_), tts_result_);
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string response_info;
+ const bool result = PrepareResponseParameters(result_code, response_info);
(*message_)[strings::params][strings::function_id] =
mobile_apis::FunctionID::eType::ChangeRegistrationID;
- SendResponse(AllHmiResponsesSuccess(ui_result_, vr_result_, tts_result_),
- static_cast<mobile_apis::Result::eType>(greates_result_code),
- NULL,
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
} else {
LOG4CXX_INFO(logger_,
@@ -255,6 +235,137 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
}
}
+namespace {
+void CheckInfo(std::string& str) {
+ if (std::string::npos != str.find("is not supported by system")) {
+ str.clear();
+ }
+}
+} // namespace
+
+bool ChangeRegistrationRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& response_info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+ const bool is_tts_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ tts_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_ui_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_vr_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ vr_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_tts_ui_vr_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ tts_result_,
+ ui_result_,
+ vr_result_);
+
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ const HmiInterfaces::InterfaceState tts_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS);
+ const HmiInterfaces::InterfaceState vr_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_VR);
+ const HmiInterfaces::InterfaceState ui_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_UI);
+
+ ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+
+ ResponseInfo tts_properties_info(tts_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ ResponseInfo vr_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_VR);
+
+ bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported &&
+ is_ui_succeeded_unsupported && is_vr_succeeded_unsupported);
+
+ const bool is_tts_or_ui_or_vr_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ tts_result_,
+ ui_result_,
+ vr_result_);
+
+ if ((result && is_tts_or_ui_or_vr_unsupported)) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ result =
+ PrepareResultForMobileResponse(ui_properties_info,
+ tts_properties_info) &&
+ PrepareResultForMobileResponse(tts_properties_info, vr_properties_info);
+ } else {
+ // If response contains erroneous result code SDL need return erroneus
+ // result code.
+ hmi_apis::Common_Result::eType ui_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType vr_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType tts_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != ui_result_) {
+ ui_result = ui_result_;
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) {
+ vr_result = vr_result_;
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != tts_result_) {
+ tts_result = tts_result_;
+ }
+ result_code = MessageHelper::HMIToMobileResult(
+ std::max(std::max(ui_result, vr_result), tts_result));
+ }
+
+ const bool is_tts_state_available =
+ tts_state == HmiInterfaces::STATE_AVAILABLE;
+ const bool is_vr_state_available = vr_state == HmiInterfaces::STATE_AVAILABLE;
+ const bool is_ui_state_available = ui_state == HmiInterfaces::STATE_AVAILABLE;
+
+ const bool is_tts_hmi_info =
+ is_tts_state_available && !tts_response_info_.empty();
+ const bool is_vr_hmi_info =
+ is_vr_state_available && !vr_response_info_.empty();
+ const bool is_ui_hmi_info =
+ is_ui_state_available && !ui_response_info_.empty();
+
+ if (is_tts_hmi_info || is_vr_hmi_info || is_ui_hmi_info) {
+ if (!is_tts_hmi_info)
+ CheckInfo(tts_response_info_);
+ if (!is_vr_hmi_info)
+ CheckInfo(ui_response_info_);
+ if (!is_ui_hmi_info)
+ CheckInfo(vr_response_info_);
+ }
+
+ response_info =
+ MergeInfos(ui_response_info_, vr_response_info_, tts_response_info_);
+ return result;
+}
+
bool ChangeRegistrationRequest::IsLanguageSupportedByUI(
const int32_t& hmi_display_lang) {
const HMICapabilities& hmi_capabilities =
diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
index 72eec3edb7..fa0d15252e 100644
--- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -51,7 +51,8 @@ CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest(
: CommandRequestImpl(message, application_manager)
, expected_chs_count_(0)
, received_chs_count_(0)
- , error_from_hmi_(false) {}
+ , error_from_hmi_(false)
+ , vr_commands_lock_(true) {}
CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -288,6 +289,48 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_);
}
+void CreateInteractionChoiceSetRequest::ProcessHmiError(
+ const hmi_apis::Common_Result::eType vr_result) {
+ LOG4CXX_DEBUG(logger_,
+ "Hmi response is not Success: "
+ << vr_result << ". Stop sending VRAddCommand requests");
+ if (!error_from_hmi_) {
+ error_from_hmi_ = true;
+ std::string info =
+ vr_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE
+ ? "VR is not supported by system"
+ : "";
+ SendResponse(false, GetMobileResultCode(vr_result), info.c_str());
+ }
+}
+
+bool CreateInteractionChoiceSetRequest::ProcessSuccesfulHMIResponse(
+ const uint32_t corr_id) {
+ SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
+ if (sent_commands_map_.end() == it) {
+ LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
+ return false;
+ }
+ VRCommandInfo& vr_command = it->second;
+ vr_command.succesful_response_received_ = true;
+ return true;
+}
+
+void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() {
+ received_chs_count_++;
+ LOG4CXX_DEBUG(logger_,
+ "Got VR.AddCommand response, there are "
+ << expected_chs_count_ - received_chs_count_
+ << " more to wait.");
+ if (received_chs_count_ < expected_chs_count_) {
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
+ LOG4CXX_DEBUG(logger_, "Timeout for request was updated");
+ } else {
+ OnAllHMIResponsesReceived();
+ }
+}
+
void CreateInteractionChoiceSetRequest::on_event(
const event_engine::Event& event) {
using namespace hmi_apis;
@@ -295,50 +338,24 @@ void CreateInteractionChoiceSetRequest::on_event(
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
+ const Common_Result::eType result = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ const bool is_no_error = Compare<Common_Result::eType, EQ, ONE>(
+ result, Common_Result::SUCCESS, Common_Result::WARNINGS);
+ uint32_t corr_id = static_cast<uint32_t>(
+ message[strings::params][strings::correlation_id].asUInt());
if (event.id() == hmi_apis::FunctionID::VR_AddCommand) {
- received_chs_count_++;
- LOG4CXX_DEBUG(logger_,
- "Got VR.AddCommand response, there are "
- << expected_chs_count_ - received_chs_count_
- << " more to wait.");
-
- uint32_t corr_id = static_cast<uint32_t>(
- message[strings::params][strings::correlation_id].asUInt());
{
sync_primitives::AutoLock commands_lock(vr_commands_lock_);
- SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
- if (sent_commands_map_.end() == it) {
- LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
- return;
- }
-
- Common_Result::eType vr_result = static_cast<Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
- const bool is_vr_no_error = Compare<Common_Result::eType, EQ, ONE>(
- vr_result, Common_Result::SUCCESS, Common_Result::WARNINGS);
-
- if (is_vr_no_error) {
- VRCommandInfo& vr_command = it->second;
- vr_command.succesful_response_received_ = true;
- } else {
- LOG4CXX_DEBUG(logger_,
- "Hmi response is not Success: "
- << vr_result
- << ". Stop sending VRAddCommand requests");
- if (!error_from_hmi_) {
- error_from_hmi_ = true;
- SendResponse(false, GetMobileResultCode(vr_result));
+ if (is_no_error) {
+ if (!ProcessSuccesfulHMIResponse(corr_id)) {
+ return;
}
+ } else {
+ ProcessHmiError(result);
}
}
- if (received_chs_count_ < expected_chs_count_) {
- application_manager_.updateRequestTimeout(
- connection_key(), correlation_id(), default_timeout());
- LOG4CXX_DEBUG(logger_, "Timeout for request was updated");
- return;
- }
- OnAllHMIResponsesReceived();
+ CountReceivedVRResponses();
}
}
@@ -354,7 +371,8 @@ void CreateInteractionChoiceSetRequest::onTimeOut() {
// according to SDLAQ-CRS-2976
sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_);
is_timed_out_ = true;
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void CreateInteractionChoiceSetRequest::DeleteChoices() {
@@ -380,7 +398,7 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param);
} else {
LOG4CXX_WARN(logger_,
- "Succesfull response has not been received for cmd_id = "
+ "succesful response has not been received for cmd_id = "
<< vr_command_info.cmd_id_);
}
}
@@ -404,7 +422,8 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
DeleteChoices();
}
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
index 9a7b92f7b8..103e87fa00 100644
--- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
@@ -94,16 +94,19 @@ void DeleteCommandRequest::Run() {
if ((*command).keyExists(strings::vr_commands)) {
++chaining_counter;
}
-
+ /* Need to set all flags before sending request to HMI
+ * for correct processing this flags in method on_event */
if ((*command).keyExists(strings::menu_params)) {
is_ui_send_ = true;
-
- SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
}
// check vr params
if ((*command).keyExists(strings::vr_commands)) {
is_vr_send_ = true;
-
+ }
+ if (is_ui_send_) {
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
+ }
+ if (is_vr_send_) {
// VR params
msg_params[strings::grammar_id] = application->get_grammar_id();
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
@@ -111,29 +114,52 @@ void DeleteCommandRequest::Run() {
}
}
+bool DeleteCommandRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ using namespace helpers;
+ ResponseInfo ui_delete_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo vr_delete_info(vr_result_, HmiInterfaces::HMI_INTERFACE_VR);
+ const bool result =
+ PrepareResultForMobileResponse(ui_delete_info, vr_delete_info);
+
+ const bool is_vr_or_ui_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+ info = MergeInfos(ui_delete_info, ui_info_, vr_delete_info, vr_info_);
+ if (is_vr_or_ui_warning && !ui_delete_info.is_unsupported_resource &&
+ !vr_delete_info.is_unsupported_resource) {
+ LOG4CXX_DEBUG(logger_, "VR or UI result is warning");
+ result_code = mobile_apis::Result::WARNINGS;
+ return result;
+ }
+ result_code = PrepareResultCodeForResponse(ui_delete_info, vr_delete_info);
+ LOG4CXX_DEBUG(logger_, "Result is " << (result ? "true" : "false"));
+ return result;
+}
+
void DeleteCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
-
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteCommand: {
is_ui_received_ = true;
- const int result = message[strings::params][hmi_response::code].asInt();
- ui_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
LOG4CXX_DEBUG(logger_,
"Received UI_DeleteCommand event with result "
<< MessageHelper::HMIResultToString(ui_result_));
+ GetInfo(message, ui_info_);
break;
}
case hmi_apis::FunctionID::VR_DeleteCommand: {
is_vr_received_ = true;
- const int result = message[strings::params][hmi_response::code].asInt();
- vr_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
LOG4CXX_DEBUG(logger_,
"Received VR_DeleteCommand event with result "
<< MessageHelper::HMIResultToString(vr_result_));
+ GetInfo(message, vr_info_);
break;
}
default: {
@@ -167,51 +193,14 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
<< connection_key());
return;
}
-
- const bool is_vr_success_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- vr_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_ui_success_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_vr_ui_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
- hmi_apis::Common_Result::INVALID_ENUM, vr_result_, ui_result_);
-
- const bool is_vr_or_ui_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
-
- const bool result =
- // In case of UI/VR is SUCCESS and other is SUCCESS/INVALID_ENUM
- (is_vr_success_invalid && is_ui_success_invalid && !is_vr_ui_invalid) ||
- // or one of them is WARNINGS
- is_vr_or_ui_warning;
-
- LOG4CXX_DEBUG(logger_, "Result code is " << (result ? "true" : "false"));
-
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string info;
+ const bool result = PrepareResponseParameters(result_code, info);
if (result) {
application->RemoveCommand(msg_params[strings::cmd_id].asInt());
}
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
- result_code = MessageHelper::HMIToMobileResult(vr_result_);
- } else if (is_vr_or_ui_warning) {
- LOG4CXX_DEBUG(logger_, "VR or UI result is warning");
- result_code = mobile_apis::Result::WARNINGS;
- } else {
- result_code =
- MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
- }
-
- SendResponse(result, result_code, NULL, &msg_params);
+ SendResponse(
+ result, result_code, info.empty() ? NULL : info.c_str(), &msg_params);
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
index bdb5521921..57748e6feb 100644
--- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/delete_sub_menu_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
#include "utils/helpers.h"
@@ -138,19 +139,17 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(
void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteSubMenu: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
ApplicationSharedPtr application =
application_manager_.application(connection_key());
@@ -168,7 +167,10 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
(*message_)[strings::msg_params][strings::menu_id].asInt());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
index 5252ea0e33..5c5d250026 100644
--- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
@@ -37,6 +37,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -93,13 +94,17 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
index 5a922f595f..f67d1f2434 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -32,6 +32,7 @@
*/
#include "application_manager/commands/mobile/end_audio_pass_thru_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -55,12 +56,13 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_EndAudioPassThru: {
- mobile_apis::Result::eType mobile_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
-
- bool result = mobile_apis::Result::SUCCESS == mobile_code;
-
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
if (result) {
bool ended_successfully = application_manager_.EndAudioPassThrough();
if (ended_successfully) {
@@ -68,7 +70,10 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
}
}
- SendResponse(result, mobile_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
index 80bc89f853..d98207c772 100644
--- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
@@ -35,6 +35,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -80,13 +81,19 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetDTCs: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
index 8b7010c6a1..25e2da3eb6 100644
--- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
@@ -230,7 +230,7 @@ void GetVehicleDataRequest::Run() {
return;
}
- if (app->IsCommandLimitsExceeded(
+ if (app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high.");
@@ -266,27 +266,28 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = false;
- if (mobile_apis::Result::SUCCESS == result_code ||
- (hmi_apis::Common_Result::DATA_NOT_AVAILABLE ==
- static_cast<hmi_apis::Common_Result::eType>(result_code) &&
- message[strings::msg_params].length() > 1)) {
- result = true;
- }
- const char* info = NULL;
- std::string error_message;
+ bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
+ result = result ||
+ ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) &&
+ (message[strings::msg_params].length() > 1));
+
if (true ==
message[strings::msg_params].keyExists(hmi_response::method)) {
message[strings::msg_params].erase(hmi_response::method);
}
if (true == message[strings::params].keyExists(strings::error_msg)) {
- error_message = message[strings::params][strings::error_msg].asString();
- info = error_message.c_str();
+ response_info = message[strings::params][strings::error_msg].asString();
}
- SendResponse(result, result_code, info, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
index 9baf747ee4..198964a333 100644
--- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/get_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -35,16 +36,21 @@ void GetWayPointsRequest::Run() {
void GetWayPointsRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager_.application(connection_key());
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_GetWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
index a4167a802e..09c407b8b5 100644
--- a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
@@ -48,9 +48,6 @@ OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {}
void OnPermissionsChangeNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- (*message_)[strings::params][strings::message_type] =
- static_cast<int32_t>(application_manager::MessageType::kNotification);
-
SendNotification();
}
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
index d595119d45..9f5fd937f9 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -47,8 +47,10 @@ namespace str = strings;
PerformAudioPassThruRequest::PerformAudioPassThruRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , is_active_tts_speak_(false)
- , result_tts_speak_(mobile_apis::Result::SUCCESS) {
+ , awaiting_tts_speak_response_(false)
+ , awaiting_ui_response_(false)
+ , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM)
+ , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -92,7 +94,10 @@ void PerformAudioPassThruRequest::Run() {
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
+ // According with new implementation processing of UNSUPPORTE_RESOURCE
+ // need set flag before sending to hmi
+ awaiting_ui_response_ = true;
if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
(0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
// In case TTS Speak, subscribe on notification
@@ -114,56 +119,41 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru");
+ awaiting_ui_response_ = false;
- if (!WaitTTSSpeak()) {
- LOG4CXX_DEBUG(logger_, "TTS.Speak is absent");
- return;
- }
-
- mobile_apis::Result::eType mobile_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
+ result_ui_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, ui_info_);
// in case perform audio is started by other request skip stopping
- if (mobile_apis::Result::REJECTED == mobile_code) {
+ if (hmi_apis::Common_Result::REJECTED == result_ui_) {
LOG4CXX_ERROR(logger_, "Request was rejected");
- SendResponse(false, mobile_code, NULL, &(message[strings::msg_params]));
+ SendResponse(false,
+ MessageHelper::HMIToMobileResult(result_ui_),
+ NULL,
+ &(message[strings::msg_params]));
return;
}
-
FinishTTSSpeak();
-
- std::string return_info;
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- mobile_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::RETRY,
- mobile_apis::Result::WARNINGS);
-
- const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- mobile_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::WARNINGS);
-
- if (is_result_ok &&
- mobile_apis::Result::UNSUPPORTED_RESOURCE == result_tts_speak_) {
- mobile_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- }
-
- SendResponse(result,
- mobile_code,
- return_info.empty() ? NULL : return_info.c_str(),
- &(message[strings::msg_params]));
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
- result_tts_speak_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- is_active_tts_speak_ = false;
- if (mobile_apis::Result::SUCCESS == result_tts_speak_) {
+ result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, tts_info_);
+ awaiting_tts_speak_response_ = false;
+ const bool is_tts_speak_success_unsuported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ result_tts_speak_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ if (is_tts_speak_success_unsuported) {
SendRecordStartNotification();
StartMicrophoneRecording();
@@ -185,6 +175,40 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
return;
}
}
+ if (IsWaitingHMIResponse()) {
+ return;
+ }
+
+ std::string return_info;
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ const bool result = PrepareResponseParameters(result_code, return_info);
+
+ SendResponse(result,
+ result_code,
+ return_info.empty() ? NULL : return_info.c_str(),
+ &(message[strings::msg_params]));
+}
+
+bool PerformAudioPassThruRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ResponseInfo ui_perform_info(result_ui_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo tts_perform_info(result_tts_speak_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(ui_perform_info, tts_perform_info);
+
+ if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) {
+ result_code = mobile_apis::Result::WARNINGS;
+ tts_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+ return result;
+ }
+ result_code = PrepareResultCodeForResponse(ui_perform_info, tts_perform_info);
+ info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+ return result;
}
void PerformAudioPassThruRequest::SendSpeakRequest() {
@@ -194,23 +218,19 @@ void PerformAudioPassThruRequest::SendSpeakRequest() {
using namespace smart_objects;
SmartObject msg_params = smart_objects::SmartObject(SmartType_Map);
-
- if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
- (0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
- for (uint32_t i = 0;
- i < (*message_)[str::msg_params][str::initial_prompt].length();
- ++i) {
- msg_params[hmi_request::tts_chunks][i][str::text] =
- (*message_)[str::msg_params][str::initial_prompt][i][str::text];
- msg_params[hmi_request::tts_chunks][i][str::type] =
- (*message_)[str::msg_params][str::initial_prompt][i][str::type];
- }
- // app_id
- msg_params[strings::app_id] = connection_key();
- msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU;
- is_active_tts_speak_ = true;
- SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
+ for (uint32_t i = 0;
+ i < (*message_)[str::msg_params][str::initial_prompt].length();
+ ++i) {
+ msg_params[hmi_request::tts_chunks][i][str::text] =
+ (*message_)[str::msg_params][str::initial_prompt][i][str::text];
+ msg_params[hmi_request::tts_chunks][i][str::type] =
+ (*message_)[str::msg_params][str::initial_prompt][i][str::type];
}
+ // app_id
+ msg_params[strings::app_id] = connection_key();
+ msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU;
+ awaiting_tts_speak_response_ = true;
+ SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
}
void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
@@ -333,37 +353,16 @@ void PerformAudioPassThruRequest::FinishTTSSpeak() {
LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
application_manager_.StopAudioPassThru(connection_key());
}
- if (!is_active_tts_speak_) {
+ if (!awaiting_tts_speak_response_) {
LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
return;
}
- is_active_tts_speak_ = false;
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL);
}
-bool PerformAudioPassThruRequest::WaitTTSSpeak() {
+bool PerformAudioPassThruRequest::IsWaitingHMIResponse() {
LOG4CXX_AUTO_TRACE(logger_);
- uint64_t default_timeout_msec =
- application_manager_.get_settings().default_timeout();
- const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
-
- // Waiting for TTS_Speak
- while (is_active_tts_speak_) {
- uint64_t difference_between_start_current_time =
- date_time::DateTime::calculateTimeSpan(start_time);
- // Send GENERIC_ERROR after default timeout
- if (difference_between_start_current_time > default_timeout_msec) {
- LOG4CXX_WARN(logger_, "Expired timeout for TTS.Speak response");
- // Don't use onTimeOut(), because default_timeout_ is bigger than
- // Default time in *.ini file
- FinishTTSSpeak();
- SendResponse(false,
- mobile_apis::Result::eType::GENERIC_ERROR,
- "Expired timeout for TTS.Speak response");
- return false;
- }
- }
- return true;
+ return awaiting_tts_speak_response_ || awaiting_ui_response_;
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
index 39ad51e822..d094c3d80e 100644
--- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
@@ -57,13 +57,11 @@ PerformInteractionRequest::PerformInteractionRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
, interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM)
- , ui_response_recived_(false)
- , vr_response_recived_(false)
- , ui_result_(false)
- , vr_result_(false)
+ , ui_response_received_(false)
+ , vr_response_received_(false)
, app_pi_was_active_before_(false)
- , vr_resultCode_(mobile_apis::Result::INVALID_ENUM)
- , ui_resultCode_(mobile_apis::Result::INVALID_ENUM) {
+ , vr_result_code_(hmi_apis::Common_Result::INVALID_ENUM)
+ , ui_result_code_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand);
subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress);
@@ -228,22 +226,24 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::UI_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event");
- ui_response_recived_ = true;
+ ui_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
- ui_resultCode_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- ProcessPerformInteractionResponse(event.smart_object(), msg_param);
+ ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, ui_info_);
+ ProcessUIResponse(event.smart_object(), msg_param);
break;
}
case hmi_apis::FunctionID::VR_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction");
- vr_response_recived_ = true;
+ vr_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction);
- vr_resultCode_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- ProcessVRResponse(event.smart_object(), msg_param);
+ vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, vr_info_);
+ if (ProcessVRResponse(event.smart_object(), msg_param)) {
+ return;
+ }
break;
}
default: {
@@ -252,8 +252,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
}
- if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
- !HasHMIResponsesToWait()) {
+ if (!HasHMIResponsesToWait()) {
LOG4CXX_DEBUG(logger_, "Send response in BOTH iteraction mode");
SendBothModeResponse(msg_param);
}
@@ -264,7 +263,8 @@ void PerformInteractionRequest::onTimeOut() {
switch (interaction_mode_) {
case mobile_apis::InteractionMode::BOTH: {
- if (true == vr_response_recived_) {
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH");
+ if (true == vr_response_received_) {
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
@@ -275,11 +275,14 @@ void PerformInteractionRequest::onTimeOut() {
break;
}
case mobile_apis::InteractionMode::VR_ONLY: {
- application_manager_.updateRequestTimeout(
- connection_key(), correlation_id(), default_timeout());
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY");
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ DisablePerformInteraction();
+ CommandRequestImpl::onTimeOut();
break;
}
case mobile_apis::InteractionMode::MANUAL_ONLY: {
+ LOG4CXX_DEBUG(logger_, "InteractionMode: MANUAL_ONLY");
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
@@ -292,12 +295,12 @@ void PerformInteractionRequest::onTimeOut() {
};
}
-void PerformInteractionRequest::ProcessVRResponse(
+bool PerformInteractionRequest::ProcessVRResponse(
const smart_objects::SmartObject& message,
smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace hmi_apis;
using namespace mobile_apis;
- using namespace mobile_apis::Result;
using namespace smart_objects;
using namespace helpers;
@@ -305,37 +308,36 @@ void PerformInteractionRequest::ProcessVRResponse(
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
+ return false;
}
- CheckResponseResultCode();
msg_params[strings::trigger_source] =
static_cast<int32_t>(TriggerSource::TS_VR);
- const bool is_vr_aborted_timeout =
- Compare<Result::eType, EQ, ONE>(vr_resultCode_, ABORTED, TIMED_OUT);
+ const bool is_vr_aborted_timeout = Compare<Common_Result::eType, EQ, ONE>(
+ vr_result_code_, Common_Result::ABORTED, Common_Result::TIMED_OUT);
if (is_vr_aborted_timeout) {
LOG4CXX_DEBUG(logger_, "VR response aborted");
if (InteractionMode::VR_ONLY == interaction_mode_) {
LOG4CXX_DEBUG(logger_, "Aborted or Timeout Send Close Popup");
TerminatePerformInteraction();
- SendResponse(false, vr_resultCode_);
- return;
+ SendResponse(false, MessageHelper::HMIToMobileResult(vr_result_code_));
+ return true;
}
LOG4CXX_DEBUG(logger_, "Update timeout for UI");
application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
- return;
+ return false;
}
- if (SUCCESS == vr_resultCode_ &&
+ if (Common_Result::SUCCESS == vr_result_code_ &&
InteractionMode::MANUAL_ONLY == interaction_mode_) {
LOG4CXX_DEBUG(logger_,
"VR response SUCCESS in MANUAL_ONLY mode "
<< "Wait for UI response");
// in case MANUAL_ONLY mode VR.PI SUCCESS just return
- return;
+ return false;
}
const SmartObject& hmi_msg_params = message[strings::msg_params];
@@ -345,26 +347,15 @@ void PerformInteractionRequest::ProcessVRResponse(
LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI");
TerminatePerformInteraction();
SendResponse(
- false, GENERIC_ERROR, "Wrong choiceID was received from HMI");
- return;
+ false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI");
+ return true;
}
msg_params[strings::choice_id] = choise_id;
}
-
- vr_result_ = true;
-
- if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
- mobile_apis::Result::SUCCESS != vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response isn't SUCCESS in BOTH mode");
- return;
- }
-
- LOG4CXX_DEBUG(logger_, "VR response consider to be SUCCESS");
- TerminatePerformInteraction();
- SendResponse(vr_result_, SUCCESS, NULL, &msg_params);
+ return false;
}
-void PerformInteractionRequest::ProcessPerformInteractionResponse(
+void PerformInteractionRequest::ProcessUIResponse(
const smart_objects::SmartObject& message,
smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -377,31 +368,37 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
return;
}
- ui_result_ = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::WARNINGS,
- mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
+ bool result = false;
+ result = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
- const bool is_pi_warning = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_, mobile_apis::Result::WARNINGS);
+ result = result ||
+ (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_code_ &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state);
- const bool is_pi_unsupported = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ const bool is_pi_warning = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_, hmi_apis::Common_Result::WARNINGS);
- std::string info;
+ const bool is_pi_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
- if (ui_result_) {
+ if (result) {
if (is_pi_warning) {
- ui_resultCode_ = mobile_apis::Result::WARNINGS;
- info = "Unsupported phoneme type was sent in an item";
+ ui_result_code_ = hmi_apis::Common_Result::WARNINGS;
+ ui_info_ = "Unsupported phoneme type was sent in an item";
if (message.keyExists(strings::params) &&
message[strings::params].keyExists(strings::data)) {
msg_params = message[strings::params][strings::data];
}
} else if (is_pi_unsupported) {
- ui_resultCode_ = mobile_apis::Result::UNSUPPORTED_RESOURCE;
- info = "Unsupported phoneme type was sent in an item";
+ ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ ui_info_ = "Unsupported phoneme type was sent in an item";
} else if (message.keyExists(strings::msg_params)) {
msg_params = message[strings::msg_params];
}
@@ -409,8 +406,8 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
if (msg_params.keyExists(strings::choice_id)) {
if (!CheckChoiceIDFromResponse(app,
msg_params[strings::choice_id].asInt())) {
- ui_resultCode_ = mobile_apis::Result::GENERIC_ERROR;
- info = "Wrong choiceID was received from HMI";
+ ui_result_code_ = hmi_apis::Common_Result::GENERIC_ERROR;
+ ui_info_ = "Wrong choiceID was received from HMI";
} else {
msg_params[strings::trigger_source] =
mobile_apis::TriggerSource::TS_MENU;
@@ -423,15 +420,6 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
}
}
}
-
- DisablePerformInteraction();
-
- const SmartObject* response_params = msg_params.empty() ? NULL : &msg_params;
-
- if (mobile_apis::InteractionMode::BOTH != interaction_mode_) {
- DisablePerformInteraction();
- SendResponse(ui_result_, ui_resultCode_, info.c_str(), response_params);
- }
}
void PerformInteractionRequest::SendUIPerformInteractionRequest(
@@ -929,60 +917,31 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
const bool PerformInteractionRequest::HasHMIResponsesToWait() const {
LOG4CXX_AUTO_TRACE(logger_);
- return !ui_response_recived_ || !vr_response_recived_;
-}
-
-void PerformInteractionRequest::CheckResponseResultCode() {
- LOG4CXX_AUTO_TRACE(logger_);
- mobile_apis::Result::eType resultCode = mobile_apis::Result::INVALID_ENUM;
- bool result = false;
- if (mobile_apis::Result::GENERIC_ERROR == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response GENERIC_ERROR");
- resultCode = mobile_apis::Result::GENERIC_ERROR;
- } else if (mobile_apis::Result::REJECTED == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR had been rejected.");
- resultCode = mobile_apis::Result::REJECTED;
- } else if (mobile_apis::Result::WARNINGS == vr_resultCode_ ||
- mobile_apis::Result::UNSUPPORTED_REQUEST == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response WARNINGS");
- resultCode = mobile_api::Result::WARNINGS;
- result = true;
- }
-
- if (mobile_apis::Result::INVALID_ENUM != resultCode) {
- TerminatePerformInteraction();
- SendResponse(result, resultCode);
- }
+ return !ui_response_received_ || !vr_response_received_;
}
void PerformInteractionRequest::SendBothModeResponse(
const smart_objects::SmartObject& msg_param) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace mobile_apis::Result;
-
- bool result = ui_result_ || vr_result_;
- mobile_apis::Result::eType perform_interaction_result_code = ui_resultCode_;
-
- if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
- UNSUPPORTED_RESOURCE != ui_resultCode_) {
- perform_interaction_result_code = vr_resultCode_;
- } else if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
- UNSUPPORTED_RESOURCE == ui_resultCode_) {
- result = false;
- }
-
- const bool is_error_code = (SUCCESS != perform_interaction_result_code ||
- WARNINGS != perform_interaction_result_code);
-
- if (vr_resultCode_ == ui_resultCode_ && is_error_code) {
- result = false;
- }
-
+ mobile_apis::Result::eType perform_interaction_result_code =
+ mobile_apis::Result::INVALID_ENUM;
+ ResponseInfo ui_perform_info(ui_result_code_,
+ HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo vr_perform_info(vr_result_code_,
+ HmiInterfaces::HMI_INTERFACE_VR);
+ const bool result =
+ PrepareResultForMobileResponse(ui_perform_info, vr_perform_info);
+ perform_interaction_result_code =
+ PrepareResultCodeForResponse(ui_perform_info, vr_perform_info);
const smart_objects::SmartObject* response_params =
msg_param.empty() ? NULL : &msg_param;
-
- TerminatePerformInteraction();
- SendResponse(result, perform_interaction_result_code, NULL, response_params);
+ std::string info =
+ MergeInfos(ui_perform_info, ui_info_, vr_perform_info, vr_info_);
+ DisablePerformInteraction();
+ SendResponse(result,
+ perform_interaction_result_code,
+ info.empty() ? NULL : info.c_str(),
+ response_params);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc
index 69885f9d40..0bf747bde3 100644
--- a/src/components/application_manager/src/commands/mobile/read_did_request.cc
+++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc
@@ -36,6 +36,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -65,7 +66,7 @@ void ReadDIDRequest::Run() {
return;
}
- if (app->IsCommandLimitsExceeded(
+ if (app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "ReadDID frequency is too high.");
@@ -96,18 +97,17 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_ReadDID: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- const std::string return_info =
- message[strings::msg_params][hmi_response::message].asString();
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
SendResponse(result,
- result_code,
- return_info.c_str(),
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
}
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index 54c58dbb1a..9ae2bac73c 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -42,6 +42,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/application_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl.h"
#include "application_manager/message_helper.h"
#include "application_manager/resumption/resume_ctrl.h"
#include "interfaces/MOBILE_API.h"
@@ -363,61 +364,40 @@ RegisterAppInterfaceRequest::GetLockScreenIconUrlNotification(
return message;
}
-void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
- LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
-
- const HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
- const uint32_t key = connection_key();
- ApplicationSharedPtr application = application_manager_.application(key);
-
- resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
+void FillVRRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ response_params[strings::language] = hmi_capabilities.active_vr_language();
+ if (hmi_capabilities.vr_capabilities()) {
+ response_params[strings::vr_capabilities] =
+ *hmi_capabilities.vr_capabilities();
+ }
+}
- if (!application) {
- LOG4CXX_ERROR(logger_,
- "There is no application for such connection key" << key);
- LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer");
- resumer.OnAppRegistrationEnd();
- return;
+void FillVIRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ if (hmi_capabilities.vehicle_type()) {
+ response_params[hmi_response::vehicle_type] =
+ *hmi_capabilities.vehicle_type();
}
+}
- response_params[strings::sync_msg_version][strings::major_version] =
- major_version; // From generated file interfaces/generated_msg_version.h
- response_params[strings::sync_msg_version][strings::minor_version] =
- minor_version; // From generated file interfaces/generated_msg_version.h
+void FillTTSRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ response_params[strings::language] = hmi_capabilities.active_tts_language();
+ if (hmi_capabilities.speech_capabilities()) {
+ response_params[strings::speech_capabilities] =
+ *hmi_capabilities.speech_capabilities();
+ }
+ if (hmi_capabilities.prerecorded_speech()) {
+ response_params[strings::prerecorded_speech] =
+ *(hmi_capabilities.prerecorded_speech());
+ }
+}
- response_params[strings::language] = hmi_capabilities.active_vr_language();
+void FillUIRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
response_params[strings::hmi_display_language] =
hmi_capabilities.active_ui_language();
-
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
-
- if (msg_params[strings::language_desired].asInt() !=
- hmi_capabilities.active_vr_language() ||
- msg_params[strings::hmi_display_language_desired].asInt() !=
- hmi_capabilities.active_ui_language()) {
- LOG4CXX_WARN(logger_,
- "Wrong language on registering application "
- << application->name().c_str());
-
- LOG4CXX_ERROR(
- logger_,
- "VR language desired code is "
- << msg_params[strings::language_desired].asInt()
- << " , active VR language code is "
- << hmi_capabilities.active_vr_language() << ", UI language code is "
- << msg_params[strings::hmi_display_language_desired].asInt()
- << " , active UI language code is "
- << hmi_capabilities.active_ui_language());
-
- result_code = mobile_apis::Result::WRONG_LANGUAGE;
- }
-
if (hmi_capabilities.display_capabilities()) {
response_params[hmi_response::display_capabilities] =
smart_objects::SmartObject(smart_objects::SmartType_Map);
@@ -453,13 +433,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
hmi_capabilities.display_capabilities()->getElement(
hmi_response::num_custom_presets_available);
- if (hmi_capabilities.display_capabilities()
- ->getElement(hmi_response::image_capabilities)
- .length() > 0) {
- display_caps[hmi_response::graphic_supported] = true;
- } else {
- display_caps[hmi_response::graphic_supported] = false;
- }
+ display_caps[hmi_response::graphic_supported] =
+ (hmi_capabilities.display_capabilities()
+ ->getElement(hmi_response::image_capabilities)
+ .length() > 0);
display_caps[hmi_response::templates_available] =
hmi_capabilities.display_capabilities()->getElement(
@@ -474,6 +451,94 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
hmi_response::num_custom_presets_available);
}
+ if (hmi_capabilities.audio_pass_thru_capabilities()) {
+ if (smart_objects::SmartType_Array ==
+ hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
+ // hmi_capabilities json contains array and HMI response object
+ response_params[strings::audio_pass_thru_capabilities] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
+ } else {
+ response_params[strings::audio_pass_thru_capabilities][0] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
+ }
+ }
+ response_params[strings::hmi_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ response_params[strings::hmi_capabilities][strings::navigation] =
+ hmi_capabilities.navigation_supported();
+ response_params[strings::hmi_capabilities][strings::phone_call] =
+ hmi_capabilities.phone_call_supported();
+}
+
+void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
+
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+
+ const uint32_t key = connection_key();
+ ApplicationSharedPtr application = application_manager_.application(key);
+
+ resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_,
+ "There is no application for such connection key" << key);
+ LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer");
+ resumer.OnAppRegistrationEnd();
+ return;
+ }
+
+ response_params[strings::sync_msg_version][strings::major_version] =
+ major_version; // From generated file interfaces/generated_msg_version.h
+ response_params[strings::sync_msg_version][strings::minor_version] =
+ minor_version; // From generated file interfaces/generated_msg_version.h
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ if (msg_params[strings::language_desired].asInt() !=
+ hmi_capabilities.active_vr_language() ||
+ msg_params[strings::hmi_display_language_desired].asInt() !=
+ hmi_capabilities.active_ui_language()) {
+ LOG4CXX_WARN(logger_,
+ "Wrong language on registering application "
+ << application->name().c_str());
+
+ LOG4CXX_ERROR(
+ logger_,
+ "VR language desired code is "
+ << msg_params[strings::language_desired].asInt()
+ << " , active VR language code is "
+ << hmi_capabilities.active_vr_language() << ", UI language code is "
+ << msg_params[strings::hmi_display_language_desired].asInt()
+ << " , active UI language code is "
+ << hmi_capabilities.active_ui_language());
+
+ result_code = mobile_apis::Result::WRONG_LANGUAGE;
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ FillTTSRelatedFields(response_params, hmi_capabilities);
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VR)) {
+ FillVRRelatedFields(response_params, hmi_capabilities);
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI)) {
+ FillUIRelatedFields(response_params, hmi_capabilities);
+ }
+
if (hmi_capabilities.button_capabilities()) {
response_params[hmi_response::button_capabilities] =
*hmi_capabilities.button_capabilities();
@@ -497,36 +562,22 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
*hmi_capabilities.hmi_zone_capabilities();
}
}
- if (hmi_capabilities.speech_capabilities()) {
- response_params[strings::speech_capabilities] =
- *hmi_capabilities.speech_capabilities();
- }
- if (hmi_capabilities.vr_capabilities()) {
- response_params[strings::vr_capabilities] =
- *hmi_capabilities.vr_capabilities();
- }
- if (hmi_capabilities.audio_pass_thru_capabilities()) {
- if (smart_objects::SmartType_Array ==
- hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
- // hmi_capabilities json contains array and HMI response object
- response_params[strings::audio_pass_thru_capabilities] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- } else {
- response_params[strings::audio_pass_thru_capabilities][0] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ FillTTSRelatedFields(response_params, hmi_capabilities);
}
+
if (hmi_capabilities.pcm_stream_capabilities()) {
response_params[strings::pcm_stream_capabilities] =
*hmi_capabilities.pcm_stream_capabilities();
}
- if (hmi_capabilities.vehicle_type()) {
- response_params[hmi_response::vehicle_type] =
- *hmi_capabilities.vehicle_type();
- }
- if (hmi_capabilities.prerecorded_speech()) {
- response_params[strings::prerecorded_speech] =
- *(hmi_capabilities.prerecorded_speech());
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
+ FillVIRelatedFields(response_params, hmi_capabilities);
}
const std::vector<uint32_t>& diag_modes =
@@ -539,13 +590,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
++index;
}
}
-
- response_params[strings::hmi_capabilities] =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- response_params[strings::hmi_capabilities][strings::navigation] =
- hmi_capabilities.navigation_supported();
- response_params[strings::hmi_capabilities][strings::phone_call] =
- hmi_capabilities.phone_call_supported();
response_params[strings::sdl_version] =
application_manager_.get_settings().sdl_version();
const std::string ccpu_version =
@@ -594,27 +638,49 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
SendOnAppRegisteredNotificationToHMI(
*(application.get()), resumption, need_restore_vr);
- // Check if application exists, because application might be unregestered
- // during sending reponse to mobile.
- application = application_manager_.application(key);
- if (application) {
- LOG4CXX_DEBUG(logger_, "Application with app_id = " << key << " exists.");
- if (result_code != mobile_apis::Result::RESUME_FAILED) {
- resumer.StartResumption(application, hash_id);
- } else {
- resumer.StartResumptionOnlyHMILevel(application);
- }
+ if (result_code != mobile_apis::Result::RESUME_FAILED) {
+ resumer.StartResumption(application, hash_id);
+ } else {
+ resumer.StartResumptionOnlyHMILevel(application);
+ }
- // By default app subscribed to CUSTOM_BUTTON
- SendSubscribeCustomButtonNotification();
- MessageHelper::SendChangeRegistrationRequestToHMI(application,
- application_manager_);
+ // By default app subscribed to CUSTOM_BUTTON
+ SendSubscribeCustomButtonNotification();
+ SendChangeRegistrationOnHMI(application);
+}
+
+void RegisterAppInterfaceRequest::SendChangeRegistration(
+ const hmi_apis::FunctionID::eType function_id,
+ const int32_t language,
+ const uint32_t app_id) {
+ using helpers::Compare;
+ using helpers::EQ;
+ using helpers::ONE;
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ const HmiInterfaces::InterfaceID interface =
+ hmi_interfaces.GetInterfaceFromFunction(function_id);
+ if (hmi_interfaces.GetInterfaceState(interface) !=
+ HmiInterfaces::STATE_NOT_AVAILABLE) {
+ smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
+ msg_params[strings::language] = language;
+ msg_params[strings::app_id] = app_id;
+ SendHMIRequest(function_id, &msg_params);
} else {
- LOG4CXX_DEBUG(logger_,
- "Application with app_id = " << key << " doesn't exist.");
+ LOG4CXX_DEBUG(logger_, "Interface " << interface << "is not avaliable");
}
}
+void RegisterAppInterfaceRequest::SendChangeRegistrationOnHMI(
+ ApplicationConstSharedPtr app) {
+ using namespace hmi_apis::FunctionID;
+ DCHECK_OR_RETURN_VOID(app);
+ DCHECK_OR_RETURN_VOID(mobile_apis::Language::INVALID_ENUM != app->language());
+ SendChangeRegistration(VR_ChangeRegistration, app->language(), app->app_id());
+ SendChangeRegistration(
+ TTS_ChangeRegistration, app->language(), app->app_id());
+ SendChangeRegistration(UI_ChangeRegistration, app->language(), app->app_id());
+}
+
void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI(
const Application& application_impl,
bool resumption,
diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
index 89bd43fcd6..0c770953fe 100644
--- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
@@ -115,7 +115,6 @@ void ScrollableMessageRequest::Run() {
void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -128,24 +127,19 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::UI_ScrollableMessage: {
LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event");
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
- bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code &&
- hmi_capabilities.is_ui_cooperating()) {
- result = true;
- }
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc
index 975f7e43c3..7b9ec53c3a 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_request.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc
@@ -31,11 +31,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#include <algorithm>
-
#include "application_manager/commands/mobile/send_location_request.h"
-
#include "application_manager/message_helper.h"
-#include "utils/helpers.h"
#include "utils/custom_string.h"
namespace application_manager {
@@ -136,21 +133,20 @@ void SendLocationRequest::Run() {
void SendLocationRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- namespace Result = mobile_apis::Result;
- using namespace helpers;
+ using namespace hmi_apis;
const smart_objects::SmartObject& message = event.smart_object();
if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) {
LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- const bool result =
- Compare<Result::eType, EQ, ONE>(result_code,
- Result::SAVED,
- Result::SUCCESS,
- Result::WARNINGS,
- Result::UNSUPPORTED_RESOURCE);
- SendResponse(result, result_code, NULL, &(message[strings::params]));
+ const Common_Result::eType result_code = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::params]));
return;
}
LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
index 40b708e30d..5d70a2fb5b 100644
--- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
@@ -34,6 +34,7 @@
#include <algorithm>
#include "application_manager/commands/mobile/set_app_icon_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -229,20 +230,17 @@ bool SetAppIconRequest::IsEnoughSpaceForIcon(const uint64_t icon_size) const {
void SetAppIconRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetAppIcon: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string response_info;
+ GetInfo(message, response_info);
if (result) {
ApplicationSharedPtr app =
application_manager_.application(connection_key());
@@ -261,7 +259,10 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) {
"Icon path was set to '" << app->app_icon_path() << "'");
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
index 6cb6318791..984690384a 100644
--- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/set_display_layout_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
namespace application_manager {
@@ -69,14 +70,14 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetDisplayLayout: {
LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event");
-
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool response_success = mobile_apis::Result::SUCCESS == result_code;
-
+ const bool response_success = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string info;
+ GetInfo(message, info);
smart_objects::SmartObject msg_params = message[strings::msg_params];
-
if (response_success) {
HMICapabilities& hmi_capabilities =
application_manager_.hmi_capabilities();
@@ -93,7 +94,10 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
}
}
}
- SendResponse(response_success, result_code, NULL, &msg_params);
+ SendResponse(response_success,
+ MessageHelper::HMIToMobileResult(result_code),
+ info.empty() ? NULL : info.c_str(),
+ &msg_params);
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
index 171b902df1..fcfea5e744 100644
--- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
@@ -127,6 +127,12 @@ void SetGlobalPropertiesRequest::Run() {
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
+
+ /* Need to set flags before sending request to HMI
+ * for correct processing this flags in method on_event */
+ if (is_help_prompt_present || is_timeout_prompt_present) {
+ is_tts_send_ = true;
+ }
if (is_vr_help_title_present && is_vr_help_present) {
LOG4CXX_DEBUG(logger_, "VRHelp params presents");
@@ -226,6 +232,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
@@ -233,6 +240,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_tts_received_ = true;
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
default: {
@@ -245,54 +253,18 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
LOG4CXX_DEBUG(logger_, "Continue waiting for response");
return;
}
-
- const bool is_tts_succeeded =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_ui_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_ui_invalid_unsupported =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::INVALID_ENUM,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
-
- bool result = (is_tts_succeeded && is_ui_succeeded) ||
- (is_ui_succeeded &&
- hmi_apis::Common_Result::INVALID_ENUM == tts_result_) ||
- (is_ui_invalid_unsupported && is_tts_succeeded);
-
mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- const char* return_info = NULL;
-
- const bool is_ui_or_tts_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, tts_result_, ui_result_);
-
- if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ ||
- is_ui_or_tts_warning)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info =
- std::string("Unsupported phoneme type sent in a prompt").c_str();
- } else {
- result_code =
- MessageHelper::HMIToMobileResult(std::max(ui_result_, tts_result_));
- }
+ std::string response_info;
+ const bool result = PrepareResponseParameters(result_code, response_info);
// TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse
ApplicationSharedPtr application =
application_manager_.application(connection_key());
- SendResponse(
- result, result_code, return_info, &(message[strings::msg_params]));
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (!application) {
LOG4CXX_DEBUG(logger_, "NULL pointer.");
@@ -304,6 +276,37 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
}
+bool SetGlobalPropertiesRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+
+ ResponseInfo tts_properties_info(tts_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(ui_properties_info, tts_properties_info);
+ if (result &&
+ (HmiInterfaces::STATE_AVAILABLE == tts_properties_info.interface_state) &&
+ (tts_properties_info.is_unsupported_resource)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ tts_response_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(tts_properties_info,
+ tts_response_info_,
+ ui_properties_info,
+ ui_response_info_);
+ return result;
+ }
+ result_code =
+ PrepareResultCodeForResponse(ui_properties_info, tts_properties_info);
+ info = MergeInfos(tts_properties_info,
+ tts_response_info_,
+ ui_properties_info,
+ ui_response_info_);
+ return result;
+}
+
bool SetGlobalPropertiesRequest::ValidateVRHelpTitle(
const smart_objects::SmartObject* const vr_help_so_ptr) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -397,17 +400,17 @@ void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData(
void SetGlobalPropertiesRequest::SendTTSRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
+ is_tts_send_ = true;
SendHMIRequest(
hmi_apis::FunctionID::TTS_SetGlobalProperties, &params, use_events);
- is_tts_send_ = true;
}
void SetGlobalPropertiesRequest::SendUIRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
+ is_ui_send_ = true;
SendHMIRequest(
hmi_apis::FunctionID::UI_SetGlobalProperties, &params, use_events);
- is_ui_send_ = true;
}
bool SetGlobalPropertiesRequest::IsPendingResponseExist() {
diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
index a198ce63c3..1e0a00318d 100644
--- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/set_media_clock_timer_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -84,13 +85,18 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetMediaClockTimer: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string response_info;
+ GetInfo(message, response_info);
+
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
index 2d79e13582..b1cc40009d 100644
--- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
@@ -178,31 +178,22 @@ void ShowConstantTBTRequest::Run() {
void ShowConstantTBTRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace hmi_apis;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_ShowConstantTBT: {
LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event");
- std::string return_info;
-
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt()));
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
- bool result = false;
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- return_info =
- message[strings::msg_params][hmi_response::message].asString();
- } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- hmi_capabilities.is_ui_cooperating()) {
- result = true;
- }
-
+ const Common_Result::eType result_code =
+ static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
SendResponse(result,
- result_code,
- return_info.empty() ? 0 : return_info.c_str(),
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
}
diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc
index 467d8d0236..cf2509cdb9 100644
--- a/src/components/application_manager/src/commands/mobile/show_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_request.cc
@@ -228,23 +228,19 @@ void ShowRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::UI_Show: {
LOG4CXX_DEBUG(logger_, "Received UI_Show event.");
std::string response_info;
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
- if (mobile_apis::Result::WARNINGS == result_code &&
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ GetInfo(message, response_info);
+ if (hmi_apis::Common_Result::WARNINGS == result_code &&
message[strings::params].keyExists(hmi_response::message)) {
response_info =
message[strings::params][hmi_response::message].asString();
}
-
SendResponse(result,
- result_code,
+ MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc
index 3920b49db3..054d0ec16d 100644
--- a/src/components/application_manager/src/commands/mobile/slider_request.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -154,13 +154,14 @@ void SliderRequest::on_event(const event_engine::Event& event) {
response_msg_params[strings::slider_position] = 0;
}
}
-
- const bool is_response_success = Compare<Common_Result::eType, EQ, ONE>(
- response_code, Common_Result::SUCCESS, Common_Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool is_response_success = PrepareResultForMobileResponse(
+ response_code, HmiInterfaces::HMI_INTERFACE_UI);
SendResponse(is_response_success,
MessageHelper::HMIToMobileResult(response_code),
- 0,
+ response_info.empty() ? NULL : response_info.c_str(),
&response_msg_params);
}
diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc
index 7e4731b569..6cbb762102 100644
--- a/src/components/application_manager/src/commands/mobile/speak_request.cc
+++ b/src/components/application_manager/src/commands/mobile/speak_request.cc
@@ -120,25 +120,14 @@ void SpeakRequest::ProcessTTSSpeakResponse(
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result_code);
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result_code, HmiInterfaces::HMI_INTERFACE_TTS);
(*message_)[strings::params][strings::function_id] =
mobile_apis::FunctionID::SpeakID;
const char* return_info = NULL;
- const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::UNSUPPORTED_RESOURCE,
- mobile_api::Result::WARNINGS);
-
- if (is_result_ok) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info =
- std::string("Unsupported phoneme type sent in a prompt").c_str();
- }
-
SendResponse(
result, result_code, return_info, &(message[strings::msg_params]));
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
index 7ec4e20fbd..eb6bbf545e 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -58,7 +58,7 @@ void SubscribeButtonRequest::Run() {
const mobile_apis::ButtonName::eType btn_id =
static_cast<mobile_apis::ButtonName::eType>(
- (*message_)[str::msg_params][str::button_name].asUInt());
+ (*message_)[str::msg_params][str::button_name].asInt());
if (!IsSubscriptionAllowed(app, btn_id)) {
LOG4CXX_ERROR(logger_,
@@ -101,7 +101,6 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed(
(mobile_apis::ButtonName::TUNEDOWN == btn_id))) {
return false;
}
-
return true;
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
index 485c5d0009..56027bacaf 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -109,115 +109,21 @@ void SubscribeVehicleDataRequest::Run() {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
-
- // counter for items to subscribe
- int32_t items_to_subscribe = 0;
- // counter for subscribed items by application
- int32_t subscribed_items = 0;
-
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
-
+ std::string info;
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
-
smart_objects::SmartObject response_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
-
- for (; vehicle_data.end() != it; ++it) {
- const std::string& key_name = it->first;
- if ((*message_)[strings::msg_params].keyExists(key_name)) {
- bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
- if (is_key_enabled) {
- ++items_to_subscribe;
-
- VehicleDataType key_type = it->second;
- if (app->IsSubscribedToIVI(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "App with connection key "
- << connection_key()
- << " is subscribed already for VehicleDataType: "
- << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_this_app_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
- continue;
- }
-
- if (IsSomeoneSubscribedFor(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "There are apps subscribed already for "
- "VehicleDataType: "
- << key_type);
- if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
- LOG4CXX_ERROR(
- logger_,
- "Unable to subscribe for VehicleDataType: " << key_type);
- continue;
- }
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_another_apps_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
- continue;
- }
-
- msg_params[key_name] = is_key_enabled;
-
- if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- }
- }
- }
- }
-
- bool is_everything_already_subscribed =
- static_cast<uint32_t>(items_to_subscribe) ==
- vi_already_subscribed_by_another_apps_.size() +
- vi_already_subscribed_by_this_app_.size();
-
- if (0 == items_to_subscribe) {
- if (HasDisallowedParams()) {
- SendResponse(false, mobile_apis::Result::DISALLOWED);
- } else {
- SendResponse(
- false, mobile_apis::Result::INVALID_DATA, "No data in the request");
- }
- return;
- }
-
- if (0 == subscribed_items) {
- SendResponse(false,
- mobile_apis::Result::IGNORED,
- "Already subscribed on provided VehicleData.",
- &response_params);
- return;
- }
-
- if (is_everything_already_subscribed) {
- mobile_apis::Result::eType result_code =
- vi_already_subscribed_by_this_app_.size()
- ? mobile_apis::Result::IGNORED
- : mobile_apis::Result::SUCCESS;
-
- const char* info = vi_already_subscribed_by_this_app_.size()
- ? "Already subscribed on some provided VehicleData."
- : NULL;
-
- SendResponse(true, result_code, info, &response_params);
+ bool result = false;
+ CheckVISubscribtions(
+ app, info, result_code, response_params, msg_params, result);
+
+ if (mobile_apis::Result::INVALID_ENUM != result_code) {
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ response_params.empty() ? NULL : &response_params);
return;
}
@@ -325,27 +231,24 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
}
}
#else
+
hmi_apis::Common_Result::eType hmi_result =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
- const bool is_result_no_error =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
-
- bool is_succeeded =
- is_result_no_error || !vi_already_subscribed_by_another_apps_.empty();
+ bool is_succeeded = result || !vi_already_subscribed_by_another_apps_.empty();
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
- const char* return_info = NULL;
if (is_succeeded) {
if (!vi_already_subscribed_by_this_app_.empty()) {
result_code = mobile_apis::Result::IGNORED;
- return_info = "Already subscribed on some provided VehicleData.";
+ response_info = "Already subscribed on some provided VehicleData.";
}
}
@@ -357,8 +260,10 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
}
- SendResponse(
- is_succeeded, result_code, return_info, &(message[strings::msg_params]));
+ SendResponse(is_succeeded,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (is_succeeded) {
app->UpdateHash();
@@ -429,5 +334,121 @@ bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
return it != accessor.GetData().end();
}
+void SubscribeVehicleDataRequest::CheckVISubscribtions(
+ ApplicationSharedPtr app,
+ std::string& out_info,
+ mobile_apis::Result::eType& out_result_code,
+ smart_objects::SmartObject& out_response_params,
+ smart_objects::SmartObject& out_request_params,
+ bool& out_result) {
+ // counter for items to subscribe
+ VehicleInfoSubscriptions::size_type items_to_subscribe = 0;
+ // counter for subscribed items by application
+ uint32_t subscribed_items = 0;
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ HmiInterfaces::InterfaceState interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+
+ const bool is_interface_not_available =
+ interface_state == HmiInterfaces::STATE_NOT_AVAILABLE;
+
+ for (; vehicle_data.end() != it; ++it) {
+ const std::string& key_name = it->first;
+ if ((*message_)[strings::msg_params].keyExists(key_name)) {
+ const bool is_key_enabled =
+ (*message_)[strings::msg_params][key_name].asBool();
+ if (is_key_enabled) {
+ ++items_to_subscribe;
+ }
+ if (!is_interface_not_available && is_key_enabled) {
+ VehicleDataType key_type = it->second;
+ if (app->IsSubscribedToIVI(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "App with connection key "
+ << connection_key()
+ << " is subscribed already for VehicleDataType: "
+ << key_type);
+ ++subscribed_items;
+ vi_already_subscribed_by_this_app_.insert(key_type);
+ out_response_params[key_name][strings::data_type] = key_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ continue;
+ }
+
+ if (IsSomeoneSubscribedFor(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "There are apps subscribed already for "
+ "VehicleDataType: "
+ << key_type);
+ if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unable to subscribe for VehicleDataType: " << key_type);
+ continue;
+ }
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
+ vi_already_subscribed_by_another_apps_.insert(key_type);
+ out_response_params[key_name][strings::data_type] = key_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ continue;
+ }
+
+ out_request_params[key_name] = is_key_enabled;
+
+ if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
+ }
+ }
+ }
+ }
+
+ const bool is_everything_already_subscribed =
+ items_to_subscribe ==
+ vi_already_subscribed_by_another_apps_.size() +
+ vi_already_subscribed_by_this_app_.size();
+
+ if (0 == items_to_subscribe) {
+ if (HasDisallowedParams()) {
+ out_result_code = mobile_apis::Result::DISALLOWED;
+ } else {
+ out_result_code = mobile_apis::Result::INVALID_DATA;
+ out_info = "No data in the request";
+ }
+ out_result = false;
+ }
+
+ if (0 == subscribed_items && !is_interface_not_available) {
+ out_result_code = mobile_apis::Result::IGNORED;
+ out_info = "Already subscribed on provided VehicleData.";
+ out_result = false;
+ }
+
+ if (is_everything_already_subscribed) {
+ out_result_code = vi_already_subscribed_by_this_app_.size()
+ ? mobile_apis::Result::IGNORED
+ : mobile_apis::Result::SUCCESS;
+ if (!(vi_already_subscribed_by_this_app_.empty())) {
+ out_info = "Already subscribed on some provided VehicleData.";
+ }
+ out_result = true;
+ }
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
index 8134730eee..29cc8e6541 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/subscribe_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -47,14 +48,20 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
application_manager_.SubscribeAppForWayPoints(app->app_id());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
app->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
index 86df8fabb1..e1bdba61a0 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
@@ -61,22 +61,16 @@ void UnsubscribeButtonRequest::Run() {
const uint32_t btn_id =
(*message_)[str::msg_params][str::button_name].asUInt();
- if (!app->IsSubscribedToButton(
+ if (!app->UnsubscribeFromButton(
static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id);
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
- app->UnsubscribeFromButton(
- static_cast<mobile_apis::ButtonName::eType>(btn_id));
-
SendUnsubscribeButtonNotification();
- const bool is_succedeed = true;
- SendResponse(is_succedeed, mobile_apis::Result::SUCCESS);
- if (is_succedeed) {
- app->UpdateHash();
- }
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ app->UpdateHash();
}
void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() {
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index 4fcc04c7be..6902a9d659 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -315,21 +315,18 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
hmi_apis::Common_Result::eType hmi_result =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool is_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
- const char* return_info = NULL;
-
- if (is_succeeded) {
+ if (result) {
if (vi_already_unsubscribed_by_this_app_.size()) {
result_code = mobile_apis::Result::IGNORED;
- return_info = "Some provided VehicleData was not subscribed.";
+ response_info = "Some provided VehicleData was not subscribed.";
}
}
@@ -339,12 +336,14 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
}
- if (is_succeeded) {
+ if (result) {
SetAllowedToTerminate(false);
}
- SendResponse(
- is_succeeded, result_code, return_info, &(message[strings::msg_params]));
- if (is_succeeded) {
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
+ if (result) {
UpdateHash();
}
#endif // #ifdef HMI_DBUS_API
@@ -401,7 +400,8 @@ void UnsubscribeVehicleDataRequest::UpdateHash() const {
"Application with connection_key = " << connection_key()
<< " doesn't exist.");
}
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
index b19e292025..728209fcf2 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/unsubscribe_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -40,14 +41,20 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
application_manager_.UnsubscribeAppFromWayPoints(app->app_id());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
app->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
index 9b3b221446..becab175e9 100644
--- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
+++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
@@ -155,18 +155,17 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::Navigation_UpdateTurnList: {
LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event");
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
- bool result =
- (mobile_apis::Result::SUCCESS == result_code) ||
- ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- (hmi_capabilities.is_ui_cooperating()));
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 73afc0b68c..c6fa321401 100644
--- a/src/components/application_manager/src/hmi_capabilities.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -30,192 +30,300 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/hmi_capabilities.h"
-
#include <map>
-#include "json/json.h"
-#include "utils/file_system.h"
-#include "interfaces/HMI_API.h"
+#include "utils/logger.h"
+#include "application_manager/hmi_capabilities_impl.h"
+#include "application_manager/application_manager_impl.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/smart_object_keys.h"
#include "application_manager/message_helper.h"
#include "application_manager/smart_object_keys.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/message_helper.h"
+#include "config_profile/profile.h"
#include "formatters/CFormatterJsonBase.h"
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
+#include "interfaces/HMI_API.h"
+#include "utils/file_system.h"
namespace application_manager {
namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
+namespace {
std::map<std::string, hmi_apis::Common_VrCapabilities::eType>
- vr_enum_capabilities = {{"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT}};
-
-std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = {
- {"OK", hmi_apis::Common_ButtonName::OK},
- {"SEEKLEFT", hmi_apis::Common_ButtonName::SEEKLEFT},
- {"SEEKRIGHT", hmi_apis::Common_ButtonName::SEEKRIGHT},
- {"TUNEUP", hmi_apis::Common_ButtonName::TUNEUP},
- {"TUNEDOWN", hmi_apis::Common_ButtonName::TUNEDOWN},
- {"PRESET_0", hmi_apis::Common_ButtonName::PRESET_0},
- {"PRESET_1", hmi_apis::Common_ButtonName::PRESET_1},
- {"PRESET_2", hmi_apis::Common_ButtonName::PRESET_2},
- {"PRESET_3", hmi_apis::Common_ButtonName::PRESET_3},
- {"PRESET_4", hmi_apis::Common_ButtonName::PRESET_4},
- {"PRESET_5", hmi_apis::Common_ButtonName::PRESET_5},
- {"PRESET_6", hmi_apis::Common_ButtonName::PRESET_6},
- {"PRESET_7", hmi_apis::Common_ButtonName::PRESET_7},
- {"PRESET_8", hmi_apis::Common_ButtonName::PRESET_8},
- {"PRESET_9", hmi_apis::Common_ButtonName::PRESET_9},
- {"CUSTOM_BUTTON", hmi_apis::Common_ButtonName::CUSTOM_BUTTON},
- {"SEARCH", hmi_apis::Common_ButtonName::SEARCH},
-
-};
-
-std::map<std::string,
- hmi_apis::Common_TextFieldName::eType> text_fields_enum_name = {
- {"mainField1", hmi_apis::Common_TextFieldName::mainField1},
- {"mainField2", hmi_apis::Common_TextFieldName::mainField2},
- {"mainField3", hmi_apis::Common_TextFieldName::mainField3},
- {"mainField4", hmi_apis::Common_TextFieldName::mainField4},
- {"statusBar", hmi_apis::Common_TextFieldName::statusBar},
- {"mediaClock", hmi_apis::Common_TextFieldName::mediaClock},
- {"mediaTrack", hmi_apis::Common_TextFieldName::mediaTrack},
- {"alertText1", hmi_apis::Common_TextFieldName::alertText1},
- {"alertText2", hmi_apis::Common_TextFieldName::alertText2},
- {"alertText3", hmi_apis::Common_TextFieldName::alertText3},
- {"scrollableMessageBody",
- hmi_apis::Common_TextFieldName::scrollableMessageBody},
- {"initialInteractionText",
- hmi_apis::Common_TextFieldName::initialInteractionText},
- {"navigationText1", hmi_apis::Common_TextFieldName::navigationText1},
- {"navigationText2", hmi_apis::Common_TextFieldName::navigationText2},
- {"ETA", hmi_apis::Common_TextFieldName::ETA},
- {"totalDistance", hmi_apis::Common_TextFieldName::totalDistance},
- {"audioPassThruDisplayText1",
- hmi_apis::Common_TextFieldName::audioPassThruDisplayText1},
- {"audioPassThruDisplayText2",
- hmi_apis::Common_TextFieldName::audioPassThruDisplayText2},
- {"sliderHeader", hmi_apis::Common_TextFieldName::sliderHeader},
- {"sliderFooter", hmi_apis::Common_TextFieldName::sliderFooter},
- {"notificationText", hmi_apis::Common_TextFieldName::notificationText},
- {"menuName", hmi_apis::Common_TextFieldName::menuName},
- {"secondaryText", hmi_apis::Common_TextFieldName::secondaryText},
- {"tertiaryText", hmi_apis::Common_TextFieldName::tertiaryText},
- {"timeToDestination", hmi_apis::Common_TextFieldName::timeToDestination},
- {"locationName", hmi_apis::Common_TextFieldName::locationName},
- {"locationDescription",
- hmi_apis::Common_TextFieldName::locationDescription},
- {"addressLines", hmi_apis::Common_TextFieldName::turnText},
- {"turnText", hmi_apis::Common_TextFieldName::addressLines},
- {"phoneNumber", hmi_apis::Common_TextFieldName::phoneNumber},
- {"turnText", hmi_apis::Common_TextFieldName::turnText},
- {"menuTitle", hmi_apis::Common_TextFieldName::menuTitle},
- {"navigationText", hmi_apis::Common_TextFieldName::navigationText},
-};
-
+ vr_enum_capabilities;
+std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name;
+std::map<std::string, hmi_apis::Common_TextFieldName::eType>
+ text_fields_enum_name;
std::map<std::string, hmi_apis::Common_MediaClockFormat::eType>
- media_clock_enum_name = {
- {"CLOCK1", hmi_apis::Common_MediaClockFormat::CLOCK1},
- {"CLOCK2", hmi_apis::Common_MediaClockFormat::CLOCK2},
- {"CLOCK3", hmi_apis::Common_MediaClockFormat::CLOCK3},
- {"CLOCKTEXT1", hmi_apis::Common_MediaClockFormat::CLOCKTEXT1},
- {"CLOCKTEXT2", hmi_apis::Common_MediaClockFormat::CLOCKTEXT2},
- {"CLOCKTEXT3", hmi_apis::Common_MediaClockFormat::CLOCKTEXT3},
- {"CLOCKTEXT4", hmi_apis::Common_MediaClockFormat::CLOCKTEXT4},
-};
-
-std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum = {
- {"STATIC", hmi_apis::Common_ImageType::STATIC},
- {"DYNAMIC", hmi_apis::Common_ImageType::DYNAMIC}};
-
-std::map<std::string, hmi_apis::Common_SamplingRate::eType> sampling_rate_enum =
- {{"RATE_8KHZ", hmi_apis::Common_SamplingRate::RATE_8KHZ},
- {"8KHZ", hmi_apis::Common_SamplingRate::RATE_8KHZ},
- {"RATE_16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ},
- {"16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ},
- {"RATE_22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ},
- {"22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ},
- {"RATE_44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ},
- {"44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ}};
-
+ media_clock_enum_name;
+std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum;
+std::map<std::string, hmi_apis::Common_SamplingRate::eType> sampling_rate_enum;
std::map<std::string, hmi_apis::Common_BitsPerSample::eType>
- bit_per_sample_enum = {
- {"RATE_8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT},
- {"8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT},
- {"RATE_16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT},
- {"16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT}};
+ bit_per_sample_enum;
+std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum;
+std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType>
+ hmi_zone_enum;
+std::map<std::string, hmi_apis::Common_ImageFieldName::eType>
+ image_field_name_enum;
+std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum;
+std::map<std::string, hmi_apis::Common_DisplayType::eType> display_type_enum;
+std::map<std::string, hmi_apis::Common_CharacterSet::eType> character_set_enum;
+
+void InitCapabilities() {
+ vr_enum_capabilities.insert(std::make_pair(
+ std::string("TEXT"), hmi_apis::Common_VrCapabilities::VR_TEXT));
+
+ button_enum_name.insert(
+ std::make_pair(std::string("OK"), hmi_apis::Common_ButtonName::OK));
+ button_enum_name.insert(std::make_pair(
+ std::string("SEEKLEFT"), hmi_apis::Common_ButtonName::SEEKLEFT));
+ button_enum_name.insert(std::make_pair(
+ std::string("SEEKRIGHT"), hmi_apis::Common_ButtonName::SEEKRIGHT));
+ button_enum_name.insert(std::make_pair(std::string("TUNEUP"),
+ hmi_apis::Common_ButtonName::TUNEUP));
+ button_enum_name.insert(std::make_pair(
+ std::string("TUNEDOWN"), hmi_apis::Common_ButtonName::TUNEDOWN));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_0"), hmi_apis::Common_ButtonName::PRESET_0));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_1"), hmi_apis::Common_ButtonName::PRESET_1));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_2"), hmi_apis::Common_ButtonName::PRESET_2));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_3"), hmi_apis::Common_ButtonName::PRESET_3));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_4"), hmi_apis::Common_ButtonName::PRESET_4));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_5"), hmi_apis::Common_ButtonName::PRESET_5));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_6"), hmi_apis::Common_ButtonName::PRESET_6));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_7"), hmi_apis::Common_ButtonName::PRESET_7));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_8"), hmi_apis::Common_ButtonName::PRESET_8));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_9"), hmi_apis::Common_ButtonName::PRESET_9));
+ button_enum_name.insert(
+ std::make_pair(std::string("CUSTOM_BUTTON"),
+ hmi_apis::Common_ButtonName::CUSTOM_BUTTON));
+ button_enum_name.insert(std::make_pair(std::string("SEARCH"),
+ hmi_apis::Common_ButtonName::SEARCH));
+
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField1"), hmi_apis::Common_TextFieldName::mainField1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField2"), hmi_apis::Common_TextFieldName::mainField2));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField3"), hmi_apis::Common_TextFieldName::mainField3));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField4"), hmi_apis::Common_TextFieldName::mainField4));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("statusBar"), hmi_apis::Common_TextFieldName::statusBar));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mediaClock"), hmi_apis::Common_TextFieldName::mediaClock));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mediaTrack"), hmi_apis::Common_TextFieldName::mediaTrack));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText1"), hmi_apis::Common_TextFieldName::alertText1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText2"), hmi_apis::Common_TextFieldName::alertText2));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText3"), hmi_apis::Common_TextFieldName::alertText3));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("scrollableMessageBody"),
+ hmi_apis::Common_TextFieldName::scrollableMessageBody));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("initialInteractionText"),
+ hmi_apis::Common_TextFieldName::initialInteractionText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText1"),
+ hmi_apis::Common_TextFieldName::navigationText1));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText2"),
+ hmi_apis::Common_TextFieldName::navigationText2));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("ETA"), hmi_apis::Common_TextFieldName::ETA));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("totalDistance"),
+ hmi_apis::Common_TextFieldName::totalDistance));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("audioPassThruDisplayText1"),
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("audioPassThruDisplayText2"),
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText2));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("sliderHeader"),
+ hmi_apis::Common_TextFieldName::sliderHeader));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("sliderFooter"),
+ hmi_apis::Common_TextFieldName::sliderFooter));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText"),
+ hmi_apis::Common_TextFieldName::navigationText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("notificationText"),
+ hmi_apis::Common_TextFieldName::notificationText));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("menuName"), hmi_apis::Common_TextFieldName::menuName));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("secondaryText"),
+ hmi_apis::Common_TextFieldName::secondaryText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("tertiaryText"),
+ hmi_apis::Common_TextFieldName::tertiaryText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("timeToDestination"),
+ hmi_apis::Common_TextFieldName::timeToDestination));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("locationName"),
+ hmi_apis::Common_TextFieldName::locationName));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("locationDescription"),
+ hmi_apis::Common_TextFieldName::locationDescription));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("turnText"), hmi_apis::Common_TextFieldName::turnText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("addressLines"),
+ hmi_apis::Common_TextFieldName::addressLines));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("phoneNumber"), hmi_apis::Common_TextFieldName::phoneNumber));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("turnText"), hmi_apis::Common_TextFieldName::turnText));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("menuTitle"), hmi_apis::Common_TextFieldName::menuTitle));
+
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK1"), hmi_apis::Common_MediaClockFormat::CLOCK1));
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK2"), hmi_apis::Common_MediaClockFormat::CLOCK2));
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK3"), hmi_apis::Common_MediaClockFormat::CLOCK3));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT1"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT1));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT2"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT2));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT3"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT3));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT4"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT4));
+
+ image_type_enum.insert(std::make_pair(std::string("STATIC"),
+ hmi_apis::Common_ImageType::STATIC));
+ image_type_enum.insert(std::make_pair(std::string("DYNAMIC"),
+ hmi_apis::Common_ImageType::DYNAMIC));
+
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("8KHZ"), hmi_apis::Common_SamplingRate::RATE_8KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("16KHZ"), hmi_apis::Common_SamplingRate::RATE_16KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("22KHZ"), hmi_apis::Common_SamplingRate::RATE_22KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("44KHZ"), hmi_apis::Common_SamplingRate::RATE_44KHZ));
+
+ bit_per_sample_enum.insert(std::make_pair(
+ std::string("RATE_8_BIT"), hmi_apis::Common_BitsPerSample::RATE_8_BIT));
+ bit_per_sample_enum.insert(std::make_pair(
+ std::string("RATE_16_BIT"), hmi_apis::Common_BitsPerSample::RATE_16_BIT));
+
+ audio_type_enum.insert(
+ std::make_pair(std::string("PCM"), hmi_apis::Common_AudioType::PCM));
+
+ hmi_zone_enum.insert(std::make_pair(
+ std::string("FRONT"), hmi_apis::Common_HmiZoneCapabilities::FRONT));
+ hmi_zone_enum.insert(std::make_pair(
+ std::string("BACK"), hmi_apis::Common_HmiZoneCapabilities::BACK));
+
+ image_field_name_enum.insert(
+ std::make_pair(std::string("softButtonImage"),
+ hmi_apis::Common_ImageFieldName::softButtonImage));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("choiceImage"),
+ hmi_apis::Common_ImageFieldName::choiceImage));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("choiceSecondaryImage"),
+ hmi_apis::Common_ImageFieldName::choiceSecondaryImage));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("vrHelpItem"), hmi_apis::Common_ImageFieldName::vrHelpItem));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("turnIcon"), hmi_apis::Common_ImageFieldName::turnIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("menuIcon"), hmi_apis::Common_ImageFieldName::menuIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("cmdIcon"), hmi_apis::Common_ImageFieldName::cmdIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("appIcon"), hmi_apis::Common_ImageFieldName::appIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("graphic"), hmi_apis::Common_ImageFieldName::graphic));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("showConstantTBTIcon"),
+ hmi_apis::Common_ImageFieldName::showConstantTBTIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("showConstantTBTNextTurnIcon"),
+ hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("locationImage"),
+ hmi_apis::Common_ImageFieldName::locationImage));
+
+ file_type_enum.insert(std::make_pair(std::string("GRAPHIC_BMP"),
+ hmi_apis::Common_FileType::GRAPHIC_BMP));
+ file_type_enum.insert(std::make_pair(
+ std::string("GRAPHIC_JPEG"), hmi_apis::Common_FileType::GRAPHIC_JPEG));
+ file_type_enum.insert(std::make_pair(std::string("GRAPHIC_PNG"),
+ hmi_apis::Common_FileType::GRAPHIC_PNG));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_WAVE"),
+ hmi_apis::Common_FileType::AUDIO_WAVE));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_MP3"),
+ hmi_apis::Common_FileType::AUDIO_MP3));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_AAC"),
+ hmi_apis::Common_FileType::AUDIO_AAC));
+ file_type_enum.insert(
+ std::make_pair(std::string("BINARY"), hmi_apis::Common_FileType::BINARY));
+ file_type_enum.insert(
+ std::make_pair(std::string("JSON"), hmi_apis::Common_FileType::JSON));
+
+ display_type_enum.insert(
+ std::make_pair(std::string("CID"), hmi_apis::Common_DisplayType::CID));
+ display_type_enum.insert(std::make_pair(std::string("TYPE2"),
+ hmi_apis::Common_DisplayType::TYPE2));
+ display_type_enum.insert(std::make_pair(std::string("TYPE5"),
+ hmi_apis::Common_DisplayType::TYPE5));
+ display_type_enum.insert(
+ std::make_pair(std::string("NGN"), hmi_apis::Common_DisplayType::NGN));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN2_8_DMA"), hmi_apis::Common_DisplayType::GEN2_8_DMA));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN2_6_DMA"), hmi_apis::Common_DisplayType::GEN2_6_DMA));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD3"), hmi_apis::Common_DisplayType::MFD3));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD4"), hmi_apis::Common_DisplayType::MFD4));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD5"), hmi_apis::Common_DisplayType::MFD5));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN3_8_INCH"), hmi_apis::Common_DisplayType::GEN3_8_INCH));
+
+ character_set_enum.insert(std::make_pair(
+ std::string("TYPE2SET"), hmi_apis::Common_CharacterSet::TYPE2SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("TYPE5SET"), hmi_apis::Common_CharacterSet::TYPE5SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("CID1SET"), hmi_apis::Common_CharacterSet::CID1SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("CID2SET"), hmi_apis::Common_CharacterSet::CID2SET));
+}
-std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum = {
- {"PCM", hmi_apis::Common_AudioType::PCM}};
+} // namespace
-std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType>
- hmi_zone_enum = {
- {"FRONT", hmi_apis::Common_HmiZoneCapabilities::FRONT},
- {"BACK", hmi_apis::Common_HmiZoneCapabilities::BACK},
-};
-
-const std::map<std::string, hmi_apis::Common_ImageFieldName::eType>
- image_field_name_enum = {
- {"softButtonImage", hmi_apis::Common_ImageFieldName::softButtonImage},
- {"choiceImage", hmi_apis::Common_ImageFieldName::choiceImage},
- {"choiceSecondaryImage",
- hmi_apis::Common_ImageFieldName::choiceSecondaryImage},
- {"vrHelpItem", hmi_apis::Common_ImageFieldName::vrHelpItem},
- {"turnIcon", hmi_apis::Common_ImageFieldName::turnIcon},
- {"menuIcon", hmi_apis::Common_ImageFieldName::menuIcon},
- {"cmdIcon", hmi_apis::Common_ImageFieldName::cmdIcon},
- {"appIcon", hmi_apis::Common_ImageFieldName::appIcon},
- {"graphic", hmi_apis::Common_ImageFieldName::graphic},
- {"showConstantTBTIcon",
- hmi_apis::Common_ImageFieldName::showConstantTBTIcon},
- {"showConstantTBTNextTurnIcon",
- hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon},
- {"locationImage", hmi_apis::Common_ImageFieldName::locationImage}};
-
-const std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum = {
- {"GRAPHIC_BMP", hmi_apis::Common_FileType::GRAPHIC_BMP},
- {"GRAPHIC_JPEG", hmi_apis::Common_FileType::GRAPHIC_JPEG},
- {"GRAPHIC_PNG", hmi_apis::Common_FileType::GRAPHIC_PNG},
- {"AUDIO_WAVE", hmi_apis::Common_FileType::AUDIO_WAVE},
- {"AUDIO_MP3", hmi_apis::Common_FileType::AUDIO_MP3},
- {"AUDIO_AAC", hmi_apis::Common_FileType::AUDIO_AAC},
- {"BINARY", hmi_apis::Common_FileType::BINARY},
- {"JSON", hmi_apis::Common_FileType::JSON}};
-
-const std::map<std::string, hmi_apis::Common_DisplayType::eType>
- display_type_enum = {
- {"CID", hmi_apis::Common_DisplayType::CID},
- {"TYPE2", hmi_apis::Common_DisplayType::TYPE2},
- {"TYPE5", hmi_apis::Common_DisplayType::TYPE5},
- {"NGN", hmi_apis::Common_DisplayType::NGN},
- {"GEN2_8_DMA", hmi_apis::Common_DisplayType::GEN2_8_DMA},
- {"GEN2_6_DMA", hmi_apis::Common_DisplayType::GEN2_6_DMA},
- {"MFD3", hmi_apis::Common_DisplayType::MFD3},
- {"MFD4", hmi_apis::Common_DisplayType::MFD4},
- {"MFD5", hmi_apis::Common_DisplayType::MFD5},
- {"GEN3_8_INCH", hmi_apis::Common_DisplayType::GEN3_8_INCH},
- {"SDL_GENERIC", hmi_apis::Common_DisplayType::SDL_GENERIC}};
-
-const std::map<std::string, hmi_apis::Common_CharacterSet::eType>
- character_set_enum = {{"TYPE2SET", hmi_apis::Common_CharacterSet::TYPE2SET},
- {"TYPE5SET", hmi_apis::Common_CharacterSet::TYPE5SET},
- {"CID1SET", hmi_apis::Common_CharacterSet::CID1SET},
- {"CID2SET", hmi_apis::Common_CharacterSet::CID2SET}};
-
-HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
+HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
: is_vr_cooperating_(false)
, is_tts_cooperating_(false)
, is_ui_cooperating_(false)
, is_navi_cooperating_(false)
, is_ivi_cooperating_(false)
- , is_vr_ready_response_recieved_(false)
- , is_tts_ready_response_recieved_(false)
- , is_ui_ready_response_recieved_(false)
- , is_navi_ready_response_recieved_(false)
- , is_ivi_ready_response_recieved_(false)
, attenuated_supported_(false)
, ui_language_(hmi_apis::Common_Language::INVALID_ENUM)
, vr_language_(hmi_apis::Common_Language::INVALID_ENUM)
@@ -237,14 +345,9 @@ HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
, is_navigation_supported_(false)
, is_phone_call_supported_(false)
, app_mngr_(app_mngr)
- , hmi_language_handler_(app_mngr_) {
+ , hmi_language_handler_(app_mngr) {
+ InitCapabilities();
if (false == app_mngr_.get_settings().launch_hmi()) {
- is_vr_ready_response_recieved_ = true;
- is_tts_ready_response_recieved_ = true;
- is_ui_ready_response_recieved_ = true;
- is_navi_ready_response_recieved_ = true;
- is_ivi_ready_response_recieved_ = true;
-
is_vr_cooperating_ = true;
is_tts_cooperating_ = true;
is_ui_cooperating_ = true;
@@ -253,7 +356,7 @@ HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
}
}
-HMICapabilities::~HMICapabilities() {
+HMICapabilitiesImpl::~HMICapabilitiesImpl() {
delete vehicle_type_;
delete ui_supported_languages_;
delete tts_supported_languages_;
@@ -270,46 +373,7 @@ HMICapabilities::~HMICapabilities() {
delete prerecorded_speech_;
}
-bool HMICapabilities::is_hmi_capabilities_initialized() const {
- bool result = true;
-
- if (is_vr_ready_response_recieved_ && is_tts_ready_response_recieved_ &&
- is_ui_ready_response_recieved_ && is_navi_ready_response_recieved_ &&
- is_ivi_ready_response_recieved_) {
- if (is_vr_cooperating_) {
- if ((!vr_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == vr_language_)) {
- result = false;
- }
- }
-
- if (is_tts_cooperating_) {
- if ((!tts_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == tts_language_)) {
- result = false;
- }
- }
-
- if (is_ui_cooperating_) {
- if ((!ui_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == ui_language_)) {
- result = false;
- }
- }
-
- if (is_ivi_cooperating_) {
- if (!vehicle_type_) {
- result = false;
- }
- }
- } else {
- result = false;
- }
-
- return result;
-}
-
-bool HMICapabilities::VerifyImageType(int32_t image_type) const {
+bool HMICapabilitiesImpl::VerifyImageType(const int32_t image_type) const {
if (!display_capabilities_) {
return false;
}
@@ -327,108 +391,52 @@ bool HMICapabilities::VerifyImageType(int32_t image_type) const {
return false;
}
-void HMICapabilities::set_is_vr_cooperating(bool value) {
- is_vr_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_vr_cooperating(const bool value) {
is_vr_cooperating_ = value;
- if (is_vr_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VR_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VR_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_tts_cooperating(bool value) {
- is_tts_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_tts_cooperating(const bool value) {
is_tts_cooperating_ = value;
- if (is_tts_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::TTS_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::TTS_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_ui_cooperating(bool value) {
- is_ui_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_ui_cooperating(const bool value) {
is_ui_cooperating_ = value;
- if (is_ui_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::UI_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::UI_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_navi_cooperating(bool value) {
- is_navi_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_navi_cooperating(const bool value) {
is_navi_cooperating_ = value;
}
-void HMICapabilities::set_is_ivi_cooperating(bool value) {
- is_ivi_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_ivi_cooperating(const bool value) {
is_ivi_cooperating_ = value;
- if (is_ivi_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_type(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleType, app_mngr_));
- app_mngr_.ManageHMICommand(get_type);
- }
}
-void HMICapabilities::set_attenuated_supported(bool state) {
+void HMICapabilitiesImpl::set_attenuated_supported(const bool state) {
attenuated_supported_ = state;
}
-void HMICapabilities::set_active_ui_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_ui_language(
+ const hmi_apis::Common_Language::eType language) {
ui_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_UI,
language);
}
-void HMICapabilities::set_active_vr_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_vr_language(
+ const hmi_apis::Common_Language::eType language) {
vr_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_VR,
language);
}
-void HMICapabilities::set_active_tts_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_tts_language(
+ const hmi_apis::Common_Language::eType language) {
tts_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_TTS,
language);
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_ui_language()
+const hmi_apis::Common_Language::eType HMICapabilitiesImpl::active_ui_language()
const {
using namespace hmi_apis;
const Common_Language::eType language =
@@ -436,7 +444,7 @@ const hmi_apis::Common_Language::eType HMICapabilities::active_ui_language()
return Common_Language::INVALID_ENUM != language ? language : ui_language_;
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_vr_language()
+const hmi_apis::Common_Language::eType HMICapabilitiesImpl::active_vr_language()
const {
using namespace hmi_apis;
const Common_Language::eType language =
@@ -444,15 +452,15 @@ const hmi_apis::Common_Language::eType HMICapabilities::active_vr_language()
return Common_Language::INVALID_ENUM != language ? language : vr_language_;
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_tts_language()
- const {
+const hmi_apis::Common_Language::eType
+HMICapabilitiesImpl::active_tts_language() const {
using namespace hmi_apis;
const Common_Language::eType language =
hmi_language_handler_.get_language_for(HMILanguageHandler::INTERFACE_TTS);
return Common_Language::INVALID_ENUM != language ? language : tts_language_;
}
-void HMICapabilities::set_ui_supported_languages(
+void HMICapabilitiesImpl::set_ui_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (ui_supported_languages_) {
delete ui_supported_languages_;
@@ -460,7 +468,7 @@ void HMICapabilities::set_ui_supported_languages(
ui_supported_languages_ = new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_tts_supported_languages(
+void HMICapabilitiesImpl::set_tts_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (tts_supported_languages_) {
delete tts_supported_languages_;
@@ -469,7 +477,7 @@ void HMICapabilities::set_tts_supported_languages(
new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_vr_supported_languages(
+void HMICapabilitiesImpl::set_vr_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (vr_supported_languages_) {
delete vr_supported_languages_;
@@ -477,7 +485,7 @@ void HMICapabilities::set_vr_supported_languages(
vr_supported_languages_ = new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_display_capabilities(
+void HMICapabilitiesImpl::set_display_capabilities(
const smart_objects::SmartObject& display_capabilities) {
if (display_capabilities_) {
delete display_capabilities_;
@@ -485,7 +493,7 @@ void HMICapabilities::set_display_capabilities(
display_capabilities_ = new smart_objects::SmartObject(display_capabilities);
}
-void HMICapabilities::set_hmi_zone_capabilities(
+void HMICapabilitiesImpl::set_hmi_zone_capabilities(
const smart_objects::SmartObject& hmi_zone_capabilities) {
if (hmi_zone_capabilities_) {
delete hmi_zone_capabilities_;
@@ -494,7 +502,7 @@ void HMICapabilities::set_hmi_zone_capabilities(
new smart_objects::SmartObject(hmi_zone_capabilities);
}
-void HMICapabilities::set_soft_button_capabilities(
+void HMICapabilitiesImpl::set_soft_button_capabilities(
const smart_objects::SmartObject& soft_button_capabilities) {
if (soft_buttons_capabilities_) {
delete soft_buttons_capabilities_;
@@ -503,7 +511,7 @@ void HMICapabilities::set_soft_button_capabilities(
new smart_objects::SmartObject(soft_button_capabilities);
}
-void HMICapabilities::set_button_capabilities(
+void HMICapabilitiesImpl::set_button_capabilities(
const smart_objects::SmartObject& button_capabilities) {
if (button_capabilities_) {
delete button_capabilities_;
@@ -511,7 +519,7 @@ void HMICapabilities::set_button_capabilities(
button_capabilities_ = new smart_objects::SmartObject(button_capabilities);
}
-void HMICapabilities::set_vr_capabilities(
+void HMICapabilitiesImpl::set_vr_capabilities(
const smart_objects::SmartObject& vr_capabilities) {
if (vr_capabilities_) {
delete vr_capabilities_;
@@ -519,7 +527,7 @@ void HMICapabilities::set_vr_capabilities(
vr_capabilities_ = new smart_objects::SmartObject(vr_capabilities);
}
-void HMICapabilities::set_speech_capabilities(
+void HMICapabilitiesImpl::set_speech_capabilities(
const smart_objects::SmartObject& speech_capabilities) {
if (speech_capabilities_) {
delete speech_capabilities_;
@@ -527,7 +535,7 @@ void HMICapabilities::set_speech_capabilities(
speech_capabilities_ = new smart_objects::SmartObject(speech_capabilities);
}
-void HMICapabilities::set_audio_pass_thru_capabilities(
+void HMICapabilitiesImpl::set_audio_pass_thru_capabilities(
const smart_objects::SmartObject& audio_pass_thru_capabilities) {
if (audio_pass_thru_capabilities_) {
delete audio_pass_thru_capabilities_;
@@ -536,7 +544,7 @@ void HMICapabilities::set_audio_pass_thru_capabilities(
new smart_objects::SmartObject(audio_pass_thru_capabilities);
}
-void HMICapabilities::set_pcm_stream_capabilities(
+void HMICapabilitiesImpl::set_pcm_stream_capabilities(
const smart_objects::SmartObject& pcm_stream_capabilities) {
if (pcm_stream_capabilities_) {
delete pcm_stream_capabilities_;
@@ -545,7 +553,7 @@ void HMICapabilities::set_pcm_stream_capabilities(
new smart_objects::SmartObject(pcm_stream_capabilities);
}
-void HMICapabilities::set_preset_bank_capabilities(
+void HMICapabilitiesImpl::set_preset_bank_capabilities(
const smart_objects::SmartObject& preset_bank_capabilities) {
if (preset_bank_capabilities_) {
delete preset_bank_capabilities_;
@@ -554,7 +562,7 @@ void HMICapabilities::set_preset_bank_capabilities(
new smart_objects::SmartObject(preset_bank_capabilities);
}
-void HMICapabilities::set_vehicle_type(
+void HMICapabilitiesImpl::set_vehicle_type(
const smart_objects::SmartObject& vehicle_type) {
if (vehicle_type_) {
delete vehicle_type_;
@@ -562,7 +570,7 @@ void HMICapabilities::set_vehicle_type(
vehicle_type_ = new smart_objects::SmartObject(vehicle_type);
}
-void HMICapabilities::set_prerecorded_speech(
+void HMICapabilitiesImpl::set_prerecorded_speech(
const smart_objects::SmartObject& prerecorded_speech) {
if (prerecorded_speech_) {
delete prerecorded_speech_;
@@ -571,19 +579,14 @@ void HMICapabilities::set_prerecorded_speech(
prerecorded_speech_ = new smart_objects::SmartObject(prerecorded_speech);
}
-void HMICapabilities::set_ccpu_version(const std::string& ccpu_version) {
- ccpu_version_ = ccpu_version;
-}
-
-void HMICapabilities::set_navigation_supported(const bool supported) {
+void HMICapabilitiesImpl::set_navigation_supported(const bool supported) {
is_navigation_supported_ = supported;
}
-
-void HMICapabilities::set_phone_call_supported(const bool supported) {
+void HMICapabilitiesImpl::set_phone_call_supported(const bool supported) {
is_phone_call_supported_ = supported;
}
-void HMICapabilities::Init(resumption::LastState* last_state) {
+void HMICapabilitiesImpl::Init(resumption::LastState* last_state) {
hmi_language_handler_.Init(last_state);
if (false == load_capabilities_from_file()) {
LOG4CXX_ERROR(logger_, "file hmi_capabilities.json was not loaded");
@@ -594,7 +597,107 @@ void HMICapabilities::Init(resumption::LastState* last_state) {
ui_language_, vr_language_, tts_language_);
}
-bool HMICapabilities::load_capabilities_from_file() {
+bool HMICapabilitiesImpl::is_ui_cooperating() const {
+ return is_ui_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_vr_cooperating() const {
+ return is_vr_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_tts_cooperating() const {
+ return is_tts_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_navi_cooperating() const {
+ return is_navi_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_ivi_cooperating() const {
+ return is_ivi_cooperating_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::ui_supported_languages()
+ const {
+ return ui_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vr_supported_languages()
+ const {
+ return vr_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::tts_supported_languages()
+ const {
+ return tts_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities()
+ const {
+ return display_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::hmi_zone_capabilities()
+ const {
+ return hmi_zone_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::soft_button_capabilities() const {
+ return soft_buttons_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::button_capabilities()
+ const {
+ return button_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::speech_capabilities()
+ const {
+ return speech_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vr_capabilities() const {
+ return vr_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::audio_pass_thru_capabilities() const {
+ return audio_pass_thru_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::pcm_stream_capabilities()
+ const {
+ return pcm_stream_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::preset_bank_capabilities() const {
+ return preset_bank_capabilities_;
+}
+
+bool HMICapabilitiesImpl::attenuated_supported() const {
+ return attenuated_supported_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vehicle_type() const {
+ return vehicle_type_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::prerecorded_speech()
+ const {
+ return prerecorded_speech_;
+}
+
+bool HMICapabilitiesImpl::navigation_supported() const {
+ return is_navigation_supported_;
+}
+
+bool HMICapabilitiesImpl::phone_call_supported() const {
+ return is_phone_call_supported_;
+}
+
+bool HMICapabilitiesImpl::load_capabilities_from_file() {
std::string json_string;
std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name();
@@ -621,6 +724,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(ui, "language")) {
const std::string lang = ui.get("language", "EN-US").asString();
set_active_ui_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_ui_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(ui, "languages")) {
@@ -650,10 +756,10 @@ bool HMICapabilities::load_capabilities_from_file() {
}
if (display_capabilities_so.keyExists(hmi_response::text_fields)) {
- uint32_t len =
+ const uint32_t kLen =
display_capabilities_so[hmi_response::text_fields].length();
- for (uint32_t i = 0; i < len; ++i) {
+ for (uint32_t i = 0; i < kLen; ++i) {
if ((display_capabilities_so[hmi_response::text_fields][i])
.keyExists(strings::name)) {
std::map<std::string,
@@ -843,6 +949,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(vr, "language")) {
const std::string lang = vr.get("language", "EN-US").asString();
set_active_vr_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_vr_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(vr, "languages")) {
@@ -872,6 +981,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(tts, "language")) {
const std::string lang = tts.get("language", "EN-US").asString();
set_active_tts_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_tts_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(tts, "languages")) {
@@ -935,17 +1047,35 @@ bool HMICapabilities::load_capabilities_from_file() {
return true;
}
-bool HMICapabilities::check_existing_json_member(const Json::Value& json_member,
- const char* name_of_member) {
+void HMICapabilitiesImpl::set_ccpu_version(const std::string& ccpu_version) {
+ ccpu_version_ = ccpu_version;
+}
+
+const std::string& HMICapabilitiesImpl::ccpu_version() const {
+ return ccpu_version_;
+}
+
+bool HMICapabilitiesImpl::check_existing_json_member(
+ const Json::Value& json_member, const char* name_of_member) const {
return json_member.isMember(name_of_member);
}
-void HMICapabilities::convert_json_languages_to_obj(
- Json::Value& json_languages, smart_objects::SmartObject& languages) {
+void HMICapabilitiesImpl::convert_json_languages_to_obj(
+ const Json::Value& json_languages,
+ smart_objects::SmartObject& languages) const {
for (uint32_t i = 0, j = 0; i < json_languages.size(); ++i) {
languages[j++] =
MessageHelper::CommonLanguageFromString(json_languages[i].asString());
}
}
+HMILanguageHandler& HMICapabilitiesImpl::get_hmi_language_handler() {
+ return hmi_language_handler_;
+}
+
+void HMICapabilitiesImpl::set_handle_response_for(
+ const smart_objects::SmartObject& request) {
+ hmi_language_handler_.set_handle_response_for(request);
+}
+
} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
new file mode 100644
index 0000000000..5665d0654a
--- /dev/null
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2016, 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/hmi_interfaces_impl.h"
+namespace application_manager {
+
+std::map<hmi_apis::FunctionID::eType, HmiInterfaces::InterfaceID>
+generate_function_to_interface_convert_map() {
+ using namespace hmi_apis::FunctionID;
+ std::map<hmi_apis::FunctionID::eType, HmiInterfaces::InterfaceID> convert_map;
+ convert_map[Buttons_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonEvent] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonPress] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonSubscription] =
+ HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[BasicCommunication_OnReady] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnStartDeviceDiscovery] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnUpdateDeviceList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnPhoneCall] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnEmergencyEvent] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnResumeAudioSource] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSDLPersistenceComplete] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_UpdateAppList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_UpdateDeviceList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnFileRemoved] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_AllowDeviceToConnect] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnDeviceChosen] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnFindApplications] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_ActivateApp] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppActivated] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppDeactivated] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppRegistered] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppUnregistered] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnExitApplication] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnExitAllApplications] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAwakeSDL] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_MixingAudioSupported] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_DialNumber] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSystemRequest] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_SystemRequest] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_PolicyUpdate] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSDLClose] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnPutFile] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_GetSystemInfo] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSystemInfoChanged] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnIgnitionCycleOver] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnDeactivateHMI] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnEventChanged] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_AddCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_OnCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetLanguage] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[TTS_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Started] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Stopped] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_IsReady] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Speak] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_StopSpeaking] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_GetLanguage] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[UI_Alert] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_Show] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_AddCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_AddSubMenu] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_DeleteSubMenu] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetMediaClockTimer] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnSystemContext] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetLanguage] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnDriverDistraction] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetAppIcon] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetDisplayLayout] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ShowCustomForm] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnKeyboardInput] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnTouchEvent] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_Slider] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ScrollableMessage] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_PerformAudioPassThru] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_EndAudioPassThru] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_IsReady] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ClosePopUp] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[Navigation_IsReady] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_SendLocation] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_ShowConstantTBT] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_AlertManeuver] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_UpdateTurnList] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnTBTClientState] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StartStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StopStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StartAudioStream] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StopAudioStream] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnAudioDataStreaming] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnVideoDataStreaming] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_GetWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnWayPointChange] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_SubscribeWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_UnsubscribeWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[VehicleInfo_IsReady] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetVehicleType] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_ReadDID] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetDTCs] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_DiagnosticMessage] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_SubscribeVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_UnsubscribeVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_OnVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[SDL_ActivateApp] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetUserFriendlyMessage] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAllowSDLFunctionality] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnReceivedPolicyUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnPolicyUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetListOfPermissions] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAppPermissionConsent] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAppPermissionChanged] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnSDLConsentNeeded] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_UpdateSDL] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnSystemError] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_AddStatisticsInfo] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL;
+ return convert_map;
+}
+
+HmiInterfacesImpl::HmiInterfacesImpl() {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_BasicCommunication] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_Buttons] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_Navigation] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_SDL] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_TTS] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_UI] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_VehicleInfo] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_VR] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+}
+
+HmiInterfaces::InterfaceState HmiInterfacesImpl::GetInterfaceState(
+ HmiInterfaces::InterfaceID interface) const {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ const InterfaceStatesMap::const_iterator it =
+ interfaces_states_.find(interface);
+ // all interfaces should be presented in interfaces_states_ map.
+ DCHECK_OR_RETURN(it != interfaces_states_.end(), STATE_NOT_RESPONSE);
+ return it->second;
+}
+
+void HmiInterfacesImpl::SetInterfaceState(HmiInterfaces::InterfaceID interface,
+ HmiInterfaces::InterfaceState state) {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ DCHECK(interfaces_states_.find(interface) != interfaces_states_.end());
+ interfaces_states_[interface] = state;
+}
+
+HmiInterfaces::InterfaceID HmiInterfacesImpl::GetInterfaceFromFunction(
+ hmi_apis::FunctionID::eType function) const {
+ // TODO(AKutsan): APPLINK-26874: Generate map of functionid to inteface
+ // automaticaly from
+ // HMI_API.xml
+ static const std::map<hmi_apis::FunctionID::eType, InterfaceID> convert_map =
+ generate_function_to_interface_convert_map();
+ const std::map<hmi_apis::FunctionID::eType, InterfaceID>::const_iterator it =
+ convert_map.find(function);
+ return it != convert_map.end() ? it->second : HMI_INTERFACE_INVALID_ENUM;
+}
+} // namespace application_manager
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 08efba3d70..a764c574d0 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -1156,51 +1156,6 @@ void MessageHelper::SendUIChangeRegistrationRequestToHMI(
}
}
-void MessageHelper::SendChangeRegistrationRequestToHMI(
- ApplicationConstSharedPtr app, ApplicationManager& app_mngr) {
- if (!app.valid()) {
- return;
- }
- if (mobile_apis::Language::INVALID_ENUM != app->language()) {
- smart_objects::SmartObjectSPtr vr_command =
- CreateChangeRegistration(hmi_apis::FunctionID::VR_ChangeRegistration,
- app->language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (vr_command) {
- app_mngr.ManageHMICommand(vr_command);
- }
- }
-
- if (mobile_apis::Language::INVALID_ENUM != app->language()) {
- smart_objects::SmartObjectSPtr tts_command =
- CreateChangeRegistration(hmi_apis::FunctionID::TTS_ChangeRegistration,
- app->language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (tts_command) {
- app_mngr.ManageHMICommand(tts_command);
- }
- }
-
- if (mobile_apis::Language::INVALID_ENUM != app->ui_language()) {
- smart_objects::SmartObjectSPtr ui_command =
- CreateChangeRegistration(hmi_apis::FunctionID::UI_ChangeRegistration,
- app->ui_language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (ui_command) {
- app_mngr.ManageHMICommand(ui_command);
- }
- }
-}
-
void MessageHelper::SendAddVRCommandToHMI(
const uint32_t cmd_id,
const smart_objects::SmartObject& vr_commands,
diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc
index f30ed5fd4f..aa2a3d7c5d 100644
--- a/src/components/application_manager/src/request_controller.cc
+++ b/src/components/application_manager/src/request_controller.cc
@@ -57,7 +57,7 @@ RequestController::RequestController(const RequestControlerSettings& settings)
, settings_(settings) {
LOG4CXX_AUTO_TRACE(logger_);
InitializeThreadpool();
- timer_.Start(0, true);
+ timer_.Start(0, timer::kSingleShot);
}
RequestController::~RequestController() {
@@ -232,37 +232,45 @@ void RequestController::removeNotification(
LOG4CXX_DEBUG(logger_, "Cant find notification");
}
-void RequestController::terminateRequest(const uint32_t& correlation_id,
- const uint32_t& connection_key,
+void RequestController::TerminateRequest(const uint32_t correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id,
bool force_terminate) {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_,
"correlation_id = "
<< correlation_id << " connection_key = " << connection_key
+ << " function_id = " << function_id
<< " force_terminate = " << force_terminate);
RequestInfoPtr request =
waiting_for_response_.Find(connection_key, correlation_id);
- if (request) {
- if (force_terminate || request->request()->AllowedToTerminate()) {
- waiting_for_response_.RemoveRequest(request);
- } else {
- LOG4CXX_WARN(logger_, "Request was not terminated");
- }
- NotifyTimer();
+ if (!request) {
+ LOG4CXX_WARN(logger_, "Request was not found in waiting_for_response");
+ return;
+ }
+ if (request->request()->function_id() != function_id) {
+ LOG4CXX_ERROR(logger_, "Request and response function_id's don't match");
+ return;
+ }
+ if (force_terminate || request->request()->AllowedToTerminate()) {
+ waiting_for_response_.RemoveRequest(request);
} else {
- LOG4CXX_WARN(logger_, "Request not found in waiting_for_response_");
+ LOG4CXX_WARN(logger_, "Request was not terminated");
}
+ NotifyTimer();
}
-void RequestController::OnMobileResponse(const uint32_t& mobile_correlation_id,
- const uint32_t& connection_key) {
+void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id) {
LOG4CXX_AUTO_TRACE(logger_);
- terminateRequest(mobile_correlation_id, connection_key);
+ TerminateRequest(mobile_correlation_id, connection_key, function_id);
}
-void RequestController::OnHMIResponse(const uint32_t& correlation_id) {
+void RequestController::OnHMIResponse(const uint32_t correlation_id,
+ const int32_t function_id) {
LOG4CXX_AUTO_TRACE(logger_);
- terminateRequest(correlation_id, RequestInfo::HmiConnectoinKey);
+ TerminateRequest(correlation_id, RequestInfo::HmiConnectoinKey, function_id);
}
void RequestController::terminateWaitingForExecutionAppRequests(
diff --git a/src/components/application_manager/src/resumption/resume_ctrl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index 16007ba11a..ad50bbf104 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -29,7 +29,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/resumption/resume_ctrl_impl.h"
#include <fstream>
#include <algorithm>
@@ -55,28 +55,28 @@ using namespace application_manager;
CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption")
-ResumeCtrl::ResumeCtrl(ApplicationManager& application_manager)
+ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager)
: event_engine::EventObserver(application_manager.event_dispatcher())
, queue_lock_(false)
, restore_hmi_level_timer_(
"RsmCtrlRstore",
- new timer::TimerTaskImpl<ResumeCtrl>(
- this, &ResumeCtrl::ApplicationResumptiOnTimer))
+ new timer::TimerTaskImpl<ResumeCtrlImpl>(
+ this, &ResumeCtrlImpl::ApplicationResumptiOnTimer))
, save_persistent_data_timer_("RsmCtrlPercist",
- new timer::TimerTaskImpl<ResumeCtrl>(
- this, &ResumeCtrl::SaveDataOnTimer))
+ new timer::TimerTaskImpl<ResumeCtrlImpl>(
+ this, &ResumeCtrlImpl::SaveDataOnTimer))
, is_resumption_active_(false)
, is_data_saved_(false)
, launch_time_(time(NULL))
, application_manager_(application_manager) {}
#ifdef BUILD_TESTS
-void ResumeCtrl::set_resumption_storage(
+void ResumeCtrlImpl::set_resumption_storage(
utils::SharedPtr<ResumptionData> mock_storage) {
resumption_storage_ = mock_storage;
}
#endif // BUILD_TESTS
-bool ResumeCtrl::Init(resumption::LastState& last_state) {
+bool ResumeCtrlImpl::Init(resumption::LastState& last_state) {
bool use_db = application_manager_.get_settings().use_db_for_resumption();
if (use_db) {
resumption_storage_.reset(
@@ -115,20 +115,21 @@ bool ResumeCtrl::Init(resumption::LastState& last_state) {
save_persistent_data_timer_.Start(
application_manager_.get_settings()
.app_resumption_save_persistent_data_timeout(),
- false);
+ timer::kPeriodic);
return true;
}
-ResumeCtrl::~ResumeCtrl() {}
+ResumeCtrlImpl::~ResumeCtrlImpl() {}
-void ResumeCtrl::SaveAllApplications() {
+void ResumeCtrlImpl::SaveAllApplications() {
DataAccessor<ApplicationSet> accessor(application_manager_.applications());
- std::for_each(accessor.GetData().begin(),
- accessor.GetData().end(),
- std::bind1st(std::mem_fun(&ResumeCtrl::SaveApplication), this));
+ std::for_each(
+ accessor.GetData().begin(),
+ accessor.GetData().end(),
+ std::bind1st(std::mem_fun(&ResumeCtrlImpl::SaveApplication), this));
}
-void ResumeCtrl::SaveApplication(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
LOG4CXX_INFO(logger_,
@@ -137,11 +138,11 @@ void ResumeCtrl::SaveApplication(ApplicationSharedPtr application) {
resumption_storage_->SaveApplication(application);
}
-void ResumeCtrl::on_event(const event_engine::Event& event) {
+void ResumeCtrlImpl::on_event(const event_engine::Event& event) {
LOG4CXX_DEBUG(logger_, "Event received" << event.id());
}
-bool ResumeCtrl::RestoreAppHMIState(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) {
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -170,7 +171,7 @@ bool ResumeCtrl::RestoreAppHMIState(ApplicationSharedPtr application) {
return result;
}
-bool ResumeCtrl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
mobile_apis::HMILevel::eType default_hmi =
@@ -178,7 +179,7 @@ bool ResumeCtrl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
return SetAppHMIState(application, default_hmi, false);
}
-void ResumeCtrl::ApplicationResumptiOnTimer() {
+void ResumeCtrlImpl::ApplicationResumptiOnTimer() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(queue_lock_);
WaitingForTimerList::iterator it = waiting_for_timer_.begin();
@@ -196,22 +197,23 @@ void ResumeCtrl::ApplicationResumptiOnTimer() {
StartSavePersistentDataTimer();
}
-void ResumeCtrl::OnAppActivated(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::OnAppActivated(ApplicationSharedPtr application) {
if (is_resumption_active_) {
RemoveFromResumption(application->app_id());
}
}
-void ResumeCtrl::RemoveFromResumption(uint32_t app_id) {
+void ResumeCtrlImpl::RemoveFromResumption(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
queue_lock_.Acquire();
waiting_for_timer_.remove(app_id);
queue_lock_.Release();
}
-bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application,
- const mobile_apis::HMILevel::eType hmi_level,
- bool check_policy) {
+bool ResumeCtrlImpl::SetAppHMIState(
+ ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
+ bool check_policy) {
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -236,30 +238,30 @@ bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application,
return true;
}
-bool ResumeCtrl::IsHMIApplicationIdExist(uint32_t hmi_app_id) {
+bool ResumeCtrlImpl::IsHMIApplicationIdExist(uint32_t hmi_app_id) {
LOG4CXX_DEBUG(logger_, "hmi_app_id :" << hmi_app_id);
return resumption_storage_->IsHMIApplicationIdExist(hmi_app_id);
}
-bool ResumeCtrl::IsApplicationSaved(const std::string& policy_app_id,
- const std::string& device_id) {
+bool ResumeCtrlImpl::IsApplicationSaved(const std::string& policy_app_id,
+ const std::string& device_id) {
return -1 !=
resumption_storage_->IsApplicationSaved(policy_app_id, device_id);
}
-uint32_t ResumeCtrl::GetHMIApplicationID(const std::string& policy_app_id,
- const std::string& device_mac) const {
+uint32_t ResumeCtrlImpl::GetHMIApplicationID(
+ const std::string& policy_app_id, const std::string& device_mac) const {
return resumption_storage_->GetHMIApplicationID(policy_app_id, device_mac);
}
-bool ResumeCtrl::RemoveApplicationFromSaved(
+bool ResumeCtrlImpl::RemoveApplicationFromSaved(
ApplicationConstSharedPtr application) {
const std::string& device_mac = application->mac_address();
return resumption_storage_->RemoveApplicationFromSaved(
application->policy_app_id(), device_mac);
}
-void ResumeCtrl::OnSuspend() {
+void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
StopSavePersistentDataTimer();
SaveAllApplications();
@@ -267,31 +269,31 @@ void ResumeCtrl::OnSuspend() {
resumption_storage_->Persist();
}
-void ResumeCtrl::OnAwake() {
+void ResumeCtrlImpl::OnAwake() {
ResetLaunchTime();
StartSavePersistentDataTimer();
return resumption_storage_->OnAwake();
}
-void ResumeCtrl::StartSavePersistentDataTimer() {
+void ResumeCtrlImpl::StartSavePersistentDataTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (!save_persistent_data_timer_.is_running()) {
save_persistent_data_timer_.Start(
application_manager_.get_settings()
.app_resumption_save_persistent_data_timeout(),
- false);
+ timer::kPeriodic);
}
}
-void ResumeCtrl::StopSavePersistentDataTimer() {
+void ResumeCtrlImpl::StopSavePersistentDataTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (save_persistent_data_timer_.is_running()) {
save_persistent_data_timer_.Stop();
}
}
-bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
- const std::string& hash) {
+bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application,
+ const std::string& hash) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(
@@ -314,7 +316,8 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
return result;
}
-bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::StartResumptionOnlyHMILevel(
+ ApplicationSharedPtr application) {
// sync_primitives::AutoLock lock(resumtion_lock_);
LOG4CXX_AUTO_TRACE(logger_);
if (!application) {
@@ -339,15 +342,19 @@ bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) {
return result;
}
-void ResumeCtrl::StartAppHmiStateResumption(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::StartAppHmiStateResumption(
+ ApplicationSharedPtr application) {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
smart_objects::SmartObject saved_app;
const std::string& device_mac = application->mac_address();
- bool result = resumption_storage_->GetSavedApplication(
+ const bool result = resumption_storage_->GetSavedApplication(
application->policy_app_id(), device_mac, saved_app);
- DCHECK_OR_RETURN_VOID(result);
+ if (!result) {
+ LOG4CXX_ERROR(logger_, "Application was not saved");
+ return;
+ }
const uint32_t ign_off_count = saved_app[strings::ign_off_count].asUInt();
bool restore_data_allowed = false;
restore_data_allowed =
@@ -365,12 +372,12 @@ void ResumeCtrl::StartAppHmiStateResumption(ApplicationSharedPtr application) {
}
}
-void ResumeCtrl::ResetLaunchTime() {
+void ResumeCtrlImpl::ResetLaunchTime() {
LOG4CXX_AUTO_TRACE(logger_);
launch_time_ = time(NULL);
}
-bool ResumeCtrl::CheckPersistenceFilesForResumption(
+bool ResumeCtrlImpl::CheckPersistenceFilesForResumption(
ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -397,8 +404,8 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(
return true;
}
-bool ResumeCtrl::CheckApplicationHash(ApplicationSharedPtr application,
- const std::string& hash) {
+bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application,
+ const std::string& hash) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(logger_,
@@ -410,7 +417,7 @@ bool ResumeCtrl::CheckApplicationHash(ApplicationSharedPtr application,
return result ? saved_app[strings::hash_id].asString() == hash : false;
}
-void ResumeCtrl::SaveDataOnTimer() {
+void ResumeCtrlImpl::SaveDataOnTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (is_resumption_active_) {
LOG4CXX_WARN(logger_, "Resumption timer is active skip saving");
@@ -426,14 +433,14 @@ void ResumeCtrl::SaveDataOnTimer() {
}
}
-bool ResumeCtrl::IsDeviceMacAddressEqual(ApplicationSharedPtr application,
- const std::string& saved_device_mac) {
+bool ResumeCtrlImpl::IsDeviceMacAddressEqual(
+ ApplicationSharedPtr application, const std::string& saved_device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
const std::string device_mac = application->mac_address();
return device_mac == saved_device_mac;
}
-bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::RestoreApplicationData(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(logger_, "app_id : " << application->app_id());
@@ -465,8 +472,8 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
return result;
}
-void ResumeCtrl::AddFiles(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddFiles(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_files)) {
@@ -493,8 +500,8 @@ void ResumeCtrl::AddFiles(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddSubmenues(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddSubmenues(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_submenus)) {
@@ -511,8 +518,8 @@ void ResumeCtrl::AddSubmenues(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddCommands(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddCommands(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_commands)) {
@@ -530,8 +537,9 @@ void ResumeCtrl::AddCommands(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddChoicesets(
+ ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_choice_sets)) {
@@ -550,7 +558,7 @@ void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::SetGlobalProperties(
+void ResumeCtrlImpl::SetGlobalProperties(
ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -563,7 +571,7 @@ void ResumeCtrl::SetGlobalProperties(
}
}
-void ResumeCtrl::AddWayPointsSubscription(
+void ResumeCtrlImpl::AddWayPointsSubscription(
app_mngr::ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -577,8 +585,9 @@ void ResumeCtrl::AddWayPointsSubscription(
}
}
-void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddSubscriptions(
+ ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_subscribtions)) {
const smart_objects::SmartObject& subscribtions =
@@ -611,7 +620,7 @@ void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application,
}
}
-bool ResumeCtrl::CheckIgnCycleRestrictions(
+bool ResumeCtrlImpl::CheckIgnCycleRestrictions(
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
bool result = true;
@@ -628,7 +637,7 @@ bool ResumeCtrl::CheckIgnCycleRestrictions(
return result;
}
-bool ResumeCtrl::DisconnectedJustBeforeIgnOff(
+bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
const smart_objects::SmartObject& saved_app) {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
@@ -650,7 +659,7 @@ bool ResumeCtrl::DisconnectedJustBeforeIgnOff(
application_manager_.get_settings().resumption_delay_before_ign();
}
-bool ResumeCtrl::CheckAppRestrictions(
+bool ResumeCtrlImpl::CheckAppRestrictions(
ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app) {
using namespace mobile_apis;
@@ -671,8 +680,8 @@ bool ResumeCtrl::CheckAppRestrictions(
return result;
}
-bool ResumeCtrl::CheckIcons(ApplicationSharedPtr application,
- smart_objects::SmartObject& obj) {
+bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application,
+ smart_objects::SmartObject& obj) {
using namespace smart_objects;
LOG4CXX_AUTO_TRACE(logger_);
const mobile_apis::Result::eType verify_images =
@@ -680,11 +689,11 @@ bool ResumeCtrl::CheckIcons(ApplicationSharedPtr application,
return mobile_apis::Result::INVALID_DATA != verify_images;
}
-bool ResumeCtrl::CheckDelayAfterIgnOn() {
+bool ResumeCtrlImpl::CheckDelayAfterIgnOn() {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
const time_t curr_time = time(NULL);
- const time_t sdl_launch_time = launch_time();
+ const time_t sdl_launch_time = LaunchTime();
const uint32_t seconds_from_sdl_start = labs(curr_time - sdl_launch_time);
const uint32_t wait_time =
application_manager_.get_settings().resumption_delay_after_ign();
@@ -696,16 +705,16 @@ bool ResumeCtrl::CheckDelayAfterIgnOn() {
return seconds_from_sdl_start <= wait_time;
}
-time_t ResumeCtrl::launch_time() const {
+time_t ResumeCtrlImpl::LaunchTime() const {
return launch_time_;
}
-time_t ResumeCtrl::GetIgnOffTime() {
+time_t ResumeCtrlImpl::GetIgnOffTime() {
return resumption_storage_->GetIgnOffTime();
}
-bool ResumeCtrl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
- bool use_events) {
+bool ResumeCtrlImpl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
+ bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
if (use_events) {
const hmi_apis::FunctionID::eType function_id =
@@ -723,7 +732,7 @@ bool ResumeCtrl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
return true;
}
-void ResumeCtrl::ProcessHMIRequests(
+void ResumeCtrlImpl::ProcessHMIRequests(
const smart_objects::SmartObjectList& requests) {
for (smart_objects::SmartObjectList::const_iterator it = requests.begin(),
total = requests.end();
@@ -733,7 +742,7 @@ void ResumeCtrl::ProcessHMIRequests(
}
}
-void ResumeCtrl::AddToResumptionTimerQueue(const uint32_t app_id) {
+void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
queue_lock_.Acquire();
waiting_for_timer_.push_back(app_id);
@@ -744,11 +753,12 @@ void ResumeCtrl::AddToResumptionTimerQueue(const uint32_t app_id) {
if (!is_resumption_active_) {
is_resumption_active_ = true;
restore_hmi_level_timer_.Start(
- application_manager_.get_settings().app_resuming_timeout(), true);
+ application_manager_.get_settings().app_resuming_timeout(),
+ timer::kSingleShot);
}
}
-void ResumeCtrl::LoadResumeData() {
+void ResumeCtrlImpl::LoadResumeData() {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject so_applications_data;
resumption_storage_->GetDataForLoadResumeData(so_applications_data);
@@ -769,8 +779,8 @@ void ResumeCtrl::LoadResumeData() {
}
}
-void ResumeCtrl::OnAppRegistrationStart(const std::string& policy_app_id,
- const std::string& device_id) {
+void ResumeCtrlImpl::OnAppRegistrationStart(const std::string& policy_app_id,
+ const std::string& device_id) {
LOG4CXX_AUTO_TRACE(logger_);
if (IsApplicationSaved(policy_app_id, device_id)) {
LOG4CXX_INFO(
@@ -781,12 +791,22 @@ void ResumeCtrl::OnAppRegistrationStart(const std::string& policy_app_id,
}
}
-void ResumeCtrl::OnAppRegistrationEnd() {
+void ResumeCtrlImpl::OnAppRegistrationEnd() {
LOG4CXX_AUTO_TRACE(logger_);
StartSavePersistentDataTimer();
}
-bool ResumeCtrl::IsAppDataResumptionExpired(
+int32_t ResumeCtrlImpl::GetSavedAppHmiLevel(
+ const std::string& app_id, const std::string& device_id) const {
+ smart_objects::SmartObject saved_app;
+ if (resumption_storage_->GetSavedApplication(app_id, device_id, saved_app)) {
+ const int32_t saved_hmi_level = saved_app[strings::hmi_level].asInt();
+ return saved_hmi_level;
+ }
+ return static_cast<int32_t>(mobile_apis::HMILevel::INVALID_ENUM);
+}
+
+bool ResumeCtrlImpl::IsAppDataResumptionExpired(
const smart_objects::SmartObject& application) const {
const int32_t max_ign_off_count = 3;
return max_ign_off_count <= application[strings::ign_off_count].asInt();
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 8b8c17fc5a..68a3a7d424 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -18,6 +18,12 @@ const char* msg_params = "msg_params";
const char* method_name = "methodName";
const char* info = "info";
const char* app_id = "appID";
+const char* bundle_id = "appBundleID";
+const char* app_info = "appInfo";
+const char* app_launch = "app_launch";
+const char* app_launch_list = "app_launch_list";
+const char* app_launch_last_session = "app_launch_last_session";
+const char* policy_app_id = "policyAppID";
const char* hmi_app_id = "hmiAppID";
const char* device_id = "deviceID";
const char* subscribed_for_way_points = "subscribed_for_way_points";
@@ -400,6 +406,4 @@ const char* event_name = "eventName";
} // namespace hmi_notification
-} // namespace application_manager
-
-#
+} // namespace application_manager \ No newline at end of file
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 118cda4fcb..ba5d684df8 100644
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2015, Ford Motor Company
+# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
# application manager(AM) singleton while refactoring of AM is finished.
if (BUILD_TESTS)
-
+
include_directories(
${GMOCK_INCLUDE_DIRECTORY}
${CMAKE_BINARY_DIR}/src/components/
@@ -152,7 +152,7 @@ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libPolicy.so
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}")
create_test("application_manager_test" "${testSources}" "${testLibraries}" )
-# TODO [AKozoriz] : Fix not buildable tests
+# TODO [AKozoriz] : Fix not buildable tests
set(ResumptionData_SOURCES
${AM_TEST_DIR}/resumption/resumption_data_test.cc
${AM_TEST_DIR}/resumption/resumption_data_db_test.cc
@@ -170,3 +170,6 @@ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libPolicy.so
add_subdirectory(state_controller)
endif()
+
+add_subdirectory(app_launch)
+add_subdirectory(commands)
diff --git a/src/components/application_manager/test/app_launch/CMakeLists.txt b/src/components/application_manager/test/app_launch/CMakeLists.txt
new file mode 100644
index 0000000000..1c038020b9
--- /dev/null
+++ b/src/components/application_manager/test/app_launch/CMakeLists.txt
@@ -0,0 +1,62 @@
+# Copyright (c) 2016, 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_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/application_manager/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+ ${COMPONENTS_DIR}/connection_handler/include/
+ ${COMPONENTS_DIR}/utils/include/
+ ${COMPONENTS_DIR}/include/test
+ ${COMPONENTS_DIR}/include/
+)
+
+set(LIBRARIES
+ gmock
+ Resumption
+ jsoncpp
+ SmartObjects
+ ApplicationManager
+)
+
+ if (ENABLE_LOG)
+ list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+ list(APPEND LIBRARIES apr-1 -L${APR_LIBS_DIRECTORY})
+ list(APPEND LIBRARIES aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY})
+ list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY})
+ endif()
+
+set(APP_LAUNCH_DATA_TEST_SOURCES
+ app_launch_data_db_test.cc
+ app_launch_data_json_test.cc
+)
+
+create_test("app_launch_ctrl_test" app_launch_ctrl_test.cc "${LIBRARIES}")
+create_test("app_launch_data_test" "${APP_LAUNCH_DATA_TEST_SOURCES}" "${LIBRARIES}")
diff --git a/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc
new file mode 100644
index 0000000000..0f5196a97e
--- /dev/null
+++ b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include <sstream>
+#include "utils/macro.h"
+#include "application_manager/app_launch/app_launch_ctrl_impl.h"
+#include "application_manager/mock_app_launch_data.h"
+#include "application_manager/mock_app_launch_settings.h"
+#include "application_manager/mock_resume_ctrl.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "connection_handler/mock_connection_handler.h"
+#include "utils/make_shared.h"
+
+namespace test {
+namespace components {
+namespace app_launch_test {
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::Truly;
+using ::testing::NiceMock;
+using ::testing::Invoke;
+using ::testing::AtLeast;
+using ::testing::InSequence;
+
+namespace ch_test = test::components::connection_handler_test;
+namespace am_test = test::components::application_manager_test;
+
+const uint32_t MAX_TEST_DURATION = 1000; // 1 second
+typedef utils::SharedPtr<am_test::MockApplication> MockAppPtr;
+class AppLaunchCtrlTest : public ::testing::Test {
+ public:
+ MockAppPtr AppFromAppData(const app_launch::ApplicationData& app_data) {
+ utils::SharedPtr<NiceMock<am_test::MockApplication>> app =
+ utils::MakeShared<NiceMock<am_test::MockApplication>>();
+
+ ON_CALL(*app, mac_address()).WillByDefault(ReturnRef(app_data.device_mac_));
+ ON_CALL(*app, bundle_id()).WillByDefault(ReturnRef(app_data.bundle_id_));
+ ON_CALL(*app, policy_app_id())
+ .WillByDefault(Return(app_data.mobile_app_id_));
+ return app;
+ }
+
+ app_launch::ApplicationDataPtr AppDataFromApp(
+ const am_test::MockApplication& app) {
+ app_launch::ApplicationDataPtr app_data =
+ utils::MakeShared<NiceMock<app_launch::ApplicationData>>(
+ app.policy_app_id(), app.bundle_id(), app.mac_address());
+ return app_data;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(settings_, app_launch_wait_time()).WillByDefault(Return(5));
+ ON_CALL(settings_, app_launch_max_retry_attempt()).WillByDefault(Return(3));
+ ON_CALL(settings_, app_launch_retry_wait_time()).WillByDefault(Return(15));
+ ON_CALL(settings_, remove_bundle_id_attempts()).WillByDefault(Return(3));
+ ON_CALL(settings_, max_number_of_ios_device()).WillByDefault(Return(10));
+ ON_CALL(settings_, wait_time_between_apps()).WillByDefault(Return(4));
+ ON_CALL(settings_, enable_app_launch_ios()).WillByDefault(Return(true));
+ ON_CALL(settings_, resumption_delay_after_ign()).WillByDefault(Return(30));
+ ON_CALL(resume_ctrl_mock_, LaunchTime()).WillByDefault(Return(0));
+
+ ON_CALL(app_mngr_mock_, resume_controller())
+ .WillByDefault(ReturnRef(resume_ctrl_mock_));
+ ON_CALL(app_mngr_mock_, connection_handler())
+ .WillByDefault(ReturnRef(connection_handler_mock_));
+ app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl(
+ app_launch_data_mock_, app_mngr_mock_, settings_));
+ FillApplications();
+ }
+
+ typedef std::pair<MockAppPtr, app_launch::ApplicationDataPtr> AppAndAppData;
+ std::vector<AppAndAppData> test_app_datas_;
+
+ app_launch::ApplicationDataPtr GetTestAppData(size_t index) {
+ return test_app_datas_[index].second;
+ }
+
+ MockAppPtr GetTestApp(size_t index) {
+ return test_app_datas_[index].first;
+ }
+
+ const std::string DeviceMac(size_t device_number) {
+ std::ostringstream ss;
+ ss << "device_mac_" << device_number;
+ return ss.str();
+ }
+
+ std::vector<AppAndAppData> DeviceApps(std::string device_mac) {
+ std::vector<AppAndAppData> res;
+ std::vector<AppAndAppData>::iterator it = test_app_datas_.begin();
+ for (; it != test_app_datas_.end(); ++it) {
+ const AppAndAppData& app_and_data = *it;
+ if (app_and_data.second->device_mac_ == device_mac) {
+ res.push_back(app_and_data);
+ }
+ }
+ return res;
+ }
+
+ AppAndAppData GetAppAndAppData(const std::string& app_id,
+ const std::string& bundle_id,
+ const std::string& device_mac) {
+ using app_launch::ApplicationData;
+ AppAndAppData app;
+ app.second =
+ utils::MakeShared<ApplicationData>(app_id, bundle_id, device_mac);
+ app.first = AppFromAppData(*app.second);
+ return app;
+ }
+
+ void FillApplications() {
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id1", "bundle_id1", DeviceMac(1)));
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id2", "bundle_id2", DeviceMac(1)));
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id3", "bundle_id3", DeviceMac(1)));
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id4", "bundle_id4", DeviceMac(2)));
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id5", "bundle_id5", DeviceMac(2)));
+ test_app_datas_.push_back(
+ GetAppAndAppData("mob_id6", "bundle_id6", DeviceMac(3)));
+ }
+
+ void ExpectRegisteration(const AppAndAppData& app_data);
+
+ NiceMock<am_test::MockApplicationManager> app_mngr_mock_;
+ NiceMock<app_launch_test::AppLaunchDataMock> app_launch_data_mock_;
+ NiceMock<ch_test::MockConnectionHandler> connection_handler_mock_;
+ NiceMock<resumprion_test::MockResumeCtrl> resume_ctrl_mock_;
+ NiceMock<app_launch_test::MockAppLaunchSettings> settings_;
+ std::auto_ptr<app_launch::AppLaunchCtrlImpl> app_launch_ctrl_;
+};
+
+app_launch::ApplicationData AppDataFromApp(
+ application_manager::Application& app) {
+ // TODO(AK) Use amc op device
+ return app_launch::ApplicationData(
+ app.policy_app_id(), app.bundle_id(), "Dummy Deevice Id");
+}
+
+struct AppDataComparator {
+ const app_launch::ApplicationData& app_data_;
+
+ AppDataComparator(const app_launch::ApplicationData& app_data)
+ : app_data_(app_data) {}
+
+ bool operator()(const app_launch::ApplicationData& app_data) const {
+ return app_data_ == app_data;
+ }
+};
+
+TEST_F(AppLaunchCtrlTest, AddRegisteredApplicationToDataStorage) {
+ MockAppPtr app = GetTestApp(0);
+ EXPECT_CALL(app_launch_data_mock_,
+ AddApplicationData(Truly(AppDataComparator(*GetTestAppData(0)))));
+ app_launch_ctrl_->OnAppRegistered(*app);
+}
+
+ACTION_P2(InvokeOnAppRegistered, app_launch_ctrl, app) {
+ (app_launch_ctrl->*&app_launch::AppLaunchCtrlImpl::OnAppRegistered)(*app);
+}
+
+TEST_F(AppLaunchCtrlTest, StoredAppIsLaunchedAfterDeviceConnected) {
+ std::vector<app_launch::ApplicationDataPtr> applications_on_device;
+ app_launch::ApplicationDataPtr app_to_launch = GetTestAppData(0);
+ MockAppPtr app = GetTestApp(0);
+
+ applications_on_device.push_back(app_to_launch);
+ EXPECT_CALL(app_launch_data_mock_,
+ GetApplicationDataByDevice(app_to_launch->device_mac_))
+ .WillOnce(Return(applications_on_device));
+ EXPECT_CALL(
+ connection_handler_mock_,
+ RunAppOnDevice(app_to_launch->device_mac_, app_to_launch->bundle_id_))
+ .Times(AtLeast(1))
+ .WillOnce(InvokeOnAppRegistered(app_launch_ctrl_.get(), app.get()));
+ app_launch_ctrl_->OnDeviceConnected(app_to_launch->device_mac_);
+ const uint32_t wait_time =
+ MAX_TEST_DURATION + settings_.app_launch_wait_time();
+ testing::Mock::AsyncVerifyAndClearExpectations(wait_time);
+}
+
+TEST_F(AppLaunchCtrlTest, RelaunchAppIfNotRegisteredMultipleTimes) {
+ std::vector<app_launch::ApplicationDataPtr> applications_on_device;
+ app_launch::ApplicationDataPtr app_to_launch = GetTestAppData(0);
+ applications_on_device.push_back(app_to_launch);
+ EXPECT_CALL(app_launch_data_mock_,
+ GetApplicationDataByDevice(app_to_launch->device_mac_))
+ .WillOnce(Return(applications_on_device));
+
+ EXPECT_CALL(
+ connection_handler_mock_,
+ RunAppOnDevice(app_to_launch->device_mac_, app_to_launch->bundle_id_))
+ .Times(settings_.app_launch_max_retry_attempt());
+
+ app_launch_ctrl_->OnDeviceConnected(app_to_launch->device_mac_);
+ const uint32_t wait_time = MAX_TEST_DURATION +
+ settings_.app_launch_wait_time() +
+ settings_.app_launch_max_retry_attempt() *
+ settings_.app_launch_retry_wait_time();
+ testing::Mock::AsyncVerifyAndClearExpectations(wait_time);
+}
+
+TEST_F(AppLaunchCtrlTest, LaunchMultipleApps) {
+ std::vector<AppAndAppData> apps_and_data = DeviceApps(DeviceMac(1));
+ std::vector<app_launch::ApplicationDataPtr> apps;
+ for (std::vector<AppAndAppData>::iterator it = apps_and_data.begin();
+ it != apps_and_data.end();
+ ++it) {
+ apps.push_back(it->second);
+ }
+
+ EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1)))
+ .WillOnce(Return(apps));
+
+ // Expect multiple call
+ for (std::vector<AppAndAppData>::iterator it = apps_and_data.begin();
+ it != apps_and_data.end();
+ ++it) {
+ ExpectRegisteration(*it);
+ }
+ app_launch_ctrl_->OnDeviceConnected(DeviceMac(1));
+ const uint32_t wait_time = MAX_TEST_DURATION +
+ settings_.app_launch_wait_time() +
+ apps.size() * settings_.wait_time_between_apps();
+ testing::Mock::AsyncVerifyAndClearExpectations(wait_time);
+}
+
+TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsNoRegister) {
+ std::vector<AppAndAppData> apps_and_data = DeviceApps(DeviceMac(1));
+ std::vector<app_launch::ApplicationDataPtr> apps;
+ for (std::vector<AppAndAppData>::iterator it = apps_and_data.begin();
+ it != apps_and_data.end();
+ ++it) {
+ apps.push_back(it->second);
+ }
+
+ EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1)))
+ .WillOnce(Return(apps));
+
+ // Expect multiple call
+ for (std::vector<AppAndAppData>::iterator it = apps_and_data.begin();
+ it != apps_and_data.end();
+ ++it) {
+ const AppAndAppData& app_data = *it;
+ EXPECT_CALL(connection_handler_mock_,
+ RunAppOnDevice(app_data.second->device_mac_,
+ app_data.second->bundle_id_))
+ .Times(settings_.app_launch_max_retry_attempt());
+ }
+ app_launch_ctrl_->OnDeviceConnected(DeviceMac(1));
+ const uint32_t wait_time = MAX_TEST_DURATION +
+ settings_.app_launch_wait_time() +
+ apps.size() * settings_.wait_time_between_apps();
+ testing::Mock::AsyncVerifyAndClearExpectations(wait_time);
+}
+
+TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsInHMILevelOrder) {
+ std::vector<AppAndAppData> apps_and_data = DeviceApps(DeviceMac(1));
+ DCHECK(apps_and_data.size() == 3);
+ std::vector<app_launch::ApplicationDataPtr> apps;
+
+ {
+ app_launch::ApplicationDataPtr app_data = apps_and_data[0].second;
+ EXPECT_CALL(
+ resume_ctrl_mock_,
+ GetSavedAppHmiLevel(app_data->mobile_app_id_, app_data->device_mac_))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
+ apps.push_back(app_data);
+ }
+
+ {
+ app_launch::ApplicationDataPtr app_data = apps_and_data[1].second;
+ EXPECT_CALL(
+ resume_ctrl_mock_,
+ GetSavedAppHmiLevel(app_data->mobile_app_id_, app_data->device_mac_))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_LIMITED));
+ ;
+ apps.push_back(app_data);
+ }
+
+ {
+ app_launch::ApplicationDataPtr app_data = apps_and_data[2].second;
+ EXPECT_CALL(
+ resume_ctrl_mock_,
+ GetSavedAppHmiLevel(app_data->mobile_app_id_, app_data->device_mac_))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_BACKGROUND));
+ ;
+ apps.push_back(app_data);
+ }
+
+ EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1)))
+ .WillOnce(Return(apps));
+ {
+ InSequence s;
+
+ ExpectRegisteration(apps_and_data[0]);
+ ExpectRegisteration(apps_and_data[1]);
+ ExpectRegisteration(apps_and_data[2]);
+ }
+
+ app_launch_ctrl_->OnDeviceConnected(DeviceMac(1));
+ const uint32_t wait_time = MAX_TEST_DURATION +
+ settings_.app_launch_wait_time() +
+ apps.size() * settings_.wait_time_between_apps();
+ testing::Mock::AsyncVerifyAndClearExpectations(wait_time);
+}
+
+void AppLaunchCtrlTest::ExpectRegisteration(
+ const AppLaunchCtrlTest::AppAndAppData& app_data) {
+ EXPECT_CALL(
+ connection_handler_mock_,
+ RunAppOnDevice(app_data.second->device_mac_, app_data.second->bundle_id_))
+ .Times(AtLeast(1))
+ .WillOnce(
+ InvokeOnAppRegistered(app_launch_ctrl_.get(), app_data.first.get()));
+}
+
+} // namespace app_launch_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc
new file mode 100644
index 0000000000..e095f0682e
--- /dev/null
+++ b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc
@@ -0,0 +1,345 @@
+/*
+ * Copyright (c) 2016, 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 <algorithm>
+#include <sstream>
+#include <string>
+#include <memory>
+#include "gtest/gtest.h"
+#include "utils/macro.h"
+#include "sql_database.h"
+#include "sql_query.h"
+#include "utils/make_shared.h"
+#include "utils/file_system.h"
+#include "application_manager/mock_app_launch_settings.h"
+#include "application_manager/app_launch/app_launch_data_db.h"
+#include "application_manager/app_launch/app_launch_sql_queries.h"
+
+namespace test {
+namespace components {
+namespace app_launch_test {
+
+using namespace file_system;
+using namespace app_launch;
+
+using ::testing::ReturnRef;
+using ::testing::Return;
+using ::testing::NiceMock;
+
+namespace {
+const std::string kEmptyString = "";
+const std::string kMobileAppId = "mobile_app_id";
+const std::string kBundleId = "bundle_id";
+const std::string kDeviceMac = "device_mac";
+} // namespace
+
+class AppLaunchDataDBTest : public ::testing::Test {
+ protected:
+ virtual void SetUp() {
+ utils::dbms::SQLQuery query(test_db());
+ EXPECT_TRUE(query.Prepare(kCreateSchema));
+ EXPECT_TRUE(query.Exec());
+ printf("Create table\n");
+ }
+
+ virtual void TearDown() {
+ utils::dbms::SQLQuery query(test_db());
+ EXPECT_TRUE(query.Prepare(kDropSchema));
+ EXPECT_TRUE(query.Exec());
+ printf("Delete table\n");
+ }
+
+ static void SetUpTestCase() {
+ NiceMock<MockAppLaunchSettings> mock_app_launch_settings_;
+ std::string curr_dir = file_system::CurrentWorkingDirectory();
+ ON_CALL(mock_app_launch_settings_, app_storage_folder())
+ .WillByDefault(ReturnRef(curr_dir));
+ ON_CALL(mock_app_launch_settings_, max_number_of_ios_device())
+ .WillByDefault(Return(15u));
+ ON_CALL(mock_app_launch_settings_, app_launch_max_retry_attempt())
+ .WillByDefault(Return(5u));
+ ON_CALL(mock_app_launch_settings_, app_launch_retry_wait_time())
+ .WillByDefault(Return(500u));
+ if (is_in_file) {
+ res_db_.reset(
+ new AppLaunchDataDB(mock_app_launch_settings_, In_File_Storage));
+ } else {
+ res_db_.reset(
+ new AppLaunchDataDB(mock_app_launch_settings_, In_Memory_Storage));
+ }
+ test_db_ = (res_db_->db());
+
+ EXPECT_TRUE(test_db()->Open());
+ EXPECT_TRUE(test_db()->IsReadWrite());
+ }
+
+ // Memory keep and clear AppLaunchDataDb
+ static utils::dbms::SQLDatabase* test_db_;
+
+ static void TearDownTestCase() {
+ DeleteFile(kDatabaseName + ".sqlite");
+ }
+
+ static utils::dbms::SQLDatabase* test_db() {
+ return test_db_;
+ }
+
+ static std::auto_ptr<AppLaunchDataDB> res_db_;
+
+ AppLaunchDataDB* res_db() {
+ return res_db_.get();
+ }
+
+ const std::string kGetSsession =
+ " SELECT * FROM `app_launch` WHERE `deviceMac` = ? AND `appID` = ? AND "
+ "`bundleID` = ?;";
+ const std::string kCheckTablesExist =
+ "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND "
+ "name='app_launch';";
+
+ const std::string kInsertTimestamp =
+ "UPDATE 'app_launch' "
+ "SET 'last_session' = ' 1666-06-16 06:06:06.666 '"
+ "WHERE `deviceMac` = ? AND `appID` = ? "
+ "AND `bundleID` = ?;";
+
+ // Write BD to file or memory
+ static const bool is_in_file = false;
+
+ public:
+ void AddApplicationDataWithIncreaseTable(const ApplicationData& data);
+ void AddApplicationDataWithoutIncreaseTable(const ApplicationData& data);
+ std::string GetApplicationData(const ApplicationData& in_data,
+ ApplicationData& out_data);
+ std::string AddCounter(const std::string& inp, int32_t val);
+ void AddApplicationData_Expect_FALSE(const ApplicationData& data);
+};
+
+utils::dbms::SQLDatabase* AppLaunchDataDBTest::test_db_ = NULL;
+std::auto_ptr<AppLaunchDataDB> AppLaunchDataDBTest::res_db_;
+
+void AppLaunchDataDBTest::AddApplicationDataWithIncreaseTable(
+ const ApplicationData& data) {
+ uint32_t sizeBeforeAdding = res_db()->GetCurentNumberOfAppData();
+ EXPECT_TRUE(res_db()->AddApplicationData(data));
+
+ uint32_t sizeAfterAdding = res_db()->GetCurentNumberOfAppData();
+ EXPECT_EQ(sizeBeforeAdding + 1u, sizeAfterAdding);
+}
+
+void AppLaunchDataDBTest::AddApplicationDataWithoutIncreaseTable(
+ const ApplicationData& data) {
+ uint32_t sizeBeforeAdding = res_db()->GetCurentNumberOfAppData();
+ EXPECT_TRUE(res_db()->AddApplicationData(data));
+
+ uint32_t sizeAfterAdding = res_db()->GetCurentNumberOfAppData();
+ EXPECT_EQ(sizeBeforeAdding, sizeAfterAdding);
+}
+
+std::string AppLaunchDataDBTest::GetApplicationData(
+ const ApplicationData& in_data, ApplicationData& out_data) {
+ utils::dbms::SQLQuery query(test_db());
+ uint32_t sizeBeforeAdding = res_db()->GetCurentNumberOfAppData();
+ EXPECT_TRUE(query.Prepare(kGetSsession));
+ query.Bind(AppLaunchDataDB::device_mac_index, in_data.device_mac_);
+ query.Bind(AppLaunchDataDB::application_id_index, in_data.mobile_app_id_);
+ query.Bind(AppLaunchDataDB::bundle_id_index, in_data.bundle_id_);
+ EXPECT_TRUE(query.Exec());
+
+ uint32_t sizeAfterAdding = res_db()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(sizeBeforeAdding, sizeAfterAdding);
+
+ out_data.device_mac_ = query.GetString(AppLaunchDataDB::device_mac_index);
+ out_data.mobile_app_id_ =
+ query.GetString(AppLaunchDataDB::application_id_index);
+ out_data.bundle_id_ = query.GetString(AppLaunchDataDB::bundle_id_index);
+ // Timestamp
+ return query.GetString(AppLaunchDataDB::timestamp_index);
+}
+
+std::string AppLaunchDataDBTest::AddCounter(const std::string& inp,
+ int32_t val) {
+ std::stringstream ss;
+ ss << inp << "_" << val;
+ return ss.str();
+}
+
+TEST_F(AppLaunchDataDBTest, Init) {
+ utils::dbms::SQLQuery query_checks(test_db());
+ EXPECT_TRUE(query_checks.Prepare(kCheckTablesExist));
+ EXPECT_TRUE(query_checks.Exec());
+ EXPECT_EQ(1u, query_checks.GetUInteger(0));
+}
+
+TEST_F(AppLaunchDataDBTest, SaveAndGetData) {
+ ApplicationData data(kMobileAppId, kBundleId, kDeviceMac);
+ AddApplicationDataWithIncreaseTable(data);
+ ApplicationData recoveredData(kEmptyString, kEmptyString, kEmptyString);
+ GetApplicationData(data, recoveredData);
+ EXPECT_TRUE(data == recoveredData);
+}
+
+TEST_F(AppLaunchDataDBTest, NotAddEmptyAppData) {
+ ApplicationData data1(kEmptyString, kBundleId, kDeviceMac);
+ ApplicationData data2(kMobileAppId, kEmptyString, kDeviceMac);
+ ApplicationData data3(kMobileAppId, kBundleId, kEmptyString);
+ ApplicationData data4(kEmptyString, kEmptyString, kEmptyString);
+ EXPECT_FALSE(res_db()->AddApplicationData(data1));
+ EXPECT_FALSE(res_db()->AddApplicationData(data2));
+ EXPECT_FALSE(res_db()->AddApplicationData(data3));
+ EXPECT_FALSE(res_db()->AddApplicationData(data4));
+ EXPECT_EQ(0u, res_db()->GetCurentNumberOfAppData());
+}
+
+TEST_F(AppLaunchDataDBTest, SaveOneAndGetAnotherData) {
+ ApplicationData data(kMobileAppId, kBundleId, kDeviceMac);
+ ApplicationData recoverData = data;
+ AddApplicationDataWithIncreaseTable(data);
+ recoverData.device_mac_ += "test";
+ GetApplicationData(recoverData, recoverData);
+ EXPECT_FALSE(data == recoverData);
+}
+
+TEST_F(AppLaunchDataDBTest, MaxCount) {
+ const uint32_t max_ios_devs = res_db()->get_max_number_iOS_devs();
+
+ for (uint32_t i = 0; i < max_ios_devs; i++) {
+ ApplicationData data(
+ AddCounter(kMobileAppId, i), AddCounter(kBundleId, i), kDeviceMac);
+ AddApplicationDataWithIncreaseTable(data);
+ }
+
+ utils::dbms::SQLQuery query(test_db());
+ ApplicationData changedRecord(
+ AddCounter(kMobileAppId, 0), AddCounter(kBundleId, 0), kDeviceMac);
+ EXPECT_TRUE(query.Prepare(kInsertTimestamp));
+ query.Bind(AppLaunchDataDB::device_mac_index, changedRecord.device_mac_);
+ query.Bind(AppLaunchDataDB::application_id_index,
+ changedRecord.mobile_app_id_);
+ query.Bind(AppLaunchDataDB::bundle_id_index, changedRecord.bundle_id_);
+ EXPECT_TRUE(query.Exec());
+
+ uint32_t size_max = res_db()->GetCurentNumberOfAppData();
+ EXPECT_EQ(max_ios_devs, size_max);
+ EXPECT_TRUE(res_db()->AddApplicationData(
+ ApplicationData(AddCounter(kMobileAppId, max_ios_devs),
+ AddCounter(kBundleId, max_ios_devs),
+ kDeviceMac)));
+ uint32_t size_after_max = res_db()->GetCurentNumberOfAppData();
+ EXPECT_EQ(size_max, size_after_max);
+ EXPECT_FALSE(res_db()->IsAppDataAlreadyExisted(changedRecord));
+}
+
+namespace {
+bool ApplicationDataComporator(const ApplicationDataPtr& left,
+ const ApplicationDataPtr& right) {
+ return (left->device_mac_ < right->device_mac_ &&
+ left->mobile_app_id_ < right->mobile_app_id_ &&
+ left->bundle_id_ < right->bundle_id_);
+}
+} // namespace
+
+TEST_F(AppLaunchDataDBTest, SelectMultipleData) {
+ std::vector<ApplicationDataPtr> input_data1;
+ std::vector<ApplicationDataPtr> input_data2;
+ std::vector<ApplicationDataPtr> output_data1;
+ std::vector<ApplicationDataPtr> output_data2;
+ const std::string device_mac_1 = "device_mac_1";
+ const std::string device_mac_2 = "device_mac_2";
+
+ uint32_t half_of_max_number_iOS_devs =
+ res_db()->get_max_number_iOS_devs() / 2u;
+
+ for (uint32_t i = 0; i < half_of_max_number_iOS_devs; i++) {
+ const std::string mobile_app_id = AddCounter("d1_mobile_app_id", i);
+ const std::string bundle_id = AddCounter("d1_bundle_id", i);
+
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac_1);
+ AddApplicationDataWithIncreaseTable(*app_data);
+ input_data1.push_back(app_data);
+ }
+
+ for (uint32_t i = 0; i < half_of_max_number_iOS_devs; i++) {
+ const std::string mobile_app_id = AddCounter("d2_mobile_app_id", i);
+ const std::string bundle_id = AddCounter("d2_bundle_id", i);
+
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac_2);
+ AddApplicationDataWithIncreaseTable(*app_data);
+ input_data2.push_back(app_data);
+ }
+
+ output_data1 = res_db()->GetApplicationDataByDevice(device_mac_1);
+ output_data2 = res_db()->GetApplicationDataByDevice(device_mac_2);
+
+ EXPECT_EQ(half_of_max_number_iOS_devs, output_data1.size());
+ EXPECT_EQ(half_of_max_number_iOS_devs, output_data2.size());
+
+ std::sort(
+ output_data1.begin(), output_data1.end(), ApplicationDataComporator);
+ std::sort(
+ output_data2.begin(), output_data2.end(), ApplicationDataComporator);
+ std::sort(input_data1.begin(), input_data1.end(), ApplicationDataComporator);
+ std::sort(input_data2.begin(), input_data2.end(), ApplicationDataComporator);
+
+ for (uint32_t i = 0; i < output_data1.size(); i++) {
+ EXPECT_TRUE(*output_data1[i] == *input_data1[i]);
+ }
+
+ for (uint32_t i = 0; i < output_data2.size(); i++) {
+ EXPECT_TRUE(*output_data2[i] == *input_data2[i]);
+ }
+}
+
+// Most be last cause after it AppLaunchDataDBTest
+// requeste manual Init call
+TEST_F(AppLaunchDataDBTest, DeleteAllTableDataTwice) {
+ for (uint32_t i = 0; i < res_db()->get_max_number_iOS_devs(); i++) {
+ ApplicationData data(
+ AddCounter(kMobileAppId, i), AddCounter(kBundleId, i), kDeviceMac);
+ AddApplicationDataWithIncreaseTable(data);
+ }
+
+ uint32_t full_size = res_db()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(full_size, res_db()->get_max_number_iOS_devs());
+ EXPECT_TRUE(res_db()->Clear()); // delete data
+ EXPECT_EQ(0u, res_db()->GetCurentNumberOfAppData());
+ EXPECT_TRUE(res_db()->Clear()); // second time delete data
+ EXPECT_EQ(0u, res_db()->GetCurentNumberOfAppData());
+}
+
+} // namespace app_launch_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc
new file mode 100644
index 0000000000..6b00365dd3
--- /dev/null
+++ b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2016, 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 <algorithm>
+#include <sstream>
+#include <memory>
+#include "json/json.h"
+#include "gtest/gtest.h"
+#include "utils/macro.h"
+#include "utils/make_shared.h"
+#include "utils/file_system.h"
+#include "utils/date_time.h"
+#include "resumption/last_state.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/mock_app_launch_settings.h"
+#include "application_manager/app_launch/app_launch_data_json.h"
+
+namespace test {
+namespace components {
+namespace test_app_launch {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::NiceMock;
+
+namespace am = application_manager;
+using namespace Json;
+using namespace file_system;
+
+using namespace app_launch;
+
+const std::string kAppStorageFolder = "app_storage_folder";
+const std::string kAppStorageFile = "./app_info.dat";
+const std::string kAppInfoStorage = "app_info_storage";
+
+class AppLaunchDataJsonTest : public ::testing::Test {
+ private:
+ virtual void SetUp() {
+ ::file_system::DeleteFile(kAppStorageFile);
+ test_last_state_ = std::auto_ptr<resumption::LastState>(
+ new resumption::LastState(kAppStorageFolder, kAppInfoStorage));
+ ASSERT_TRUE(::file_system::CreateFile(kAppStorageFile));
+
+ NiceMock<app_launch_test::MockAppLaunchSettings> mock_app_launch_settings_;
+ ON_CALL(mock_app_launch_settings_, max_number_of_ios_device())
+ .WillByDefault(Return(15u));
+
+ res_json_.reset(
+ new AppLaunchDataJson(mock_app_launch_settings_, *test_last_state_));
+ }
+
+ public:
+ void TearDown() OVERRIDE {
+ res_json_.get()->Clear();
+ }
+
+ static void SetUpTestCase() {}
+
+ static void TearDownTestCase() {
+ ::file_system::DeleteFile(kAppStorageFile);
+ ::file_system::RemoveDirectory(kAppStorageFolder);
+ }
+
+ AppLaunchDataJson* res_json() {
+ return res_json_.get();
+ }
+
+ void AddApplicationDataWithIncreaseTable(const ApplicationData& data);
+ void AddApplicationDataWithoutIncreaseTable(const ApplicationData& data);
+ TimevalStruct GetApplicationData_EXPECT_TRUE(const ApplicationData& in_data,
+ ApplicationData& out_data);
+ void GetApplicationData_EXPECT_FALSE(const ApplicationData& in_data);
+ std::string AddCounter(const std::string& inp, int32_t val);
+
+ std::auto_ptr<resumption::LastState> test_last_state_;
+ std::auto_ptr<AppLaunchDataJson> res_json_;
+ void SetTimestamp(const ApplicationData& in_data, TimevalStruct& timestamp);
+};
+
+void AppLaunchDataJsonTest::AddApplicationDataWithIncreaseTable(
+ const ApplicationData& data) {
+ uint32_t sizeBeforeAdding = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_TRUE(res_json()->AddApplicationData(data));
+
+ uint32_t sizeAfterAdding = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(sizeBeforeAdding + 1u, sizeAfterAdding);
+}
+
+void AppLaunchDataJsonTest::AddApplicationDataWithoutIncreaseTable(
+ const ApplicationData& data) {
+ uint32_t sizeBeforeAdding = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_TRUE(res_json()->AddApplicationData(data));
+
+ uint32_t sizeAfterAdding = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(sizeBeforeAdding, sizeAfterAdding);
+}
+
+TimevalStruct AppLaunchDataJsonTest::GetApplicationData_EXPECT_TRUE(
+ const ApplicationData& in_data, ApplicationData& out_data) {
+ uint32_t sizeBeforeGetting = res_json()->GetCurentNumberOfAppData();
+
+ int32_t index = NotFound;
+ Json::Value& json_data_list =
+ res_json()->GetApplicationListAndIndex(in_data, index);
+ EXPECT_FALSE(index == NotFound);
+
+ uint32_t sizeAfterGetting = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(sizeBeforeGetting, sizeAfterGetting);
+ out_data.device_mac_ =
+ json_data_list[index][am::strings::device_id].asString();
+ out_data.mobile_app_id_ =
+ json_data_list[index][am::strings::app_id].asString();
+ out_data.bundle_id_ =
+ json_data_list[index][am::strings::bundle_id].asString();
+ // time stamp
+ TimevalStruct tmVal = {0};
+ tmVal.tv_sec =
+ json_data_list[index][am::strings::app_launch_last_session].asUInt64();
+ return tmVal;
+}
+
+void AppLaunchDataJsonTest::GetApplicationData_EXPECT_FALSE(
+ const ApplicationData& in_data) {
+ uint32_t sizeBeforeGetting = res_json()->GetCurentNumberOfAppData();
+
+ int32_t index = NotFound;
+ res_json()->GetApplicationListAndIndex(in_data, index);
+ EXPECT_TRUE(index == NotFound);
+
+ uint32_t sizeAfterGetting = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(sizeBeforeGetting, sizeAfterGetting);
+}
+
+void AppLaunchDataJsonTest::SetTimestamp(const ApplicationData& in_data,
+ TimevalStruct& timestamp) {
+ uint32_t sizeBeforeGetting = res_json()->GetCurentNumberOfAppData();
+
+ int32_t index = NotFound;
+ Json::Value& json_data_list =
+ res_json()->GetApplicationListAndIndex(in_data, index);
+ EXPECT_FALSE(index == NotFound);
+
+ uint32_t sizeAfterGetting = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_FALSE(index == NotFound);
+
+ EXPECT_EQ(sizeBeforeGetting, sizeAfterGetting);
+ // time stamp
+ json_data_list[index][am::strings::app_launch_last_session] =
+ static_cast<Json::Value::UInt64>(timestamp.tv_sec);
+}
+
+std::string AppLaunchDataJsonTest::AddCounter(const std::string& inp,
+ int32_t val) {
+ std::stringstream ss;
+ ss << inp << val;
+ return ss.str();
+}
+
+TEST_F(AppLaunchDataJsonTest, SaveAndGetData) {
+ ApplicationData data("mobile_app_id", "bundle_id", "device_mac");
+ AddApplicationDataWithIncreaseTable(data);
+ ApplicationData recoveredData("", "", "");
+ GetApplicationData_EXPECT_TRUE(data, recoveredData);
+ EXPECT_TRUE(data == recoveredData);
+}
+
+TEST_F(AppLaunchDataJsonTest, NotAddEmptyAppData) {
+ ApplicationData data1("", "bundle_id", "device_mac");
+ ApplicationData data2("mobile_app_id", "", "device_mac");
+ ApplicationData data3("mobile_app_id", "bundle_id", "");
+ ApplicationData data4("", "", "");
+ EXPECT_FALSE(res_json()->AddApplicationData(data1));
+ EXPECT_FALSE(res_json()->AddApplicationData(data2));
+ EXPECT_FALSE(res_json()->AddApplicationData(data3));
+ EXPECT_FALSE(res_json()->AddApplicationData(data4));
+ EXPECT_EQ(0u, res_json()->GetCurentNumberOfAppData());
+}
+
+TEST_F(AppLaunchDataJsonTest, SaveOneAndGetAnotherData) {
+ ApplicationData data("mobile_app_id", "bundle_id", "device_mac");
+ ApplicationData recoverData = data;
+ AddApplicationDataWithIncreaseTable(data);
+ recoverData.device_mac_ += "test";
+ GetApplicationData_EXPECT_FALSE(recoverData);
+}
+
+TEST_F(AppLaunchDataJsonTest, RefreshTimestamp) {
+ ApplicationData data("mobile_app_id", "bundle_id", "device_mac");
+ AddApplicationDataWithIncreaseTable(data);
+ ApplicationData recoveredData("", "", "");
+ TimevalStruct timestamp1 =
+ GetApplicationData_EXPECT_TRUE(data, recoveredData);
+ TimevalStruct tm = {0, 0};
+ SetTimestamp(data, tm);
+ TimevalStruct timestamp2 =
+ GetApplicationData_EXPECT_TRUE(data, recoveredData);
+ EXPECT_NE(timestamp1.tv_sec, timestamp2.tv_sec);
+ AddApplicationDataWithoutIncreaseTable(data); // again insert the same
+ TimevalStruct timestamp3 =
+ GetApplicationData_EXPECT_TRUE(data, recoveredData);
+ EXPECT_TRUE(data == recoveredData);
+ EXPECT_NE(timestamp2.tv_sec, timestamp3.tv_sec);
+}
+
+TEST_F(AppLaunchDataJsonTest, MaxCount) {
+ const uint32_t max_ios_devs = res_json()->get_max_number_iOS_devs();
+ for (uint32_t i = 0; i < max_ios_devs; i++) {
+ ApplicationData data(AddCounter("mobile_app_id_", i),
+ AddCounter("bundle_id_", i),
+ "device_mac");
+ AddApplicationDataWithIncreaseTable(data);
+ }
+
+ // insert new time stamp
+ ApplicationData changedRecord("mobile_app_id_0", "bundle_id_0", "device_mac");
+ TimevalStruct tm = {0, 0};
+ SetTimestamp(changedRecord, tm);
+
+ uint32_t size_max = res_json()->GetCurentNumberOfAppData();
+ EXPECT_EQ(max_ios_devs, size_max);
+ EXPECT_TRUE(res_json()->AddApplicationData(ApplicationData(
+ "mobile_app_id_last", "bundle_id_last", "device_mac_last")));
+ uint32_t size_after_max = res_json()->GetCurentNumberOfAppData();
+ EXPECT_EQ(size_max, size_after_max);
+ EXPECT_FALSE(res_json()->IsAppDataAlreadyExisted(changedRecord));
+}
+
+TEST_F(AppLaunchDataJsonTest, DeleteAllJsonDataTwice) {
+ for (uint32_t i = 0; i < res_json()->get_max_number_iOS_devs(); i++) {
+ ApplicationData data(AddCounter("mobile_app_id_", i),
+ AddCounter("bundle_id_", i),
+ "device_mac");
+ AddApplicationDataWithIncreaseTable(data);
+ }
+
+ uint32_t full_size = res_json()->GetCurentNumberOfAppData();
+
+ EXPECT_EQ(full_size, res_json()->get_max_number_iOS_devs());
+ EXPECT_TRUE(res_json()->Clear()); // delete data
+ EXPECT_EQ(0u, res_json()->GetCurentNumberOfAppData());
+ EXPECT_TRUE(res_json()->Clear()); // second time delete data
+ EXPECT_EQ(0u, res_json()->GetCurentNumberOfAppData());
+}
+
+namespace {
+bool ApplicationDataComporator(const ApplicationDataPtr& left,
+ const ApplicationDataPtr& right) {
+ return (left->device_mac_ < right->device_mac_ &&
+ left->mobile_app_id_ < right->mobile_app_id_ &&
+ left->bundle_id_ < right->bundle_id_);
+}
+} // namespace
+
+TEST_F(AppLaunchDataJsonTest, SelectMultipleData) {
+ std::vector<ApplicationDataPtr> input_data1;
+ std::vector<ApplicationDataPtr> input_data2;
+ std::vector<ApplicationDataPtr> output_data1;
+ std::vector<ApplicationDataPtr> output_data2;
+ const std::string device_mac_1 = "device_mac_1";
+ const std::string device_mac_2 = "device_mac_2";
+ uint32_t half_part = res_json()->get_max_number_iOS_devs() / 2u;
+
+ for (uint32_t i = 0; i < half_part; i++) {
+ const std::string mobile_app_id = AddCounter("d1_mobile_app_id_", i);
+ const std::string bundle_id = AddCounter("d1_bundle_id_", i);
+
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac_1);
+ AddApplicationDataWithIncreaseTable(*app_data);
+ input_data1.push_back(app_data);
+ }
+
+ for (uint32_t i = 0; i < half_part; i++) {
+ const std::string mobile_app_id = AddCounter("d2_mobile_app_id_", i);
+ const std::string bundle_id = AddCounter("d2_bundle_id_", i);
+
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac_2);
+ AddApplicationDataWithIncreaseTable(*app_data);
+ input_data2.push_back(app_data);
+ }
+
+ output_data1 = res_json()->GetApplicationDataByDevice(device_mac_1);
+ output_data2 = res_json()->GetApplicationDataByDevice(device_mac_2);
+
+ EXPECT_EQ(half_part, output_data1.size());
+ EXPECT_EQ(half_part, output_data2.size());
+
+ std::sort(
+ output_data1.begin(), output_data1.end(), ApplicationDataComporator);
+ std::sort(
+ output_data2.begin(), output_data2.end(), ApplicationDataComporator);
+ std::sort(input_data1.begin(), input_data1.end(), ApplicationDataComporator);
+ std::sort(input_data2.begin(), input_data2.end(), ApplicationDataComporator);
+
+ for (uint32_t i = 0; i < output_data1.size(); i++) {
+ EXPECT_TRUE(*output_data1[i] == *input_data1[i]);
+ }
+
+ for (uint32_t i = 0; i < output_data2.size(); i++) {
+ EXPECT_TRUE(*output_data2[i] == *input_data2[i]);
+ }
+}
+
+} // namespace app_launch
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc
index 7989f11fce..fbd3a2a469 100644
--- a/src/components/application_manager/test/application_impl_test.cc
+++ b/src/components/application_manager/test/application_impl_test.cc
@@ -31,7 +31,10 @@
*/
#include "application_manager/application_impl.h"
+
+#include <stdint.h>
#include <iostream>
+
#include "gtest/gtest.h"
#include "application_manager/hmi_state.h"
#include "utils/file_system.h"
@@ -475,7 +478,7 @@ TEST_F(ApplicationImplTest, LoadPersistentFiles) {
EXPECT_EQ(FileType::AUDIO_MP3, test_file8->file_type);
}
-TEST_F(ApplicationImplTest, IsCommandLimitsExceeded_SetLimitFromConfig) {
+TEST_F(ApplicationImplTest, AreCommandLimitsExceeded_SetLimitFromConfig) {
std::pair<uint32_t, int32_t> get_frequency;
get_frequency.first = 5;
get_frequency.second = 1;
@@ -484,21 +487,22 @@ TEST_F(ApplicationImplTest, IsCommandLimitsExceeded_SetLimitFromConfig) {
EXPECT_CALL(mock_application_manager_settings_, get_vehicle_data_frequency())
.WillRepeatedly(ReturnRef(get_frequency));
for (uint32_t i = 0; i < get_frequency.first; i++) {
- EXPECT_FALSE(app_impl->IsCommandLimitsExceeded(FunctionID::ReadDIDID,
- TLimitSource::CONFIG_FILE));
+ EXPECT_FALSE(app_impl->AreCommandLimitsExceeded(FunctionID::ReadDIDID,
+ TLimitSource::CONFIG_FILE));
}
- EXPECT_TRUE(app_impl->IsCommandLimitsExceeded(FunctionID::ReadDIDID,
- TLimitSource::CONFIG_FILE));
+ EXPECT_TRUE(app_impl->AreCommandLimitsExceeded(FunctionID::ReadDIDID,
+ TLimitSource::CONFIG_FILE));
for (uint32_t i = 0; i < get_frequency.first; i++) {
- EXPECT_FALSE(app_impl->IsCommandLimitsExceeded(FunctionID::GetVehicleDataID,
- TLimitSource::CONFIG_FILE));
+ EXPECT_FALSE(app_impl->AreCommandLimitsExceeded(
+ FunctionID::GetVehicleDataID, TLimitSource::CONFIG_FILE));
}
- EXPECT_TRUE(app_impl->IsCommandLimitsExceeded(FunctionID::GetVehicleDataID,
- TLimitSource::CONFIG_FILE));
+ EXPECT_TRUE(app_impl->AreCommandLimitsExceeded(FunctionID::GetVehicleDataID,
+ TLimitSource::CONFIG_FILE));
}
-TEST_F(ApplicationImplTest, IsCommandLimitsExceeded_LimitFromPT) {
+TEST_F(ApplicationImplTest, AreCommandLimitsExceeded_LimitFromPT) {
+ const uint32_t cmd_limit = 100u;
policy_test::MockPolicyHandlerInterface policy_interface;
EXPECT_CALL(mock_application_manager_, GetPolicyHandler())
.WillRepeatedly(ReturnRef(policy_interface));
@@ -506,20 +510,20 @@ TEST_F(ApplicationImplTest, IsCommandLimitsExceeded_LimitFromPT) {
.WillRepeatedly(Return(false));
EXPECT_CALL(policy_interface, GetNotificationsNumber(_))
- .WillOnce(Return(100u));
- EXPECT_FALSE(app_impl->IsCommandLimitsExceeded(FunctionID::ReadDIDID,
- TLimitSource::POLICY_TABLE));
+ .WillOnce(Return(cmd_limit));
+ EXPECT_FALSE(app_impl->AreCommandLimitsExceeded(FunctionID::ReadDIDID,
+ TLimitSource::POLICY_TABLE));
EXPECT_CALL(policy_interface, GetNotificationsNumber(_))
- .WillOnce(Return(100u));
- EXPECT_FALSE(app_impl->IsCommandLimitsExceeded(FunctionID::GetVehicleDataID,
- TLimitSource::POLICY_TABLE));
+ .WillOnce(Return(cmd_limit));
+ EXPECT_FALSE(app_impl->AreCommandLimitsExceeded(FunctionID::GetVehicleDataID,
+ TLimitSource::POLICY_TABLE));
EXPECT_CALL(policy_interface, GetNotificationsNumber(_))
.WillRepeatedly(Return(0));
- EXPECT_TRUE(app_impl->IsCommandLimitsExceeded(FunctionID::ReadDIDID,
- TLimitSource::POLICY_TABLE));
- EXPECT_TRUE(app_impl->IsCommandLimitsExceeded(FunctionID::GetVehicleDataID,
- TLimitSource::POLICY_TABLE));
+ EXPECT_TRUE(app_impl->AreCommandLimitsExceeded(FunctionID::ReadDIDID,
+ TLimitSource::POLICY_TABLE));
+ EXPECT_TRUE(app_impl->AreCommandLimitsExceeded(FunctionID::GetVehicleDataID,
+ TLimitSource::POLICY_TABLE));
}
TEST_F(ApplicationImplTest, SubscribeToButton_UnsubscribeFromButton) {
diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt
new file mode 100644
index 0000000000..ebcb1b5086
--- /dev/null
+++ b/src/components/application_manager/test/commands/CMakeLists.txt
@@ -0,0 +1,63 @@
+# Copyright (c) 2016, 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_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/application_manager/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/commands/
+)
+
+set(COMMANDS_TEST_SOURCE_DIR
+ ${COMPONENTS_DIR}/application_manager/test/commands
+)
+
+set (SOURCES
+ ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/command_impl_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/command_response_impl_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/command_request_impl_test.cc
+)
+
+set(LIBRARIES
+ gmock
+ Utils
+ ApplicationManager
+ connectionHandler
+ HMI_API
+ MOBILE_API
+ SmartObjects
+ jsoncpp
+)
+
+create_test("commands_test" "${SOURCES}" "${LIBRARIES}" )
+
+add_subdirectory(mobile)
+add_subdirectory(hmi)
diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc
new file mode 100644
index 0000000000..bb56e984e5
--- /dev/null
+++ b/src/components/application_manager/test/commands/command_impl_test.cc
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <algorithm>
+#include <functional>
+#include <set>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/mock_application.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+using ::testing::Return;
+using ::testing::AtLeast;
+using ::testing::_;
+
+using ::utils::SharedPtr;
+namespace strings = ::application_manager::strings;
+using ::application_manager::commands::CommandImpl;
+using ::application_manager::ApplicationManager;
+using ::application_manager::commands::MessageSharedPtr;
+using ::application_manager::ApplicationSharedPtr;
+using ::test::components::application_manager_test::MockApplication;
+
+typedef SharedPtr<MockApplication> MockAppPtr;
+
+namespace {
+const uint32_t kDefaultMsgCount = 5u;
+const uint32_t kAppId1 = 5u;
+const uint32_t kAppId2 = 10u;
+} // namespace
+
+void ExpectEqualAppId(const smart_objects::SmartObject& obj) {
+ EXPECT_EQ(kAppId2, obj[strings::app_id].asUInt());
+}
+
+void ExpectEqualKeyAppId(const std::string obj, MessageSharedPtr msg) {
+ EXPECT_EQ(kAppId2, (*msg)[obj][strings::app_id].asUInt());
+}
+
+class CommandImplTest : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ class UnwrappedCommandImpl : CommandImpl {
+ public:
+ using CommandImpl::ReplaceMobileByHMIAppId;
+ using CommandImpl::ReplaceHMIByMobileAppId;
+
+ UnwrappedCommandImpl(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandImpl(message, application_manager) {}
+ };
+
+ // Create `SmartObject` which handle array of `SmartObjects`
+ static MessageSharedPtr CreateArrayMessage(
+ const size_t msg_count = kDefaultMsgCount) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Array);
+ smart_objects::SmartArray* array = msg->asArray();
+ for (size_t i = 0u; i < msg_count; ++i) {
+ SmartObject obj;
+ obj[strings::app_id] = i;
+ array->push_back(obj);
+ }
+ return msg;
+ }
+ // Create `SmartObject` which handle map of `SmartObjects`
+ static MessageSharedPtr CreateMapMessage(
+ const size_t msg_count = kDefaultMsgCount) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ char key[] = {'A', '\0'};
+ for (size_t i = 0u; i < msg_count; ++i, ++key[0]) {
+ SmartObject obj;
+ obj[strings::app_id] = i;
+ (*msg)[key] = obj;
+ }
+ return msg;
+ }
+};
+
+typedef CommandImplTest::UnwrappedCommandImpl UCommandImpl;
+typedef SharedPtr<UCommandImpl> UCommandImplPtr;
+
+TEST_F(CommandImplTest, GetMethods_SUCCESS) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandImpl> command =
+ CreateCommand<CommandImpl>(kDefaultTimeout_, msg);
+
+ // Current implementation always return `true`
+ EXPECT_TRUE(command->Init());
+ EXPECT_TRUE(command->CheckPermissions());
+ EXPECT_TRUE(command->CleanUp());
+
+ // Default value of `allowed_to_terminate_` is true
+ EXPECT_TRUE(command->AllowedToTerminate());
+ command->SetAllowedToTerminate(false);
+ EXPECT_FALSE(command->AllowedToTerminate());
+
+ const uint32_t kCorrelationId = 3u;
+ const int32_t kFunctionId = 4u;
+ const uint32_t kConnectionKey = 5u;
+
+ (*msg)[strings::params][strings::correlation_id] = kCorrelationId;
+ (*msg)[strings::params][strings::function_id] = kFunctionId;
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ EXPECT_EQ(kDefaultTimeout_, command->default_timeout());
+ EXPECT_EQ(kCorrelationId, command->correlation_id());
+ EXPECT_EQ(kConnectionKey, command->connection_key());
+ EXPECT_EQ(kFunctionId, command->function_id());
+ EXPECT_NO_THROW(command->Run());
+ EXPECT_NO_THROW(command->onTimeOut());
+}
+
+TEST_F(CommandImplTest, ReplaceMobileByHMIAppId_NoAppIdInMessage_UNSUCCESS) {
+ MessageSharedPtr msg;
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ EXPECT_CALL(app_mngr_, application(_)).Times(0);
+
+ command->ReplaceMobileByHMIAppId(*msg);
+}
+
+TEST_F(CommandImplTest, ReplaceMobileByHMIAppId_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::app_id] = kAppId1;
+
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application(kAppId1)).WillOnce(Return(app));
+ ON_CALL(*app, hmi_app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceMobileByHMIAppId(*msg);
+
+ EXPECT_EQ(kAppId2, (*msg)[strings::app_id].asUInt());
+}
+
+TEST_F(CommandImplTest, ReplaceMobileByHMIAppId_Array_SUCCESS) {
+ MessageSharedPtr msg = CreateArrayMessage(kDefaultMsgCount);
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .Times(kDefaultMsgCount)
+ .WillRepeatedly(Return(app));
+ ON_CALL(*app, hmi_app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceMobileByHMIAppId(*msg);
+
+ EXPECT_TRUE(msg->asArray());
+ std::for_each(
+ msg->asArray()->begin(), msg->asArray()->end(), ExpectEqualAppId);
+}
+
+TEST_F(CommandImplTest, ReplaceMobileByHMIAppId_Map_SUCCESS) {
+ MessageSharedPtr msg = CreateMapMessage(kDefaultMsgCount);
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .Times(kDefaultMsgCount)
+ .WillRepeatedly(Return(app));
+ ON_CALL(*app, hmi_app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceMobileByHMIAppId(*msg);
+
+ std::set<std::string> keys(msg->enumerate());
+ std::for_each(keys.begin(),
+ keys.end(),
+ std::bind2nd(std::ptr_fun(&ExpectEqualKeyAppId), msg));
+}
+
+TEST_F(CommandImplTest, ReplaceHMIByMobileAppId_NoHMIAppIdInMessage_UNSUCCESS) {
+ MessageSharedPtr msg;
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(_)).Times(0);
+
+ command->ReplaceHMIByMobileAppId(*msg);
+}
+
+TEST_F(CommandImplTest, ReplaceHMIByMobileAppId_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::app_id] = kAppId1;
+
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(kAppId1)).WillOnce(Return(app));
+ ON_CALL(*app, app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceHMIByMobileAppId(*msg);
+
+ EXPECT_EQ(kAppId2, (*msg)[strings::app_id].asUInt());
+}
+
+TEST_F(CommandImplTest, ReplaceHMIByMobileAppId_Array_SUCCESS) {
+ MessageSharedPtr msg = CreateArrayMessage(kDefaultMsgCount);
+
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(_))
+ .Times(kDefaultMsgCount)
+ .WillRepeatedly(Return(app));
+ ON_CALL(*app, app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceHMIByMobileAppId(*msg);
+
+ EXPECT_TRUE(msg->asArray());
+ std::for_each(
+ msg->asArray()->begin(), msg->asArray()->end(), ExpectEqualAppId);
+}
+
+TEST_F(CommandImplTest, ReplaceHMIByMobileAppId_Map_SUCCESS) {
+ MessageSharedPtr msg = CreateMapMessage(kDefaultMsgCount);
+
+ UCommandImplPtr command = CreateCommand<UCommandImpl>(msg);
+ MockAppPtr app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(_))
+ .Times(kDefaultMsgCount)
+ .WillRepeatedly(Return(app));
+ ON_CALL(*app, app_id()).WillByDefault(Return(kAppId2));
+
+ command->ReplaceHMIByMobileAppId(*msg);
+
+ std::set<std::string> keys = msg->enumerate();
+ std::for_each(keys.begin(),
+ keys.end(),
+ std::bind2nd(std::ptr_fun(&ExpectEqualKeyAppId), msg));
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc
new file mode 100644
index 0000000000..973438cb55
--- /dev/null
+++ b/src/components/application_manager/test/commands/command_request_impl_test.cc
@@ -0,0 +1,519 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <algorithm>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/commands/command_request_impl.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "utils/lock.h"
+#include "utils/shared_ptr.h"
+#include "utils/data_accessor.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+namespace strings = am::strings;
+namespace hmi_response = am::hmi_response;
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::testing::DoAll;
+
+using ::utils::SharedPtr;
+using am::commands::MessageSharedPtr;
+using am::CommandParametersPermissions;
+using am::event_engine::EventObserver;
+using am::commands::CommandImpl;
+using am::commands::CommandRequestImpl;
+using am::ApplicationManager;
+using am::ApplicationSet;
+using am::RPCParams;
+using am::MockHmiInterfaces;
+
+typedef am::commands::CommandRequestImpl::RequestState RequestState;
+
+namespace {
+const uint32_t kConnectionKey = 5u;
+const uint32_t kCorrelationId = 3u;
+const hmi_apis::FunctionID::eType kInvalidFunctionId =
+ hmi_apis::FunctionID::INVALID_ENUM;
+const std::string kPolicyAppId = "Test";
+const mobile_apis::Result::eType kMobResultSuccess =
+ mobile_apis::Result::SUCCESS;
+const std::string kDisallowedParam1 = "disallowed_param1";
+const std::string kDisallowedParam2 = "disallowed_param2";
+const std::string kAllowedParam = "allowed_param";
+const std::string kUndefinedParam = "undefined_params";
+const std::string kMissedParam = "missed_param";
+} // namespace
+
+class CommandRequestImplTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ class UnwrappedCommandRequestImpl : public CommandRequestImpl {
+ public:
+ using CommandRequestImpl::CheckAllowedParameters;
+ using CommandRequestImpl::RemoveDisallowedParameters;
+ using CommandRequestImpl::AddDisallowedParameters;
+ using CommandRequestImpl::HasDisallowedParams;
+
+ UnwrappedCommandRequestImpl(const MessageSharedPtr& message,
+ ApplicationManager& am)
+ : CommandRequestImpl(message, am) {}
+
+ const RequestState current_state() const {
+ return current_state_;
+ }
+ void set_current_state(const RequestState state) {
+ current_state_ = state;
+ }
+
+ CommandParametersPermissions& parameters_permissions() {
+ return parameters_permissions_;
+ }
+
+ CommandParametersPermissions& removed_parameters_permissions() {
+ return removed_parameters_permissions_;
+ }
+ };
+
+ CommandRequestImplTest() {
+ mock_message_helper_ = am::MockMessageHelper::message_helper_mock();
+ }
+ ~CommandRequestImplTest() {
+ mock_message_helper_ = NULL;
+ }
+
+ MockAppPtr InitAppSetDataAccessor(SharedPtr<ApplicationSet>& app_set) {
+ app_set = (!app_set ? ::utils::MakeShared<ApplicationSet>() : app_set);
+ MockAppPtr app(CreateMockApp());
+ app_set->insert(app);
+ EXPECT_CALL(app_mngr_, applications())
+ .WillOnce(
+ Return(DataAccessor<ApplicationSet>(*app_set, app_set_lock_)));
+ return app;
+ }
+
+ sync_primitives::Lock app_set_lock_;
+ am::MockMessageHelper* mock_message_helper_;
+};
+
+typedef CommandRequestImplTest::UnwrappedCommandRequestImpl UCommandRequestImpl;
+typedef SharedPtr<UCommandRequestImpl> CommandPtr;
+
+TEST_F(CommandRequestImplTest, OnTimeOut_StateCompleted_UNSUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ // Should be called twice:
+ // First -- on `onTimeOut` method call
+ // Second -- on destruction;
+ EXPECT_CALL(event_dispatcher_, remove_observer(_)).Times(2);
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ // If `command` already done, then state should change to `kCompleted`.
+ command->set_current_state(RequestState::kCompleted);
+
+ command->onTimeOut();
+
+ EXPECT_EQ(RequestState::kCompleted, command->current_state());
+}
+
+TEST_F(CommandRequestImplTest, OnTimeOut_StateAwaitingHMIResponse_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][strings::correlation_id] = kCorrelationId;
+ (*msg)[strings::params][strings::function_id] = kInvalidFunctionId;
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ MessageSharedPtr dummy_msg(CreateMessage());
+ EXPECT_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _))
+ .WillOnce(Return(dummy_msg));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(dummy_msg, Command::CommandOrigin::ORIGIN_SDL));
+
+ command->onTimeOut();
+
+ // If `command` not done till now, then state should change to `kTimedOut`
+ // and sent it to application manager to deal with it.
+ EXPECT_EQ(RequestState::kTimedOut, command->current_state());
+}
+
+TEST_F(CommandRequestImplTest, CheckSyntax_SUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ // Checking message syntax.
+ const std::string str1("\t\n");
+ EXPECT_FALSE(command->CheckSyntax(str1, false));
+ const std::string str2("\\n");
+ EXPECT_FALSE(command->CheckSyntax(str2, false));
+ const std::string str3("\\t");
+ EXPECT_FALSE(command->CheckSyntax(str3, false));
+ const std::string str4(" ");
+ EXPECT_FALSE(command->CheckSyntax(str4, false));
+ EXPECT_TRUE(command->CheckSyntax(str4, true));
+}
+
+TEST_F(CommandRequestImplTest, GetMobileResultCode_SUCCESS) {
+ union ResultU {
+ int32_t value_;
+ hmi_apis::Common_Result::eType hmi_;
+ mobile_apis::Result::eType mobile_;
+ };
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ // Run thru all possible accordance
+ // of HMI and Mobile result codes.
+ ResultU result_it;
+ for (result_it.hmi_ = hmi_apis::Common_Result::SUCCESS;
+ result_it.value_ < hmi_apis::Common_Result::TRUNCATED_DATA;
+ ++result_it.value_) {
+ if (result_it.hmi_ != hmi_apis::Common_Result::NO_DEVICES_CONNECTED &&
+ result_it.hmi_ != hmi_apis::Common_Result::NO_APPS_REGISTERED) {
+ EXPECT_EQ(result_it.mobile_,
+ command->GetMobileResultCode(result_it.hmi_));
+ }
+ }
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ command->GetMobileResultCode(
+ hmi_apis::Common_Result::NO_DEVICES_CONNECTED));
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ command->GetMobileResultCode(
+ hmi_apis::Common_Result::NO_APPS_REGISTERED));
+ EXPECT_EQ(
+ mobile_apis::Result::GENERIC_ERROR,
+ command->GetMobileResultCode(hmi_apis::Common_Result::TRUNCATED_DATA));
+}
+
+TEST_F(CommandRequestImplTest, BasicMethodsOverloads_SUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ // Current implementation always return `true`
+ EXPECT_TRUE(command->Init());
+ EXPECT_TRUE(command->CleanUp());
+ EXPECT_NO_THROW(command->Run());
+ am::event_engine::Event event(kInvalidFunctionId);
+ EXPECT_NO_THROW(command->on_event(event));
+}
+
+TEST_F(CommandRequestImplTest, CreateHMINotification_SUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ const std::string kTestParamsKey = "test_msg_params";
+
+ MessageSharedPtr msg_params = CreateMessage();
+ (*msg_params)[kTestParamsKey] = 0;
+
+ MessageSharedPtr result;
+
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ command->CreateHMINotification(kInvalidFunctionId, *msg_params);
+
+ // Check if message been formed and sent to application manager.
+ EXPECT_TRUE((*result).keyExists(strings::msg_params));
+ EXPECT_TRUE((*result)[strings::msg_params].keyExists(kTestParamsKey));
+}
+
+TEST_F(CommandRequestImplTest, SendHMIRequest_NoUseEvent_SUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
+ .WillOnce(Return(kCorrelationId));
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ // Return `true` prevents call of `SendResponse` method;
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
+
+ EXPECT_EQ(kCorrelationId,
+ command->SendHMIRequest(kInvalidFunctionId, NULL, false));
+}
+
+TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
+ .WillOnce(Return(kCorrelationId));
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ // Return `true` prevents call of `SendResponse` method;
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
+
+ EXPECT_CALL(event_dispatcher_, add_observer(_, _, _));
+
+ EXPECT_EQ(kCorrelationId,
+ command->SendHMIRequest(kInvalidFunctionId, NULL, true));
+}
+
+TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) {
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(
+ am::VehicleData::value_type(kMissedParam, am::VehicleDataType::MYKEY));
+
+ EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::msg_params][kDisallowedParam1] = 0u;
+ (*msg)[strings::msg_params][kDisallowedParam2] = 0u;
+ (*msg)[strings::msg_params][kAllowedParam] = 0u;
+ (*msg)[strings::msg_params][kUndefinedParam] = 0u;
+ (*msg)[strings::msg_params][kMissedParam] = 0u;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ CommandParametersPermissions& permission = command->parameters_permissions();
+ permission.disallowed_params.push_back(kDisallowedParam1);
+ permission.disallowed_params.push_back(kDisallowedParam2);
+ permission.allowed_params.push_back(kAllowedParam);
+ permission.undefined_params.push_back(kUndefinedParam);
+
+ command->RemoveDisallowedParameters();
+
+ EXPECT_FALSE((*msg)[strings::msg_params].keyExists(kDisallowedParam1));
+ EXPECT_FALSE((*msg)[strings::msg_params].keyExists(kDisallowedParam2));
+ EXPECT_FALSE((*msg)[strings::msg_params].keyExists(kUndefinedParam));
+ EXPECT_FALSE((*msg)[strings::msg_params].keyExists(kMissedParam));
+ EXPECT_TRUE((*msg)[strings::msg_params].keyExists(kAllowedParam));
+ EXPECT_TRUE(command->HasDisallowedParams());
+}
+
+TEST_F(CommandRequestImplTest,
+ CheckAllowedParameters_RegisterAppInterface_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::RegisterAppInterfaceID;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ EXPECT_CALL(app_mngr_, applications()).Times(0);
+ EXPECT_TRUE(command->CheckPermissions());
+}
+
+TEST_F(CommandRequestImplTest,
+ CheckAllowedParameters_NoAppWithSameConnectionKey_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ SharedPtr<ApplicationSet> app_set;
+ MockAppPtr app(InitAppSetDataAccessor(app_set));
+ EXPECT_CALL(*app, app_id()).WillOnce(Return(6u));
+ EXPECT_TRUE(command->CheckPermissions());
+}
+
+TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params] = 0u;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ SharedPtr<ApplicationSet> app_set;
+ MockAppPtr app(InitAppSetDataAccessor(app_set));
+ EXPECT_CALL(*app, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
+ EXPECT_CALL(*app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ .WillOnce(Return(kMobResultSuccess));
+
+ EXPECT_TRUE(command->CheckPermissions());
+}
+
+TEST_F(CommandRequestImplTest,
+ CheckAllowedParameters_WrongPolicyPermissions_UNSUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params] = 0u;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ SharedPtr<ApplicationSet> app_set;
+ MockAppPtr app(InitAppSetDataAccessor(app_set));
+ EXPECT_CALL(*app, app_id()).Times(2).WillRepeatedly(Return(kConnectionKey));
+ EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
+ EXPECT_CALL(*app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::INVALID_ENUM));
+
+ MessageSharedPtr dummy_msg;
+ EXPECT_CALL(*mock_message_helper_,
+ CreateBlockedByPoliciesResponse(_, _, _, _))
+ .WillOnce(Return(dummy_msg));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _));
+ EXPECT_FALSE(command->CheckPermissions());
+}
+
+ACTION_P(GetArg3, output) {
+ *output = arg3;
+}
+
+TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][kPolicyAppId] = true;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ SharedPtr<ApplicationSet> app_set;
+ MockAppPtr app(InitAppSetDataAccessor(app_set));
+ EXPECT_CALL(*app, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
+ EXPECT_CALL(*app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ RPCParams params;
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ .WillOnce(DoAll(GetArg3(&params), Return(kMobResultSuccess)));
+
+ EXPECT_TRUE(command->CheckPermissions());
+ EXPECT_TRUE(params.end() !=
+ std::find(params.begin(), params.end(), kPolicyAppId));
+}
+
+TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) {
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kDisallowedParam1,
+ am::VehicleDataType::MYKEY));
+
+ EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+
+ MessageSharedPtr msg;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ command->removed_parameters_permissions().disallowed_params.push_back(
+ kDisallowedParam1);
+
+ command->AddDisallowedParameters(*msg);
+
+ EXPECT_TRUE((*msg)[strings::msg_params].keyExists(kDisallowedParam1));
+}
+
+TEST_F(CommandRequestImplTest, SendResponse_TimedOut_UNSUCCESS) {
+ CommandPtr command = CreateCommand<UCommandRequestImpl>();
+
+ command->set_current_state(RequestState::kTimedOut);
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ // Args do not affect on anything in this case;
+ command->SendResponse(true, kMobResultSuccess, NULL, NULL);
+
+ EXPECT_EQ(RequestState::kTimedOut, command->current_state());
+}
+
+TEST_F(CommandRequestImplTest, SendResponse_SUCCESS) {
+ MessageSharedPtr msg;
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ EXPECT_TRUE(smart_objects::SmartType_Null == (*msg).getType());
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ // Args do not affect on anything in this case;
+ command->SendResponse(true, kMobResultSuccess, NULL, NULL);
+
+ EXPECT_EQ(RequestState::kCompleted, command->current_state());
+
+ EXPECT_TRUE(smart_objects::SmartType_Map == (*msg).getType());
+}
+
+TEST_F(CommandRequestImplTest,
+ SendResponse_AddDisallowedParametersToInfo_SUCCESS) {
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kDisallowedParam1,
+ am::VehicleDataType::MYKEY));
+
+ EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::SubscribeVehicleDataID;
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+
+ command->removed_parameters_permissions().disallowed_params.push_back(
+ kDisallowedParam1);
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ command->SendResponse(true, kMobResultSuccess, NULL, NULL);
+
+ EXPECT_EQ(RequestState::kCompleted, command->current_state());
+
+ EXPECT_TRUE((*result)[strings::msg_params].keyExists(strings::info));
+ EXPECT_FALSE(
+ (*result)[strings::msg_params][strings::info].asString().empty());
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/command_response_impl_test.cc b/src/components/application_manager/test/commands/command_response_impl_test.cc
new file mode 100644
index 0000000000..c7a5edae63
--- /dev/null
+++ b/src/components/application_manager/test/commands/command_response_impl_test.cc
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command.h"
+#include "application_manager/commands/command_response_impl.h"
+#include "application_manager/mock_application.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace strings = ::application_manager::strings;
+namespace hmi_response = ::application_manager::hmi_response;
+using ::utils::SharedPtr;
+using ::application_manager::commands::MessageSharedPtr;
+using ::application_manager::commands::CommandResponseImpl;
+
+class CommandResponseImplTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(CommandResponseImplTest, BasicMethodsOverloads_SUCCESS) {
+ SharedPtr<CommandResponseImpl> command = CreateCommand<CommandResponseImpl>();
+ // Current implementation always return `true`
+ EXPECT_TRUE(command->Init());
+ EXPECT_TRUE(command->CleanUp());
+ EXPECT_NO_THROW(command->Run());
+}
+
+TEST_F(CommandResponseImplTest, SendResponse_MessageWithResultCode_SUCCESS) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandResponseImpl> command =
+ CreateCommand<CommandResponseImpl>(msg);
+ // Do not have a weight in this case
+ const bool kSuccess = true;
+ const mobile_apis::Result::eType kResultCode =
+ mobile_apis::Result::eType::INVALID_ENUM;
+ const bool kFinalResponse = true;
+
+ // If `msg_params->result_code` exist in message,
+ // then send message to mobile.
+ (*msg)[strings::msg_params][strings::result_code] = kResultCode;
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, kFinalResponse));
+
+ command->SendResponse(kSuccess, kResultCode, kFinalResponse);
+}
+
+TEST_F(CommandResponseImplTest,
+ SendResponse_EmptyMessageValidResultCode_SUCCESS) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandResponseImpl> command =
+ CreateCommand<CommandResponseImpl>(msg);
+
+ const bool kSuccess = true;
+ const mobile_apis::Result::eType kResultCode =
+ mobile_apis::Result::eType::SUCCESS;
+ const bool kFinalResponse = true;
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, kFinalResponse));
+
+ // If `msg_params->result_code` does not exist in message
+ // and arg `result_code` not equals `INVALID_ENUM`,
+ // then set it to `msg_params->result_code` and send message to mobile.
+ command->SendResponse(kSuccess, kResultCode, kFinalResponse);
+
+ EXPECT_EQ(kResultCode,
+ (*msg)[strings::msg_params][strings::result_code].asInt());
+}
+
+TEST_F(CommandResponseImplTest,
+ SendResponse_EmptyMessageInvalidResultCode_SUCCESS) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandResponseImpl> command =
+ CreateCommand<CommandResponseImpl>(msg);
+
+ const bool kSuccess = true;
+ const mobile_apis::Result::eType kResultCode =
+ mobile_apis::Result::eType::INVALID_ENUM;
+ const bool kFinalResponse = true;
+
+ // If `msg_params->result_code` does not exist in message
+ // and arg `result_code` equals `INVALID_ENUM`,
+ // then if `params->hmi_response::code` exist in message,
+ // then set it to `msg_params->result_code` and send message to mobile.
+ (*msg)[strings::params][hmi_response::code] = mobile_apis::Result::SUCCESS;
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, kFinalResponse));
+
+ command->SendResponse(kSuccess, kResultCode, kFinalResponse);
+
+ EXPECT_EQ((*msg)[strings::params][hmi_response::code].asInt(),
+ (*msg)[strings::msg_params][strings::result_code].asInt());
+}
+
+TEST_F(CommandResponseImplTest,
+ SendResponse_EmptyMessageInvalidResultCodeNoHmiResponse_SUCCESS) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandResponseImpl> command =
+ CreateCommand<CommandResponseImpl>(msg);
+
+ const mobile_apis::Result::eType kResultCode =
+ mobile_apis::Result::eType::INVALID_ENUM;
+ const bool kFinalResponse = true;
+
+ // If `msg_params->result_code` does not exist in message
+ // and arg `result_code` equals `INVALID_ENUM`,
+ // then if `params->hmi_response::code` does not exist in message,
+ // then if `kSuccess` equals `true`,
+ // then `msg_params->result_code` will be `SUCCESS`
+ const bool kSuccess = true;
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, kFinalResponse));
+
+ command->SendResponse(kSuccess, kResultCode, kFinalResponse);
+
+ EXPECT_EQ(mobile_apis::Result::SUCCESS,
+ (*msg)[strings::msg_params][strings::result_code].asInt());
+}
+
+TEST_F(CommandResponseImplTest,
+ SendResponse_EmptyMessageInvalidResultCodeNoHmiResponse_INVALID_ENUM) {
+ MessageSharedPtr msg;
+ SharedPtr<CommandResponseImpl> command =
+ CreateCommand<CommandResponseImpl>(msg);
+
+ const mobile_apis::Result::eType kResultCode =
+ mobile_apis::Result::eType::INVALID_ENUM;
+ const bool kFinalResponse = true;
+
+ // If `msg_params->result_code` does not exist in message
+ // and arg `result_code` equals `INVALID_ENUM`,
+ // then if `params->hmi_response::code` does not exist in message,
+ // then if `kSuccess` equals `false`,
+ // then `msg_params->result_code` will be `INVALID_ENUM`
+ const bool kSuccess = false;
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, kFinalResponse));
+
+ command->SendResponse(kSuccess, kResultCode, kFinalResponse);
+
+ EXPECT_EQ(mobile_apis::Result::INVALID_ENUM,
+ (*msg)[strings::msg_params][strings::result_code].asInt());
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/CMakeLists.txt b/src/components/application_manager/test/commands/hmi/CMakeLists.txt
new file mode 100644
index 0000000000..d99e211bdc
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/CMakeLists.txt
@@ -0,0 +1,59 @@
+# Copyright (c) 2016, 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_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/application_manager/include/application_manager/
+ ${COMPONENTS_DIR}/application_manager/include/application_manager/commands/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/application_manager/commands/
+)
+
+file(GLOB SOURCES
+ ${AM_SOURCE_DIR}/src/smart_object_keys.cc
+ ${AM_SOURCE_DIR}/test/mock_message_helper.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/hmi/*
+ ${COMMANDS_TEST_SOURCE_DIR}/hmi/vi_is_ready_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/hmi/vr_is_ready_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/hmi/ui_is_ready_request_test.cc
+ )
+
+set(LIBRARIES
+ gmock
+ jsoncpp
+ Utils
+ ApplicationManager
+ connectionHandler
+ HMI_API
+ MOBILE_API
+ SmartObjects
+)
+
+create_test("hmi_commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc
new file mode 100644
index 0000000000..1256914225
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2016, 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 <utility>
+
+#include "application_manager/commands/hmi/navi_audio_start_stream_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+namespace commands = am::commands;
+using commands::MessageSharedPtr;
+using commands::AudioStartStreamRequest;
+using am::event_engine::Event;
+
+namespace {
+const uint32_t kHmiAppId = 13u;
+const am::HmiInterfaces::InterfaceID kHmiInterface =
+ am::HmiInterfaces::HMI_INTERFACE_Navigation;
+} // namespace
+
+class AudioStartStreamRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ AudioStartStreamRequestTest() {
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ ON_CALL(app_mngr_settings_, start_stream_retry_amount())
+ .WillByDefault(ReturnRef(start_stream_retry_amount_));
+ msg_ = CreateMessage();
+ command_ = CreateCommand<AudioStartStreamRequest>(msg_);
+ }
+
+ std::pair<uint32_t, int32_t> start_stream_retry_amount_;
+ MessageSharedPtr msg_;
+ SharedPtr<AudioStartStreamRequest> command_;
+ MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
+};
+
+TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) {
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0);
+
+ command_->Run();
+}
+
+TEST_F(AudioStartStreamRequestTest,
+ Run_HmiInterfaceAvailableButNoApp_NoRequest) {
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId;
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0);
+
+ command_->Run();
+}
+
+TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) {
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId;
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_audio_streaming_allowed(true));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(msg_));
+
+ command_->Run();
+}
+
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc
new file mode 100644
index 0000000000..4ebb04041e
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016, 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/hmi/navi_is_ready_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::NaviIsReadyRequest;
+using am::event_engine::Event;
+
+namespace {
+const hmi_apis::FunctionID::eType kEventID =
+ hmi_apis::FunctionID::Navigation_IsReady;
+} // namespace
+
+typedef SharedPtr<NaviIsReadyRequest> NaviIsReadyRequestPtr;
+
+class NaviIsReadyRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ NaviIsReadyRequestTest() : command_(CreateCommand<NaviIsReadyRequest>()) {
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(mock_hmi_capabilities_));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ }
+
+ NaviIsReadyRequestPtr command_;
+ MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
+ MOCK(application_manager_test::MockHMICapabilities) mock_hmi_capabilities_;
+};
+
+TEST_F(NaviIsReadyRequestTest,
+ OnEvent_HmiInterfaceIsAvailable_NaviCooperatingIsAvailable) {
+ const bool is_hmi_interface_available = true;
+
+ MessageSharedPtr event_msg = CreateMessage();
+ (*event_msg)[am::strings::msg_params][am::strings::available] =
+ is_hmi_interface_available;
+
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(mock_hmi_interfaces_,
+ SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation,
+ am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_navi_cooperating(is_hmi_interface_available));
+
+ command_->on_event(event);
+}
+
+TEST_F(NaviIsReadyRequestTest,
+ OnEvent_HmiInterfaceIsNotAvailable_NaviCooperatingIsNotAvailable) {
+ const bool is_hmi_interface_available = false;
+
+ MessageSharedPtr event_msg = CreateMessage();
+ (*event_msg)[am::strings::msg_params][am::strings::available] =
+ is_hmi_interface_available;
+
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(mock_hmi_interfaces_,
+ SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_navi_cooperating(is_hmi_interface_available));
+
+ command_->on_event(event);
+}
+
+TEST_F(NaviIsReadyRequestTest,
+ OnEvent_AvailabilityFieldMissing_NaviCooperatingIsNotAvailable) {
+ const bool is_hmi_interface_available = false;
+
+ MessageSharedPtr event_msg = CreateMessage();
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_navi_cooperating(is_hmi_interface_available));
+
+ command_->on_event(event);
+}
+
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc
new file mode 100644
index 0000000000..e5fce1a099
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2016, 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 <utility>
+
+#include "application_manager/commands/hmi/navi_start_stream_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+namespace commands = am::commands;
+using commands::MessageSharedPtr;
+using commands::NaviStartStreamRequest;
+using am::event_engine::Event;
+
+namespace {
+const uint32_t kHmiAppId = 13u;
+const am::HmiInterfaces::InterfaceID kHmiInterface =
+ am::HmiInterfaces::HMI_INTERFACE_Navigation;
+} // namespace
+
+class NaviStartStreamRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ NaviStartStreamRequestTest() {
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ ON_CALL(app_mngr_settings_, start_stream_retry_amount())
+ .WillByDefault(ReturnRef(start_stream_retry_amount_));
+ msg_ = CreateMessage();
+ command_ = CreateCommand<NaviStartStreamRequest>(msg_);
+ }
+
+ std::pair<uint32_t, int32_t> start_stream_retry_amount_;
+ MessageSharedPtr msg_;
+ SharedPtr<NaviStartStreamRequest> command_;
+ MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
+};
+
+TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) {
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0);
+
+ command_->Run();
+}
+
+TEST_F(NaviStartStreamRequestTest,
+ Run_HmiInterfaceAvailableButNoApp_NoRequest) {
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId;
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0);
+
+ command_->Run();
+}
+
+TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) {
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId;
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_video_streaming_allowed(true));
+ EXPECT_CALL(app_mngr_, SendMessageToHMI(msg_));
+
+ command_->Run();
+}
+
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc
new file mode 100644
index 0000000000..f812ead115
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016, 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/hmi/navi_stop_stream_request.h"
+#include "application_manager/commands/hmi/navi_audio_stop_stream_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+namespace commands = am::commands;
+using commands::MessageSharedPtr;
+using am::event_engine::Event;
+
+namespace {
+const am::HmiInterfaces::InterfaceID kHmiInterface =
+ am::HmiInterfaces::HMI_INTERFACE_Navigation;
+} // namespace
+
+template <typename Command>
+class NaviStopStreamRequestsTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ NaviStopStreamRequestsTest() {
+ ON_CALL(this->app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ msg_ = CreateMessage();
+ command_ = CreateCommand<Command>(msg_);
+ }
+
+ MessageSharedPtr msg_;
+ SharedPtr<Command> command_;
+ MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
+};
+
+typedef testing::Types<commands::AudioStopStreamRequest,
+ commands::NaviStopStreamRequest> RequestCommandsList;
+TYPED_TEST_CASE(NaviStopStreamRequestsTest, RequestCommandsList);
+
+TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceNotAvailable_NoRequest) {
+ EXPECT_CALL(TestFixture::mock_hmi_interfaces_,
+ GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(TestFixture::app_mngr_, SendMessageToHMI(_)).Times(0);
+
+ TestFixture::command_->Run();
+}
+
+TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceAvailable_SentRequest) {
+ EXPECT_CALL(TestFixture::mock_hmi_interfaces_,
+ GetInterfaceState(kHmiInterface))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(TestFixture::app_mngr_, SendMessageToHMI(TestFixture::msg_));
+
+ TestFixture::command_->Run();
+}
+
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc
new file mode 100644
index 0000000000..0a1ad28c79
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2016, 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/hmi/ui_is_ready_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::MessageSharedPtr;
+using am::commands::UIIsReadyRequest;
+using am::MockMessageHelper;
+using am::event_engine::Event;
+
+typedef SharedPtr<UIIsReadyRequest> UIIsReadyRequestPtr;
+
+class UIIsReadyRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ UIIsReadyRequestTest()
+ : command_(CreateCommand<UIIsReadyRequest>())
+ , mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(mock_hmi_capabilities_));
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+ void SetUpExpectations(bool is_ui_cooperating_available,
+ bool is_send_message_to_hmi,
+ bool is_message_contain_param,
+ am::HmiInterfaces::InterfaceState state) {
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_ui_cooperating(is_ui_cooperating_available));
+
+ if (is_message_contain_param) {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(
+ mock_hmi_interfaces_,
+ SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI, state));
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillOnce(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0);
+ }
+
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(state));
+
+ if (is_send_message_to_hmi) {
+ ExpectSendMessagesToHMI();
+ }
+ }
+
+ void ExpectSendMessagesToHMI() {
+ smart_objects::SmartObjectSPtr get_language(CreateMessage());
+ (*get_language)[am::strings::params][am::strings::message_type] =
+ static_cast<int>(am::MessageType::kRequest);
+ (*get_language)[am::strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ EXPECT_CALL(mock_message_helper_,
+ CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage, _))
+ .WillOnce(Return(get_language));
+
+ smart_objects::SmartObjectSPtr get_all_language(CreateMessage());
+ (*get_all_language)[am::strings::params][am::strings::message_type] =
+ static_cast<int>(am::MessageType::kRequest);
+ (*get_all_language)[am::strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ EXPECT_CALL(
+ mock_message_helper_,
+ CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetSupportedLanguages, _))
+ .WillOnce(Return(get_all_language));
+
+ smart_objects::SmartObjectSPtr get_capabilities(CreateMessage());
+ (*get_capabilities)[am::strings::params][am::strings::message_type] =
+ static_cast<int>(am::MessageType::kRequest);
+ (*get_capabilities)[am::strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ EXPECT_CALL(mock_message_helper_,
+ CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetCapabilities, _))
+ .WillOnce(Return(get_capabilities));
+
+ EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*get_language));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(get_language));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(get_all_language));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(get_capabilities));
+ }
+
+ void PrepareEvent(bool is_message_contain_param,
+ Event& event,
+ bool is_ui_cooperating_available = false) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ if (is_message_contain_param) {
+ (*msg)[am::strings::msg_params][am::strings::available] =
+ is_ui_cooperating_available;
+ }
+ event.set_smart_object(*msg);
+ }
+
+ UIIsReadyRequestPtr command_;
+ am::MockHmiInterfaces mock_hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
+ policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_;
+};
+
+TEST_F(UIIsReadyRequestTest,
+ OnEvent_NoKeyAvailableInMessage_HmiInterfacesIgnored) {
+ const bool is_ui_cooperating_available = false;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = false;
+ Event event(hmi_apis::FunctionID::UI_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_ui_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_RESPONSE);
+
+ command_->on_event(event);
+}
+
+TEST_F(UIIsReadyRequestTest,
+ OnEvent_KeyAvailableEqualToFalse_StateNotAvailable) {
+ const bool is_ui_cooperating_available = false;
+ const bool is_send_message_to_hmi = false;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::UI_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_ui_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(UIIsReadyRequestTest, OnEvent_KeyAvailableEqualToTrue_StateAvailable) {
+ const bool is_ui_cooperating_available = true;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::UI_IsReady);
+ PrepareEvent(is_message_contain_param, event, is_ui_cooperating_available);
+ SetUpExpectations(is_ui_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(UIIsReadyRequestTest, OnTimeout_SUCCESS) {
+ ExpectSendMessagesToHMI();
+ command_->onTimeOut();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc
new file mode 100644
index 0000000000..aa4b450a98
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2016, 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/hmi/vi_is_ready_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+using ::testing::Return;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::VIIsReadyRequest;
+using am::MockMessageHelper;
+using am::event_engine::Event;
+
+typedef SharedPtr<VIIsReadyRequest> VIIsReadyRequestPtr;
+
+class VIIsReadyRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ VIIsReadyRequestTest() : command_(CreateCommand<VIIsReadyRequest>()) {}
+
+ void SetUpExpectations(bool is_vi_cooperating_available,
+ bool is_send_message_to_hmi,
+ bool is_message_contain_param,
+ am::HmiInterfaces::InterfaceState state) {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_ivi_cooperating(is_vi_cooperating_available));
+
+ if (is_message_contain_param) {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(mock_hmi_interfaces_,
+ SetInterfaceState(
+ am::HmiInterfaces::HMI_INTERFACE_VehicleInfo, state));
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillOnce(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0);
+ }
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler_interface_));
+ EXPECT_CALL(mock_policy_handler_interface_, OnVIIsReady());
+
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VehicleInfo))
+ .WillOnce(Return(state));
+
+ if (is_send_message_to_hmi) {
+ ExpectSendMessagesToHMI();
+ }
+ }
+
+ void ExpectSendMessagesToHMI() {
+ smart_objects::SmartObjectSPtr ivi_type;
+ EXPECT_CALL(
+ *(MockMessageHelper::message_helper_mock()),
+ CreateModuleInfoSO(hmi_apis::FunctionID::VehicleInfo_GetVehicleType, _))
+ .WillOnce(Return(ivi_type));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(ivi_type));
+ }
+
+ void PrepareEvent(bool is_message_contain_param,
+ Event& event,
+ bool is_vi_cooperating_available = false) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ if (is_message_contain_param) {
+ (*msg)[am::strings::msg_params][am::strings::available] =
+ is_vi_cooperating_available;
+ }
+ event.set_smart_object(*msg);
+ }
+
+ VIIsReadyRequestPtr command_;
+ am::MockHmiInterfaces mock_hmi_interfaces_;
+ application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
+ policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_;
+};
+
+TEST_F(VIIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) {
+ const bool is_vi_cooperating_available = false;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = false;
+ Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_vi_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_RESPONSE);
+ command_->on_event(event);
+}
+
+TEST_F(VIIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) {
+ const bool is_vi_cooperating_available = false;
+ const bool is_send_message_to_hmi = false;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_vi_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(VIIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
+ const bool is_vi_cooperating_available = true;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ PrepareEvent(is_message_contain_param, event, is_vi_cooperating_available);
+ SetUpExpectations(is_vi_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(VIIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
+ ExpectSendMessagesToHMI();
+ command_->onTimeOut();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc
new file mode 100644
index 0000000000..e5989d0b64
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2016, 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/hmi/vr_is_ready_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::VRIsReadyRequest;
+using am::MockMessageHelper;
+using am::event_engine::Event;
+
+typedef SharedPtr<VRIsReadyRequest> VRIsReadyRequestPtr;
+
+class VRIsReadyRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ VRIsReadyRequestTest() : command_(CreateCommand<VRIsReadyRequest>()) {}
+
+ void SetUpExpectations(bool is_vr_cooperating_available,
+ bool is_send_message_to_hmi,
+ bool is_message_contain_param,
+ am::HmiInterfaces::InterfaceState state) {
+ const bool is_send_message_by_timeout = false;
+ if (is_send_message_to_hmi) {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillRepeatedly(ReturnRef(mock_hmi_capabilities_));
+ ExpectSendMessagesToHMI(is_send_message_by_timeout);
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+ }
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_vr_cooperating(is_vr_cooperating_available));
+
+ if (is_message_contain_param) {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(
+ mock_hmi_interfaces_,
+ SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR, state));
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillOnce(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0);
+ }
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillOnce(Return(state));
+ }
+
+ void ExpectSendMessagesToHMI(bool is_send_message_by_timeout) {
+ if (is_send_message_by_timeout) {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+ }
+
+ smart_objects::SmartObjectSPtr language(
+ new smart_objects::SmartObject(smart_objects::SmartType_Map));
+ EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
+ CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, _))
+ .WillOnce(Return(language));
+ EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*language));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(language));
+
+ smart_objects::SmartObjectSPtr support_language(
+ new smart_objects::SmartObject(smart_objects::SmartType_Map));
+ EXPECT_CALL(
+ *(MockMessageHelper::message_helper_mock()),
+ CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages, _))
+ .WillOnce(Return(support_language));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(support_language));
+
+ smart_objects::SmartObjectSPtr capabilities(
+ new smart_objects::SmartObject(smart_objects::SmartType_Map));
+ EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
+ CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, _))
+ .WillOnce(Return(capabilities));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities));
+ }
+
+ void PrepareEvent(bool is_message_contain_param,
+ Event& event,
+ bool is_vr_cooperating_available = false) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ if (is_message_contain_param) {
+ (*msg)[am::strings::msg_params][am::strings::available] =
+ is_vr_cooperating_available;
+ }
+ event.set_smart_object(*msg);
+ }
+
+ VRIsReadyRequestPtr command_;
+ am::MockHmiInterfaces mock_hmi_interfaces_;
+ application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
+};
+
+TEST_F(VRIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) {
+ const bool is_vr_cooperating_available = false;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = false;
+ Event event(hmi_apis::FunctionID::VR_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_vr_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_RESPONSE);
+ command_->on_event(event);
+}
+
+TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) {
+ const bool is_vr_cooperating_available = false;
+ const bool is_send_message_to_hmi = false;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::VR_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_vr_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
+ const bool is_vr_cooperating_available = true;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::VR_IsReady);
+ PrepareEvent(is_message_contain_param, event, is_vr_cooperating_available);
+ SetUpExpectations(is_vr_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(VRIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
+ const bool is_send_message_by_timeout = true;
+ ExpectSendMessagesToHMI(is_send_message_by_timeout);
+ command_->onTimeOut();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/CMakeLists.txt b/src/components/application_manager/test/commands/mobile/CMakeLists.txt
new file mode 100644
index 0000000000..31c8503573
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/CMakeLists.txt
@@ -0,0 +1,75 @@
+# Copyright (c) 2016, 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_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/application_manager/include/application_manager/
+ ${COMPONENTS_DIR}/application_manager/include/application_manager/commands/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/application_manager/commands/
+)
+
+set (SOURCES
+ ${AM_SOURCE_DIR}/src/smart_object_keys.cc
+ ${AM_SOURCE_DIR}/test/mock_message_helper.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/delete_command_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/add_command_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/perform_interaction_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/change_registration_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/create_interaction_choice_set_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/register_app_interface_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/speak_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/alert_maneuver_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/show_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/alert_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/add_sub_menu_request_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/delete_sub_menu_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/set_media_clock_timer_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/set_global_properties_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/set_app_icon_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/set_display_layout_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/slider_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/scrollable_message_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/perform_audio_pass_thru_test.cc
+ ${COMMANDS_TEST_SOURCE_DIR}/mobile/end_audio_pass_thru_request_test.cc
+)
+
+set(LIBRARIES
+ gmock
+ jsoncpp
+ Utils
+ ApplicationManager
+ connectionHandler
+ HMI_API
+ MOBILE_API
+ SmartObjects
+)
+
+create_test("mobile_commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
new file mode 100644
index 0000000000..b337acd52f
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/add_command_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "smart_objects/smart_object.h"
+#include "utils/custom_string.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace add_command_request {
+
+namespace am = application_manager;
+
+using am::commands::AddCommandRequest;
+using am::commands::CommandImpl;
+using am::ApplicationManager;
+using am::commands::MessageSharedPtr;
+using am::ApplicationSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::utils::SharedPtr;
+using ::test::components::application_manager_test::MockApplication;
+
+namespace custom_str = utils::custom_string;
+namespace strings = ::application_manager::strings;
+namespace hmi_response = ::application_manager::hmi_response;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class AddCommandRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ AddCommandRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ protected:
+ MessageSharedPtr CreateFullParamsVRSO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] = kCmdId;
+ msg_params[strings::vr_commands] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ msg_params[strings::vr_commands][0] = "lamer";
+ msg_params[strings::type] = 34;
+ msg_params[strings::grammar_id] = 12;
+ msg_params[strings::app_id] = kAppId;
+ (*msg)[strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ MessageSharedPtr CreateParamsUISOWithOutCmdIcon() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(AddCommandRequestTest, OnTimeout_GENERIC_ERROR) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::msg_params][strings::result_code] =
+ am::mobile_api::Result::GENERIC_ERROR;
+ (*msg)[strings::msg_params][strings::success] = false;
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<AddCommandRequest> command =
+ CreateCommand<AddCommandRequest>(msg);
+
+ ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app_, RemoveCommand(_)).WillByDefault(Return());
+
+ EXPECT_CALL(
+ mock_message_helper_,
+ CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
+ .WillOnce(Return(msg));
+
+ MessageSharedPtr command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true)));
+
+ command->onTimeOut();
+ EXPECT_EQ((*command_result)[strings::msg_params][strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*command_result)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
+}
+
+TEST_F(AddCommandRequestTest, OnEvent_VR_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_vr = CreateFullParamsVRSO();
+ (*msg_vr)[strings::msg_params][strings::menu_params]
+ [am::hmi_request::parent_id] = 10u;
+ (*msg_vr)[strings::msg_params][strings::menu_params][strings::menu_name] =
+ "menu_name";
+
+ utils::SharedPtr<AddCommandRequest> command =
+ CreateCommand<AddCommandRequest>(msg_vr);
+
+ ON_CALL(*mock_app_, FindSubMenu(_)).WillByDefault(Return(&(*msg_vr)));
+ ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "VR is not supported by system";
+ (*msg)[strings::msg_params][strings::cmd_id] = kCommandId;
+
+ Event event(hmi_apis::FunctionID::VR_AddCommand);
+ event.set_smart_object(*msg);
+
+ smart_objects::SmartObject* ptr = NULL;
+ ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr));
+
+ ON_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_vr)[strings::msg_params]));
+
+ am::CommandsMap commands_map;
+ ON_CALL(*mock_app_, commands_map())
+ .WillByDefault(
+ Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
+
+ EXPECT_CALL(*mock_app_, UpdateHash());
+
+ MessageSharedPtr msg_ui(CreateMessage(smart_objects::SmartType_Map));
+ (*msg_ui)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+
+ Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
+ event_ui.set_smart_object(*msg_ui);
+
+ command->Run();
+ command->on_event(event_ui);
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(vr_command_result, "VR is not supported by system");
+}
+
+TEST_F(AddCommandRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_vr = CreateFullParamsUISO();
+ (*msg_vr)[am::strings::msg_params][am::strings::vr_commands][0] =
+ "vr_command";
+
+ utils::SharedPtr<AddCommandRequest> command =
+ CreateCommand<AddCommandRequest>(msg_vr);
+
+ ON_CALL(*mock_app_, FindSubMenu(_)).WillByDefault(Return(&(*msg_vr)));
+
+ ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+ (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+
+ Event event(hmi_apis::FunctionID::UI_AddCommand);
+ event.set_smart_object(*msg);
+
+ smart_objects::SmartObject* ptr = NULL;
+ ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr));
+ EXPECT_EQ(NULL, ptr);
+
+ ON_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(*mock_app_,
+ AddCommand(kCmdId, (*msg_vr)[am::strings::msg_params]));
+
+ am::CommandsMap commands_map;
+ ON_CALL(*mock_app_, commands_map())
+ .WillByDefault(
+ Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
+
+ EXPECT_CALL(*mock_app_, UpdateHash());
+
+ MessageSharedPtr msg_ui(CreateMessage(smart_objects::SmartType_Map));
+ (*msg_ui)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+
+ Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
+ event_vr.set_smart_object(*msg_vr);
+
+ command->Run();
+ command->on_event(event_vr);
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+} // namespace add_command_test
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
new file mode 100644
index 0000000000..7eae10d10b
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "application_manager/commands/mobile/add_sub_menu_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+using am::commands::AddSubMenuRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockHmiInterfaces;
+using am::MockMessageHelper;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+
+typedef SharedPtr<AddSubMenuRequest> AddSubMenuPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class AddSubMenuRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ AddSubMenuRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+};
+
+TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ const uint32_t menu_id = 10u;
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ (*msg)[am::strings::msg_params][am::strings::menu_id] = menu_id;
+
+ utils::SharedPtr<AddSubMenuRequest> command =
+ CreateCommand<AddSubMenuRequest>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ EXPECT_CALL(*mock_app, AddSubMenu(menu_id, _));
+ EXPECT_CALL(*mock_app, UpdateHash());
+
+ MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*ev_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*ev_msg)[am::strings::msg_params][am::strings::info] = "info";
+
+ Event event(hmi_apis::FunctionID::UI_AddSubMenu);
+ event.set_smart_object(*ev_msg);
+
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
new file mode 100644
index 0000000000..157f3db750
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "event_engine/event.h"
+#include "application_manager/commands/mobile/alert_maneuver_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/policies/policy_handler_interface.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::AlertManeuverRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockHmiInterfaces;
+using am::MockMessageHelper;
+
+typedef SharedPtr<AlertManeuverRequest> CommandPtr;
+
+class AlertManeuverRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
+ const mobile_apis::Result::eType mobile_response,
+ const am::HmiInterfaces::InterfaceState state,
+ const bool success) {
+ MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
+ (*response)[am::strings::params][am::hmi_response::code] = hmi_response;
+ (*response)[am::strings::msg_params][am::strings::info] = "test";
+
+ am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak);
+ event.set_smart_object(*response);
+
+ utils::SharedPtr<AlertManeuverRequest> command =
+ CreateCommand<AlertManeuverRequest>(response);
+
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ MockMessageHelper* mock_message_helper =
+ MockMessageHelper::message_helper_mock();
+ EXPECT_CALL(*mock_message_helper, HMIToMobileResult(_))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillRepeatedly(Return(state));
+
+ MessageSharedPtr response_to_mobile;
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+ command->on_event(event);
+
+ EXPECT_EQ(
+ (*response_to_mobile)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ success);
+ EXPECT_EQ(
+ (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(mobile_response));
+ }
+
+ protected:
+ NiceMock<policy_test::MockPolicyHandlerInterface> policy_interface_;
+};
+
+TEST_F(AlertManeuverRequestTest, Run_RequiredFieldsDoesNotExist_UNSUCCESS) {
+ CommandPtr command(CreateCommand<AlertManeuverRequest>());
+ EXPECT_CALL(app_mngr_, application(_)).Times(0);
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+ (*msg)[am::strings::msg_params][am::strings::tts_chunks] = 0;
+
+ CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
+
+ ON_CALL(app_mngr_, application(_))
+ .WillByDefault(Return(ApplicationSharedPtr()));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_UNSUCCESS) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+
+ CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ ON_CALL(app_mngr_, GetPolicyHandler())
+ .WillByDefault(ReturnRef(policy_interface_));
+
+ const mobile_apis::Result::eType kProcessingResult =
+ mobile_apis::Result::ABORTED;
+
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
+ ProcessSoftButtons(_, _, _, _))
+ .WillOnce(Return(kProcessingResult));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(kProcessingResult,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, Run_IsWhiteSpaceExist_UNSUCCESS) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+ (*msg)[am::strings::msg_params][am::strings::tts_chunks] =
+ SmartObject(smart_objects::SmartType_Array);
+
+ SmartObject tts_chunk(smart_objects::SmartType_Map);
+ tts_chunk[am::strings::text] = "wrong chunk syntax\t\n";
+
+ (*msg)[am::strings::msg_params][am::strings::tts_chunks].asArray()->push_back(
+ tts_chunk);
+
+ CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+
+ CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ ON_CALL(app_mngr_, GetPolicyHandler())
+ .WillByDefault(ReturnRef(policy_interface_));
+
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
+ ProcessSoftButtons(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ .WillRepeatedly(
+ Return(am::HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
+ SubscribeApplicationToSoftButton(_, _, _));
+
+ MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command)));
+ EXPECT_EQ(hmi_apis::FunctionID::Navigation_AlertManeuver,
+ static_cast<hmi_apis::FunctionID::eType>(
+ (*result_msg)[am::strings::params][am::strings::function_id]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) {
+ CommandPtr command(CreateCommand<AlertManeuverRequest>());
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ MessageSharedPtr result_msg(
+ CatchMobileCommandResult(CallOnEvent(*command, event)));
+ EXPECT_EQ(mobile_apis::Result::INVALID_ENUM,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE_Case1) {
+ CheckExpectations(hmi_apis::Common_Result::SUCCESS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ true);
+}
+
+TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE_Case2) {
+ CheckExpectations(hmi_apis::Common_Result::SUCCESS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE,
+ true);
+}
+
+TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE_Case3) {
+ CheckExpectations(hmi_apis::Common_Result::SUCCESS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_RESPONSE,
+ true);
+}
+
+TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE_Case4) {
+ CheckExpectations(hmi_apis::Common_Result::GENERIC_ERROR,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_RESPONSE,
+ false);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
new file mode 100644
index 0000000000..2c80f6e5e2
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/alert_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace alert_request {
+
+namespace am = application_manager;
+using am::commands::AlertRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ AlertRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ protected:
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(
+ Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillByDefault(
+ Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
+ }
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(AlertRequestTest, OnTimeout_GENERIC_ERROR) {
+ MessageSharedPtr command_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*command_msg)[am::strings::msg_params][am::strings::result_code] =
+ am::mobile_api::Result::GENERIC_ERROR;
+ (*command_msg)[am::strings::msg_params][am::strings::success] = false;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ utils::SharedPtr<AlertRequest> command = CreateCommand<AlertRequest>();
+
+ EXPECT_CALL(
+ mock_message_helper_,
+ CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
+ .WillOnce(Return(command_msg));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->onTimeOut();
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ false);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
+}
+
+TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr command_msg = CreateFullParamsUISO();
+ (*command_msg)[am::strings::msg_params][am::strings::menu_params]
+ [am::hmi_request::parent_id] = 10u;
+ (*command_msg)[am::strings::msg_params][am::strings::menu_params]
+ [am::strings::menu_name] = "menu_name";
+
+ utils::SharedPtr<AlertRequest> command =
+ CreateCommand<AlertRequest>(command_msg);
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ ON_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ MessageSharedPtr msg_tts = CreateMessage();
+ (*msg_tts)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ Event event_vr(hmi_apis::FunctionID::TTS_Speak);
+ event_vr.set_smart_object(*msg_tts);
+
+ command->on_event(event_vr);
+
+ Event event(hmi_apis::FunctionID::UI_Alert);
+ event.set_smart_object(*msg);
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+} // namespace alert_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
new file mode 100644
index 0000000000..a2a137d0f4
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
@@ -0,0 +1,539 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/change_registration_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "utils/custom_string.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/smart_object_keys.h"
+#include "policy/usage_statistics/mock_statistics_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace change_registration_request {
+
+namespace am = application_manager;
+using am::commands::CommandImpl;
+using am::ApplicationManager;
+using am::commands::MessageSharedPtr;
+using am::ApplicationSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::testing::_;
+using ::testing::Mock;
+using ::utils::SharedPtr;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::ChangeRegistrationRequest;
+using ::test::components::application_manager_test::MockApplication;
+
+namespace custom_str = utils::custom_string;
+namespace strings = ::application_manager::strings;
+namespace hmi_response = ::application_manager::hmi_response;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class ChangeRegistrationRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ ChangeRegistrationRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ MessageSharedPtr CreateMsgFromMobile() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::hmi_display_language] = mobile_apis::Language::EN_US;
+ msg_params[strings::language] = mobile_apis::Language::EN_US;
+ (*msg)[strings::msg_params] = msg_params;
+ return msg;
+ }
+ void PrepareExpectationBeforeRun() {
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities_));
+ smart_objects::SmartObject supported_languages(
+ smart_objects::SmartType_Array);
+ supported_languages[0] = static_cast<int32_t>(mobile_apis::Language::EN_US);
+ EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
+ .WillOnce(Return(&supported_languages));
+ EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
+ .WillOnce(Return(&supported_languages));
+ EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
+ .WillOnce(Return(&supported_languages));
+
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces_));
+ EXPECT_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ EXPECT_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ EXPECT_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ EXPECT_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ }
+
+ void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
+ const mobile_apis::Result::eType mobile_response,
+ const am::HmiInterfaces::InterfaceState state,
+ const bool success,
+ const hmi_apis::Common_Result::eType ui_hmi_response =
+ hmi_apis::Common_Result::WARNINGS,
+ const hmi_apis::Common_Result::eType vr_hmi_response =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
+
+ ON_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_response));
+
+ utils::SharedPtr<ChangeRegistrationRequest> command =
+ CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(1));
+ am::ApplicationSet application_set;
+ const utils::custom_string::CustomString name("name");
+ MockAppPtr app = CreateMockApp();
+ app->set_name(name);
+
+ DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
+
+ application_set.insert(app);
+
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+ EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
+ PrepareExpectationBeforeRun();
+ command->Run();
+
+ MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
+ CreateResponseFromHMI(ui_response, ui_hmi_response, "ui_info");
+ CreateResponseFromHMI(vr_response, vr_hmi_response, "unsupported_resource");
+
+ (*tts_response)[strings::params][hmi_response::code] = hmi_response;
+ (*tts_response)[strings::msg_params] = 0;
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillRepeatedly(Return(state));
+
+ am::event_engine::Event event_ui(
+ hmi_apis::FunctionID::UI_ChangeRegistration);
+ event_ui.set_smart_object(*ui_response);
+ am::event_engine::Event event_vr(
+ hmi_apis::FunctionID::VR_ChangeRegistration);
+ event_vr.set_smart_object(*vr_response);
+ am::event_engine::Event event_tts(
+ hmi_apis::FunctionID::TTS_ChangeRegistration);
+ event_tts.set_smart_object(*tts_response);
+
+ MessageSharedPtr response_to_mobile;
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_ui);
+ command->on_event(event_vr);
+ command->on_event(event_tts);
+
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
+ success);
+ EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(mobile_response));
+ }
+
+ void CreateResponseFromHMI(MessageSharedPtr msg,
+ hmi_apis::Common_Result::eType result,
+ const std::string& info) {
+ (*msg)[strings::params][hmi_response::code] = static_cast<int32_t>(result);
+ (*msg)[strings::msg_params][strings::info] = info;
+ }
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ExpectationsHmiCapabilities(
+ smart_objects::SmartObjectSPtr supported_languages) {
+ EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
+ .WillOnce(Return(supported_languages.get()));
+ EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
+ .WillOnce(Return(supported_languages.get()));
+ EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
+ .WillOnce(Return(supported_languages.get()));
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ typedef TypeIf<kMocksAreNice,
+ NiceMock<application_manager_test::MockHMICapabilities>,
+ application_manager_test::MockHMICapabilities>::Result
+ MockHMICapabilities;
+ sync_primitives::Lock app_set_lock_;
+ MockHMICapabilities hmi_capabilities_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+typedef ChangeRegistrationRequestTest::MockHMICapabilities MockHMICapabilities;
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
+
+ utils::SharedPtr<ChangeRegistrationRequest> command =
+ CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
+ am::ApplicationSet application_set;
+ const utils::custom_string::CustomString name("name");
+ MockAppPtr app = CreateMockApp();
+ app->set_name(name);
+
+ DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
+
+ application_set.insert(app);
+
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+ EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
+
+ smart_objects::SmartObjectSPtr supported_languages(
+ CreateMessage(smart_objects::SmartType_Array));
+ (*supported_languages)[0] =
+ static_cast<int32_t>(mobile_apis::Language::EN_US);
+
+ ExpectationsHmiCapabilities(supported_languages);
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
+
+ ON_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ command->Run();
+
+ MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
+ CreateResponseFromHMI(
+ ui_response, hmi_apis::Common_Result::WARNINGS, "ui_info");
+ CreateResponseFromHMI(vr_response,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ "VR is not supported by system");
+ CreateResponseFromHMI(
+ tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info");
+ (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*tts_response)[am::strings::msg_params][am::strings::app_id] =
+ kConnectionKey;
+ am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration);
+ event_ui.set_smart_object(*ui_response);
+ am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration);
+ event_vr.set_smart_object(*vr_response);
+ am::event_engine::Event event_tts(
+ hmi_apis::FunctionID::TTS_ChangeRegistration);
+ event_tts.set_smart_object(*tts_response);
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_to_mobile;
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_ui);
+ command->on_event(event_tts);
+ command->on_event(event_vr);
+
+ ResultCommandExpectations(response_to_mobile,
+ "ui_info, VR is not supported by system, tts_info");
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_true) {
+ CheckExpectations(hmi_apis::Common_Result::SUCCESS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE,
+ true);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_RESPONSE,
+ false);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ false);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ false,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::SUCCESS);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::SUCCESS,
+ mobile_apis::Result::SUCCESS,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ true,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::SUCCESS);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_WRONG_LANGUAGE_STATE_AVAILABLE_Expect_true) {
+ CheckExpectations(hmi_apis::Common_Result::WRONG_LANGUAGE,
+ mobile_apis::Result::SUCCESS,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ true,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::SUCCESS);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_TTS_INVALID_DATA_STATE_AVAILABLE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::INVALID_DATA,
+ mobile_apis::Result::SUCCESS,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ false,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::SUCCESS);
+}
+
+TEST_F(ChangeRegistrationRequestTest,
+ OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
+
+ utils::SharedPtr<ChangeRegistrationRequest> command =
+ CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
+
+ am::ApplicationSet application_set;
+ const utils::custom_string::CustomString name("name");
+ MockAppPtr app = CreateMockApp();
+ app->set_name(name);
+
+ DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
+
+ application_set.insert(app);
+
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+ EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
+
+ smart_objects::SmartObjectSPtr supported_languages(
+ CreateMessage(smart_objects::SmartType_Array));
+ (*supported_languages)[0] =
+ static_cast<int32_t>(mobile_apis::Language::EN_US);
+
+ ExpectationsHmiCapabilities(supported_languages);
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ ON_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ command->Run();
+
+ MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
+ MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
+ CreateResponseFromHMI(ui_response,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ "unsupported_resource");
+ CreateResponseFromHMI(
+ vr_response, hmi_apis::Common_Result::WARNINGS, "vr_info");
+ CreateResponseFromHMI(
+ tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info");
+ (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*tts_response)[am::strings::msg_params][am::strings::app_id] =
+ kConnectionKey;
+ am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration);
+ event_ui.set_smart_object(*ui_response);
+ am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration);
+ event_vr.set_smart_object(*vr_response);
+ am::event_engine::Event event_tts(
+ hmi_apis::FunctionID::TTS_ChangeRegistration);
+ event_tts.set_smart_object(*tts_response);
+
+ MessageSharedPtr response_to_mobile;
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_vr);
+ command->on_event(event_tts);
+ command->on_event(event_ui);
+
+ ResultCommandExpectations(response_to_mobile,
+ "unsupported_resource, vr_info, tts_info");
+}
+
+} // namespace change_registration_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
new file mode 100644
index 0000000000..138723b0c3
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/create_interaction_choice_set_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "smart_objects/smart_object.h"
+#include "utils/custom_string.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace create_interaction_choice_set_request {
+
+namespace am = application_manager;
+using am::commands::CommandImpl;
+using am::ApplicationManager;
+using am::commands::MessageSharedPtr;
+using am::ApplicationSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::testing::_;
+using ::testing::Mock;
+using ::utils::SharedPtr;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::CreateInteractionChoiceSetRequest;
+using ::test::components::application_manager_test::MockApplication;
+
+namespace custom_str = utils::custom_string;
+namespace strings = ::application_manager::strings;
+namespace hmi_response = ::application_manager::hmi_response;
+
+namespace {
+const hmi_apis::FunctionID::eType kInvalidFunctionId =
+ hmi_apis::FunctionID::INVALID_ENUM;
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class CreateInteractionChoiceSetRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ sync_primitives::Lock lock_;
+
+ MessageSharedPtr CreateFullParamsVRSO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] = kCmdId;
+ msg_params[strings::vr_commands] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ msg_params[strings::vr_commands][0] = "lamer";
+ msg_params[strings::type] = 34;
+ msg_params[strings::grammar_id] = 12;
+ msg_params[strings::app_id] = kAppId;
+ (*msg)[strings::msg_params] = msg_params;
+
+ return msg;
+ }
+};
+TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeout_GENERIC_ERROR) {
+ MessageSharedPtr msg_vr = CreateMessage(smart_objects::SmartType_Map);
+ (*msg_vr)[strings::msg_params][strings::result_code] =
+ am::mobile_api::Result::GENERIC_ERROR;
+ (*msg_vr)[strings::msg_params][strings::success] = false;
+
+ utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr =
+ CreateCommand<CreateInteractionChoiceSetRequest>();
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app, RemoveCommand(_)).WillByDefault(Return());
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ req_vr->onTimeOut();
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
+}
+
+TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_vr = CreateFullParamsVRSO();
+ (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::choice_id] =
+ 10;
+ (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] =
+ "menu_name";
+ (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11;
+ utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr =
+ CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ smart_objects::SmartObject* null_obj = NULL;
+ ON_CALL(*mock_app, FindChoiceSet(_)).WillByDefault(Return(null_obj));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[strings::msg_params][strings::info] = "VR is not supported by system";
+ (*msg)[strings::msg_params][strings::cmd_id] = kCommandId;
+
+ am::event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand);
+ event.set_smart_object(*msg);
+
+ smart_objects::SmartObject* ptr = NULL;
+ ON_CALL(*mock_app, FindCommand(kCmdId)).WillByDefault(Return(ptr));
+ EXPECT_EQ(NULL, ptr);
+
+ MockMessageHelper* mock_message_helper =
+ MockMessageHelper::message_helper_mock();
+ ON_CALL(*mock_message_helper, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ am::CommandsMap commands_map;
+ ON_CALL(*mock_app, commands_map())
+ .WillByDefault(
+ Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ ON_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ .WillByDefault(
+ Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ ON_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
+
+ req_vr->Run();
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ req_vr->on_event(event);
+
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*vr_command_result)[strings::msg_params].keyExists(strings::info)) {
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::info].asString(),
+ (*msg)[strings::msg_params][strings::info].asString());
+ }
+}
+
+} // namespace create_interaction_choice_set_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
new file mode 100644
index 0000000000..1e03dcaaf1
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "application_manager/commands/mobile/delete_command_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace delete_command_request {
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::DeleteCommandRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+
+typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class DeleteCommandRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ DeleteCommandRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ MessageSharedPtr CreateFullParamsVRSO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::vr_commands] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ msg_params[am::strings::vr_commands][0] = "lamer";
+ msg_params[am::strings::type] = 34;
+ msg_params[am::strings::grammar_id] = 12;
+ msg_params[am::strings::app_id] = kAppId;
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(DeleteCommandRequestTest,
+ OnEvent_VrHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr command_msg = CreateFullParamsVRSO();
+ (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg));
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
+
+ MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*test_msg)[am::strings::vr_commands] = 0;
+ (*test_msg)[am::strings::menu_params] = 0;
+
+ ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(*mock_app_, FindCommand(kCommandId))
+ .WillByDefault(Return(test_msg.get()));
+ ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey));
+
+ MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand);
+ event_ui.set_smart_object(*msg);
+
+ command->Run();
+ command->on_event(event_ui);
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*event_msg)[am::strings::msg_params][am::strings::info] =
+ "VR is not supported by system";
+ Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand);
+ event_vr.set_smart_object(*event_msg);
+
+ EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId));
+
+ EXPECT_CALL(*mock_app_, UpdateHash());
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ command->on_event(event_vr);
+
+ ResultCommandExpectations(vr_command_result, "VR is not supported by system");
+}
+
+TEST_F(DeleteCommandRequestTest,
+ OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr command_msg = CreateFullParamsUISO();
+ (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg));
+
+ MockAppPtr app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*test_msg)[am::strings::vr_commands] = 0;
+ (*test_msg)[am::strings::menu_params] = 0;
+
+ ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get()));
+ ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
+
+ MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand);
+ event_vr.set_smart_object(*msg);
+
+ command->Run();
+ command->on_event(event_vr);
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*event_msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+ Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand);
+ event_ui.set_smart_object(*event_msg);
+
+ EXPECT_CALL(*app, RemoveCommand(kCommandId));
+
+ EXPECT_CALL(*app, UpdateHash());
+
+ MessageSharedPtr result_msg(
+ CatchMobileCommandResult(CallOnEvent(*command, event_ui)));
+
+ ASSERT_TRUE(result_msg);
+
+ ResultCommandExpectations(result_msg, "UI is not supported by system");
+}
+
+} // namespace delete_command_request
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
new file mode 100644
index 0000000000..36c4614343
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "application_manager/commands/mobile/delete_sub_menu_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::DeleteSubMenuRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockHmiInterfaces;
+using am::MockMessageHelper;
+
+typedef SharedPtr<DeleteSubMenuRequest> AddSubMenuPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class DeleteSubMenuRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ DeleteSubMenuRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+ sync_primitives::Lock lock_;
+};
+
+TEST_F(DeleteSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ (*msg)[am::strings::msg_params][am::strings::menu_id] = 10u;
+
+ utils::SharedPtr<DeleteSubMenuRequest> command =
+ CreateCommand<DeleteSubMenuRequest>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ EXPECT_CALL(*mock_app, RemoveSubMenu(_));
+
+ MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*ev_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*ev_msg)[am::strings::msg_params][am::strings::info] = "info";
+
+ Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
+ event.set_smart_object(*ev_msg);
+
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ am::CommandsMap commands_map;
+ smart_objects::SmartObject commands_msg(smart_objects::SmartType_Map);
+ commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &commands_msg));
+ DataAccessor<am::CommandsMap> accessor(commands_map, lock_);
+ EXPECT_CALL(*mock_app, commands_map())
+ .WillOnce(Return(accessor))
+ .WillOnce(Return(accessor));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc
new file mode 100644
index 0000000000..ff8098b228
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/commands/mobile/diagnostic_message_request.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::DiagnosticMessageRequest;
+using am::event_engine::Event;
+namespace mobile_result = mobile_apis::Result;
+
+typedef SharedPtr<DiagnosticMessageRequest> DiagnosticMessageRequestPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+const uint32_t kDiagnosticMode = 5u;
+} // namespace
+
+class DiagnosticMessageRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DiagnosticMessageRequestPtr command(
+ CreateCommand<DiagnosticMessageRequest>(command_msg));
+
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(DiagnosticMessageRequestTest, Run_NotSupportedDiagnosticMode_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::message_data][0] =
+ kDiagnosticMode;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DiagnosticMessageRequestPtr command(
+ CreateCommand<DiagnosticMessageRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ const std::vector<uint32_t> empty_supported_diag_modes;
+ EXPECT_CALL(app_mngr_settings_, supported_diag_modes())
+ .WillOnce(ReturnRef(empty_supported_diag_modes));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::REJECTED), _));
+
+ command->Run();
+}
+
+TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::message_data][0] =
+ kDiagnosticMode;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DiagnosticMessageRequestPtr command(
+ CreateCommand<DiagnosticMessageRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ std::vector<uint32_t> supported_diag_modes;
+ supported_diag_modes.push_back(kDiagnosticMode);
+
+ EXPECT_CALL(app_mngr_settings_, supported_diag_modes())
+ .WillOnce(ReturnRef(supported_diag_modes));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage)));
+
+ command->Run();
+}
+
+TEST_F(DiagnosticMessageRequestTest, OnEvent_UNSUCCESS) {
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ DiagnosticMessageRequestPtr command(
+ CreateCommand<DiagnosticMessageRequest>());
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->on_event(event);
+}
+
+TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) {
+ Event event(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage);
+
+ MessageSharedPtr event_message(CreateMessage(smart_objects::SmartType_Map));
+ (*event_message)[am::strings::msg_params] = 0;
+ (*event_message)[am::strings::params][am::hmi_response::code] =
+ mobile_result::SUCCESS;
+ event.set_smart_object(*event_message);
+
+ DiagnosticMessageRequestPtr command(
+ CreateCommand<DiagnosticMessageRequest>());
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ command->on_event(event);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
new file mode 100644
index 0000000000..6f51b4f421
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/commands/mobile/dial_number_request.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::DialNumberRequest;
+using am::event_engine::Event;
+namespace mobile_result = mobile_apis::Result;
+
+typedef SharedPtr<DialNumberRequest> DialNumberRequestPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class DialNumberRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(DialNumberRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>());
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(DialNumberRequestTest, Run_InvalidNumber_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::number] = "\t\n";
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command->Run();
+}
+
+TEST_F(DialNumberRequestTest, Run_EmptyNumber_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::number] = "NotANumber";
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command->Run();
+}
+
+TEST_F(DialNumberRequestTest, Run_SUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::number] = "123";
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::BasicCommunication_DialNumber)));
+
+ command->Run();
+}
+
+TEST_F(DialNumberRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->on_event(event);
+}
+
+TEST_F(DialNumberRequestTest, OnEvent_SUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_apis::Result::SUCCESS;
+ (*event_msg)[am::strings::params][am::strings::info] = "test_info";
+
+ Event event(hmi_apis::FunctionID::BasicCommunication_DialNumber);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+
+ command->on_event(event);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
new file mode 100644
index 0000000000..79a09c004e
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <vector>
+
+#include "application_manager/commands/mobile/end_audio_pass_thru_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::MessageSharedPtr;
+using am::commands::EndAudioPassThruRequest;
+using am::event_engine::Event;
+using am::MockHmiInterfaces;
+using am::MockMessageHelper;
+
+typedef SharedPtr<EndAudioPassThruRequest> EndAudioPassThruRequestPtr;
+
+class EndAudioPassThruRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ EndAudioPassThruRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+};
+
+TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
+ const uint32_t kConnectionKey = 2u;
+
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ EndAudioPassThruRequestPtr command(
+ CreateCommand<EndAudioPassThruRequest>(command_msg));
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::msg_params] = 0;
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_apis::Result::UNSUPPORTED_RESOURCE;
+
+ Event event(hmi_apis::FunctionID::UI_EndAudioPassThru);
+ event.set_smart_object(*event_msg);
+
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ ON_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
index 0a5ff9745b..4552b1f033 100644
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
@@ -30,18 +30,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdint.h>
+#include <string>
+#include <vector>
+
#include "gtest/gtest.h"
#include "utils/shared_ptr.h"
#include "smart_objects/smart_object.h"
-#include "commands/commands_test.h"
-#include "commands/command_request_test.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
#include "application_manager/application.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_application.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "mobile/unsubscribe_way_points_request.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/commands/mobile/get_dtcs_request.h"
#include "interfaces/MOBILE_API.h"
-#include "application_manager/smart_object_keys.h"
namespace test {
namespace components {
@@ -50,45 +54,74 @@ namespace mobile_commands_test {
using ::testing::_;
using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::DoAll;
-using ::testing::SaveArg;
-using ::testing::InSequence;
namespace am = ::application_manager;
-using am::commands::UnSubscribeWayPointsRequest;
using am::commands::MessageSharedPtr;
+using am::commands::GetDTCsRequest;
+using am::event_engine::Event;
+namespace mobile_result = mobile_apis::Result;
+
+typedef SharedPtr<GetDTCsRequest> GetDTCsRequestPtr;
+
+class GetDTCsRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
-typedef SharedPtr<UnSubscribeWayPointsRequest> CommandPtr;
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
-class UnsubscribeWayPointsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- typedef TypeIf<kMocksIsNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
-};
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(GetDTCsRequestTest, Run_SUCCESS) {
+ const uint32_t kConnectionKey = 2u;
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::dtc_mask] = 0;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>(command_msg));
-TEST_F(UnsubscribeWayPointsRequestTest, OnEvent_SUCCESS) {
- CommandPtr command(CreateCommand<UnSubscribeWayPointsRequest>());
MockAppPtr app(CreateMockApp());
- Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints);
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_GetDTCs)));
+
+ command->Run();
+}
+
+TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
+ GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
+
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->on_event(event);
+}
+
+TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) {
+ GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::msg_params] = 0;
(*event_msg)[am::strings::params][am::hmi_response::code] =
mobile_apis::Result::SUCCESS;
- (*event_msg)[am::strings::msg_params] = 0;
+ Event event(hmi_apis::FunctionID::VehicleInfo_GetDTCs);
event.set_smart_object(*event_msg);
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- {
- InSequence dummy;
- EXPECT_CALL(app_mngr_, UnsubscribeAppFromWayPoints(_));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*app, UpdateHash());
- }
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
command->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..93fbaa54ca
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/commands/mobile/get_vehicle_data_request.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::GetVehicleDataRequest;
+using am::event_engine::Event;
+namespace mobile_result = mobile_apis::Result;
+
+typedef SharedPtr<GetVehicleDataRequest> GetVehicleDataRequestPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class GetVehicleDataRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest {
+ public:
+ UnwrappedGetVehicleDataRequest(const MessageSharedPtr& message,
+ am::ApplicationManager& application_manager)
+ : GetVehicleDataRequest(message, application_manager) {}
+
+ std::vector<std::string>& get_disallowed_params() {
+ return removed_parameters_permissions_.disallowed_params;
+ }
+
+ using GetVehicleDataRequest::on_event;
+};
+
+#ifdef HMI_DBUS_API
+// HMI_DBUS_API currently not supported
+#else
+
+TEST_F(GetVehicleDataRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ GetVehicleDataRequestPtr command(CreateCommand<GetVehicleDataRequest>());
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(GetVehicleDataRequestTest, Run_TooHighFrequency_UNSUCCESS) {
+ const mobile_apis::FunctionID::eType kFunctionId =
+ mobile_apis::FunctionID::GetVehicleDataID;
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::function_id] = kFunctionId;
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ GetVehicleDataRequestPtr command(
+ CreateCommand<GetVehicleDataRequest>(command_msg));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(
+ *app,
+ AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::CONFIG_FILE))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::REJECTED), _));
+
+ command->Run();
+}
+
+TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ GetVehicleDataRequestPtr command(
+ CreateCommand<GetVehicleDataRequest>(command_msg));
+
+ const am::VehicleData kEmptyVehicleData;
+ EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data())
+ .WillOnce(ReturnRef(kEmptyVehicleData));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command->Run();
+}
+
+TEST_F(GetVehicleDataRequestTest,
+ Run_EmptyMsgParamsAndHasDisallowedParams_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ SharedPtr<UnwrappedGetVehicleDataRequest> command(
+ CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+
+ const am::VehicleData kEmptyVehicleData;
+ EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data())
+ .WillRepeatedly(ReturnRef(kEmptyVehicleData));
+
+ std::vector<std::string>& disallowed_params =
+ command->get_disallowed_params();
+ disallowed_params.push_back("test_param");
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::DISALLOWED), _));
+
+ command->Run();
+}
+
+TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) {
+ const std::string kMsgParamKey("test_key");
+
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+
+ GetVehicleDataRequestPtr command(
+ CreateCommand<GetVehicleDataRequest>(command_msg));
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(
+ am::VehicleData::value_type(kMsgParamKey, am::VehicleDataType::SPEED));
+ EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleData)));
+
+ command->Run();
+}
+
+TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ SharedPtr<UnwrappedGetVehicleDataRequest> command(
+ CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->on_event(event);
+}
+
+TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ SharedPtr<UnwrappedGetVehicleDataRequest> command(
+ CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_result::VEHICLE_DATA_NOT_AVAILABLE;
+ (*event_msg)[am::strings::params][am::strings::error_msg] = "test_error";
+ (*event_msg)[am::strings::msg_params][am::hmi_response::method] = 0;
+
+ Event event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::VEHICLE_DATA_NOT_AVAILABLE), _));
+
+ command->on_event(event);
+}
+
+#endif // HMI_DBUS_API
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
new file mode 100644
index 0000000000..9b33bc0ade
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/commands/mobile/list_files_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/smart_object_keys.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::DoAll;
+using ::testing::SaveArg;
+namespace am = ::application_manager;
+using am::commands::ListFilesRequest;
+using am::commands::MessageSharedPtr;
+
+class ListFilesRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(ListFilesRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
+
+ ON_CALL(app_mngr_, application(_))
+ .WillByDefault(Return(SharedPtr<am::Application>()));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ListFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) {
+ MockAppPtr app(CreateMockApp());
+ SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, hmi_level())
+ .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ const uint32_t kListFilesInNoneAllowed = 1u;
+ const uint32_t kListFilesInNoneCount = 2u;
+
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, list_files_in_none())
+ .WillByDefault(ReturnRef(kListFilesInNoneAllowed));
+ ON_CALL(*app, list_files_in_none_count())
+ .WillByDefault(Return(kListFilesInNoneCount));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::REJECTED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ListFilesRequestTest, Run_SUCCESS) {
+ MockAppPtr app(CreateMockApp());
+ SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, hmi_level())
+ .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ ON_CALL(*app, increment_list_files_in_none_count()).WillByDefault(Return());
+
+ ON_CALL(*app, GetAvailableDiskSpace()).WillByDefault(Return(0));
+
+ am::AppFilesMap files_map;
+ ON_CALL(*app, getAppFiles()).WillByDefault(ReturnRef(files_map));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::SUCCESS,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
new file mode 100644
index 0000000000..c2da619941
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+
+#include "application_manager/include/application_manager/commands/command_impl.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/commands/mobile/on_button_event_notification.h"
+#include "application_manager/commands/mobile/on_button_press_notification.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace commands = am::commands;
+
+using ::testing::_;
+using ::testing::Types;
+using ::testing::Return;
+
+using ::utils::SharedPtr;
+using am::commands::MessageSharedPtr;
+
+namespace {
+const uint32_t kAppId = 5u;
+const uint32_t kCustomButtonId = 3u;
+const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK;
+} // namespace
+
+template <class NotificationT,
+ mobile_apis::FunctionID::eType kExpectedFunctionId>
+struct NotificationData {
+ typedef NotificationT Notification;
+ enum { kFunctionId = kExpectedFunctionId };
+};
+
+template <class NotificationDataT>
+class OnButtonNotificationCommandsTest
+ : public CommandsTest<CommandsTestMocks::kIsNice>,
+ public NotificationDataT {};
+
+typedef Types<NotificationData<commands::mobile::OnButtonEventNotification,
+ mobile_apis::FunctionID::OnButtonEventID>,
+ NotificationData<commands::mobile::OnButtonPressNotification,
+ mobile_apis::FunctionID::OnButtonPressID>>
+ OnButtonNotificationCommandsList;
+
+MATCHER_P(CheckNotificationMessage, function_id, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ const bool kIsFunctionIdCorrect =
+ (*arg)[am::strings::params][am::strings::function_id].asInt() ==
+ function_id;
+
+ bool is_custom_button_id_correct = true;
+ if ((*arg)[am::strings::msg_params].keyExists(
+ am::hmi_response::custom_button_id)) {
+ is_custom_button_id_correct =
+ (*arg)[am::strings::msg_params][am::strings::custom_button_id] ==
+ kCustomButtonId;
+ }
+
+ return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect &&
+ kIsNotificationCorrect && kIsFunctionIdCorrect &&
+ is_custom_button_id_correct;
+}
+
+TYPED_TEST_CASE(OnButtonNotificationCommandsTest,
+ OnButtonNotificationCommandsList);
+
+TYPED_TEST(OnButtonNotificationCommandsTest,
+ Run_CustomButton_NoAppId_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ mobile_apis::ButtonName::CUSTOM_BUTTON;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest,
+ Run_CustomButton_NoCustomButtonId_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ mobile_apis::ButtonName::CUSTOM_BUTTON;
+ (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest,
+ Run_CustomButton_AppNotRegistered_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ mobile_apis::ButtonName::CUSTOM_BUTTON;
+ (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*notification_msg)[am::strings::msg_params]
+ [am::hmi_response::custom_button_id] = kCustomButtonId;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ EXPECT_CALL(this->app_mngr_, application(kAppId))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest,
+ Run_CustomButton_AppNotSubscribedToCustomButtonId_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ mobile_apis::ButtonName::CUSTOM_BUTTON;
+ (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*notification_msg)[am::strings::msg_params]
+ [am::hmi_response::custom_button_id] = kCustomButtonId;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId))
+ .WillOnce(Return(false));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ mobile_apis::ButtonName::CUSTOM_BUTTON;
+ (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*notification_msg)[am::strings::msg_params]
+ [am::hmi_response::custom_button_id] = kCustomButtonId;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(this->app_mngr_,
+ SendMessageToMobile(
+ CheckNotificationMessage(TestFixture::kFunctionId), _));
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest, Run_NoSubscribedApps_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ kButtonName;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ const std::vector<ApplicationSharedPtr> empty_subscribed_apps_list;
+ EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
+ .WillOnce(Return(empty_subscribed_apps_list));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest, Run_InvalidHmiLevel_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ kButtonName;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ std::vector<ApplicationSharedPtr> subscribed_apps_list;
+ subscribed_apps_list.push_back(mock_app);
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
+ .WillOnce(Return(subscribed_apps_list));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest,
+ Run_ButtonOkOnlyForHmiLevelFull_UNSUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ kButtonName;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ std::vector<ApplicationSharedPtr> subscribed_apps_list;
+ subscribed_apps_list.push_back(mock_app);
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED));
+
+ EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
+ .WillOnce(Return(subscribed_apps_list));
+
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command->Run();
+}
+
+TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) {
+ typedef typename TestFixture::Notification Notification;
+
+ MessageSharedPtr notification_msg(
+ this->CreateMessage(smart_objects::SmartType_Map));
+
+ (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
+ kButtonName;
+
+ SharedPtr<Notification> command(
+ this->template CreateCommand<Notification>(notification_msg));
+
+ typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
+ std::vector<ApplicationSharedPtr> subscribed_apps_list;
+ subscribed_apps_list.push_back(mock_app);
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
+ .WillOnce(Return(subscribed_apps_list));
+
+ EXPECT_CALL(this->app_mngr_,
+ SendMessageToMobile(
+ CheckNotificationMessage(TestFixture::kFunctionId), _));
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_command_notification_test.cc
new file mode 100644
index 0000000000..b4eb684bb8
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_command_notification_test.cc
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/commands/mobile/on_command_notification.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Return;
+
+using am::commands::MessageSharedPtr;
+using am::commands::OnCommandNotification;
+
+typedef ::utils::SharedPtr<OnCommandNotification> CommandPtr;
+
+namespace {
+const uint32_t kAppId = 1u;
+const uint32_t kCommandId = 5u;
+} // namespace
+
+class OnCommandNotificationTest
+ : public CommandsTest<CommandsTestMocks::kNotNice> {};
+
+TEST_F(OnCommandNotificationTest, Run_AppNotRegistered_UNSUCCESS) {
+ CommandPtr command(CreateCommand<OnCommandNotification>());
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->Run();
+}
+
+TEST_F(OnCommandNotificationTest, Run_NoAppsForTheCommand_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+
+ CommandPtr command(CreateCommand<OnCommandNotification>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, FindCommand(kCommandId))
+ .WillOnce(Return(static_cast<SmartObject*>(NULL)));
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command->Run();
+}
+
+MATCHER(CheckNotificationMessage, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ am::commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ am::commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect &&
+ kIsNotificationCorrect;
+}
+
+TEST_F(OnCommandNotificationTest, Run_SUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+
+ CommandPtr command(CreateCommand<OnCommandNotification>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ MessageSharedPtr dummy_msg(CreateMessage());
+ EXPECT_CALL(*mock_app, FindCommand(kCommandId))
+ .WillOnce(Return(dummy_msg.get()));
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckNotificationMessage(), _));
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
new file mode 100644
index 0000000000..bc6f507e14
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016, 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 <string>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_hash_change_notification.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace strings = application_manager::strings;
+
+using application_manager::commands::mobile::OnHashChangeNotification;
+using application_manager::MockMessageHelper;
+using application_manager::commands::CommandImpl;
+using testing::Mock;
+using testing::Return;
+using testing::ReturnRef;
+using testing::_;
+
+class OnHashChangeNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnHashChangeNotificationTest()
+ : message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+ MockMessageHelper& message_helper_;
+};
+
+TEST_F(OnHashChangeNotificationTest, Run_ValidApp_SUCCESS) {
+ const uint32_t kConnectionKey = 1u;
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ SharedPtr<OnHashChangeNotification> command =
+ CreateCommand<OnHashChangeNotification>(msg);
+
+ std::string return_string = "1234";
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, curHash()).WillOnce(ReturnRef(return_string));
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ ASSERT_EQ(CommandImpl::mobile_protocol_type_,
+ (*msg)[strings::params][strings::protocol_type].asInt());
+ ASSERT_EQ(CommandImpl::protocol_version_,
+ (*msg)[strings::params][strings::protocol_version].asInt());
+ ASSERT_EQ(return_string,
+ (*msg)[strings::msg_params][strings::hash_id].asString());
+}
+
+TEST_F(OnHashChangeNotificationTest, Run_InvalidApp_NoNotification) {
+ const uint32_t kConnectionKey = 1u;
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+
+ SharedPtr<OnHashChangeNotification> command =
+ CreateCommand<OnHashChangeNotification>(msg);
+
+ std::string return_string;
+ MockAppPtr mock_app = CreateMockApp();
+
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(MockAppPtr()));
+ EXPECT_CALL(*mock_app, curHash()).Times(0);
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).Times(0);
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
new file mode 100644
index 0000000000..bb92c19214
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_hmi_status_notification_from_mobile.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include <application_manager/smart_object_keys.h>
+#include "application_manager/message.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/mock_message_helper.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+const connection_handler::DeviceHandle kHandle = 2u;
+} // namespace
+
+namespace strings = application_manager::strings;
+
+using application_manager::commands::OnHMIStatusNotificationFromMobile;
+using application_manager::ProtocolVersion;
+using application_manager::ApplicationSet;
+using testing::Mock;
+using testing::Return;
+using testing::_;
+
+class OnHMIStatusNotificationFromMobileTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ MessageSharedPtr CreateMsgParams(
+ const mobile_apis::HMILevel::eType kHMIState) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::hmi_level] = kHMIState;
+ return msg;
+ }
+ ApplicationSet app_set_;
+ sync_primitives::Lock lock_;
+};
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_CurrentStateForeground_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(true));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
+
+ DataAccessor<ApplicationSet> accessor(app_set_, lock_);
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillRepeatedly(Return(ProtocolVersion::kV4));
+ EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest, Run_InvalidApp_NoNotification) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(MockAppPtr()));
+ EXPECT_CALL(*mock_app, set_foreground(true)).Times(0);
+
+ EXPECT_CALL(*mock_app, device()).Times(0);
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).Times(0);
+
+ EXPECT_CALL(app_mngr_, applications()).Times(0);
+
+ EXPECT_CALL(*mock_app, protocol_version()).Times(0);
+ EXPECT_CALL(*mock_app, is_foreground()).Times(0);
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_CurrentStateNotForeground_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(false));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
+
+ DataAccessor<ApplicationSet> accessor(app_set_, lock_);
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillRepeatedly(Return(ProtocolVersion::kV4));
+ EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_ProtocolVersionKV3_NoNotification) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(false));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
+
+ DataAccessor<ApplicationSet> accessor(app_set_, lock_);
+ EXPECT_CALL(app_mngr_, applications()).Times(0);
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillOnce(Return(ProtocolVersion::kV3));
+ EXPECT_CALL(*mock_app, is_foreground()).Times(0);
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_AppNotRequestedBeforeAndKV3_NoNotification) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(true));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false));
+
+ EXPECT_CALL(app_mngr_, applications()).Times(0);
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillOnce(Return(ProtocolVersion::kV3));
+ EXPECT_CALL(*mock_app, is_foreground()).Times(0);
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_AppNotRequestedBefore_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(true));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false));
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillOnce(Return(ProtocolVersion::kV4));
+
+ EXPECT_CALL(app_mngr_, applications()).Times(0);
+
+ EXPECT_CALL(*mock_app, is_foreground()).WillOnce(Return(true));
+
+ application_manager::MockMessageHelper& mock_message_helper =
+ *application_manager::MockMessageHelper::message_helper_mock();
+ Mock::VerifyAndClearExpectations(&mock_message_helper);
+ EXPECT_CALL(mock_message_helper, SendQueryApps(kConnectionKey, _));
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ Mock::VerifyAndClearExpectations(&mock_message_helper);
+}
+
+TEST_F(OnHMIStatusNotificationFromMobileTest,
+ Run_AnotherForegroundSDLApp_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotificationFromMobile> command =
+ CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, set_foreground(true));
+
+ EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
+ EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
+
+ DataAccessor<ApplicationSet> accessor(app_set_, lock_);
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+
+ EXPECT_CALL(*mock_app, protocol_version())
+ .WillRepeatedly(Return(ProtocolVersion::kV4));
+ EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(false));
+
+ EXPECT_CALL(app_mngr_, MarkAppsGreyOut(kHandle, false));
+ EXPECT_CALL(app_mngr_, SendUpdateAppList());
+
+ command->Run();
+
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
new file mode 100644
index 0000000000..016bb2bb1d
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_hmi_status_notification.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/commands/command_impl.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+} // namespace
+
+namespace strings = application_manager::strings;
+
+using application_manager::commands::OnHMIStatusNotification;
+using application_manager::ProtocolVersion;
+using application_manager::MockMessageHelper;
+using application_manager::commands::CommandImpl;
+using testing::Mock;
+using testing::Return;
+using testing::_;
+
+class OnHMIStatusNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnHMIStatusNotificationTest()
+ : message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ MessageSharedPtr CreateMsgParams(
+ const mobile_apis::HMILevel::eType kHMIState) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::hmi_level] = kHMIState;
+ return msg;
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+
+ void SetSendNotificationExpectations(MessageSharedPtr& msg) {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ }
+
+ void VerifySendNotificationData(MessageSharedPtr& msg) {
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ ASSERT_EQ(CommandImpl::mobile_protocol_type_,
+ (*msg)[strings::params][strings::protocol_type].asInt());
+ ASSERT_EQ(CommandImpl::protocol_version_,
+ (*msg)[strings::params][strings::protocol_version].asInt());
+ }
+
+ MockMessageHelper& message_helper_;
+};
+
+TEST_F(OnHMIStatusNotificationTest, Run_InvalidApp_NoNotification) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(MockAppPtr()));
+
+ EXPECT_CALL(*mock_app, tts_properties_in_full()).Times(0);
+ EXPECT_CALL(*mock_app, set_tts_properties_in_full(_)).Times(0);
+ EXPECT_CALL(*mock_app, app_id()).Times(0);
+ EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey))
+ .Times(0);
+
+ command->Run();
+}
+
+TEST_F(OnHMIStatusNotificationTest, Run_InvalidEnum_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::INVALID_ENUM);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ VerifySendNotificationData(msg);
+}
+
+TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndFalseProperties_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
+ SetSendNotificationExpectations(msg);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(false));
+ EXPECT_CALL(*mock_app, set_tts_properties_in_none(true));
+ EXPECT_CALL(message_helper_, SendTTSGlobalProperties(_, false, _));
+
+ command->Run();
+
+ VerifySendNotificationData(msg);
+}
+
+TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndTrueProperties_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(true));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ VerifySendNotificationData(msg);
+}
+
+TEST_F(OnHMIStatusNotificationTest, Run_FullAndFalseProperties_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(false));
+ EXPECT_CALL(*mock_app, set_tts_properties_in_full(true));
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ VerifySendNotificationData(msg);
+}
+
+TEST_F(OnHMIStatusNotificationTest, Run_FullAndTrueProperties_SUCCESS) {
+ MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
+
+ SharedPtr<OnHMIStatusNotification> command =
+ CreateCommand<OnHMIStatusNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(true));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ VerifySendNotificationData(msg);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
new file mode 100644
index 0000000000..2eeadce078
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_keyboard_input_notification.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include <application_manager/smart_object_keys.h>
+#include "application_manager/message.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/commands/command_impl.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace strings = application_manager::strings;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+} // namespace
+
+using application_manager::commands::mobile::OnKeyBoardInputNotification;
+using application_manager::MockMessageHelper;
+using application_manager::commands::CommandImpl;
+using application_manager::ApplicationSet;
+using testing::Mock;
+using testing::Return;
+using testing::_;
+
+class OnKeyBoardInputNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnKeyBoardInputNotificationTest()
+ : message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ void SetSendNotificationExpectations(MessageSharedPtr msg) {
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ }
+
+ void SetSendNotificationVariables(MessageSharedPtr msg) {
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ ASSERT_EQ(CommandImpl::mobile_protocol_type_,
+ (*msg)[strings::params][strings::protocol_type].asInt());
+ ASSERT_EQ(CommandImpl::protocol_version_,
+ (*msg)[strings::params][strings::protocol_version].asInt());
+ }
+
+ void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+
+ MockAppPtr InitAppSetDataAccessor(SharedPtr<ApplicationSet>& app_set) {
+ app_set = (!app_set ? ::utils::MakeShared<ApplicationSet>() : app_set);
+ MockAppPtr app(CreateMockApp());
+ app_set->insert(app);
+ EXPECT_CALL(app_mngr_, applications())
+ .WillOnce(Return(DataAccessor<ApplicationSet>(*app_set, lock_)));
+ return app;
+ }
+
+ MockMessageHelper& message_helper_;
+ SharedPtr<ApplicationSet> app_set_;
+ sync_primitives::Lock lock_;
+};
+
+TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+
+ SharedPtr<OnKeyBoardInputNotification> command =
+ CreateCommand<OnKeyBoardInputNotification>(msg);
+
+ MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
+ EXPECT_CALL(*mock_app, is_perform_interaction_active()).WillOnce(Return(1));
+ EXPECT_CALL(*mock_app, hmi_level()).Times(0);
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ SetSendNotificationVariables(msg);
+
+ ASSERT_EQ(kConnectionKey,
+ (*msg)[strings::params][strings::connection_key].asInt());
+}
+
+TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+
+ SharedPtr<OnKeyBoardInputNotification> command =
+ CreateCommand<OnKeyBoardInputNotification>(msg);
+
+ MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
+ EXPECT_CALL(*mock_app, is_perform_interaction_active())
+ .WillRepeatedly(Return(0));
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_FULL));
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
+
+ SetSendNotificationExpectations(msg);
+
+ command->Run();
+
+ SetSendNotificationVariables(msg);
+
+ ASSERT_EQ(kConnectionKey,
+ (*msg)[strings::params][strings::connection_key].asInt());
+}
+
+TEST_F(OnKeyBoardInputNotificationTest, Run_InvalidApp_NoNotification) {
+ MessageSharedPtr msg = CreateMessage();
+
+ SharedPtr<OnKeyBoardInputNotification> command =
+ CreateCommand<OnKeyBoardInputNotification>(msg);
+
+ MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
+ EXPECT_CALL(*mock_app, is_perform_interaction_active())
+ .WillRepeatedly(Return(0));
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_BACKGROUND));
+
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).Times(0);
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
new file mode 100644
index 0000000000..2b5efd29cb
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2016, 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 <string>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_system_request_notification.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace strings = application_manager::strings;
+
+using application_manager::commands::mobile::OnSystemRequestNotification;
+using application_manager::commands::CommandImpl;
+using application_manager::MockMessageHelper;
+using test::components::policy_test::MockPolicyHandlerInterface;
+using namespace mobile_apis;
+using testing::Mock;
+using testing::Return;
+using testing::ReturnRef;
+using testing::_;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+} // namespace
+
+class OnSystemRequestNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnSystemRequestNotificationTest()
+ : message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&message_helper_);
+ }
+ MockMessageHelper& message_helper_;
+};
+
+TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) {
+ const RequestType::eType kRequestType = RequestType::PROPRIETARY;
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::request_type] = kRequestType;
+
+ SharedPtr<OnSystemRequestNotification> command =
+ CreateCommand<OnSystemRequestNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ MockPolicyHandlerInterface mock_policy_handler;
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillRepeatedly(ReturnRef(mock_policy_handler));
+ std::string policy_app_id;
+ EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
+ EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
+ .WillOnce(Return(true));
+
+#ifdef EXTENDED_POLICY
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .Times(2)
+ .WillRepeatedly(ReturnRef(mock_policy_handler));
+ EXPECT_CALL(mock_policy_handler, TimeoutExchange()).WillOnce(Return(5u));
+#endif
+
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+
+ command->Run();
+
+ ASSERT_EQ(FileType::JSON,
+ (*msg)[strings::msg_params][strings::file_type].asInt());
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ ASSERT_EQ(CommandImpl::mobile_protocol_type_,
+ (*msg)[strings::params][strings::protocol_type].asInt());
+ ASSERT_EQ(CommandImpl::protocol_version_,
+ (*msg)[strings::params][strings::protocol_version].asInt());
+}
+
+TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) {
+ const RequestType::eType kRequestType = RequestType::HTTP;
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::request_type] = kRequestType;
+
+ SharedPtr<OnSystemRequestNotification> command =
+ CreateCommand<OnSystemRequestNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ MockPolicyHandlerInterface mock_policy_handler;
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler));
+ std::string policy_app_id;
+ EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
+ EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+
+ command->Run();
+
+ ASSERT_EQ(FileType::BINARY,
+ (*msg)[strings::msg_params][strings::file_type].asInt());
+ ASSERT_EQ(application_manager::MessageType::kNotification,
+ (*msg)[strings::params][strings::message_type].asInt());
+ ASSERT_EQ(CommandImpl::mobile_protocol_type_,
+ (*msg)[strings::params][strings::protocol_type].asInt());
+ ASSERT_EQ(CommandImpl::protocol_version_,
+ (*msg)[strings::params][strings::protocol_version].asInt());
+}
+
+TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) {
+ const RequestType::eType kRequestType = RequestType::HTTP;
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::request_type] = kRequestType;
+
+ SharedPtr<OnSystemRequestNotification> command =
+ CreateCommand<OnSystemRequestNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(MockAppPtr()));
+ EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0);
+ EXPECT_CALL(*mock_app, policy_app_id()).Times(0);
+ MockPolicyHandlerInterface mock_policy_handler;
+ EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _)).Times(0);
+
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).Times(0);
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
+
+ command->Run();
+}
+
+TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) {
+ const RequestType::eType kRequestType = RequestType::HTTP;
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg)[strings::msg_params][strings::request_type] = kRequestType;
+
+ SharedPtr<OnSystemRequestNotification> command =
+ CreateCommand<OnSystemRequestNotification>(msg);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ MockPolicyHandlerInterface mock_policy_handler;
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler));
+ std::string policy_app_id;
+ EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
+ EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
+ .WillOnce(Return(false));
+
+ EXPECT_CALL(message_helper_, PrintSmartObject(_)).Times(0);
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
+ ;
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
new file mode 100644
index 0000000000..c32c334c0f
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_tbt_client_state_notification.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "utils/helpers.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Return;
+
+using am::commands::MessageSharedPtr;
+using am::commands::OnTBTClientStateNotification;
+
+typedef ::utils::SharedPtr<OnTBTClientStateNotification> NotificationPtr;
+
+namespace {
+const uint32_t kAppId = 1u;
+} // namespace
+
+class OnTBTClientStateNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnTBTClientStateNotificationTest()
+ : command_(CreateCommand<OnTBTClientStateNotification>()) {}
+
+ NotificationPtr command_;
+};
+
+TEST_F(OnTBTClientStateNotificationTest, Run_HmiLevelNone_UNSUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ std::vector<ApplicationSharedPtr> applications_with_navi;
+ applications_with_navi.push_back(mock_app);
+
+ EXPECT_CALL(app_mngr_, applications_with_navi())
+ .WillOnce(Return(applications_with_navi));
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(*mock_app, app_id()).Times(0);
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command_->Run();
+}
+
+MATCHER(CheckMessageData, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ am::commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ am::commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ const bool kIsConnectionKeyCorrect =
+ (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
+ kAppId;
+
+ using namespace helpers;
+ return Compare<bool, EQ, ALL>(true,
+ kIsMobileProtocolTypeCorrect,
+ kIsProtocolVersionCorrect,
+ kIsNotificationCorrect,
+ kIsConnectionKeyCorrect);
+}
+
+TEST_F(OnTBTClientStateNotificationTest,
+ Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ std::vector<ApplicationSharedPtr> applications_with_navi;
+ applications_with_navi.push_back(mock_app);
+
+ EXPECT_CALL(app_mngr_, applications_with_navi())
+ .WillOnce(Return(applications_with_navi));
+
+ EXPECT_CALL(*mock_app, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
+
+ command_->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
new file mode 100644
index 0000000000..2156aa4c97
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_touch_event_notification.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "utils/helpers.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Return;
+
+using am::commands::MessageSharedPtr;
+using am::commands::mobile::OnTouchEventNotification;
+
+typedef ::utils::SharedPtr<OnTouchEventNotification> NotificationPtr;
+
+namespace {
+const uint32_t kAppId = 1u;
+} // namespace
+
+class OnTouchEventNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnTouchEventNotificationTest()
+ : command_(CreateCommand<OnTouchEventNotification>()) {}
+
+ NotificationPtr command_;
+};
+
+TEST_F(OnTouchEventNotificationTest, Run_AppIsNotFullscreen_UNSUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ std::vector<ApplicationSharedPtr> applications_with_navi;
+ applications_with_navi.push_back(mock_app);
+
+ EXPECT_CALL(app_mngr_, applications_with_navi())
+ .WillOnce(Return(applications_with_navi));
+
+ EXPECT_CALL(*mock_app, IsFullscreen()).WillOnce(Return(false));
+
+ EXPECT_CALL(*mock_app, app_id()).Times(0);
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0);
+
+ command_->Run();
+}
+
+MATCHER(CheckMessageData, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ am::commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ am::commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ const bool kIsConnectionKeyCorrect =
+ (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
+ kAppId;
+
+ using namespace helpers;
+ return Compare<bool, EQ, ALL>(true,
+ kIsMobileProtocolTypeCorrect,
+ kIsProtocolVersionCorrect,
+ kIsNotificationCorrect,
+ kIsConnectionKeyCorrect);
+}
+
+TEST_F(OnTouchEventNotificationTest, Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ std::vector<ApplicationSharedPtr> applications_with_navi;
+ applications_with_navi.push_back(mock_app);
+
+ EXPECT_CALL(app_mngr_, applications_with_navi())
+ .WillOnce(Return(applications_with_navi));
+
+ EXPECT_CALL(*mock_app, IsFullscreen()).WillOnce(Return(true));
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
+
+ command_->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
new file mode 100644
index 0000000000..c71c40d8c2
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <vector>
+#include <map>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_vehicle_data_notification.h"
+#include "utils/shared_ptr.h"
+#include "utils/custom_string.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/mock_message_helper.h"
+#include "utils/helpers.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using am::commands::MessageSharedPtr;
+using am::commands::OnVehicleDataNotification;
+
+typedef ::utils::SharedPtr<OnVehicleDataNotification> NotificationPtr;
+
+namespace {
+const uint32_t kAppId = 1u;
+} // namespace
+
+class OnVehicleDataNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnVehicleDataNotificationTest()
+ : mock_message_helper_(*am::MockMessageHelper::message_helper_mock())
+ , command_msg_(CreateMessage(smart_objects::SmartType_Map))
+ , command_(CreateCommand<OnVehicleDataNotification>(command_msg_)) {}
+
+ am::MockMessageHelper& mock_message_helper_;
+ MessageSharedPtr command_msg_;
+ NotificationPtr command_;
+};
+
+MATCHER_P2(CheckMessageData, key, value, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ am::commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ am::commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ const bool kIsConnectionKeyCorrect =
+ (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
+ kAppId;
+
+ const bool kAreMsgParamsCorrect =
+ (*arg)[am::strings::msg_params][key].asInt() == value;
+
+ using namespace helpers;
+ return Compare<bool, EQ, ALL>(true,
+ kIsMobileProtocolTypeCorrect,
+ kIsProtocolVersionCorrect,
+ kIsNotificationCorrect,
+ kIsConnectionKeyCorrect,
+ kAreMsgParamsCorrect);
+}
+
+TEST_F(OnVehicleDataNotificationTest,
+ Run_NotEmptyListOfAppsSubscribedForEvent_SUCCESS) {
+ am::VehicleData test_vehicle_data;
+ test_vehicle_data.insert(am::VehicleData::value_type(
+ am::strings::fuel_level, am::VehicleDataType::FUELLEVEL));
+
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
+ .WillOnce(ReturnRef(test_vehicle_data));
+
+ const int kFuelLevel = 100;
+ (*command_msg_)[am::strings::msg_params][am::strings::fuel_level] =
+ kFuelLevel;
+
+ MockAppPtr mock_app(CreateMockApp());
+ std::vector<ApplicationSharedPtr> applications;
+ applications.push_back(mock_app);
+
+ EXPECT_CALL(app_mngr_,
+ IviInfoUpdated(am::VehicleDataType::FUELLEVEL, kFuelLevel))
+ .WillOnce(Return(applications));
+
+ EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
+ ::utils::custom_string::CustomString dummy_name("test_app");
+ ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(dummy_name));
+
+ EXPECT_CALL(app_mngr_,
+ SendMessageToMobile(
+ CheckMessageData(am::strings::fuel_level, kFuelLevel), _));
+
+ command_->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
new file mode 100644
index 0000000000..aaa6c8f171
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <set>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/on_way_point_change_notification.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "utils/helpers.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Return;
+
+using am::commands::MessageSharedPtr;
+using am::commands::OnWayPointChangeNotification;
+
+typedef ::utils::SharedPtr<OnWayPointChangeNotification> NotificationPtr;
+
+namespace {
+const uint32_t kAppId = 1u;
+} // namespace
+
+class OnWayPointChangeNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ OnWayPointChangeNotificationTest()
+ : command_(CreateCommand<OnWayPointChangeNotification>()) {}
+
+ NotificationPtr command_;
+};
+
+MATCHER(CheckMessageData, "") {
+ const bool kIsMobileProtocolTypeCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ am::commands::CommandImpl::mobile_protocol_type_;
+
+ const bool kIsProtocolVersionCorrect =
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ am::commands::CommandImpl::protocol_version_;
+
+ const bool kIsNotificationCorrect =
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ am::MessageType::kNotification;
+
+ const bool kIsConnectionKeyCorrect =
+ (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
+ kAppId;
+
+ using namespace helpers;
+ return Compare<bool, EQ, ALL>(true,
+ kIsMobileProtocolTypeCorrect,
+ kIsProtocolVersionCorrect,
+ kIsNotificationCorrect,
+ kIsConnectionKeyCorrect);
+}
+
+TEST_F(OnWayPointChangeNotificationTest,
+ Run_NotEmptyListOfAppsSubscribedForWayPoints_SUCCESS) {
+ std::set<int32_t> apps_subscribed_for_way_points;
+ apps_subscribed_for_way_points.insert(kAppId);
+
+ EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
+ .WillOnce(Return(apps_subscribed_for_way_points));
+
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
+
+ command_->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
new file mode 100644
index 0000000000..b6a76d51cc
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/perform_audio_pass_thru_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace perform_audio_pass_thru_request {
+
+namespace am = application_manager;
+using am::commands::PerformAudioPassThruRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class PerformAudioPassThruRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ PerformAudioPassThruRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) {
+ MessageSharedPtr msg_ui = CreateMessage(smart_objects::SmartType_Map);
+ (*msg_ui)[am::strings::msg_params][am::strings::result_code] =
+ am::mobile_api::Result::GENERIC_ERROR;
+ (*msg_ui)[am::strings::msg_params][am::strings::success] = false;
+
+ utils::SharedPtr<PerformAudioPassThruRequest> command =
+ CreateCommand<PerformAudioPassThruRequest>();
+
+ EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
+
+ EXPECT_CALL(
+ mock_message_helper_,
+ CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
+ .WillOnce(Return(msg_ui));
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ command->onTimeOut();
+ EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ false);
+ EXPECT_EQ(
+ (*vr_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+TEST_F(PerformAudioPassThruRequestTest,
+ OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_ui = CreateFullParamsUISO();
+ (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<PerformAudioPassThruRequest> command =
+ CreateCommand<PerformAudioPassThruRequest>(msg_ui);
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru);
+ event.set_smart_object(*msg);
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_msg_tts =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_tts)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*response_msg_tts)[am::strings::msg_params][am::strings::cmd_id] = kCmdId;
+ am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
+ event_tts.set_smart_object(*response_msg_tts);
+ command->on_event(event_tts);
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+} // namespace perform_audio_pass_thru_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
new file mode 100644
index 0000000000..d261dee8ec
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/perform_interaction_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "smart_objects/smart_object.h"
+#include "utils/custom_string.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace perform_interaction_request {
+
+namespace am = application_manager;
+using am::commands::CommandImpl;
+using am::ApplicationManager;
+using am::commands::MessageSharedPtr;
+using am::ApplicationSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::testing::_;
+using ::testing::Mock;
+using ::utils::SharedPtr;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::PerformInteractionRequest;
+using ::test::components::application_manager_test::MockApplication;
+
+namespace strings = ::application_manager::strings;
+namespace hmi_response = ::application_manager::hmi_response;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class PerformInteractionRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ PerformInteractionRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(PerformInteractionRequestTest, OnTimeout_VR_GENERIC_ERROR) {
+ MessageSharedPtr response_msg_vr =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_vr)[strings::params][hmi_response::code] =
+ static_cast<uint64_t>(hmi_apis::Common_Result::SUCCESS);
+ (*response_msg_vr)[strings::msg_params][strings::info] = "info";
+ MessageSharedPtr request_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*request_msg)[strings::msg_params][strings::interaction_mode] =
+ mobile_apis::InteractionMode::BOTH;
+ utils::SharedPtr<PerformInteractionRequest> command =
+ CreateCommand<PerformInteractionRequest>(request_msg);
+ MockAppPtr mock_app;
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ Event event(hmi_apis::FunctionID::VR_PerformInteraction);
+ event.set_smart_object(*response_msg_vr);
+
+ command->Init();
+ command->on_event(event);
+ MessageSharedPtr response_to_mobile =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_to_mobile)[strings::msg_params][strings::result_code] =
+ static_cast<uint64_t>(am::mobile_api::Result::GENERIC_ERROR);
+ EXPECT_CALL(
+ mock_message_helper_,
+ CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
+ .WillOnce(Return(response_to_mobile));
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+ command->onTimeOut();
+
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
+}
+
+TEST_F(PerformInteractionRequestTest,
+ OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_from_mobile =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] =
+ mobile_apis::InteractionMode::VR_ONLY;
+ utils::SharedPtr<PerformInteractionRequest> command =
+ CreateCommand<PerformInteractionRequest>(msg_from_mobile);
+ command->Init();
+
+ MockAppPtr mock_app;
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app));
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+
+ MessageSharedPtr response_msg_vr =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_vr)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*response_msg_vr)[strings::msg_params][strings::cmd_id] = kCommandId;
+ (*response_msg_vr)[am::strings::msg_params][am::strings::info] =
+ "VR is not supported by system";
+
+ am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction);
+ event_vr.set_smart_object(*response_msg_vr);
+
+ MessageSharedPtr response_msg_ui =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_ui)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+
+ am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction);
+ event_ui.set_smart_object(*response_msg_ui);
+
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_to_mobile;
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_vr);
+ command->on_event(event_ui);
+
+ ResultCommandExpectations(response_to_mobile,
+ "VR is not supported by system");
+}
+
+TEST_F(PerformInteractionRequestTest,
+ OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_from_mobile =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey;
+ (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] =
+ mobile_apis::InteractionMode::VR_ONLY;
+ utils::SharedPtr<PerformInteractionRequest> command =
+ CreateCommand<PerformInteractionRequest>(msg_from_mobile);
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_msg_vr =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_vr)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction);
+ event_vr.set_smart_object(*response_msg_vr);
+
+ MessageSharedPtr response_msg_ui =
+ CreateMessage(smart_objects::SmartType_Map);
+ (*response_msg_ui)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*response_msg_ui)[strings::msg_params][strings::cmd_id] = kCommandId;
+ (*response_msg_ui)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction);
+ event_ui.set_smart_object(*response_msg_ui);
+
+ MessageSharedPtr response_to_mobile;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_vr);
+
+ EXPECT_CALL(*mock_app_, is_perform_interaction_active())
+ .WillOnce(Return(false));
+ EXPECT_CALL(*mock_app_, DeletePerformInteractionChoiceSet(_));
+
+ command->on_event(event_ui);
+
+ ResultCommandExpectations(response_to_mobile,
+ "UI is not supported by system");
+}
+
+} // namespace perform_interaction_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
new file mode 100644
index 0000000000..9028a470a0
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/commands/mobile/read_did_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+#include "application_manager/smart_object_keys.h"
+#include "event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SaveArg;
+namespace am = ::application_manager;
+using am::commands::ReadDIDRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using ::utils::SharedPtr;
+
+class ReadDIDRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
+ Event event(Event::EventID::INVALID_ENUM);
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+ command->on_event(event);
+}
+
+TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) {
+ Event event(Event::EventID::VehicleInfo_ReadDID);
+
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+
+ const mobile_apis::Result::eType kResultCode = mobile_apis::Result::SUCCESS;
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] = kResultCode;
+ (*event_msg)[am::strings::msg_params] = 0;
+
+ event.set_smart_object(*event_msg);
+
+ MessageSharedPtr result_msg(
+ CatchMobileCommandResult(CallOnEvent(*command, event)));
+ EXPECT_EQ(kResultCode,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+
+ ON_CALL(app_mngr_, application(_))
+ .WillByDefault(Return(SharedPtr<am::Application>()));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) {
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(true));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::REJECTED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ReadDIDRequestTest, Run_EmptyDidLocation_UNSUCCESS) {
+ MockAppPtr app(CreateMockApp());
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(false));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(ReadDIDRequestTest, Run_SUCCESS) {
+ MockAppPtr app(CreateMockApp());
+ MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
+ (*msg)[am::strings::msg_params][am::strings::did_location]["SomeData"] = 0;
+ SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>(msg));
+
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(false));
+
+ MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command)));
+ EXPECT_EQ(hmi_apis::FunctionID::VehicleInfo_ReadDID,
+ static_cast<hmi_apis::FunctionID::eType>(
+ (*result_msg)[am::strings::params][am::strings::function_id]
+ .asInt()));
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
new file mode 100644
index 0000000000..5679d49b63
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "mobile/register_app_interface_request.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "utils/data_accessor.h"
+#include "protocol_handler/mock_session_observer.h"
+#include "connection_handler/mock_connection_handler.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/mock_resume_ctrl.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "utils/custom_string.h"
+#include "utils/lock.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::DoAll;
+
+namespace am = ::application_manager;
+
+using ::utils::SharedPtr;
+using am::commands::MessageSharedPtr;
+using am::commands::RegisterAppInterfaceRequest;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+const hmi_apis::Common_Language::eType kHmiLanguage =
+ hmi_apis::Common_Language::EN_US;
+const mobile_apis::Language::eType kMobileLanguage =
+ mobile_apis::Language::EN_US;
+const std::string kMacAddress = "test_mac_address";
+const std::string kAppId = "test_app_id";
+const std::string kDummyString = "test_string";
+const std::vector<uint32_t> kDummyDiagModes;
+} // namespace
+
+class RegisterAppInterfaceRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ RegisterAppInterfaceRequestTest()
+ : msg_(CreateMessage())
+ , command_(CreateCommand<RegisterAppInterfaceRequest>(msg_))
+ , app_name_("test_app_name_") {
+ InitGetters();
+ InitLanguage();
+ }
+
+ void InitBasicMessage() {
+ (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_;
+ (*msg_)[am::strings::msg_params][am::strings::language_desired] =
+ kHmiLanguage;
+ (*msg_)[am::strings::msg_params]
+ [am::strings::hmi_display_language_desired] = kHmiLanguage;
+ }
+
+ MockAppPtr CreateBasicMockedApp() {
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_));
+ ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress));
+ ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString));
+ ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage));
+ ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage));
+ return mock_app;
+ }
+
+ void InitLanguage(
+ hmi_apis::Common_Language::eType ui_language = kHmiLanguage,
+ hmi_apis::Common_Language::eType vr_language = kHmiLanguage,
+ hmi_apis::Common_Language::eType tts_language = kHmiLanguage) {
+ ON_CALL(mock_hmi_capabilities_, active_vr_language())
+ .WillByDefault(Return(vr_language));
+ ON_CALL(mock_hmi_capabilities_, active_ui_language())
+ .WillByDefault(Return(ui_language));
+ ON_CALL(mock_hmi_capabilities_, active_tts_language())
+ .WillByDefault(Return(tts_language));
+ }
+
+ void InitGetters() {
+ ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true));
+ ON_CALL(app_mngr_, GetPolicyHandler())
+ .WillByDefault(ReturnRef(mock_policy_handler_));
+ ON_CALL(app_mngr_, resume_controller())
+ .WillByDefault(ReturnRef(mock_resume_crt_));
+ ON_CALL(app_mngr_, connection_handler())
+ .WillByDefault(ReturnRef(mock_connection_handler_));
+ ON_CALL(mock_connection_handler_, get_session_observer())
+ .WillByDefault(ReturnRef(mock_session_observer_));
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(mock_hmi_capabilities_));
+ ON_CALL(app_mngr_settings_, sdl_version())
+ .WillByDefault(ReturnRef(kDummyString));
+ ON_CALL(mock_hmi_capabilities_, ccpu_version())
+ .WillByDefault(ReturnRef(kDummyString));
+ ON_CALL(app_mngr_settings_, supported_diag_modes())
+ .WillByDefault(ReturnRef(kDummyDiagModes));
+ ON_CALL(mock_policy_handler_, GetAppRequestTypes(_))
+ .WillByDefault(Return(std::vector<std::string>()));
+ ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_))
+ .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed));
+ ON_CALL(app_mngr_, GetDeviceTransportType(_))
+ .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(
+ mock_hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ ON_CALL(
+ mock_hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ ON_CALL(
+ mock_hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ }
+
+ MessageSharedPtr msg_;
+ SharedPtr<RegisterAppInterfaceRequest> command_;
+
+ const utils::custom_string::CustomString app_name_;
+ sync_primitives::Lock lock_;
+ am::ApplicationSet app_set_;
+
+ typedef IsNiceMock<policy_test::MockPolicyHandlerInterface,
+ kMocksAreNice>::Result MockPolicyHandlerInterface;
+
+ typedef IsNiceMock<resumprion_test::MockResumeCtrl, kMocksAreNice>::Result
+ MockResumeCtrl;
+
+ typedef IsNiceMock<connection_handler_test::MockConnectionHandler,
+ kMocksAreNice>::Result MockConnectionHandler;
+
+ typedef IsNiceMock<protocol_handler_test::MockSessionObserver,
+ kMocksAreNice>::Result MockSessionObserver;
+
+ typedef IsNiceMock<application_manager_test::MockHMICapabilities,
+ kMocksAreNice>::Result MockHMICapabilities;
+
+ typedef IsNiceMock<am::MockHmiInterfaces, kMocksAreNice>::Result
+ MockHmiInterfaces;
+
+ MockPolicyHandlerInterface mock_policy_handler_;
+ MockResumeCtrl mock_resume_crt_;
+ MockConnectionHandler mock_connection_handler_;
+ MockSessionObserver mock_session_observer_;
+ MockHMICapabilities mock_hmi_capabilities_;
+ MockHmiInterfaces mock_hmi_interfaces_;
+};
+
+TEST_F(RegisterAppInterfaceRequestTest, DISABLED_Run_MinimalData_SUCCESS) {
+ InitBasicMessage();
+
+ MockAppPtr mock_app = CreateBasicMockedApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()))
+ .WillRepeatedly(Return(mock_app));
+
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(Return(DataAccessor<am::ApplicationSet>(app_set_, lock_)));
+ ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true));
+ ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _))
+ .WillByDefault(Return(true));
+
+ EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ command_->Run();
+}
+
+MATCHER_P(CheckHMIInterfacesRealtedData, expected_data, "") {
+ const bool is_result_id_correct =
+ mobile_apis::Result::SUCCESS ==
+ static_cast<mobile_apis::Result::eType>(
+ (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
+
+ const bool are_ui_related_data_exist =
+ (*arg)[am::strings::msg_params].keyExists(
+ am::hmi_response::display_capabilities);
+
+ const bool are_vi_related_data_exist =
+ (*arg)[am::strings::msg_params][am::hmi_response::vehicle_type] ==
+ (*expected_data)[am::hmi_response::vehicle_type];
+
+ const bool are_vr_related_data_exist =
+ (*arg)[am::strings::msg_params][am::strings::vr_capabilities] ==
+ (*expected_data)[am::strings::vr_capabilities];
+
+ return is_result_id_correct && are_ui_related_data_exist &&
+ are_vi_related_data_exist && are_vr_related_data_exist;
+}
+
+TEST_F(RegisterAppInterfaceRequestTest,
+ DISABLED_Run_HmiInterfacesStateAvailable_SUCCESS) {
+ InitBasicMessage();
+
+ MockAppPtr mock_app = CreateBasicMockedApp();
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()))
+ .WillRepeatedly(Return(mock_app));
+
+ MessageSharedPtr expected_message =
+ CreateMessage(smart_objects::SmartType_Map);
+
+ (*expected_message)[am::hmi_response::vehicle_type] = "test_vehicle_type";
+ (*expected_message)[am::strings::vr_capabilities] = "test_vr_capabilities";
+ (*expected_message)[am::hmi_response::display_capabilities] = 0;
+ SmartObject& display_capabilities =
+ (*expected_message)[am::hmi_response::display_capabilities];
+ display_capabilities[am::hmi_response::display_type] = "test_display_type";
+ display_capabilities[am::hmi_response::text_fields] = "test_text_fields";
+ display_capabilities[am::hmi_response::image_fields] = "test_image_fields";
+ display_capabilities[am::hmi_response::media_clock_formats] =
+ "test_media_clock_formats";
+ display_capabilities[am::hmi_response::num_custom_presets_available] =
+ "test_num_custom_presets_available";
+ display_capabilities[am::hmi_response::graphic_supported] =
+ "test_graphic_supported";
+ display_capabilities[am::hmi_response::templates_available] =
+ "test_templates_available";
+ display_capabilities[am::hmi_response::screen_params] = "test_screen_params";
+
+ ON_CALL(mock_hmi_capabilities_, vehicle_type())
+ .WillByDefault(
+ Return(&(*expected_message)[am::hmi_response::vehicle_type]));
+ ON_CALL(mock_hmi_capabilities_, vr_capabilities())
+ .WillByDefault(
+ Return(&(*expected_message)[am::strings::vr_capabilities]));
+ ON_CALL(mock_hmi_capabilities_, display_capabilities())
+ .WillByDefault(
+ Return(&(*expected_message)[am::hmi_response::display_capabilities]));
+
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(Return(DataAccessor<am::ApplicationSet>(app_set_, lock_)));
+ ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true));
+ ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _))
+ .WillByDefault(Return(true));
+
+ EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::TTS_ChangeRegistration)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(CheckHMIInterfacesRealtedData(expected_message), _));
+
+ command_->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
new file mode 100644
index 0000000000..02744a66ea
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/scrollable_message_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+using am::commands::ScrollableMessageRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class ScrollableMessageRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ ScrollableMessageRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+ typedef TypeIf<kMocksAreNice,
+ NiceMock<application_manager_test::MockHMICapabilities>,
+ application_manager_test::MockHMICapabilities>::Result
+ MockHMICapabilities;
+ sync_primitives::Lock lock_;
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+};
+
+typedef ScrollableMessageRequestTest::MockHMICapabilities MockHMICapabilities;
+
+TEST_F(ScrollableMessageRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_ui = CreateFullParamsUISO();
+ (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<ScrollableMessageRequest> command =
+ CreateCommand<ScrollableMessageRequest>(msg_ui);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MockHMICapabilities hmi_capabilities;
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities));
+ ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::info] = "info1";
+
+ Event event(hmi_apis::FunctionID::UI_ScrollableMessage);
+ event.set_smart_object(*msg);
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
new file mode 100644
index 0000000000..9e5e62fc1c
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/set_app_icon_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+using am::commands::SetAppIconRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class SetAppIconRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SetAppIconRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+};
+
+TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ const std::string file_path = "file_path";
+ MessageSharedPtr msg_vr = CreateFullParamsUISO();
+ (*msg_vr)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ (*msg_vr)[am::strings::msg_params][am::strings::sync_file_name]
+ [am::strings::value] = file_path;
+
+ const std::string dir_path = "./";
+ ON_CALL(app_mngr_settings_, app_icons_folder())
+ .WillByDefault(ReturnRef(dir_path));
+
+ utils::SharedPtr<SetAppIconRequest> req_vr =
+ CreateCommand<SetAppIconRequest>(msg_vr);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true));
+ ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(file_path));
+
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::info] = "info1";
+
+ Event event(hmi_apis::FunctionID::UI_SetAppIcon);
+ event.set_smart_object(*msg);
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ req_vr->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
new file mode 100644
index 0000000000..839d9a452e
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/set_display_layout_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace set_display_layout_request {
+
+namespace am = application_manager;
+using am::commands::SetDisplayLayoutRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class SetDisplayLayoutRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SetDisplayLayoutRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+ typedef TypeIf<kMocksAreNice,
+ NiceMock<application_manager_test::MockHMICapabilities>,
+ application_manager_test::MockHMICapabilities>::Result
+ MockHMICapabilities;
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+typedef SetDisplayLayoutRequestTest::MockHMICapabilities MockHMICapabilities;
+
+TEST_F(SetDisplayLayoutRequestTest,
+ OnEvent_UIHmiUnsupportedResource_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_ui = CreateFullParamsUISO();
+ (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<SetDisplayLayoutRequest> command =
+ CreateCommand<SetDisplayLayoutRequest>(msg_ui);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ Event event(hmi_apis::FunctionID::UI_SetDisplayLayout);
+ event.set_smart_object(*msg);
+
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+} // namespace set_display_layout_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
new file mode 100644
index 0000000000..487be74667
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/set_global_properties_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace set_global_properties_request {
+
+namespace am = application_manager;
+using am::commands::SetGlobalPropertiesRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class SetGlobalPropertiesRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SetGlobalPropertiesRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ msg_params[am::strings::vr_help_title] = "vr_help_title";
+ msg_params[am::strings::vr_help][0][am::strings::text] = "vr_help";
+ msg_params[am::strings::vr_help][0][am::strings::position] = 1u;
+ msg_params[am::strings::help_prompt][0][am::strings::text] = "help_promt";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ void ExpectationsHmiInterface_Run() {
+ EXPECT_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ EXPECT_CALL(
+ hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ ON_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ }
+ sync_primitives::Lock lock_;
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(SetGlobalPropertiesRequestTest,
+ OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_vr = CreateFullParamsUISO();
+ (*msg_vr)[am::strings::msg_params][am::strings::vr_commands][0] =
+ "vr_command";
+
+ utils::SharedPtr<SetGlobalPropertiesRequest> command =
+ CreateCommand<SetGlobalPropertiesRequest>(msg_vr);
+
+ EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
+ const smart_objects::SmartObject* vr_help_title =
+ &((*msg_vr)[am::strings::msg_params][am::strings::vr_help_title]);
+ const smart_objects::SmartObject* vr_help =
+ &((*msg_vr)[am::strings::msg_params][am::strings::vr_help]);
+ const smart_objects::SmartObject* vr_help_prompt =
+ &((*msg_vr)[am::strings::msg_params][am::strings::help_prompt]);
+ ON_CALL(*mock_app_, vr_help_title()).WillByDefault(Return(vr_help_title));
+ ON_CALL(*mock_app_, vr_help()).WillByDefault(Return(vr_help));
+ ON_CALL(*mock_app_, help_prompt()).WillByDefault(Return(vr_help_prompt));
+
+ ExpectationsHmiInterface_Run();
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
+ event.set_smart_object(*msg);
+
+ ON_CALL(mock_message_helper_,
+ VerifyImageVrHelpItems(
+ (*msg_vr)[am::strings::msg_params][am::strings::vr_help], _, _))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(*mock_app_, UpdateHash());
+
+ (*msg_vr)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties);
+ event_vr.set_smart_object(*msg_vr);
+
+ command->Run();
+ command->on_event(event_vr);
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
+ MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
+ (*response)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*response)[am::strings::msg_params][am::strings::info] = "test";
+
+ am::event_engine::Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
+ event.set_smart_object(*response);
+
+ utils::SharedPtr<SetGlobalPropertiesRequest> command =
+ CreateCommand<SetGlobalPropertiesRequest>(response);
+
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .Times(0);
+ command->on_event(event);
+}
+
+TEST_F(SetGlobalPropertiesRequestTest,
+ OnEvent_UNSUPPORTED_RESOURCE_Expect_false) {
+ MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
+ (*response)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*response)[am::strings::msg_params][am::strings::info] = "qwe";
+
+ am::event_engine::Event event_tts(
+ hmi_apis::FunctionID::TTS_SetGlobalProperties);
+ event_tts.set_smart_object(*response);
+ am::event_engine::Event event_ui(
+ hmi_apis::FunctionID::UI_SetGlobalProperties);
+ event_tts.set_smart_object(*response);
+ utils::SharedPtr<SetGlobalPropertiesRequest> command =
+ CreateCommand<SetGlobalPropertiesRequest>(response);
+
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ ON_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_to_mobile;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->Run();
+ command->on_event(event_ui);
+ command->on_event(event_tts);
+
+ EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ false);
+ EXPECT_EQ(
+ (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(mobile_apis::Result::INVALID_DATA));
+}
+
+} // namespace set_global_properties_request
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
new file mode 100644
index 0000000000..e7e4513f15
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "application_manager/commands/mobile/set_media_clock_timer_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace set_media_clock_timer_request {
+
+namespace am = ::application_manager;
+using am::commands::SetMediaClockRequest;
+using am::commands::MessageSharedPtr;
+using am::event_engine::Event;
+using am::MockHmiInterfaces;
+using am::MockMessageHelper;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+typedef SharedPtr<SetMediaClockRequest> SetMediaClockRequestPtr;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class SetMediaClockRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SetMediaClockRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , mock_app_(CreateMockApp()) {}
+
+ void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(hmi_interfaces_));
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ResultCommandExpectations(MessageSharedPtr msg,
+ const std::string& info) {
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
+ info);
+ }
+
+ NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ MockMessageHelper& mock_message_helper_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(SetMediaClockRequestTest,
+ OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<SetMediaClockRequest> command =
+ CreateCommand<SetMediaClockRequest>(msg);
+
+ MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*ev_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
+ (*ev_msg)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+
+ Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer);
+ event.set_smart_object(*ev_msg);
+
+ EXPECT_CALL(hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+}
+
+} // namespace set_media_clock_timer_request
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/show_test.cc b/src/components/application_manager/test/commands/mobile/show_test.cc
new file mode 100644
index 0000000000..89c600362b
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/show_test.cc
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/show_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+using am::commands::ShowRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class ShowRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ ShowRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ sync_primitives::Lock lock_;
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+ MockMessageHelper& mock_message_helper_;
+};
+
+TEST_F(ShowRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_vr = CreateFullParamsUISO();
+ (*msg_vr)[am::strings::msg_params][am::strings::menu_params]
+ [am::hmi_request::parent_id] = 10u;
+ (*msg_vr)[am::strings::msg_params][am::strings::menu_params]
+ [am::strings::menu_name] = "menu_name";
+
+ utils::SharedPtr<ShowRequest> command = CreateCommand<ShowRequest>(msg_vr);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ ON_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ .WillByDefault(
+ Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ ON_CALL(hmi_interfaces, GetInterfaceState(_))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+
+ Event event(hmi_apis::FunctionID::UI_Show);
+ event.set_smart_object(*msg);
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr vr_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*vr_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*vr_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*vr_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc
new file mode 100644
index 0000000000..b8b2409c15
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/commands/mobile/on_app_interface_unregistered_notification.h"
+#include "application_manager/commands/mobile/on_audio_pass_thru_notification.h"
+#include "application_manager/commands/mobile/on_driver_distraction_notification.h"
+#include "application_manager/commands/mobile/on_language_change_notification.h"
+#include "application_manager/commands/mobile/on_permissions_change_notification.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace commands = am::commands;
+
+using ::testing::_;
+using ::testing::Types;
+
+template <class Command>
+class MobileNotificationCommandsTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ typedef Command CommandType;
+};
+
+typedef Types<commands::OnAppInterfaceUnregisteredNotification,
+ commands::OnAudioPassThruNotification,
+ commands::OnLanguageChangeNotification,
+ commands::OnPermissionsChangeNotification,
+ commands::mobile::OnDriverDistractionNotification>
+ NotificationCommandsList;
+
+MATCHER(CheckNotificationMessage, "") {
+ return (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
+ commands::CommandImpl::mobile_protocol_type_ &&
+ (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
+ commands::CommandImpl::protocol_version_ &&
+ (*arg)[am::strings::params][am::strings::message_type].asInt() ==
+ application_manager::MessageType::kNotification;
+}
+
+TYPED_TEST_CASE(MobileNotificationCommandsTest, NotificationCommandsList);
+
+TYPED_TEST(MobileNotificationCommandsTest, Run_SendMessageToMobile_SUCCESS) {
+ ::utils::SharedPtr<typename TestFixture::CommandType> command =
+ this->template CreateCommand<typename TestFixture::CommandType>();
+ EXPECT_CALL(this->app_mngr_,
+ SendMessageToMobile(CheckNotificationMessage(), _));
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
new file mode 100644
index 0000000000..9534da9561
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/include/application_manager/commands/mobile/read_did_response.h"
+#include "application_manager/include/application_manager/commands/mobile/delete_command_response.h"
+#include "application_manager/include/application_manager/commands/mobile/alert_maneuver_response.h"
+#include "application_manager/include/application_manager/commands/mobile/alert_response.h"
+#include "application_manager/include/application_manager/commands/mobile/list_files_response.h"
+#include "application_manager/include/application_manager/commands/mobile/subscribe_button_response.h"
+#include "application_manager/include/application_manager/commands/mobile/add_sub_menu_response.h"
+#include "application_manager/include/application_manager/commands/mobile/diagnostic_message_response.h"
+#include "application_manager/include/application_manager/commands/mobile/dial_number_response.h"
+#include "application_manager/include/application_manager/commands/mobile/end_audio_pass_thru_response.h"
+#include "application_manager/include/application_manager/commands/mobile/get_dtcs_response.h"
+#include "application_manager/include/application_manager/commands/mobile/get_vehicle_data_response.h"
+#include "application_manager/include/application_manager/commands/mobile/unregister_app_interface_response.h"
+#include "application_manager/include/application_manager/commands/mobile/unsubscribe_button_response.h"
+#include "application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_response.h"
+#include "application_manager/include/application_manager/commands/mobile/update_turn_list_response.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace commands = ::application_manager::commands;
+
+using ::testing::_;
+using ::testing::NotNull;
+using ::testing::Types;
+
+using commands::MessageSharedPtr;
+
+template <class Command>
+class MobileResponseCommandsTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ typedef Command CommandType;
+};
+
+typedef Types<commands::ListFilesResponse,
+ commands::ReadDIDResponse,
+ commands::DeleteCommandResponse,
+ commands::AlertManeuverResponse,
+ commands::AlertResponse,
+ commands::SubscribeButtonResponse,
+ commands::AddSubMenuResponse,
+ commands::DiagnosticMessageResponse,
+ commands::DialNumberResponse,
+ commands::EndAudioPassThruResponse,
+ commands::GetDTCsResponse,
+ commands::GetVehicleDataResponse,
+ commands::UnregisterAppInterfaceResponse,
+ commands::UnsubscribeWayPointsResponse,
+ commands::UpdateTurnListResponse,
+ commands::UnsubscribeButtonResponse> ResponseCommandsList;
+TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList);
+
+TYPED_TEST(MobileResponseCommandsTest, Run_SendResponseToMobile_SUCCESS) {
+ ::utils::SharedPtr<typename TestFixture::CommandType> command =
+ this->template CreateCommand<typename TestFixture::CommandType>();
+ EXPECT_CALL(this->app_mngr_, SendMessageToMobile(NotNull(), _));
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/slider_test.cc b/src/components/application_manager/test/commands/mobile/slider_test.cc
new file mode 100644
index 0000000000..7600d30304
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/slider_test.cc
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+#include <set>
+
+#include "application_manager/commands/mobile/slider_request.h"
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+using am::commands::SliderRequest;
+using am::commands::CommandImpl;
+using am::commands::MessageSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::utils::SharedPtr;
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+namespace {
+const int32_t kCommandId = 1;
+const uint32_t kAppId = 1u;
+const uint32_t kCmdId = 1u;
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class SliderRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SliderRequestTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ MockMessageHelper& mock_message_helper_;
+ sync_primitives::Lock lock_;
+
+ MessageSharedPtr CreateFullParamsUISO() {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ smart_objects::SmartObject menu_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ menu_params[am::strings::position] = 10;
+ menu_params[am::strings::menu_name] = "LG";
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[am::strings::cmd_id] = kCmdId;
+ msg_params[am::strings::menu_params] = menu_params;
+ msg_params[am::strings::app_id] = kAppId;
+ msg_params[am::strings::cmd_icon] = 1;
+ msg_params[am::strings::cmd_icon][am::strings::value] = "10";
+ (*msg)[am::strings::msg_params] = msg_params;
+
+ return msg;
+ }
+};
+
+TEST_F(SliderRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
+ MessageSharedPtr msg_ui = CreateFullParamsUISO();
+ (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
+ utils::SharedPtr<SliderRequest> command =
+ CreateCommand<SliderRequest>(msg_ui);
+
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ MockHmiInterfaces hmi_interfaces;
+ ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*msg)[am::strings::msg_params][am::strings::info] = "info";
+
+ Event event(hmi_apis::FunctionID::UI_Slider);
+ event.set_smart_object(*msg);
+
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
+
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+
+ command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ if ((*ui_command_result)[am::strings::msg_params].keyExists(
+ am::strings::info)) {
+ EXPECT_FALSE(
+ (*ui_command_result)[am::strings::msg_params][am::strings::info]
+ .asString()
+ .empty());
+ }
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
new file mode 100644
index 0000000000..65f1ef36db
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
@@ -0,0 +1,189 @@
+/*
+
+ Copyright (c) 2016, 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 <string>
+#include "gtest/gtest.h"
+#include "mobile/speak_request.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "interfaces/HMI_API.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/shared_ptr.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "smart_objects/smart_object.h"
+#include "utils/custom_string.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_hmi_interface.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = application_manager;
+namespace hmi_response = ::application_manager::hmi_response;
+namespace strings = ::application_manager::strings;
+using am::commands::CommandImpl;
+using am::ApplicationManager;
+using am::commands::MessageSharedPtr;
+using am::ApplicationSharedPtr;
+using am::MockMessageHelper;
+using am::MockHmiInterfaces;
+using ::testing::_;
+using ::utils::SharedPtr;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using am::commands::SpeakRequest;
+using ::test::components::application_manager_test::MockApplication;
+
+class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SpeakRequestTest()
+ : request_(CreateMessage(smart_objects::SmartType_Map))
+ , response_(CreateMessage(smart_objects::SmartType_Map)) {}
+
+ MessageSharedPtr ManageResponse() {
+ return response_;
+ }
+ MessageSharedPtr ManageRequest() {
+ return request_;
+ }
+
+ void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
+ const mobile_apis::Result::eType mobile_response,
+ const am::HmiInterfaces::InterfaceState state,
+ const bool success) {
+ utils::SharedPtr<SpeakRequest> command =
+ CreateCommand<SpeakRequest>(ManageRequest());
+
+ (*ManageResponse())[strings::params][hmi_response::code] = hmi_response;
+ (*ManageResponse())[strings::msg_params] = 0;
+
+ am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
+ event_tts.set_smart_object(*ManageResponse());
+
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ MessageSharedPtr response_to_mobile;
+ MockHmiInterfaces hmi_interfaces;
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillOnce(ReturnRef(hmi_interfaces));
+ EXPECT_CALL(hmi_interfaces, GetInterfaceState(_)).WillOnce(Return(state));
+ MockMessageHelper* mock_message_helper =
+ MockMessageHelper::message_helper_mock();
+ EXPECT_CALL(*mock_message_helper, HMIToMobileResult(_))
+ .WillOnce(Return(mobile_response));
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_tts);
+
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
+ success);
+ EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(mobile_response));
+ }
+
+ private:
+ MessageSharedPtr request_;
+ MessageSharedPtr response_;
+};
+
+TEST_F(SpeakRequestTest, OnEvent_SUCCESS_Expect_true) {
+ utils::SharedPtr<SpeakRequest> command =
+ CreateCommand<SpeakRequest>(ManageRequest());
+
+ (*ManageResponse())[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*ManageResponse())[strings::msg_params] = 0;
+
+ am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
+ event_tts.set_smart_object(*ManageResponse());
+
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ MessageSharedPtr response_to_mobile;
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+
+ command->on_event(event_tts);
+
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
+ true);
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(mobile_apis::Result::SUCCESS));
+}
+
+TEST_F(SpeakRequestTest,
+ OnEvent_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_true) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_AVAILABLE,
+ true);
+}
+
+TEST_F(SpeakRequestTest,
+ OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE,
+ false);
+}
+
+TEST_F(SpeakRequestTest,
+ OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_true) {
+ CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ am::HmiInterfaces::STATE_NOT_RESPONSE,
+ true);
+}
+
+} // namespace commands_test
+} // namespace component
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
new file mode 100644
index 0000000000..ea82670913
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/include/application_manager/commands/mobile/subscribe_button_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/smart_object_keys.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::DoAll;
+using ::testing::SaveArg;
+namespace am = ::application_manager;
+using am::commands::SubscribeButtonRequest;
+using am::commands::MessageSharedPtr;
+
+typedef SharedPtr<SubscribeButtonRequest> CommandPtr;
+
+class SubscribeButtonRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ typedef TypeIf<kMocksAreNice,
+ NiceMock<application_manager_test::MockHMICapabilities>,
+ application_manager_test::MockHMICapabilities>::Result
+ MockHMICapabilities;
+};
+
+typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities;
+
+TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ CommandPtr command(CreateCommand<SubscribeButtonRequest>());
+
+ ON_CALL(app_mngr_, application(_))
+ .WillByDefault(Return(SharedPtr<am::Application>()));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(SubscribeButtonRequestTest, Run_SubscriptionNotAllowed_UNSUCCESS) {
+ MessageSharedPtr msg(CreateMessage());
+ (*msg)[am::strings::msg_params][am::strings::button_name] =
+ mobile_apis::ButtonName::SEEKLEFT;
+ CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, is_media_application()).WillByDefault(Return(false));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::REJECTED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) {
+ CommandPtr command(CreateCommand<SubscribeButtonRequest>());
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
+ MockHMICapabilities hmi_capabilities;
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities));
+ ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(false));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) {
+ const mobile_apis::ButtonName::eType kButtonName =
+ mobile_apis::ButtonName::SEEKLEFT;
+
+ MessageSharedPtr msg(CreateMessage());
+ (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName;
+ CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, is_media_application()).WillByDefault(Return(true));
+
+ MockHMICapabilities hmi_capabilities;
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities));
+ ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
+
+ MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
+ (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName;
+
+ ON_CALL(hmi_capabilities, button_capabilities())
+ .WillByDefault(Return(button_caps_ptr.get()));
+
+ ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(true));
+
+ MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
+ EXPECT_EQ(mobile_apis::Result::IGNORED,
+ static_cast<mobile_apis::Result::eType>(
+ (*result_msg)[am::strings::msg_params][am::strings::result_code]
+ .asInt()));
+}
+
+TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) {
+ const mobile_apis::ButtonName::eType kButtonName =
+ mobile_apis::ButtonName::SEEKLEFT;
+
+ MessageSharedPtr msg(CreateMessage());
+ (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName;
+ CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
+
+ MockAppPtr app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+ ON_CALL(*app, is_media_application()).WillByDefault(Return(true));
+
+ MockHMICapabilities hmi_capabilities;
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities));
+ ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
+
+ MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
+ (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName;
+
+ ON_CALL(hmi_capabilities, button_capabilities())
+ .WillByDefault(Return(button_caps_ptr.get()));
+
+ ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false));
+
+ MessageSharedPtr hmi_result_msg;
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_))
+ .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true)));
+
+ MessageSharedPtr mobile_result_msg(
+ CatchMobileCommandResult(CallRun(*command)));
+
+ EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription,
+ static_cast<hmi_apis::FunctionID::eType>(
+ (*hmi_result_msg)[am::strings::params][am::strings::function_id]
+ .asInt()));
+
+ EXPECT_EQ(mobile_apis::Result::SUCCESS,
+ static_cast<mobile_apis::Result::eType>(
+ (*mobile_result_msg)[am::strings::msg_params]
+ [am::strings::result_code].asInt()));
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
index 35755a08bb..ff149504fa 100644
--- a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
@@ -33,13 +33,13 @@
#include "gtest/gtest.h"
#include "utils/shared_ptr.h"
#include "smart_objects/smart_object.h"
-#include "commands/commands_test.h"
-#include "commands/command_request_test.h"
+#include "application_manager/test/include/application_manager/commands/commands_test.h"
+#include "application_manager/test/include/application_manager/commands/command_request_test.h"
#include "application_manager/application.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_hmi_capabilities.h"
-#include "mobile/subscribe_way_points_request.h"
+#include "application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h"
#include "interfaces/MOBILE_API.h"
#include "application_manager/smart_object_keys.h"
@@ -61,13 +61,7 @@ using am::commands::MessageSharedPtr;
typedef SharedPtr<SubscribeWayPointsRequest> CommandPtr;
class SubscribeWayPointsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- typedef TypeIf<kMocksIsNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
-};
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) {
CommandPtr command(CreateCommand<SubscribeWayPointsRequest>());
diff --git a/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
new file mode 100644
index 0000000000..b2b1901d4e
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/commands/mobile/unregister_app_interface_request.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace mobile_result = mobile_apis::Result;
+
+using ::testing::_;
+
+using am::commands::UnregisterAppInterfaceRequest;
+using am::commands::MessageSharedPtr;
+
+typedef ::utils::SharedPtr<UnregisterAppInterfaceRequest> CommandPtr;
+
+class UnregisterAppInterfaceRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(UnregisterAppInterfaceRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>());
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(UnregisterAppInterfaceRequestTest, Run_SUCCESS) {
+ const uint32_t kConnectionKey = 1u;
+
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ const mobile_apis::AppInterfaceUnregisteredReason::eType kUnregisterReason =
+ mobile_apis::AppInterfaceUnregisteredReason::INVALID_ENUM;
+
+ MessageSharedPtr dummy_msg(CreateMessage());
+ EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(),
+ GetOnAppInterfaceUnregisteredNotificationToMobile(
+ kConnectionKey, kUnregisterReason))
+ .WillOnce(Return(dummy_msg));
+ {
+ ::testing::InSequence sequence;
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(dummy_msg, _));
+
+ EXPECT_CALL(app_mngr_,
+ UnregisterApplication(
+ kConnectionKey, mobile_apis::Result::SUCCESS, _, _));
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ }
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
new file mode 100644
index 0000000000..6518d8131a
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
@@ -0,0 +1,103 @@
+#include <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/commands/mobile/unsubscribe_button_request.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace mobile_result = mobile_apis::Result;
+
+using ::testing::_;
+
+using am::commands::UnsubscribeButtonRequest;
+using am::commands::MessageSharedPtr;
+
+typedef ::utils::SharedPtr<UnsubscribeButtonRequest> CommandPtr;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK;
+} // namespace
+
+class UnsubscribeButtonRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ CommandPtr command(CreateCommand<UnsubscribeButtonRequest>());
+
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeButtonRequestTest,
+ Run_UnsubscribeNotSubscribedButton_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
+
+ CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
+ .WillOnce(Return(false));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
+ const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK;
+
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
+
+ CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::Buttons_OnButtonSubscription)));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ EXPECT_CALL(*mock_app, UpdateHash());
+
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
new file mode 100644
index 0000000000..964f1944c5
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
@@ -0,0 +1,291 @@
+/*
+ Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/commands/mobile/unsubscribe_vehicle_data_request.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace mobile_result = mobile_apis::Result;
+
+using ::testing::_;
+
+using am::commands::UnsubscribeVehicleDataRequest;
+using am::commands::MessageSharedPtr;
+
+typedef ::utils::SharedPtr<UnsubscribeVehicleDataRequest> CommandPtr;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+const std::string kMsgParamKey = "test_key";
+const am::VehicleDataType kVehicleType = am::VehicleDataType::SPEED;
+} // namespace
+
+class UnsubscribeVehicleRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ protected:
+ void UnsubscribeSuccessfully();
+ sync_primitives::Lock app_set_lock_;
+};
+
+TEST_F(UnsubscribeVehicleRequestTest, Run_AppNotRegistered_UNSUCCESS) {
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>());
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest,
+ Run_DataToUnsubscribeIsNotExisted_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][am::strings::button_name] =
+ kVehicleType;
+
+ am::VehicleData data;
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(data));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest,
+ Run_UnsubscribeNotSubscribedBeforeData_IGNORED) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = kVehicleType;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest,
+ Run_UnsubscribeNotSubscribedBeforeData_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeDataDisabled_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command->Run();
+}
+
+void UnsubscribeVehicleRequestTest::UnsubscribeSuccessfully() {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ am::ApplicationSet application_set_;
+ MockAppPtr mock_app(CreateMockApp());
+ application_set_.insert(mock_app);
+ DataAccessor<am::ApplicationSet> accessor(application_set_, app_set_lock_);
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+
+ EXPECT_CALL(*mock_app, IsSubscribedToIVI(kVehicleType))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app, UnsubscribeFromIVI(kVehicleType))
+ .WillRepeatedly(Return(true));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeData_SUCCESS) {
+ UnsubscribeSuccessfully();
+}
+
+TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+
+ am::VehicleData vehicle_data;
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(mock_app));
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
+ .WillOnce(ReturnRef(vehicle_data));
+ EXPECT_CALL(*mock_app, IsSubscribedToIVI(kVehicleType))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+ command->Run();
+
+ am::event_engine::Event test_event(
+ hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData);
+ SmartObject message(smart_objects::SmartType_Map);
+ const hmi_apis::Common_Result::eType hmi_result =
+ hmi_apis::Common_Result::SUCCESS;
+ const mobile_apis::Result::eType mob_result = mobile_apis::Result::SUCCESS;
+ message[am::strings::params][am::hmi_response::code] = hmi_result;
+ message[am::strings::msg_params][kMsgParamKey] = true;
+ test_event.set_smart_object(message);
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
+ HMIToMobileResult(hmi_result)).WillOnce(Return(mob_result));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+ EXPECT_CALL(*mock_app, UpdateHash());
+
+ command->on_event(test_event);
+}
+
+TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) {
+ UnsubscribeSuccessfully();
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ MockAppPtr mock_app(CreateMockApp());
+
+ am::event_engine::Event test_event(
+ hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData);
+ SmartObject message(smart_objects::SmartType_Map);
+ const hmi_apis::Common_Result::eType hmi_result =
+ hmi_apis::Common_Result::SUCCESS;
+ const mobile_apis::Result::eType mob_result = mobile_apis::Result::SUCCESS;
+ message[am::strings::params][am::hmi_response::code] = hmi_result;
+ message[am::strings::msg_params][kMsgParamKey] = true;
+ test_event.set_smart_object(message);
+
+ EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
+ HMIToMobileResult(hmi_result)).WillOnce(Return(mob_result));
+
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ EXPECT_CALL(*mock_app, UpdateHash());
+
+ command->on_event(test_event);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc
new file mode 100644
index 0000000000..9c87b350b8
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016, 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/mobile/unsubscribe_vehicle_data_response.h"
+#include <stdint.h>
+#include <string>
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/mock_application_manager.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace commands = ::application_manager::commands;
+
+using ::testing::_;
+using ::testing::NotNull;
+using ::testing::Types;
+
+using commands::MessageSharedPtr;
+namespace am = ::application_manager;
+
+class UnsubscribeVehicleResponseTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {};
+
+MATCHER_P(ResultCodeIs, result_code, "") {
+ return result_code ==
+ static_cast<mobile_apis::Result::eType>(
+ (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
+}
+
+TEST_F(UnsubscribeVehicleResponseTest,
+ Run_SendFalseResponseToMobile_SendInvalidEnum) {
+ MessageSharedPtr command_msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ (*command_msg)[am::strings::msg_params][am::strings::success] = false;
+
+ ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
+ CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
+ EXPECT_CALL(
+ app_mngr_,
+ SendMessageToMobile(ResultCodeIs(mobile_apis::Result::INVALID_ENUM), _));
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleResponseTest,
+ Run_SendSuccessfulResponseToMobile_SUCCESS) {
+ MessageSharedPtr command_msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ (*command_msg)[am::strings::msg_params][am::strings::success] = true;
+ ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
+ CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
+ EXPECT_CALL(
+ app_mngr_,
+ SendMessageToMobile(ResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ command->Run();
+}
+
+TEST_F(UnsubscribeVehicleResponseTest,
+ Run_SendResponseToMobile_SendCodeToMobile) {
+ MessageSharedPtr command_msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ (*command_msg)[am::strings::msg_params][am::strings::success] = true;
+
+ mobile_apis::Result::eType result_type = mobile_apis::Result::WARNINGS;
+ (*command_msg)[am::strings::msg_params][am::strings::result_code] =
+ result_type;
+ ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
+ CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(ResultCodeIs(result_type), _));
+ command->Run();
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc~ff89c63... Cover UnsubscribeWayPoints and UpdateTurnList by Unit Tests. b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc~ff89c63... Cover UnsubscribeWayPoints and UpdateTurnList by Unit Tests.
new file mode 100644
index 0000000000..e4a0d0fb6d
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc~ff89c63... Cover UnsubscribeWayPoints and UpdateTurnList by Unit Tests.
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "mobile/unsubscribe_way_points_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "commands/commands_test.h"
+#include "commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace mobile_result = mobile_apis::Result;
+
+using ::testing::_;
+using ::testing::Return;
+
+using am::commands::UnSubscribeWayPointsRequest;
+using am::commands::MessageSharedPtr;
+
+namespace {
+const uint32_t kConnectionKey = 3u;
+const uint32_t kAppId = 5u;
+} // namespace
+
+class UnSubscribeWayPointsRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ UnSubscribeWayPointsRequestTest()
+ : command_msg_(CreateMessage(smart_objects::SmartType_Map))
+ , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) {
+ (*command_msg_)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ }
+
+ MessageSharedPtr command_msg_;
+ ::utils::SharedPtr<UnSubscribeWayPointsRequest> command_;
+};
+
+TEST_F(UnSubscribeWayPointsRequestTest,
+ Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ EXPECT_CALL(app_mngr_, application(_))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command_->Run();
+}
+
+TEST_F(UnSubscribeWayPointsRequestTest,
+ Run_AppIsNotSubscribedForWayPoints_UNSUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+
+ EXPECT_CALL(app_mngr_, IsAppSubscribedForWayPoints(kAppId))
+ .WillOnce(Return(false));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+
+ command_->Run();
+}
+
+TEST_F(UnSubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+
+ EXPECT_CALL(app_mngr_, IsAppSubscribedForWayPoints(kAppId))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints)));
+
+ command_->Run();
+}
+
+TEST_F(UnSubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ command_->on_event(event);
+}
+
+TEST_F(UnSubscribeWayPointsRequestTest,
+ OnEvent_ReceivedNavigationUnSubscribeWayPointsEvent_SUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::msg_params] = 0;
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_result::SUCCESS;
+ Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints);
+ event.set_smart_object(*event_msg);
+
+ EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+
+ EXPECT_CALL(app_mngr_, UnsubscribeAppFromWayPoints(kAppId));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ command_->on_event(event);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc
new file mode 100644
index 0000000000..7c8cb76041
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2016, 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 <stdint.h>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "application_manager/commands/mobile/update_turn_list_request.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+
+namespace am = ::application_manager;
+namespace mobile_result = mobile_apis::Result;
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::Ref;
+using ::testing::Eq;
+
+using am::commands::UpdateTurnListRequest;
+using am::commands::MessageSharedPtr;
+using application_manager_test::MockHMICapabilities;
+
+namespace {
+const uint32_t kConnectionKey = 3u;
+const hmi_apis::FunctionID::eType kFunctionId =
+ hmi_apis::FunctionID::Buttons_OnButtonEvent;
+const uint32_t kAppId = 5u;
+} // namespace
+
+class UpdateTurnListRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ UpdateTurnListRequestTest()
+ : mock_message_helper_(*am::MockMessageHelper::message_helper_mock())
+ , command_msg_(CreateMessage(smart_objects::SmartType_Map))
+ , command_(CreateCommand<UpdateTurnListRequest>(command_msg_)) {
+ (*command_msg_)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg_)[am::strings::params][am::strings::function_id] =
+ kFunctionId;
+ }
+
+ am::MockMessageHelper& mock_message_helper_;
+ MessageSharedPtr command_msg_;
+ ::utils::SharedPtr<UpdateTurnListRequest> command_;
+ TypeIf<kMocksAreNice,
+ NiceMock<policy_test::MockPolicyHandlerInterface>,
+ policy_test::MockPolicyHandlerInterface>::Result mock_policy_handler_;
+};
+
+TEST_F(UpdateTurnListRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
+
+ command_->Run();
+}
+
+TEST_F(UpdateTurnListRequestTest, Run_InvalidNavigationText_UNSUCCESS) {
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::navigation_text] = "invalid_navigation_text\t\n";
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command_->Run();
+}
+
+TEST_F(UpdateTurnListRequestTest, Run_InvalidTurnIcon_UNSUCCESS) {
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::navigation_text] = "valid_navigation_text";
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::turn_icon][am::strings::value] =
+ "invalid_turn_icon\t\n";
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command_->Run();
+}
+
+TEST_F(UpdateTurnListRequestTest,
+ Run_ProcessSoftButtonsNotSucceeded_UNSUCCESS) {
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::navigation_text] = "valid_navigation_text";
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::turn_icon][am::strings::value] =
+ "valid_turn_icon";
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler_));
+
+ const mobile_result::eType kExpectedResult = mobile_result::INVALID_ENUM;
+ EXPECT_CALL(mock_message_helper_,
+ ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
+ Eq(mock_app),
+ Ref(mock_policy_handler_),
+ Ref(app_mngr_)))
+ .WillOnce(Return(kExpectedResult));
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(kExpectedResult), _));
+
+ command_->Run();
+}
+
+TEST_F(UpdateTurnListRequestTest, Run_NoTurnList_UNSUCCESS) {
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler_));
+
+ EXPECT_CALL(mock_message_helper_,
+ ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
+ Eq(mock_app),
+ Ref(mock_policy_handler_),
+ Ref(app_mngr_)))
+ .WillOnce(Return(mobile_result::SUCCESS));
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
+
+ command_->Run();
+}
+
+TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) {
+ const std::string kNavigationText = "valid_navigation_text";
+
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::navigation_text] = kNavigationText;
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::turn_icon][am::strings::value] =
+ "valid_turn_icon";
+ (*command_msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0;
+
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, GetPolicyHandler())
+ .WillOnce(ReturnRef(mock_policy_handler_));
+
+ EXPECT_CALL(mock_message_helper_,
+ ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
+ Eq(mock_app),
+ Ref(mock_policy_handler_),
+ Ref(app_mngr_)))
+ .WillOnce(Return(mobile_result::SUCCESS));
+
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyImage(
+ (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::strings::turn_icon],
+ Eq(mock_app),
+ Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS));
+
+ EXPECT_CALL(mock_message_helper_,
+ SubscribeApplicationToSoftButton(_, _, kFunctionId));
+
+ MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_)));
+ ASSERT_TRUE(result_msg);
+ EXPECT_EQ(
+ hmi_apis::FunctionID::Navigation_UpdateTurnList,
+ (*result_msg)[am::strings::params][am::strings::function_id].asInt());
+
+ ASSERT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
+ .keyExists(am::hmi_request::navi_text));
+
+ EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::hmi_request::navi_text].keyExists(
+ am::hmi_request::field_name));
+ EXPECT_EQ(
+ hmi_apis::Common_TextFieldName::turnText,
+ (*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::hmi_request::navi_text][am::hmi_request::field_name]
+ .asInt());
+
+ EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::hmi_request::navi_text].keyExists(
+ am::hmi_request::field_text));
+ EXPECT_EQ(
+ kNavigationText,
+ (*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
+ [am::hmi_request::navi_text][am::hmi_request::field_text]
+ .asString());
+}
+
+TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
+ Event event(hmi_apis::FunctionID::INVALID_ENUM);
+
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
+
+ command_->on_event(event);
+}
+
+TEST_F(UpdateTurnListRequestTest, OnEvent_UnsupportedResource_SUCCESS) {
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_result::UNSUPPORTED_RESOURCE;
+ (*event_msg)[am::strings::msg_params] = 0;
+
+ Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList);
+ event.set_smart_object(*event_msg);
+
+ MockHMICapabilities mock_hmi_capabilities;
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities));
+
+ EXPECT_CALL(mock_hmi_capabilities, is_ui_cooperating())
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _));
+
+ command_->on_event(event);
+}
+
+TEST_F(UpdateTurnListRequestTest,
+ OnEvent_ReceivedNavigationUpdateTurnListEvent_SUCCESS) {
+ MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ mobile_result::SUCCESS;
+ (*event_msg)[am::strings::msg_params] = 0;
+
+ Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList);
+ event.set_smart_object(*event_msg);
+
+ MockHMICapabilities mock_hmi_capabilities;
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities));
+
+ EXPECT_CALL(mock_hmi_capabilities, is_ui_cooperating()).Times(0);
+
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+
+ command_->on_event(event);
+}
+
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc
index 1ed2123eba..738797b122 100644
--- a/src/components/application_manager/test/hmi_capabilities_test.cc
+++ b/src/components/application_manager/test/hmi_capabilities_test.cc
@@ -30,6 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string>
+
#include "application_manager/hmi_capabilities.h"
#include "gtest/gtest.h"
#include "smart_objects/smart_object.h"
@@ -62,14 +64,16 @@ using namespace application_manager;
class HMICapabilitiesTest : public ::testing::Test {
protected:
- HMICapabilitiesTest() : last_state_("app_storage_folder", "app_info_data") {}
+ HMICapabilitiesTest()
+ : last_state_("app_storage_folder", "app_info_data")
+ , file_name_("hmi_capabilities.json") {}
virtual void SetUp() OVERRIDE {
EXPECT_CALL(app_mngr_, event_dispatcher())
.WillOnce(ReturnRef(mock_event_dispatcher));
EXPECT_CALL(app_mngr_, get_settings())
.WillRepeatedly(ReturnRef(mock_application_manager_settings_));
EXPECT_CALL(mock_application_manager_settings_,
- hmi_capabilities_file_name()).WillOnce(ReturnRef(kFileName));
+ hmi_capabilities_file_name()).WillOnce(ReturnRef(file_name_));
EXPECT_CALL(mock_event_dispatcher, add_observer(_, _, _)).Times(1);
EXPECT_CALL(mock_event_dispatcher, remove_observer(_)).Times(1);
EXPECT_CALL(mock_application_manager_settings_, launch_hmi())
@@ -94,7 +98,7 @@ class HMICapabilitiesTest : public ::testing::Test {
resumption::LastState last_state_;
MockApplicationManagerSettings mock_application_manager_settings_;
utils::SharedPtr<HMICapabilitiesForTesting> hmi_capabilities_test;
- const std::string kFileName = "hmi_capabilities.json";
+ const std::string file_name_;
};
const char* const cstring_values_[] = {
@@ -349,75 +353,6 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) {
EXPECT_EQ("SE", vehicle_type_so["trim"].asString());
}
-TEST_F(HMICapabilitiesTest, ConvertJsonLanguagesToObj) {
- Json::Value json_languages(Json::arrayValue);
- json_languages[0] = "EN_US";
- json_languages[1] = "ES_MX";
- smart_objects::SmartObject sm_obj =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CommonLanguageFromString(json_languages[0].asString()))
- .WillOnce(Return(hmi_apis::Common_Language::EN_US));
-
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CommonLanguageFromString(json_languages[1].asString()))
- .WillOnce(Return(hmi_apis::Common_Language::ES_MX));
-
- hmi_capabilities_test->ConvertJsonLanguagesToObj(json_languages, sm_obj);
-
- EXPECT_EQ(hmi_apis::Common_Language::EN_US,
- static_cast<hmi_apis::Common_Language::eType>(sm_obj[0].asInt()));
- EXPECT_EQ(hmi_apis::Common_Language::ES_MX,
- static_cast<hmi_apis::Common_Language::eType>(sm_obj[1].asInt()));
-}
-
-TEST_F(HMICapabilitiesTest,
- HmiCapabilitiesInitialized_UiVrTtsIviNotCooperating) {
- // Precondition
- hmi_capabilities_test->set_is_vr_cooperating(false);
- hmi_capabilities_test->set_is_tts_cooperating(false);
-
- hmi_capabilities_test->set_is_ui_cooperating(false);
- hmi_capabilities_test->set_is_navi_cooperating(false);
- hmi_capabilities_test->set_is_ivi_cooperating(false);
- EXPECT_TRUE(hmi_capabilities_test->is_hmi_capabilities_initialized());
-}
-
-TEST_F(HMICapabilitiesTest, HmiCapabilitiesInitialized) {
- // Precondition
- SetCooperating();
- smart_objects::SmartObjectSPtr language(
- new smart_objects::SmartObject(smart_objects::SmartType_Map));
-
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(_, _)).WillRepeatedly(Return(language));
-
- hmi_capabilities_test->set_is_vr_cooperating(true);
- smart_objects::SmartObject supported_languages;
- supported_languages[0] = "EN_US";
- hmi_capabilities_test->set_vr_supported_languages(supported_languages);
- hmi_capabilities_test->set_tts_supported_languages(supported_languages);
- hmi_capabilities_test->set_ui_supported_languages(supported_languages);
- hmi_capabilities_test->set_vehicle_type(supported_languages);
-
- hmi_capabilities_test->set_is_tts_cooperating(true);
- hmi_capabilities_test->set_is_ui_cooperating(true);
- hmi_capabilities_test->set_is_navi_cooperating(true);
- hmi_capabilities_test->set_is_ivi_cooperating(true);
-
- hmi_capabilities_test->set_active_vr_language(
- hmi_apis::Common_Language::EN_US);
- SetCooperating();
- hmi_capabilities_test->set_active_tts_language(
- hmi_apis::Common_Language::EN_US);
- SetCooperating();
- hmi_capabilities_test->set_active_ui_language(
- hmi_apis::Common_Language::EN_US);
-
- EXPECT_TRUE(hmi_capabilities_test->is_hmi_capabilities_initialized());
-}
-
TEST_F(HMICapabilitiesTest, VerifyImageType) {
const int32_t image_type = 1;
smart_objects::SmartObject sm_obj;
@@ -438,88 +373,23 @@ void HMICapabilitiesTest::SetCooperating() {
}
TEST_F(HMICapabilitiesTest, SetVRCooperating) {
- // Without sequence it is impossible to check correct call of ManageHMICommand
- InSequence dummy;
- smart_objects::SmartObjectSPtr language(
- new smart_objects::SmartObject(smart_objects::SmartType_Map));
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, _))
- .WillOnce(Return(language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(language));
-
- smart_objects::SmartObjectSPtr support_language;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages,
- _)).WillOnce(Return(support_language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(support_language));
-
- smart_objects::SmartObjectSPtr capabilities;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, _))
- .WillOnce(Return(capabilities));
- EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities));
-
hmi_capabilities_test->set_is_vr_cooperating(true);
+ EXPECT_EQ(true, hmi_capabilities_test->is_vr_cooperating());
}
TEST_F(HMICapabilitiesTest, SetTTSCooperating) {
- smart_objects::SmartObjectSPtr language(
- new smart_objects::SmartObject(smart_objects::SmartType_Map));
- InSequence dummy;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage, _))
- .WillOnce(Return(language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(language));
-
- smart_objects::SmartObjectSPtr support_language;
- EXPECT_CALL(
- *(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetSupportedLanguages, _))
- .WillOnce(Return(support_language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(support_language));
-
- smart_objects::SmartObjectSPtr capabilities;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetCapabilities, _))
- .WillOnce(Return(capabilities));
- EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities));
-
hmi_capabilities_test->set_is_tts_cooperating(true);
+ EXPECT_EQ(true, hmi_capabilities_test->is_tts_cooperating());
}
TEST_F(HMICapabilitiesTest, SetUICooperating) {
- InSequence dummy;
- smart_objects::SmartObjectSPtr language(
- new smart_objects::SmartObject(smart_objects::SmartType_Map));
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage, _))
- .WillOnce(Return(language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(language));
-
- smart_objects::SmartObjectSPtr support_language;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetSupportedLanguages,
- _)).WillOnce(Return(support_language));
- EXPECT_CALL(app_mngr_, ManageHMICommand(support_language));
-
- smart_objects::SmartObjectSPtr capabilities;
- EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetCapabilities, _))
- .WillOnce(Return(capabilities));
- EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities));
-
hmi_capabilities_test->set_is_ui_cooperating(true);
+ EXPECT_EQ(true, hmi_capabilities_test->is_ui_cooperating());
}
TEST_F(HMICapabilitiesTest, SetIviCooperating) {
- smart_objects::SmartObjectSPtr ivi_type;
- EXPECT_CALL(
- *(MockMessageHelper::message_helper_mock()),
- CreateModuleInfoSO(hmi_apis::FunctionID::VehicleInfo_GetVehicleType, _))
- .WillOnce(Return(ivi_type));
- EXPECT_CALL(app_mngr_, ManageHMICommand(ivi_type));
-
hmi_capabilities_test->set_is_ivi_cooperating(true);
+ EXPECT_EQ(true, hmi_capabilities_test->is_ivi_cooperating());
}
} // namespace application_manager_test
diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h
new file mode 100644
index 0000000000..d4cca96431
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMAND_RESPONSES_TEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMAND_RESPONSES_TEST_H_
+
+#include <stdint.h>
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_request_impl.h"
+#include "application_manager/mock_event_dispatcher.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::testing::DoAll;
+using ::testing::NiceMock;
+using ::test::components::event_engine_test::MockEventDispatcher;
+namespace am = ::application_manager;
+using am::commands::Command;
+using am::commands::CommandRequestImpl;
+using am::event_engine::Event;
+
+class CallRun {
+ public:
+ CallRun(CommandRequestImpl& command) : command_(command) {}
+
+ void operator()() {
+ command_.Run();
+ }
+
+ CommandRequestImpl& command_;
+};
+
+class CallOnEvent {
+ public:
+ CallOnEvent(CommandRequestImpl& command, Event& event)
+ : command_(command), event_(event) {}
+
+ void operator()() {
+ command_.on_event(event_);
+ }
+
+ CommandRequestImpl& command_;
+ Event& event_;
+};
+
+template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice>
+class CommandRequestTest : public CommandsTest<kIsNice> {
+ public:
+ typedef typename TypeIf<kIsNice,
+ NiceMock<MockEventDispatcher>,
+ MockEventDispatcher>::Result MockEventDisp;
+
+ template <class CallableT>
+ MessageSharedPtr CatchMobileCommandResult(CallableT delegate,
+ bool call_return = true) {
+ MessageSharedPtr result_msg;
+ EXPECT_CALL(this->app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(call_return)));
+ delegate();
+ return result_msg;
+ }
+
+ template <class CallableT>
+ MessageSharedPtr CatchHMICommandResult(CallableT delegate,
+ bool call_return = true) {
+ MessageSharedPtr result_msg;
+ EXPECT_CALL(this->app_mngr_, ManageHMICommand(_))
+ .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(call_return)));
+ delegate();
+ return result_msg;
+ }
+
+ MockEventDisp event_dispatcher_;
+
+ protected:
+ CommandRequestTest() : CommandsTest<kIsNice>() {}
+
+ virtual void InitCommand(const uint32_t& default_timeout) OVERRIDE {
+ CommandsTest<kIsNice>::InitCommand(default_timeout);
+ ON_CALL(CommandsTest<kIsNice>::app_mngr_, event_dispatcher())
+ .WillByDefault(ReturnRef(event_dispatcher_));
+ }
+};
+
+MATCHER_P(MobileResultCodeIs, result_code, "") {
+ return result_code ==
+ static_cast<mobile_apis::Result::eType>(
+ (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
+}
+
+MATCHER_P(HMIResultCodeIs, result_code, "") {
+ return result_code ==
+ static_cast<hmi_apis::FunctionID::eType>(
+ (*arg)[am::strings::params][am::strings::function_id].asInt());
+}
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMAND_RESPONSES_TEST_H_
diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
new file mode 100644
index 0000000000..232b8fef0b
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
+
+#include <stdint.h>
+#include "gtest/gtest.h"
+
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/commands/command.h"
+#include "utils/make_shared.h"
+#include "application_manager/mock_application_manager.h"
+#include "test/application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_application.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+using ::testing::ReturnRef;
+using ::testing::NiceMock;
+
+using ::utils::SharedPtr;
+using ::smart_objects::SmartObject;
+using ::application_manager::commands::MessageSharedPtr;
+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;
+
+// Depending on the value type will be selected
+template <const bool kIf, class ThenT, class ElseT>
+struct TypeIf {
+ typedef ThenT Result;
+};
+template <class ThenT, class ElseT>
+struct TypeIf<false, ThenT, ElseT> {
+ typedef ElseT Result;
+};
+
+template <class MockT, bool kIsNice>
+struct IsNiceMock : public TypeIf<kIsNice, ::testing::NiceMock<MockT>, MockT> {
+};
+
+#define MOCK(Type) typename IsNiceMock<Type, kMocksAreNice>::Result
+
+// If `kIsNice` is `true` then all used mock types
+// will be wrapped by a `NiceMock`
+
+enum CommandsTestMocks { kNotNice = 0, kIsNice };
+
+template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice>
+class CommandsTest : public ::testing::Test {
+ public:
+ enum { kMocksAreNice = kIsNice };
+
+ typedef NiceMock<MockApplicationManagerSettings> MockAppManagerSettings;
+ typedef typename TypeIf<kIsNice,
+ NiceMock<MockApplicationManager>,
+ MockApplicationManager>::Result MockAppManager;
+ typedef typename TypeIf<kIsNice,
+ NiceMock<MockApplication>,
+ MockApplication>::Result MockApp;
+
+ typedef SharedPtr<MockApp> MockAppPtr;
+
+ virtual ~CommandsTest() {}
+
+ static MessageSharedPtr CreateMessage(
+ const smart_objects::SmartType type = smart_objects::SmartType_Null) {
+ return ::utils::MakeShared<SmartObject>(type);
+ }
+
+ static MockAppPtr CreateMockApp() {
+ return ::utils::MakeShared<MockApp>();
+ }
+
+ template <class Command>
+ SharedPtr<Command> CreateCommand(const uint32_t timeout,
+ MessageSharedPtr& msg) {
+ InitCommand(timeout);
+ return ::utils::MakeShared<Command>((msg ? msg : msg = CreateMessage()),
+ app_mngr_);
+ }
+
+ template <class Command>
+ SharedPtr<Command> CreateCommand(MessageSharedPtr& msg) {
+ return CreateCommand<Command>(kDefaultTimeout_, msg);
+ }
+
+ template <class Command>
+ SharedPtr<Command> CreateCommand(const uint32_t timeout = kDefaultTimeout_) {
+ InitCommand(timeout);
+ MessageSharedPtr msg = CreateMessage();
+ return ::utils::MakeShared<Command>(msg, app_mngr_);
+ }
+
+ enum { kDefaultTimeout_ = 100 };
+
+ MockAppManager app_mngr_;
+ MockAppManagerSettings app_mngr_settings_;
+
+ protected:
+ virtual void InitCommand(const uint32_t& timeout) {
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, default_timeout())
+ .WillByDefault(ReturnRef(timeout));
+ }
+
+ CommandsTest() {}
+};
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
diff --git a/src/components/application_manager/test/include/application_manager/hmi_capabilities_for_testing.h b/src/components/application_manager/test/include/application_manager/hmi_capabilities_for_testing.h
index ec8e92e859..9764a9997f 100644
--- a/src/components/application_manager/test/include/application_manager/hmi_capabilities_for_testing.h
+++ b/src/components/application_manager/test/include/application_manager/hmi_capabilities_for_testing.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,26 +33,20 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_FOR_TESTING_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_FOR_TESTING_H_
-#include "application_manager/hmi_capabilities.h"
+#include "application_manager/hmi_capabilities_impl.h"
namespace test {
namespace components {
namespace application_manager_test {
class HMICapabilitiesForTesting
- : public ::application_manager::HMICapabilities {
+ : public ::application_manager::HMICapabilitiesImpl {
public:
HMICapabilitiesForTesting(::application_manager::ApplicationManager& app_mngr)
- : HMICapabilities(app_mngr) {}
+ : HMICapabilitiesImpl(app_mngr) {}
bool LoadCapabilitiesFromFile() {
return load_capabilities_from_file();
}
-
- void ConvertJsonLanguagesToObj(
- Json::Value& json_languages,
- ::NsSmartDeviceLink::NsSmartObjects::SmartObject& languages) {
- convert_json_languages_to_obj(json_languages, languages);
- }
};
} // namespace application_manager_test
diff --git a/src/components/application_manager/test/include/application_manager/mock_app_launch_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_app_launch_ctrl.h
new file mode 100644
index 0000000000..181b8c4691
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_app_launch_ctrl.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_CTRL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_CTRL_H_
+
+#include "application_manager/app_launch/app_launch_ctrl.h"
+
+namespace test {
+namespace components {
+namespace app_launch_test {
+
+class AppLaunchCtrlMock : public app_launch::AppLaunchCtrl {};
+
+} // namespace app_launch_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_CTRL_H_
diff --git a/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h
new file mode 100644
index 0000000000..881ebb2575
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_
+
+#include "gmock/gmock.h"
+#include "application_manager/app_launch/app_launch_data.h"
+
+namespace test {
+namespace components {
+namespace app_launch_test {
+
+class AppLaunchDataMock : public app_launch::AppLaunchData {
+ // AppLaunchData interface
+ public:
+ MOCK_METHOD1(AddApplicationData, bool(const app_launch::ApplicationData&));
+ MOCK_METHOD1(GetApplicationDataByDevice,
+ std::vector<app_launch::ApplicationDataPtr>(const std::string&));
+ MOCK_METHOD0(Clear, bool());
+ MOCK_METHOD0(Persist, bool());
+};
+
+} // namespace app_launch_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 066ad9baae..f57ce53e38 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2016, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
#include "application_manager/application.h"
#include "smart_objects/smart_object.h"
#include "utils/custom_string.h"
+#include "application_manager/usage_statistics.h"
namespace test {
namespace components {
@@ -142,7 +143,7 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD1(IsSubscribedToIVI, bool(uint32_t vehicle_info_type));
MOCK_METHOD1(UnsubscribeFromIVI, bool(uint32_t vehicle_info_type));
MOCK_METHOD0(ResetDataInNone, void());
- MOCK_METHOD2(IsCommandLimitsExceeded,
+ MOCK_METHOD2(AreCommandLimitsExceeded,
bool(mobile_apis::FunctionID::eType cmd_id,
::application_manager::TLimitSource source));
MOCK_METHOD0(usage_report, ::application_manager::UsageStatistics&());
@@ -271,6 +272,8 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD0(is_reset_global_properties_active, bool());
MOCK_CONST_METHOD0(app_id, uint32_t());
MOCK_CONST_METHOD0(mac_address, const std::string&());
+ MOCK_CONST_METHOD0(bundle_id, const std::string&());
+ MOCK_METHOD1(set_bundle_id, void(const std::string& bundle_id));
MOCK_METHOD0(GetAvailableDiskSpace, uint32_t());
MOCK_METHOD1(set_mobile_app_id, void(const std::string& policy_app_id));
MOCK_CONST_METHOD0(is_foreground, bool());
diff --git a/src/components/application_manager/test/include/application_manager/mock_application_manager.h b/src/components/application_manager/test/include/application_manager/mock_application_manager.h
index 6ad8aeb250..851592cc32 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application_manager.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application_manager.h
@@ -47,6 +47,9 @@
#include "application_manager/state_controller.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/state_controller.h"
namespace test {
namespace components {
@@ -170,8 +173,10 @@ class MockApplicationManager : public application_manager::ApplicationManager {
int32_t audio_type));
MOCK_METHOD0(StartDevicesDiscovery, void());
MOCK_METHOD1(StopAudioPassThru, void(int32_t application_key));
- MOCK_METHOD2(TerminateRequest,
- void(uint32_t connection_key, uint32_t corr_id));
+ MOCK_METHOD3(TerminateRequest,
+ void(const uint32_t connection_key,
+ const uint32_t corr_id,
+ const int32_t function_id));
MOCK_METHOD4(UnregisterApplication,
void(const uint32_t&, mobile_apis::Result::eType, bool, bool));
MOCK_METHOD3(updateRequestTimeout,
@@ -197,6 +202,8 @@ class MockApplicationManager : public application_manager::ApplicationManager {
bool(uint32_t connection_key,
const std::string& policy_app_id));
MOCK_METHOD0(resume_controller, resumption::ResumeCtrl&());
+ MOCK_METHOD0(hmi_interfaces, application_manager::HmiInterfaces&());
+ MOCK_METHOD0(app_launch_ctrl, app_launch::AppLaunchCtrl&());
MOCK_METHOD1(
GetDeviceTransportType,
hmi_apis::Common_TransportType::eType(const std::string& transport_type));
diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
new file mode 100644
index 0000000000..a8664f5e2c
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HMI_CAPABILITIES_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HMI_CAPABILITIES_H_
+
+#include <stdint.h>
+
+#include "application_manager/hmi_capabilities.h"
+#include "gmock/gmock.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+class MockHMICapabilities : public ::application_manager::HMICapabilities {
+ public:
+ MOCK_CONST_METHOD1(VerifyImageType, bool(const int32_t image_type));
+
+ MOCK_CONST_METHOD0(is_vr_cooperating, bool());
+ MOCK_METHOD1(set_is_vr_cooperating, void(const bool value));
+
+ MOCK_CONST_METHOD0(is_tts_cooperating, bool());
+ MOCK_METHOD1(set_is_tts_cooperating, void(const bool value));
+
+ MOCK_CONST_METHOD0(is_ui_cooperating, bool());
+ MOCK_METHOD1(set_is_ui_cooperating, void(const bool value));
+
+ MOCK_CONST_METHOD0(is_navi_cooperating, bool());
+ MOCK_METHOD1(set_is_navi_cooperating, void(const bool value));
+
+ MOCK_CONST_METHOD0(is_ivi_cooperating, bool());
+ MOCK_METHOD1(set_is_ivi_cooperating, void(const bool value));
+
+ MOCK_CONST_METHOD0(attenuated_supported, bool());
+
+ MOCK_METHOD1(set_attenuated_supported, void(const bool state));
+
+ MOCK_CONST_METHOD0(active_ui_language,
+ const hmi_apis::Common_Language::eType());
+
+ MOCK_METHOD1(set_active_ui_language,
+ void(const hmi_apis::Common_Language::eType language));
+
+ MOCK_CONST_METHOD0(ui_supported_languages,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_ui_supported_languages,
+ void(const smart_objects::SmartObject& supported_languages));
+
+ MOCK_CONST_METHOD0(active_vr_language,
+ const hmi_apis::Common_Language::eType());
+ MOCK_METHOD1(set_active_vr_language,
+ void(const hmi_apis::Common_Language::eType language));
+
+ MOCK_CONST_METHOD0(vr_supported_languages,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_vr_supported_languages,
+ void(const smart_objects::SmartObject& supported_languages));
+
+ MOCK_CONST_METHOD0(active_tts_language,
+ const hmi_apis::Common_Language::eType());
+ MOCK_METHOD1(set_active_tts_language,
+ void(const hmi_apis::Common_Language::eType language));
+
+ MOCK_CONST_METHOD0(tts_supported_languages,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_tts_supported_languages,
+ void(const smart_objects::SmartObject& supported_languages));
+
+ MOCK_CONST_METHOD0(display_capabilities, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_display_capabilities,
+ void(const smart_objects::SmartObject& display_capabilities));
+
+ MOCK_CONST_METHOD0(hmi_zone_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_hmi_zone_capabilities,
+ void(const smart_objects::SmartObject& hmi_zone_capabilities));
+
+ MOCK_CONST_METHOD0(soft_button_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(
+ set_soft_button_capabilities,
+ void(const smart_objects::SmartObject& soft_button_capabilities));
+
+ MOCK_CONST_METHOD0(button_capabilities, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_button_capabilities,
+ void(const smart_objects::SmartObject& button_capabilities));
+
+ MOCK_CONST_METHOD0(speech_capabilities, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_speech_capabilities,
+ void(const smart_objects::SmartObject& speech_capabilities));
+
+ MOCK_CONST_METHOD0(vr_capabilities, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_vr_capabilities,
+ void(const smart_objects::SmartObject& vr_capabilities));
+
+ MOCK_CONST_METHOD0(audio_pass_thru_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(
+ set_audio_pass_thru_capabilities,
+ void(const smart_objects::SmartObject& audio_pass_thru_capabilities));
+
+ MOCK_CONST_METHOD0(pcm_stream_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_pcm_stream_capabilities,
+ void(const smart_objects::SmartObject& pcm_stream_capabilities));
+
+ MOCK_CONST_METHOD0(preset_bank_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(
+ set_preset_bank_capabilities,
+ void(const smart_objects::SmartObject& preset_bank_capabilities));
+
+ MOCK_CONST_METHOD0(vehicle_type, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_vehicle_type,
+ void(const smart_objects::SmartObject& vehicle_type));
+
+ MOCK_CONST_METHOD0(prerecorded_speech, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_prerecorded_speech,
+ void(const smart_objects::SmartObject& prerecorded_speech));
+
+ MOCK_CONST_METHOD0(navigation_supported, bool());
+ MOCK_METHOD1(set_navigation_supported, void(const bool supported));
+
+ MOCK_CONST_METHOD0(phone_call_supported, bool());
+ MOCK_METHOD1(set_phone_call_supported, void(const bool supported));
+
+ MOCK_METHOD1(Init, void(resumption::LastState* last_state));
+
+ MOCK_CONST_METHOD0(ccpu_version, const std::string&());
+ MOCK_METHOD1(set_ccpu_version, void(const std::string& ccpu_version));
+ MOCK_METHOD0(get_hmi_language_handler,
+ application_manager::HMILanguageHandler&());
+ MOCK_METHOD1(set_handle_response_for,
+ void(const smart_objects::SmartObject& request));
+
+ protected:
+ MOCK_CONST_METHOD2(check_existing_json_member,
+ bool(const Json::Value& json_member,
+ const char* name_of_member));
+
+ MOCK_CONST_METHOD2(convert_json_languages_to_obj,
+ void(const Json::Value& json_languages,
+ smart_objects::SmartObject& languages));
+};
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HMI_CAPABILITIES_H_
diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_interface.h b/src/components/application_manager/test/include/application_manager/mock_hmi_interface.h
new file mode 100644
index 0000000000..c38e2711f5
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_hmi_interface.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HMI_INTERFACE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HMI_INTERFACE_H_
+
+#include "gmock/gmock.h"
+
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/hmi_interfaces_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+class MockHmiInterfaces : public application_manager::HmiInterfaces {
+ public:
+ MOCK_CONST_METHOD1(GetInterfaceState,
+ HmiInterfaces::InterfaceState(HmiInterfaces::InterfaceID));
+ MOCK_CONST_METHOD1(GetInterfaceFromFunction,
+ HmiInterfaces::InterfaceID(hmi_apis::FunctionID::eType));
+ MOCK_METHOD2(SetInterfaceState,
+ void(HmiInterfaces::InterfaceID, HmiInterfaces::InterfaceState));
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APPLICATION_MANAGER_H_
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 289b20a105..d30905fc7c 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_MOCK_MESSAGE_HELPER_H_
#include "gmock/gmock.h"
#include "application_manager/application.h"
+#include "application_manager/message_helper.h"
#include "interfaces/HMI_API.h"
#include "policy/policy_types.h"
#include "application_manager/policies/policy_handler_interface.h"
@@ -151,9 +152,13 @@ class MockMessageHelper {
smart_objects::SmartObjectList(ApplicationSharedPtr app));
MOCK_METHOD3(VerifyImageFiles,
mobile_apis::Result::eType(smart_objects::SmartObject& message,
-
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr));
+ MOCK_METHOD3(VerifyImage,
+ mobile_apis::Result::eType(smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr));
+
MOCK_METHOD6(GetBCActivateAppRequestToHMI,
smart_objects::SmartObjectSPtr(
ApplicationConstSharedPtr app,
@@ -166,6 +171,75 @@ class MockMessageHelper {
NsSmartDeviceLink::NsSmartObjects::SmartObjectSPtr(
int32_t connection_key,
mobile_apis::AppInterfaceUnregisteredReason::eType reason));
+ MOCK_METHOD4(ProcessSoftButtons,
+ mobile_apis::Result::eType(
+ smart_objects::SmartObject& message_params,
+ ApplicationConstSharedPtr app,
+ const policy::PolicyHandlerInterface& policy_handler,
+ ApplicationManager& app_mngr));
+ MOCK_METHOD3(SubscribeApplicationToSoftButton,
+ void(smart_objects::SmartObject& message_params,
+ ApplicationSharedPtr app,
+ int32_t function_id));
+ MOCK_METHOD4(CreateNegativeResponse,
+ smart_objects::SmartObjectSPtr(uint32_t connection_key,
+ int32_t function_id,
+ const uint32_t correlation_id,
+ int32_t result_code));
+ MOCK_METHOD4(
+ CreateBlockedByPoliciesResponse,
+ smart_objects::SmartObjectSPtr(mobile_apis::FunctionID::eType function_id,
+ mobile_apis::Result::eType result,
+ const uint32_t correlation_id,
+ uint32_t connection_key));
+ MOCK_METHOD0(vehicle_data, const VehicleData&());
+ MOCK_METHOD1(SendStopAudioPathThru, bool(ApplicationManager& app_mngr));
+ MOCK_METHOD1(StringifiedFunctionID,
+ std::string(const mobile_apis::FunctionID::eType function_id));
+ MOCK_METHOD2(SendUIChangeRegistrationRequestToHMI,
+ void(ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr));
+ MOCK_METHOD5(CreateHMIApplicationStruct,
+ bool(ApplicationConstSharedPtr app,
+ const protocol_handler::SessionObserver& session_observer,
+ const policy::PolicyHandlerInterface& policy_handler,
+ smart_objects::SmartObject* output,
+ ApplicationManager& app_mngr));
+ MOCK_METHOD3(SendOnAppUnregNotificationToHMI,
+ void(ApplicationConstSharedPtr app,
+ const bool is_unexpected_disconnect,
+ ApplicationManager& app_mngr));
+ MOCK_METHOD4(SendLaunchApp,
+ void(const uint32_t connection_key,
+ const std::string& urlSchema,
+ const std::string& packageName,
+ ApplicationManager& app_man));
+ MOCK_METHOD1(SendUnsubscribedWayPoints, bool(ApplicationManager& app_mngr));
+
+ MOCK_METHOD2(SendQueryApps,
+ void(const uint32_t connection_key,
+ ApplicationManager& app_man));
+ MOCK_METHOD1(CreateAppVrHelp,
+ smart_objects::SmartObjectSPtr(ApplicationConstSharedPtr app));
+ MOCK_METHOD3(VerifyImageVrHelpItems,
+ mobile_apis::Result::eType(smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr));
+
+ MOCK_METHOD1(GetPriorityCode, const uint32_t(const std::string& priority));
+
+ MOCK_METHOD1(PrintSmartObject,
+ bool(const smart_objects::SmartObject& object));
+ MOCK_METHOD3(SendTTSGlobalProperties,
+ void(ApplicationSharedPtr app,
+ const bool default_help_prompt,
+ ApplicationManager& app_man));
+ MOCK_METHOD3(SendSetAppIcon,
+ void(const uint32_t app_id,
+ const std::string& icon_path,
+ ApplicationManager& application_manager));
+ MOCK_METHOD1(StringifiedHMILevel,
+ std::string(const mobile_apis::HMILevel::eType hmi_level));
static MockMessageHelper* message_helper_mock();
};
diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
new file mode 100644
index 0000000000..b06b207f84
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_
+#include "gmock/gmock.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/application.h"
+#include "resumption/last_state.h"
+
+namespace test {
+namespace components {
+namespace resumprion_test {
+
+class MockResumeCtrl : public resumption::ResumeCtrl {
+ public:
+ MOCK_METHOD0(SaveAllApplications, void());
+ MOCK_METHOD1(SaveApplication,
+ void(app_mngr::ApplicationSharedPtr application));
+ MOCK_METHOD1(RemoveApplicationFromSaved,
+ bool(app_mngr::ApplicationConstSharedPtr application));
+ MOCK_METHOD0(OnSuspend, void());
+ MOCK_METHOD0(OnAwake, void());
+ MOCK_METHOD0(StopSavePersistentDataTimer, void());
+ MOCK_METHOD2(StartResumption,
+ bool(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash));
+ MOCK_METHOD1(StartResumptionOnlyHMILevel,
+ bool(app_mngr::ApplicationSharedPtr application));
+ MOCK_METHOD1(CheckPersistenceFilesForResumption,
+ bool(app_mngr::ApplicationSharedPtr application));
+ MOCK_METHOD2(CheckApplicationHash,
+ bool(app_mngr::ApplicationSharedPtr application,
+ const std::string& hash));
+ MOCK_METHOD1(IsHMIApplicationIdExist, bool(uint32_t hmi_app_id));
+ MOCK_METHOD2(IsApplicationSaved,
+ bool(const std::string& policy_app_id,
+ const std::string& device_id));
+ MOCK_CONST_METHOD2(GetHMIApplicationID,
+ uint32_t(const std::string& policy_app_id,
+ const std::string& device_id));
+ MOCK_METHOD0(ApplicationsDataUpdated, void());
+ MOCK_METHOD0(ResetLaunchTime, void());
+ MOCK_METHOD1(OnAppActivated,
+ void(app_mngr::ApplicationSharedPtr application));
+ MOCK_METHOD1(RemoveFromResumption, void(uint32_t app_id));
+ MOCK_METHOD1(Init, bool(resumption::LastState& last_state));
+ MOCK_METHOD2(OnAppRegistrationStart,
+ void(const std::string& policy_app_id,
+ const std::string& device_id));
+ MOCK_METHOD0(OnAppRegistrationEnd, void());
+ MOCK_CONST_METHOD2(GetSavedAppHmiLevel,
+ int32_t(const std::string&, const std::string&));
+ MOCK_METHOD1(RestoreAppHMIState,
+ bool(application_manager::ApplicationSharedPtr application));
+ MOCK_METHOD1(SetupDefaultHMILevel,
+ bool(application_manager::ApplicationSharedPtr application));
+ MOCK_METHOD1(StartAppHmiStateResumption,
+ void(application_manager::ApplicationSharedPtr application));
+ MOCK_METHOD3(SetAppHMIState,
+ bool(application_manager::ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
+ bool check_policy));
+ MOCK_CONST_METHOD0(LaunchTime, time_t());
+
+#ifdef BUILD_TESTS
+ MOCK_METHOD1(set_resumption_storage,
+ void(utils::SharedPtr<resumption::ResumptionData> mock_storage));
+#endif // BUILD_TESTS
+};
+
+} // namespace resumprion_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index c53927d3a4..57cfa5a26e 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -269,6 +269,14 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests(
app);
}
+mobile_apis::Result::eType MessageHelper::VerifyImage(
+ smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->VerifyImage(
+ message, app, app_mngr);
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
@@ -276,6 +284,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
return MockMessageHelper::message_helper_mock()->VerifyImageFiles(
message, app, app_mngr);
}
+
std::string MessageHelper::CommonLanguageToString(
hmi_apis::Common_Language::eType lang) {
return MockMessageHelper::message_helper_mock()->CommonLanguageToString(lang);
@@ -306,4 +315,139 @@ MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
reason);
}
+mobile_apis::Result::eType MessageHelper::ProcessSoftButtons(
+ smart_objects::SmartObject& message_params,
+ ApplicationConstSharedPtr app,
+ const policy::PolicyHandlerInterface& policy_handler,
+ ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->ProcessSoftButtons(
+ message_params, app, policy_handler, app_mngr);
+}
+
+void MessageHelper::SubscribeApplicationToSoftButton(
+ smart_objects::SmartObject& message_params,
+ ApplicationSharedPtr app,
+ int32_t function_id) {
+ return MockMessageHelper::message_helper_mock()
+ ->SubscribeApplicationToSoftButton(message_params, app, function_id);
+}
+
+smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse(
+ uint32_t connection_key,
+ int32_t function_id,
+ const uint32_t correlation_id,
+ int32_t result_code) {
+ return MockMessageHelper::message_helper_mock()->CreateNegativeResponse(
+ connection_key, function_id, correlation_id, result_code);
+}
+
+smart_objects::SmartObjectSPtr MessageHelper::CreateBlockedByPoliciesResponse(
+ mobile_apis::FunctionID::eType function_id,
+ mobile_apis::Result::eType result,
+ const uint32_t correlation_id,
+ uint32_t connection_key) {
+ return MockMessageHelper::message_helper_mock()
+ ->CreateBlockedByPoliciesResponse(
+ function_id, result, correlation_id, connection_key);
+}
+
+const VehicleData& MessageHelper::vehicle_data() {
+ return MockMessageHelper::message_helper_mock()->vehicle_data();
+}
+
+bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->SendStopAudioPathThru(
+ app_mngr);
+}
+
+std::string MessageHelper::StringifiedFunctionID(
+ const mobile_apis::FunctionID::eType function_id) {
+ return MockMessageHelper::message_helper_mock()->StringifiedFunctionID(
+ function_id);
+}
+
+void MessageHelper::SendUIChangeRegistrationRequestToHMI(
+ ApplicationConstSharedPtr app, ApplicationManager& app_mngr) {
+ MockMessageHelper::message_helper_mock()
+ ->SendUIChangeRegistrationRequestToHMI(app, app_mngr);
+}
+
+bool MessageHelper::CreateHMIApplicationStruct(
+ ApplicationConstSharedPtr app,
+ const protocol_handler::SessionObserver& session_observer,
+ const policy::PolicyHandlerInterface& policy_handler,
+ smart_objects::SmartObject* output,
+ ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->CreateHMIApplicationStruct(
+ app, session_observer, policy_handler, output, app_mngr);
+}
+
+void MessageHelper::SendOnAppUnregNotificationToHMI(
+ ApplicationConstSharedPtr app,
+ const bool is_unexpected_disconnect,
+ ApplicationManager& app_mngr) {
+ MockMessageHelper::message_helper_mock()->SendOnAppUnregNotificationToHMI(
+ app, is_unexpected_disconnect, app_mngr);
+}
+
+void MessageHelper::SendLaunchApp(const uint32_t connection_key,
+ const std::string& urlSchema,
+ const std::string& packageName,
+ ApplicationManager& app_man) {
+ MockMessageHelper::message_helper_mock()->SendLaunchApp(
+ connection_key, urlSchema, packageName, app_man);
+}
+
+bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->SendUnsubscribedWayPoints(
+ app_mngr);
+}
+
+void MessageHelper::SendQueryApps(const uint32_t connection_key,
+ ApplicationManager& app_man) {
+ MockMessageHelper::message_helper_mock()->SendQueryApps(connection_key,
+ app_man);
+}
+
+smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp(
+ ApplicationConstSharedPtr app) {
+ return MockMessageHelper::message_helper_mock()->CreateAppVrHelp(app);
+}
+
+mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems(
+ smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->VerifyImageVrHelpItems(
+ message, app, app_mngr);
+}
+
+const uint32_t MessageHelper::GetPriorityCode(const std::string& priority) {
+ return MockMessageHelper::message_helper_mock()->GetPriorityCode(priority);
+}
+
+void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app,
+ const bool default_help_prompt,
+ ApplicationManager& app_man) {
+ MockMessageHelper::message_helper_mock()->SendTTSGlobalProperties(
+ app, default_help_prompt, app_man);
+}
+
+bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) {
+ return MockMessageHelper::message_helper_mock()->PrintSmartObject(object);
+}
+
+void MessageHelper::SendSetAppIcon(const uint32_t app_id,
+ const std::string& icon_path,
+ ApplicationManager& application_manager) {
+ MockMessageHelper::message_helper_mock()->SendSetAppIcon(
+ app_id, icon_path, application_manager);
+}
+
+std::string MessageHelper::StringifiedHMILevel(
+ const mobile_apis::HMILevel::eType hmi_level) {
+ return MockMessageHelper::message_helper_mock()->StringifiedHMILevel(
+ hmi_level);
+}
+
} // namespace application_manager
diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
index 9857072674..27376e8118 100644
--- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -30,10 +30,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/resumption/resume_ctrl.h"
#include <string>
#include <algorithm>
+
#include "gtest/gtest.h"
+#include "application_manager/resumption/resume_ctrl_impl.h"
#include "application_manager/usage_statistics.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_resumption_data.h"
@@ -85,7 +86,7 @@ class ResumeCtrlTest : public ::testing::Test {
::utils::MakeShared<NiceMock<resumption_test::MockResumptionData>>(
app_mngr_);
app_mock = utils::MakeShared<NiceMock<MockApplication>>();
- res_ctrl = utils::MakeShared<ResumeCtrl>(app_mngr_);
+ res_ctrl = utils::MakeShared<ResumeCtrlImpl>(app_mngr_);
res_ctrl->set_resumption_storage(mock_storage);
ON_CALL(app_mngr_, state_controller())
@@ -784,6 +785,30 @@ TEST_F(ResumeCtrlTest, CheckApplicationkHash_) {
EXPECT_TRUE(res_ctrl->CheckApplicationHash(app_mock, kHash_));
}
+TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_NoAskedApp_INVALID_ENUM) {
+ const std::string app_id = "test_app_id";
+ const std::string device_id = "test_device_id";
+ EXPECT_CALL(*mock_storage, GetSavedApplication(app_id, device_id, _))
+ .WillOnce(Return(false));
+ EXPECT_EQ(mobile_apis::HMILevel::INVALID_ENUM,
+ res_ctrl->GetSavedAppHmiLevel(app_id, device_id));
+}
+
+ACTION_P(SetHmiLevel, hmi_level) {
+ arg2[am::strings::hmi_level] = hmi_level;
+}
+
+TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_AskedAppFound_INVALID_ENUM) {
+ const std::string app_id = "test_app_id";
+ const std::string device_id = "test_device_id";
+ const mobile_apis::HMILevel::eType hmi_level =
+ mobile_apis::HMILevel::HMI_FULL;
+
+ EXPECT_CALL(*mock_storage, GetSavedApplication(app_id, device_id, _))
+ .WillOnce(DoAll(SetHmiLevel(hmi_level), Return(true)));
+ EXPECT_EQ(hmi_level, res_ctrl->GetSavedAppHmiLevel(app_id, device_id));
+}
+
} // namespace resumption_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/smartDeviceLink_test.ini b/src/components/application_manager/test/smartDeviceLink_test.ini
index c544a6e02d..48f4d2c808 100644
--- a/src/components/application_manager/test/smartDeviceLink_test.ini
+++ b/src/components/application_manager/test/smartDeviceLink_test.ini
@@ -37,3 +37,19 @@ AttemptsToOpenResumptionDB = 5
# Timeout between attempts during opening DB in milliseconds
OpenAttemptTimeoutMsResumptionDB = 500
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 5abf8a9f78..14983a46b2 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -271,13 +271,13 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
* @brief Returns timeout for SDL to wait for the next package of raw data
* over audio service
*/
- const std::uint32_t audio_data_stopped_timeout() const;
+ const uint32_t audio_data_stopped_timeout() const;
/**
* @brief Returns timeout for SDL to wait for the next package of raw data
* over video service
*/
- const std::uint32_t video_data_stopped_timeout() const;
+ const uint32_t video_data_stopped_timeout() const;
/**
* @brief Returns allowable max amount of requests per time scale for
@@ -560,7 +560,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
uint32_t resumption_delay_before_ign() const;
- uint32_t resumption_delay_after_ign() const;
+ const uint32_t resumption_delay_after_ign() const;
uint32_t hash_string_size() const;
@@ -582,6 +582,44 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
*/
uint16_t open_attempt_timeout_ms_resumption_db() const;
+ /**
+ * @brief Returns wait time after device connection
+ * before app launch request
+ */
+ const uint16_t app_launch_wait_time() const OVERRIDE;
+
+ /**
+ * @brief Returns max number of attempts to launch an application
+ * after device connection
+ */
+ const uint16_t app_launch_max_retry_attempt() const OVERRIDE;
+
+ /**
+ * @brief Returns wait time before next app launch request
+ */
+ const uint16_t app_launch_retry_wait_time() const OVERRIDE;
+
+ /**
+ * @brief Returns max number of failed iOS app
+ * registration requests
+ */
+ const uint16_t remove_bundle_id_attempts() const OVERRIDE;
+
+ /**
+ * @brief Returns max number of iOS devices to be stored
+ */
+ const uint16_t max_number_of_ios_device() const OVERRIDE;
+
+ /**
+ * @brief Returns wait time before attempt to launch next app
+ */
+ const uint16_t wait_time_between_apps() const OVERRIDE;
+
+ /**
+ * @brief Returns status of feature of app launch on iOS
+ */
+ const bool enable_app_launch_ios() const OVERRIDE;
+
/*
* @brief Updates all related values from ini file
*/
@@ -752,8 +790,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
std::string system_files_path_;
uint16_t transport_manager_tcp_adapter_port_;
std::string tts_delimiter_;
- std::uint32_t audio_data_stopped_timeout_;
- std::uint32_t video_data_stopped_timeout_;
+ uint32_t audio_data_stopped_timeout_;
+ uint32_t video_data_stopped_timeout_;
std::string mme_db_name_;
std::string event_mq_name_;
std::string ack_mq_name_;
@@ -810,6 +848,13 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
bool use_db_for_resumption_;
uint16_t attempts_to_open_resumption_db_;
uint16_t open_attempt_timeout_ms_resumption_db_;
+ uint16_t app_launch_wait_time_;
+ uint16_t app_launch_max_retry_attempt_;
+ uint16_t app_launch_retry_wait_time_;
+ uint16_t remove_bundle_id_attempts_;
+ uint16_t max_number_of_ios_device_;
+ uint16_t wait_time_between_apps_;
+ bool enable_app_launch_ios_;
DISALLOW_COPY_AND_ASSIGN(Profile);
};
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index 4eacbe88ec..1a38b77254 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -84,6 +84,7 @@ const char* kIAPSection = "IAP";
const char* kProtocolHandlerSection = "ProtocolHandler";
const char* kSDL4Section = "SDL4";
const char* kResumptionSection = "Resumption";
+const char* kAppLaunchSection = "AppLaunch";
const char* kSDLVersionKey = "SDLVersion";
const char* kHmiCapabilitiesKey = "HMICapabilities";
@@ -102,7 +103,6 @@ const char* kAppIconsFolderKey = "AppIconsFolder";
const char* kAppIconsFolderMaxSizeKey = "AppIconsFolderMaxSize";
const char* kAppIconsAmountToRemoveKey = "AppIconsAmountToRemove";
const char* kLaunchHMIKey = "LaunchHMI";
-
const char* kDefaultSDLVersion = "";
#ifdef WEB_HMI
const char* kLinkToWebHMI = "LinkToWebHMI";
@@ -197,6 +197,13 @@ const char* kAttemptsToOpenResumptionDBKey = "AttemptsToOpenResumptionDB";
const char* kOpenAttemptTimeoutMsResumptionDBKey =
"OpenAttemptTimeoutMsResumptionDB";
+const char* kAppLaunchWaitTimeKey = "AppLaunchWaitTime";
+const char* kAppLaunchMaxRetryAttemptKey = "AppLaunchMaxRetryAttempt";
+const char* kAppLaunchRetryWaitTimeKey = "AppLaunchRetryWaitTime";
+const char* kRemoveBundleIDattemptsKey = "RemoveBundleIDattempts";
+const char* kMaxNumberOfiOSDeviceKey = "MaxNumberOfiOSDevice";
+const char* kWaitTimeBetweenAppsKey = "WaitTimeBetweenApps";
+const char* kEnableAppLaunchIOSKey = "EnableAppLaunchIOS";
#ifdef WEB_HMI
const char* kDefaultLinkToWebHMI = "HMI/index.html";
#endif // WEB_HMI
@@ -278,6 +285,13 @@ const uint32_t kDefaultAppIconsFolderMaxSize = 104857600;
const uint32_t kDefaultAppIconsAmountToRemove = 1;
const uint16_t kDefaultAttemptsToOpenResumptionDB = 5;
const uint16_t kDefaultOpenAttemptTimeoutMsResumptionDB = 500;
+const uint16_t kDefaultAppLaunchWaitTime = 5000;
+const uint16_t kDefaultAppLaunchMaxRetryAttempt = 3;
+const uint16_t kDefaultAppLaunchRetryWaitTime = 15000;
+const uint16_t kDefaultRemoveBundleIDattempts = 3;
+const uint16_t kDefaultMaxNumberOfiOSDevice = 10;
+const uint16_t kDefaultWaitTimeBetweenApps = 4000;
+const bool kDefaultEnableAppLaunchIOS = true;
} // namespace
namespace profile {
@@ -359,7 +373,17 @@ Profile::Profile()
, use_db_for_resumption_(false)
, attempts_to_open_resumption_db_(kDefaultAttemptsToOpenResumptionDB)
, open_attempt_timeout_ms_resumption_db_(
- kDefaultOpenAttemptTimeoutMsResumptionDB) {
+ kDefaultOpenAttemptTimeoutMsResumptionDB)
+ , app_launch_wait_time_(kDefaultAppLaunchWaitTime)
+ , app_launch_max_retry_attempt_(kDefaultAppLaunchMaxRetryAttempt)
+ , app_launch_retry_wait_time_(kDefaultAppLaunchRetryWaitTime)
+ , remove_bundle_id_attempts_(kDefaultRemoveBundleIDattempts)
+ , max_number_of_ios_device_(kDefaultMaxNumberOfiOSDevice)
+ , wait_time_between_apps_(kDefaultWaitTimeBetweenApps)
+ , enable_app_launch_ios_(kDefaultEnableAppLaunchIOS) {
+ // SDL version
+ ReadStringValue(
+ &sdl_version_, kDefaultSDLVersion, kMainSection, kSDLVersionKey);
}
Profile::~Profile() {}
@@ -525,11 +549,11 @@ const std::string& Profile::audio_stream_file() const {
return audio_stream_file_;
}
-const std::uint32_t Profile::audio_data_stopped_timeout() const {
+const uint32_t Profile::audio_data_stopped_timeout() const {
return audio_data_stopped_timeout_;
}
-const std::uint32_t Profile::video_data_stopped_timeout() const {
+const uint32_t Profile::video_data_stopped_timeout() const {
return video_data_stopped_timeout_;
}
@@ -751,7 +775,7 @@ uint32_t Profile::resumption_delay_before_ign() const {
return resumption_delay_before_ign_;
}
-uint32_t Profile::resumption_delay_after_ign() const {
+const uint32_t Profile::resumption_delay_after_ign() const {
return resumption_delay_after_ign_;
}
@@ -822,6 +846,34 @@ uint16_t Profile::open_attempt_timeout_ms_resumption_db() const {
return open_attempt_timeout_ms_resumption_db_;
}
+const uint16_t Profile::app_launch_max_retry_attempt() const {
+ return app_launch_max_retry_attempt_;
+}
+
+const uint16_t Profile::app_launch_retry_wait_time() const {
+ return app_launch_retry_wait_time_;
+}
+
+const uint16_t Profile::app_launch_wait_time() const {
+ return app_launch_wait_time_;
+}
+
+const bool Profile::enable_app_launch_ios() const {
+ return enable_app_launch_ios_;
+}
+
+const uint16_t Profile::max_number_of_ios_device() const {
+ return max_number_of_ios_device_;
+}
+
+const uint16_t Profile::remove_bundle_id_attempts() const {
+ return remove_bundle_id_attempts_;
+}
+
+const uint16_t Profile::wait_time_between_apps() const {
+ return wait_time_between_apps_;
+}
+
void Profile::UpdateValues() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1680,6 +1732,66 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(open_attempt_timeout_ms_resumption_db_,
kOpenAttemptTimeoutMsResumptionDBKey,
kResumptionSection);
+
+ // Read parameters from App Launch section
+ ReadUIntValue(&app_launch_wait_time_,
+ kDefaultAppLaunchWaitTime,
+ kAppLaunchSection,
+ kAppLaunchWaitTimeKey);
+
+ LOG_UPDATED_VALUE(
+ app_launch_wait_time_, kAppLaunchWaitTimeKey, kAppLaunchSection);
+
+ ReadUIntValue(&app_launch_max_retry_attempt_,
+ kDefaultAppLaunchMaxRetryAttempt,
+ kAppLaunchSection,
+ kAppLaunchMaxRetryAttemptKey);
+
+ LOG_UPDATED_VALUE(app_launch_max_retry_attempt_,
+ kAppLaunchMaxRetryAttemptKey,
+ kAppLaunchSection);
+
+ ReadUIntValue(&app_launch_retry_wait_time_,
+ kDefaultAppLaunchRetryWaitTime,
+ kAppLaunchSection,
+ kAppLaunchRetryWaitTimeKey);
+
+ LOG_UPDATED_VALUE(app_launch_retry_wait_time_,
+ kAppLaunchRetryWaitTimeKey,
+ kAppLaunchSection);
+
+ ReadUIntValue(&remove_bundle_id_attempts_,
+ kDefaultRemoveBundleIDattempts,
+ kAppLaunchSection,
+ kRemoveBundleIDattemptsKey);
+
+ LOG_UPDATED_VALUE(remove_bundle_id_attempts_,
+ kRemoveBundleIDattemptsKey,
+ kAppLaunchSection);
+
+ ReadUIntValue(&max_number_of_ios_device_,
+ kDefaultMaxNumberOfiOSDevice,
+ kAppLaunchSection,
+ kMaxNumberOfiOSDeviceKey);
+
+ LOG_UPDATED_VALUE(
+ max_number_of_ios_device_, kMaxNumberOfiOSDeviceKey, kAppLaunchSection);
+
+ ReadUIntValue(&wait_time_between_apps_,
+ kDefaultWaitTimeBetweenApps,
+ kAppLaunchSection,
+ kWaitTimeBetweenAppsKey);
+
+ LOG_UPDATED_VALUE(
+ wait_time_between_apps_, kWaitTimeBetweenAppsKey, kAppLaunchSection);
+
+ ReadBoolValue(&enable_app_launch_ios_,
+ kDefaultEnableAppLaunchIOS,
+ kAppLaunchSection,
+ kEnableAppLaunchIOSKey);
+
+ LOG_UPDATED_BOOL_VALUE(
+ enable_app_launch_ios_, kEnableAppLaunchIOSKey, kAppLaunchSection);
}
bool Profile::ReadValue(bool* value,
diff --git a/src/components/config_profile/test/smartDeviceLink.ini b/src/components/config_profile/test/smartDeviceLink.ini
index 41dabaa530..6ea131b095 100644
--- a/src/components/config_profile/test/smartDeviceLink.ini
+++ b/src/components/config_profile/test/smartDeviceLink.ini
@@ -183,3 +183,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true
diff --git a/src/components/config_profile/test/smartDeviceLink_invalid_boolean.ini b/src/components/config_profile/test/smartDeviceLink_invalid_boolean.ini
index 560fb5117a..f93fa39597 100644
--- a/src/components/config_profile/test/smartDeviceLink_invalid_boolean.ini
+++ b/src/components/config_profile/test/smartDeviceLink_invalid_boolean.ini
@@ -183,3 +183,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true \ No newline at end of file
diff --git a/src/components/config_profile/test/smartDeviceLink_invalid_int.ini b/src/components/config_profile/test/smartDeviceLink_invalid_int.ini
index 76bcc5a0f0..9c88a8950c 100644
--- a/src/components/config_profile/test/smartDeviceLink_invalid_int.ini
+++ b/src/components/config_profile/test/smartDeviceLink_invalid_int.ini
@@ -185,3 +185,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true \ No newline at end of file
diff --git a/src/components/config_profile/test/smartDeviceLink_invalid_pairs.ini b/src/components/config_profile/test/smartDeviceLink_invalid_pairs.ini
index 1507b2a84c..b389b0b492 100644
--- a/src/components/config_profile/test/smartDeviceLink_invalid_pairs.ini
+++ b/src/components/config_profile/test/smartDeviceLink_invalid_pairs.ini
@@ -185,3 +185,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true \ No newline at end of file
diff --git a/src/components/config_profile/test/smartDeviceLink_invalid_string.ini b/src/components/config_profile/test/smartDeviceLink_invalid_string.ini
index 6669b580c5..f18b43cb41 100644
--- a/src/components/config_profile/test/smartDeviceLink_invalid_string.ini
+++ b/src/components/config_profile/test/smartDeviceLink_invalid_string.ini
@@ -188,3 +188,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true \ No newline at end of file
diff --git a/src/components/config_profile/test/smartDeviceLink_test.ini b/src/components/config_profile/test/smartDeviceLink_test.ini
index 6e2943b569..9791544e16 100644
--- a/src/components/config_profile/test/smartDeviceLink_test.ini
+++ b/src/components/config_profile/test/smartDeviceLink_test.ini
@@ -190,3 +190,19 @@ ResumptionDelayBeforeIgn = 30;
# Timeout in seconds to restore hmi_level for media app after sdl run
ResumptionDelayAfterIgn = 30;
+
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler.h b/src/components/connection_handler/include/connection_handler/connection_handler.h
index cb22b87bbb..7e7a7db114 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -68,6 +68,18 @@ class ConnectionHandler {
virtual void ConnectToDevice(
connection_handler::DeviceHandle device_handle) = 0;
+ /**
+ * @brief RunAppOnDevice allows to run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param app_id application id also known as bundle id on some devices to
+ *run.
+ */
+ virtual void RunAppOnDevice(const std::string& device_handle,
+ const std::string& bundle_id) const = 0;
+
virtual void ConnectToAllDevices() = 0;
/**
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
index d061e55491..cd8aec0ff3 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -102,6 +102,18 @@ class ConnectionHandlerImpl
*/
void ConnectToDevice(connection_handler::DeviceHandle device_handle) OVERRIDE;
+ /**
+ * @brief RunAppOnDevice allows to run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param app_id application id also known as bundle id on some devices to
+ *run.
+ */
+ void RunAppOnDevice(const std::string& device_mac,
+ const std::string& bundle_id) const OVERRIDE;
+
void ConnectToAllDevices() OVERRIDE;
void StartTransportManager() OVERRIDE;
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index d8c05e6e6e..62a1f46fba 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -697,6 +697,20 @@ void ConnectionHandlerImpl::ConnectToDevice(
}
}
+void ConnectionHandlerImpl::RunAppOnDevice(const std::string& device_mac,
+ const std::string& bundle_id) const {
+ for (DeviceMap::const_iterator i = device_list_.begin();
+ i != device_list_.end();
+ ++i) {
+ const connection_handler::Device& device = i->second;
+ if (device.mac_address() == device_mac) {
+ transport_manager_.RunAppOnDevice(device.device_handle(), bundle_id);
+ return;
+ }
+ }
+ LOG4CXX_WARN(logger_, "No apps found on device " << device_mac);
+}
+
void ConnectionHandlerImpl::ConnectToAllDevices() {
for (DeviceMap::iterator i = device_list_.begin(); i != device_list_.end();
++i) {
diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc
index 3a8aaa70b4..08f2198fa0 100644
--- a/src/components/connection_handler/test/connection_handler_impl_test.cc
+++ b/src/components/connection_handler/test/connection_handler_impl_test.cc
@@ -65,8 +65,14 @@ enum UnnamedService { kServedService1 = 0x06, kServedService2 = 0x08 };
class ConnectionHandlerTest : public ::testing::Test {
protected:
void SetUp() OVERRIDE {
+ device_handle_ = 0;
+
+ connection_type_ = "BTMAC";
+ device_name_ = "test_name";
+ mac_address_ = "test_address";
+
connection_handler_ = new ConnectionHandlerImpl(
- mock_connection_handler_settings, mock_transport_manager);
+ mock_connection_handler_settings, mock_transport_manager_);
uid_ = 1u;
connection_key_ = connection_handler_->KeyFromPair(0, 0u);
protected_services_.clear();
@@ -87,12 +93,6 @@ class ConnectionHandlerTest : public ::testing::Test {
}
// Additional SetUp
void AddTestDeviceConnection() {
- device_handle_ = 0;
-
- connection_type_ = "BTMAC";
- device_name_ = "test_name";
- mac_address_ = "test_address";
-
const transport_manager::DeviceInfo device_info(
device_handle_, mac_address_, device_name_, connection_type_);
// Add Device and connection
@@ -239,7 +239,7 @@ class ConnectionHandlerTest : public ::testing::Test {
ConnectionHandlerImpl* connection_handler_;
testing::NiceMock<transport_manager_test::MockTransportManager>
- mock_transport_manager;
+ mock_transport_manager_;
testing::NiceMock<MockConnectionHandlerSettings>
mock_connection_handler_settings;
protocol_handler_test::MockProtocolHandler mock_protocol_handler_;
@@ -563,7 +563,7 @@ TEST_F(ConnectionHandlerTest, StartDevicesDiscovery) {
connection_handler_->set_connection_handler_observer(
&mock_connection_handler_observer);
- EXPECT_CALL(mock_transport_manager, SearchDevices());
+ EXPECT_CALL(mock_transport_manager_, SearchDevices());
EXPECT_CALL(mock_connection_handler_observer, OnDeviceListUpdated(_));
connection_handler_->StartDevicesDiscovery();
}
@@ -662,7 +662,7 @@ TEST_F(ConnectionHandlerTest, StartTransportManager) {
AddTestDeviceConnection();
AddTestSession();
- EXPECT_CALL(mock_transport_manager, Visibility(true));
+ EXPECT_CALL(mock_transport_manager_, Visibility(true));
connection_handler_->StartTransportManager();
}
@@ -759,9 +759,9 @@ TEST_F(ConnectionHandlerTest, ConnectToDevice) {
connection_handler_->OnDeviceAdded(device1);
connection_handler_->OnDeviceAdded(device2);
- EXPECT_CALL(mock_transport_manager, ConnectDevice(dev_handle1))
+ EXPECT_CALL(mock_transport_manager_, ConnectDevice(dev_handle1))
.WillOnce(Return(transport_manager::E_SUCCESS));
- EXPECT_CALL(mock_transport_manager, ConnectDevice(dev_handle2)).Times(0);
+ EXPECT_CALL(mock_transport_manager_, ConnectDevice(dev_handle2)).Times(0);
connection_handler_->ConnectToDevice(dev_handle1);
}
@@ -777,9 +777,9 @@ TEST_F(ConnectionHandlerTest, ConnectToAllDevices) {
connection_handler_->OnDeviceAdded(device1);
connection_handler_->OnDeviceAdded(device2);
- EXPECT_CALL(mock_transport_manager, ConnectDevice(dev_handle1))
+ EXPECT_CALL(mock_transport_manager_, ConnectDevice(dev_handle1))
.WillOnce(Return(transport_manager::E_SUCCESS));
- EXPECT_CALL(mock_transport_manager, ConnectDevice(dev_handle2))
+ EXPECT_CALL(mock_transport_manager_, ConnectDevice(dev_handle2))
.WillOnce(Return(transport_manager::E_SUCCESS));
connection_handler_->ConnectToAllDevices();
}
@@ -788,7 +788,7 @@ TEST_F(ConnectionHandlerTest, CloseConnection) {
AddTestDeviceConnection();
AddTestSession();
- EXPECT_CALL(mock_transport_manager, DisconnectForce(uid_));
+ EXPECT_CALL(mock_transport_manager_, DisconnectForce(uid_));
connection_handler_->CloseConnection(uid_);
}
@@ -796,7 +796,7 @@ TEST_F(ConnectionHandlerTest, CloseRevokedConnection) {
AddTestDeviceConnection();
AddTestSession();
- EXPECT_CALL(mock_transport_manager, DisconnectForce(uid_));
+ EXPECT_CALL(mock_transport_manager_, DisconnectForce(uid_));
connection_handler_->CloseRevokedConnection(connection_key_);
}
@@ -1428,6 +1428,40 @@ TEST_F(ConnectionHandlerTest, SendHeartBeat) {
connection_handler_->SendHeartBeat(uid_, start_session_id_);
}
+TEST_F(ConnectionHandlerTest, RunAppOnDevice_NoAppOnDevice_UNSUCCESS) {
+ const std::string bundle_id = "test_bundle_id";
+ const std::string mac_address0 = "test_mac_address0";
+ // All MAC addresses were stored in device list of ConnectionHandler in form
+ // of hashed string.
+ const std::string hash_of_mac_address0 = encryption::MakeHash(mac_address0);
+ const std::string hash_of_mac_address1 =
+ encryption::MakeHash("test_mac_address1");
+
+ // By default device list of ConnectionHandler was empty.
+ EXPECT_CALL(mock_transport_manager_, RunAppOnDevice(_, _)).Times(0);
+ connection_handler_->RunAppOnDevice(hash_of_mac_address0, bundle_id);
+
+ transport_manager::DeviceInfo device_info(
+ device_handle_, mac_address0, device_name_, connection_type_);
+ connection_handler_->OnDeviceAdded(device_info);
+
+ connection_handler_->RunAppOnDevice(hash_of_mac_address1, bundle_id);
+}
+
+TEST_F(ConnectionHandlerTest, RunAppOnDevice_AppOnDevice_SUCCESS) {
+ const std::string bundle_id = "test_bundle_id";
+
+ transport_manager::DeviceInfo device_info(
+ device_handle_, mac_address_, device_name_, connection_type_);
+ connection_handler_->OnDeviceAdded(device_info);
+
+ const std::string hash_of_mac_address = encryption::MakeHash(mac_address_);
+
+ EXPECT_CALL(mock_transport_manager_,
+ RunAppOnDevice(device_handle_, bundle_id));
+ connection_handler_->RunAppOnDevice(hash_of_mac_address, bundle_id);
+}
+
} // namespace connection_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/include/application_manager/app_launch_settings.h b/src/components/include/application_manager/app_launch_settings.h
new file mode 100644
index 0000000000..47daf2f87c
--- /dev/null
+++ b/src/components/include/application_manager/app_launch_settings.h
@@ -0,0 +1,22 @@
+#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_SETTINGS_H_
+#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_SETTINGS_H_
+
+#include <stdint.h>
+#include <string>
+namespace app_launch {
+class AppLaunchSettings {
+ public:
+ virtual const uint16_t app_launch_wait_time() const = 0;
+ virtual const uint16_t app_launch_max_retry_attempt() const = 0;
+ virtual const uint16_t app_launch_retry_wait_time() const = 0;
+ virtual const uint16_t remove_bundle_id_attempts() const = 0;
+ virtual const uint16_t max_number_of_ios_device() const = 0;
+ virtual const uint16_t wait_time_between_apps() const = 0;
+ virtual const bool enable_app_launch_ios() const = 0;
+ virtual const uint32_t resumption_delay_after_ign() const = 0;
+ virtual const std::string& app_storage_folder() const = 0;
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_SETTINGS_H_
diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h
index b429da88c2..899b098359 100644
--- a/src/components/include/application_manager/application_manager_settings.h
+++ b/src/components/include/application_manager/application_manager_settings.h
@@ -34,20 +34,21 @@
#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_SETTINGS_H_
#include "application_manager/request_controller_settings.h"
+#include "application_manager/app_launch_settings.h"
#include <stdint.h>
#include <string>
namespace application_manager {
-class ApplicationManagerSettings : public RequestControlerSettings {
+class ApplicationManagerSettings : public RequestControlerSettings,
+ public app_launch::AppLaunchSettings {
public:
virtual const uint32_t video_data_stopped_timeout() const = 0;
- virtual const std::uint32_t audio_data_stopped_timeout() const = 0;
+ virtual const uint32_t audio_data_stopped_timeout() const = 0;
virtual const std::pair<uint32_t, int32_t>& read_did_frequency() const = 0;
virtual const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency()
const = 0;
virtual uint32_t hash_string_size() const = 0;
- virtual const std::string& app_storage_folder() const = 0;
virtual const uint32_t& app_dir_quota() const = 0;
virtual uint32_t stop_streaming_timeout() const = 0;
virtual uint32_t application_list_update_timeout() const = 0;
@@ -82,7 +83,6 @@ class ApplicationManagerSettings : public RequestControlerSettings {
virtual const uint32_t& app_resumption_save_persistent_data_timeout()
const = 0;
virtual uint32_t resumption_delay_before_ign() const = 0;
- virtual uint32_t resumption_delay_after_ign() const = 0;
virtual const uint32_t& app_resuming_timeout() const = 0;
virtual uint16_t attempts_to_open_resumption_db() const = 0;
virtual uint16_t open_attempt_timeout_ms_resumption_db() const = 0;
@@ -94,6 +94,7 @@ class ApplicationManagerSettings : public RequestControlerSettings {
virtual const uint32_t& app_icons_amount_to_remove() const = 0;
virtual const uint32_t& list_files_response_size() const = 0;
};
+
} // namespace application_manager
#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_SETTINGS_H_
diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h
new file mode 100644
index 0000000000..39cedf3273
--- /dev/null
+++ b/src/components/include/application_manager/hmi_capabilities.h
@@ -0,0 +1,448 @@
+/*
+ * Copyright (c) 2016, 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.
+*/
+
+#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
+#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
+
+#include "interfaces/HMI_API.h"
+#include "interfaces/MOBILE_API.h"
+#include "json/json.h"
+#include "utils/macro.h"
+#include "application_manager/hmi_language_handler.h"
+
+namespace NsSmartDeviceLink {
+namespace NsSmartObjects {
+class SmartObject;
+}
+}
+namespace resumption {
+class LastState;
+}
+
+namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
+
+namespace application_manager {
+class ApplicationManager;
+
+class HMICapabilities {
+ public:
+ /*
+ * @brief Class destructor
+ *
+ */
+ virtual ~HMICapabilities() {}
+
+ /**
+ * @brief return component which follows for correctness of
+ * languages
+ * @return HMI language handler
+ */
+ virtual HMILanguageHandler& get_hmi_language_handler() = 0;
+
+ /*
+ * @brief Checks is image type(Static/Dynamic) requested by
+ * Mobile Device is supported on current HMI.
+ * @param image_type recieved type of image from Enum.
+ * @return Bool true if supported
+ */
+ virtual bool VerifyImageType(const int32_t image_type) const = 0;
+
+ /**
+ * @brief Checks if all HMI capabilities received
+ *
+ * @return TRUE if all information received, otherwise FALSE
+ */
+ virtual bool is_vr_cooperating() const = 0;
+ virtual void set_is_vr_cooperating(const bool value) = 0;
+
+ virtual bool is_tts_cooperating() const = 0;
+ virtual void set_is_tts_cooperating(const bool value) = 0;
+
+ virtual bool is_ui_cooperating() const = 0;
+ virtual void set_is_ui_cooperating(const bool value) = 0;
+
+ virtual bool is_navi_cooperating() const = 0;
+ virtual void set_is_navi_cooperating(const bool value) = 0;
+
+ virtual bool is_ivi_cooperating() const = 0;
+ virtual void set_is_ivi_cooperating(const bool value) = 0;
+
+ /*
+ * @brief Interface used to store information about software version of the
+ *target
+ *
+ * @param ccpu_version Received system/hmi software version
+ */
+ virtual void set_ccpu_version(const std::string& ccpu_version) = 0;
+
+ /*
+ * @brief Returns software version of the target
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ virtual const std::string& ccpu_version() const = 0;
+
+ /*
+ * @brief Retrieves if mixing audio is supported by HMI
+ * (ie recording TTS command and playing audio)
+ *
+ * @return Current state of the mixing audio flag
+ */
+ virtual bool attenuated_supported() const = 0;
+
+ /*
+ * @brief Sets state for mixing audio
+ *
+ * @param state New state to be set
+ */
+ virtual void set_attenuated_supported(const bool state) = 0;
+
+ /*
+ * @brief Retrieves currently active UI language
+ *
+ * @return Currently active UI language
+ */
+ virtual const hmi_apis::Common_Language::eType active_ui_language() const = 0;
+
+ /*
+ * @brief Sets currently active UI language
+ *
+ * @param language Currently active UI language
+ */
+ virtual void set_active_ui_language(
+ const hmi_apis::Common_Language::eType language) = 0;
+
+ /*
+ * @brief Retrieves UI supported languages
+ *
+ * @return Currently supported UI languages
+ */
+ virtual const smart_objects::SmartObject* ui_supported_languages() const = 0;
+
+ /*
+ * @brief Sets supported UI languages
+ *
+ * @param supported_languages Supported UI languages
+ */
+ virtual void set_ui_supported_languages(
+ const smart_objects::SmartObject& supported_languages) = 0;
+
+ /*
+ * @brief Retrieves currently active VR language
+ *
+ * @return Currently active VR language
+ */
+ virtual const hmi_apis::Common_Language::eType active_vr_language() const = 0;
+
+ /*
+ * @brief Sets currently active VR language
+ *
+ * @param language Currently active VR language
+ */
+ virtual void set_active_vr_language(
+ const hmi_apis::Common_Language::eType language) = 0;
+
+ /*
+ * @brief Retrieves VR supported languages
+ *
+ * @return Currently supported VR languages
+ */
+ virtual const smart_objects::SmartObject* vr_supported_languages() const = 0;
+
+ /*
+ * @brief Sets supported VR languages
+ *
+ * @param supported_languages Supported VR languages
+ */
+ virtual void set_vr_supported_languages(
+ const smart_objects::SmartObject& supported_languages) = 0;
+
+ /*
+ * @brief Retrieves currently active TTS language
+ *
+ * @return Currently active TTS language
+ */
+ virtual const hmi_apis::Common_Language::eType active_tts_language()
+ const = 0;
+
+ /*
+ * @brief Sets currently active TTS language
+ *
+ * @param language Currently active TTS language
+ */
+ virtual void set_active_tts_language(
+ const hmi_apis::Common_Language::eType language) = 0;
+
+ /*
+ * @brief Retrieves TTS supported languages
+ *
+ * @return Currently supported TTS languages
+ */
+ virtual const smart_objects::SmartObject* tts_supported_languages() const = 0;
+
+ /*
+ * @brief Sets supported TTS languages
+ *
+ * @param supported_languages Supported TTS languages
+ */
+ virtual void set_tts_supported_languages(
+ const smart_objects::SmartObject& supported_languages) = 0;
+
+ /*
+ * @brief Retrieves information about the display capabilities
+ *
+ * @return Currently supported display capabilities
+ */
+ virtual const smart_objects::SmartObject* display_capabilities() const = 0;
+
+ /*
+ * @brief Sets supported display capabilities
+ *
+ * @param display_capabilities supported display capabilities
+ */
+ virtual void set_display_capabilities(
+ const smart_objects::SmartObject& display_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the HMI zone capabilities
+ *
+ * @return Currently supported HMI zone capabilities
+ */
+ virtual const smart_objects::SmartObject* hmi_zone_capabilities() const = 0;
+
+ /*
+ * @brief Sets supported HMI zone capabilities
+ *
+ * @param hmi_zone_capabilities supported HMI zone capabilities
+ */
+ virtual void set_hmi_zone_capabilities(
+ const smart_objects::SmartObject& hmi_zone_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the SoftButton's capabilities
+ *
+ * @return Currently supported SoftButton's capabilities
+ */
+ virtual const smart_objects::SmartObject* soft_button_capabilities()
+ const = 0;
+
+ /*
+ * @brief Sets supported SoftButton's capabilities
+ *
+ * @param soft_button_capabilities supported SoftButton's capabilities
+ */
+ virtual void set_soft_button_capabilities(
+ const smart_objects::SmartObject& soft_button_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the Button's capabilities
+ *
+ * @return Currently supported Button's capabilities
+ */
+ virtual const smart_objects::SmartObject* button_capabilities() const = 0;
+
+ /*
+ * @brief Sets supported Button's capabilities
+ *
+ * @param soft_button_capabilities supported Button's capabilities
+ */
+ virtual void set_button_capabilities(
+ const smart_objects::SmartObject& button_capabilities) = 0;
+
+ /*
+ * @brief Sets supported speech capabilities
+ *
+ * @param speech_capabilities supported speech capabilities
+ */
+ virtual void set_speech_capabilities(
+ const smart_objects::SmartObject& speech_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the speech capabilities
+ *
+ * @return Currently supported speech capabilities
+ */
+ virtual const smart_objects::SmartObject* speech_capabilities() const = 0;
+
+ /*
+ * @brief Sets supported VR capabilities
+ *
+ * @param vr_capabilities supported VR capabilities
+ */
+ virtual void set_vr_capabilities(
+ const smart_objects::SmartObject& vr_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the VR capabilities
+ *
+ * @return Currently supported VR capabilities
+ */
+ virtual const smart_objects::SmartObject* vr_capabilities() const = 0;
+
+ /*
+ * @brief Sets supported audio_pass_thru capabilities
+ *
+ * @param vr_capabilities supported audio_pass_thru capabilities
+ */
+ virtual void set_audio_pass_thru_capabilities(
+ const smart_objects::SmartObject& audio_pass_thru_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the audio_pass_thru capabilities
+ *
+ * @return Currently supported audio_pass_thru capabilities
+ */
+ virtual const smart_objects::SmartObject* audio_pass_thru_capabilities()
+ const = 0;
+
+ /*
+ * @brief Sets supported pcm_stream capabilities
+ *
+ * @param supported pcm_stream capabilities
+ */
+ virtual void set_pcm_stream_capabilities(
+ const smart_objects::SmartObject& pcm_stream_capabilities) = 0;
+
+ /*
+ * @brief Retrieves information about the pcm_stream capabilities
+ *
+ * @return Currently supported pcm_streaming capabilities
+ */
+ virtual const smart_objects::SmartObject* pcm_stream_capabilities() const = 0;
+
+ /*
+ * @brief Retrieves information about the preset bank capabilities
+ *
+ * @return Currently supported preset bank capabilities
+ */
+ virtual const smart_objects::SmartObject* preset_bank_capabilities()
+ const = 0;
+
+ /*
+ * @brief Sets supported preset bank capabilities
+ *
+ * @param soft_button_capabilities supported preset bank capabilities
+ */
+ virtual void set_preset_bank_capabilities(
+ const smart_objects::SmartObject& preset_bank_capabilities) = 0;
+
+ /*
+ * @brief Sets vehicle information(make, model, modelYear)
+ *
+ * @param vehicle_type Cuurent vehicle information
+ */
+ virtual void set_vehicle_type(
+ const smart_objects::SmartObject& vehicle_type) = 0;
+
+ /*
+ * @brief Retrieves vehicle information(make, model, modelYear)
+ *
+ * @param vehicle_type Cuurent vehicle information
+ */
+ virtual const smart_objects::SmartObject* vehicle_type() const = 0;
+
+ /*
+ * @brief Retrieves information about the prerecorded speech
+ *
+ * @return Currently supported prerecorded speech
+ */
+ virtual const smart_objects::SmartObject* prerecorded_speech() const = 0;
+
+ /*
+ * @brief Sets supported prerecorded speech
+ *
+ * @param prerecorded_speech supported prerecorded speech
+ */
+ virtual void set_prerecorded_speech(
+ const smart_objects::SmartObject& prerecorded_speech) = 0;
+
+ /*
+ * @brief Interface used to store information if navigation
+ * supported by the system
+ *
+ * @param supported Indicates if navigation supported by the system
+ */
+ virtual void set_navigation_supported(const bool supported) = 0;
+
+ /*
+ * @brief Retrieves information if navi supported by the system
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ virtual bool navigation_supported() const = 0;
+
+ /*
+ * @brief Interface used to store information if phone call
+ * supported by the system
+ *
+ * @param supported Indicates if navigation supported by the sustem
+ */
+ virtual void set_phone_call_supported(const bool supported) = 0;
+
+ /*
+ * @brief Retrieves information if phone call supported by the system
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ virtual bool phone_call_supported() const = 0;
+
+ virtual void Init(resumption::LastState* last_state) = 0;
+
+ /**
+ * @brief Trigger waiting for response
+ * @param request Request object
+ */
+ virtual void set_handle_response_for(
+ const smart_objects::SmartObject& request) = 0;
+
+ protected:
+ /*
+ * @brief function checks if json member exists
+ *
+ * @param json_member from file hmi_capabilities.json
+ * @param name_of_member name which we should check
+ * hmi_capabilities.json
+ *
+ * @returns TRUE if member exists and returns FALSE if
+ * member does not exist.
+ */
+ virtual bool check_existing_json_member(const Json::Value& json_member,
+ const char* name_of_member) const = 0;
+
+ virtual void convert_json_languages_to_obj(
+ const Json::Value& json_languages,
+ smart_objects::SmartObject& languages) const = 0;
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_
diff --git a/src/components/include/security_manager/crypto_manager.h b/src/components/include/security_manager/crypto_manager.h
index 9b11a8e4ae..18c06ffe06 100644
--- a/src/components/include/security_manager/crypto_manager.h
+++ b/src/components/include/security_manager/crypto_manager.h
@@ -58,7 +58,7 @@ class CryptoManager : public policy::PolicyHandlerObserver {
/**
* @brief Init allows to initialize cryptomanager with certain values.
*
- * @return true in case initialization was succesfull, false otherwise.
+ * @return true in case initialization was succesful, false otherwise.
*/
virtual bool Init() = 0;
virtual SSLContext* CreateSSLContext() = 0;
diff --git a/src/components/include/test/application_manager/mock_app_launch_settings.h b/src/components/include/test/application_manager/mock_app_launch_settings.h
new file mode 100644
index 0000000000..2ceaefcae4
--- /dev/null
+++ b/src/components/include/test/application_manager/mock_app_launch_settings.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_LAUNCH_SETTINGS_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_LAUNCH_SETTINGS_H_
+
+#include <string>
+#include "gmock/gmock.h"
+#include "application_manager/app_launch_settings.h"
+
+namespace test {
+namespace components {
+namespace app_launch_test {
+
+class MockAppLaunchSettings : public app_launch::AppLaunchSettings {
+ public:
+ MOCK_CONST_METHOD0(app_launch_wait_time, const uint16_t());
+ MOCK_CONST_METHOD0(app_launch_max_retry_attempt, const uint16_t());
+ MOCK_CONST_METHOD0(app_launch_retry_wait_time, const uint16_t());
+ MOCK_CONST_METHOD0(remove_bundle_id_attempts, const uint16_t());
+ MOCK_CONST_METHOD0(max_number_of_ios_device, const uint16_t());
+ MOCK_CONST_METHOD0(wait_time_between_apps, const uint16_t());
+ MOCK_CONST_METHOD0(enable_app_launch_ios, const bool());
+ MOCK_CONST_METHOD0(resumption_delay_after_ign, const uint32_t());
+ MOCK_CONST_METHOD0(app_storage_folder, std::string&());
+};
+
+} // namespace app_launch_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_LAUNCH_SETTINGS_H_
diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h
index b1c32c982b..eee121149e 100644
--- a/src/components/include/test/application_manager/mock_application_manager_settings.h
+++ b/src/components/include/test/application_manager/mock_application_manager_settings.h
@@ -90,7 +90,7 @@ class MockApplicationManagerSettings
MOCK_CONST_METHOD0(app_resumption_save_persistent_data_timeout,
const uint32_t&());
MOCK_CONST_METHOD0(resumption_delay_before_ign, uint32_t());
- MOCK_CONST_METHOD0(resumption_delay_after_ign, uint32_t());
+ MOCK_CONST_METHOD0(resumption_delay_after_ign, const uint32_t());
MOCK_CONST_METHOD0(app_resuming_timeout, const uint32_t&());
MOCK_CONST_METHOD0(attempts_to_open_resumption_db, uint16_t());
MOCK_CONST_METHOD0(open_attempt_timeout_ms_resumption_db, uint16_t());
@@ -113,6 +113,15 @@ class MockApplicationManagerSettings
MOCK_CONST_METHOD0(app_time_scale, const uint32_t&());
MOCK_CONST_METHOD0(app_time_scale_max_requests, const uint32_t&());
MOCK_CONST_METHOD0(pending_requests_amount, const uint32_t&());
+
+ // app_launch::AppLaunchSettings
+ MOCK_CONST_METHOD0(app_launch_wait_time, const uint16_t());
+ MOCK_CONST_METHOD0(app_launch_max_retry_attempt, const uint16_t());
+ MOCK_CONST_METHOD0(app_launch_retry_wait_time, const uint16_t());
+ MOCK_CONST_METHOD0(remove_bundle_id_attempts, const uint16_t());
+ MOCK_CONST_METHOD0(max_number_of_ios_device, const uint16_t());
+ MOCK_CONST_METHOD0(wait_time_between_apps, const uint16_t());
+ MOCK_CONST_METHOD0(enable_app_launch_ios, const bool());
};
} // namespace application_manager_test
diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h
index eac82cc177..e17224b097 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler.h
@@ -59,6 +59,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler {
MOCK_METHOD0(StartTransportManager, void());
MOCK_METHOD1(ConnectToDevice,
void(connection_handler::DeviceHandle device_handle));
+ MOCK_CONST_METHOD2(RunAppOnDevice,
+ void(const std::string&, const std::string&));
MOCK_METHOD0(ConnectToAllDevices, void());
MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key));
MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle));
diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h
index 618e85a4fa..cc8bd5ab85 100644
--- a/src/components/include/test/transport_manager/mock_transport_manager.h
+++ b/src/components/include/test/transport_manager/mock_transport_manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ class MockTransportManager : public ::transport_manager::TransportManager,
MOCK_METHOD1(DisconnectForce, int(const ConnectionUID));
MOCK_METHOD1(SendMessageToDevice,
int(const ::protocol_handler::RawMessagePtr));
+ MOCK_METHOD2(RunAppOnDevice, void(const DeviceHandle, const std::string&));
MOCK_METHOD1(ReceiveEventFromDevice, int(const TransportAdapterEvent&));
MOCK_METHOD1(AddTransportAdapter, int(TransportAdapter* adapter));
MOCK_METHOD1(AddEventListener, int(TransportManagerListener* listener));
diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h
index a1dd7b9bcf..3adb6cd2e6 100644
--- a/src/components/include/transport_manager/transport_adapter/device.h
+++ b/src/components/include/transport_manager/transport_adapter/device.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@
#include "transport_manager/common.h"
#include "utils/shared_ptr.h"
+#include "utils/macro.h"
namespace transport_manager {
namespace transport_adapter {
@@ -76,6 +77,15 @@ class Device {
virtual ApplicationList GetApplicationList() const = 0;
+ /**
+ * @brief LaunchApp allows to run appropriate application on the device.
+ *
+ * @param bundle_id application identifier to run.
+ */
+ virtual void LaunchApp(const std::string& bundle_id) const {
+ UNUSED(bundle_id);
+ }
+
virtual void Stop() {}
inline const DeviceUID& unique_device_id() const {
diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h
index 3ff1aa6eee..ee726ff1d3 100644
--- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h
+++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h
@@ -2,7 +2,7 @@
* \file transport_adapter.h
* \brief TransportAdapter class header file.
*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -175,6 +175,18 @@ class TransportAdapter {
virtual Error ConnectDevice(const DeviceUID& device_handle) = 0;
/**
+ * @brief RunAppOnDevice allows to run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param app_id application id also known as bundle id on some devices to
+ *run.
+ */
+ virtual void RunAppOnDevice(const std::string& device_uid,
+ const std::string& bundle_id) = 0;
+
+ /**
* @brief Notify that listener of client connection is available.
*
* @return true - available, false - not available.
diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h
index 718f9e12aa..0847886c46 100644
--- a/src/components/include/transport_manager/transport_manager.h
+++ b/src/components/include/transport_manager/transport_manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -121,6 +121,18 @@ class TransportManager {
const protocol_handler::RawMessagePtr message) = 0;
/**
+ * @brief RunAppOnDevice allows run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param bundle_id application id alsow known as bundle id on some devices to
+ *run.
+ */
+ virtual void RunAppOnDevice(const DeviceHandle device_handle,
+ const std::string& bundle_id) = 0;
+
+ /**
* @brief Post event in the event queue.
*
* @param event Current event information.
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 09c0bb3613..d0326ce647 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -1284,6 +1284,26 @@
</param>
</struct>
+ <struct name="AppInfo">
+ <description>Contains detailed information about the registered application.</description>
+
+ <param name="appDisplayName" type="String" maxlength="100" mandatory="true">
+ <description>The name displayed for the mobile application on the mobile device (can differ from the app name set in the initial RAI request).</description>
+ </param>
+
+ <param name="appBundleID" type="String" maxlength="256" mandatory="true">
+ <description>The AppBundleID of an iOS application or package name of the Android application. This supports App Launch strategies for each platform.</description>
+ </param>
+
+ <param name="appVersion" type="String" maxlength="256" mandatory="true">
+ <description>Represents the build version number of this particular mobile app.</description>
+ </param>
+
+ <param name="appIcon" type="String" maxlength="500" mandatory="false">
+ <description>A file reference to the icon utilized by this app (simplifies the process of setting an app icon during app registration).</description>
+ </param>
+ </struct>
+
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Ford Specific Data Items -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
@@ -2447,6 +2467,11 @@
<param name="appID" type="String" maxlength="100" mandatory="true">
<description>ID used to validate app with policy table entries</description>
</param>
+ <param name="appInfo" type="AppInfo" mandatory="false">
+ <description>
+ See AppInfo.
+ </description>
+ </param>
</function>
<function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="response">
diff --git a/src/components/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy_manager_impl.cc
index 4e3f892b45..fed1a51af1 100644
--- a/src/components/policy/src/policy_manager_impl.cc
+++ b/src/components/policy/src/policy_manager_impl.cc
@@ -311,7 +311,7 @@ void PolicyManagerImpl::StartPTExchange() {
if (update_status_manager_.IsUpdateRequired()) {
if (RequestPTUpdate() && !timer_retry_sequence_.is_running()) {
// Start retry sequency
- timer_retry_sequence_.Start(NextRetryTimeout(), false);
+ timer_retry_sequence_.Start(NextRetryTimeout(), timer::kPeriodic);
}
}
}
@@ -1008,7 +1008,7 @@ void PolicyManagerImpl::RetrySequence() {
return;
}
- timer_retry_sequence_.Start(timeout, false);
+ timer_retry_sequence_.Start(timeout, timer::kPeriodic);
}
} // namespace policy
diff --git a/src/components/policy/src/usage_statistics/counter.cc b/src/components/policy/src/usage_statistics/counter.cc
index c5d7eaf9df..60e34a929d 100644
--- a/src/components/policy/src/usage_statistics/counter.cc
+++ b/src/components/policy/src/usage_statistics/counter.cc
@@ -103,7 +103,8 @@ AppStopwatchImpl::AppStopwatchImpl(
void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) {
stopwatch_type_ = stopwatch_type;
- timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND, false);
+ timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND,
+ timer::kPeriodic);
}
void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) {
diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h
index 3dedead540..d4c97d5233 100644
--- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h
+++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -414,6 +414,18 @@ class TransportAdapterImpl : public TransportAdapter,
*/
std::string GetConnectionType() const OVERRIDE;
+ /**
+ * @brief RunAppOnDevice allows run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param bundle_id application id also known as bundle id on some devices to
+ *run.
+ */
+ void RunAppOnDevice(const DeviceUID& device_uid,
+ const std::string& bundle_id) OVERRIDE;
+
#ifdef TELEMETRY_MONITOR
/**
* @brief Setup observer for time metric.
diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
index 289df3535d..4dd74086be 100644
--- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
+++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -181,6 +181,18 @@ class TransportManagerImpl
const protocol_handler::RawMessagePtr message) OVERRIDE;
/**
+ * @brief RunAppOnDevice allows to run specific application on the certain
+ *device.
+ *
+ * @param device_handle device identifier to run application on.
+ *
+ * @param bundle_id application id also known as bundle id on some devices to
+ *run.
+ */
+ void RunAppOnDevice(const DeviceHandle device_handle,
+ const std::string& bundle_id) OVERRIDE;
+
+ /**
* @brief Post event in the event queue.
*
* @param event Current event information.
diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
index 2d0d9b91d4..f0fddfb4f5 100644
--- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
+++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
@@ -951,6 +951,21 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice(DeviceSptr device) {
}
}
+void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid,
+ const std::string& bundle_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ DeviceSptr device = FindDevice(device_uid);
+ if (!device) {
+ LOG4CXX_WARN(logger_,
+ "Device with id: " << device_uid << " Not found"
+ << "withing list of connected deviced");
+ return;
+ }
+
+ device->LaunchApp(bundle_id);
+}
+
void TransportAdapterImpl::RemoveDevice(const DeviceUID& device_handle) {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Device_handle: " << &device_handle);
diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc
index 113d280c8d..8a4b01ad85 100644
--- a/src/components/transport_manager/src/transport_manager_impl.cc
+++ b/src/components/transport_manager/src/transport_manager_impl.cc
@@ -341,6 +341,34 @@ int TransportManagerImpl::SendMessageToDevice(
return E_SUCCESS;
}
+void TransportManagerImpl::RunAppOnDevice(const DeviceHandle device_handle,
+ const std::string& bundle_id) {
+ if (!this->is_initialized_) {
+ LOG4CXX_ERROR(logger_, "TransportManager is not initialized.");
+ return;
+ }
+ DeviceUID device_id = converter_.HandleToUid(device_handle);
+ LOG4CXX_DEBUG(logger_, "Convert handle to id:" << device_id);
+
+ sync_primitives::AutoReadLock lock(device_to_adapter_map_lock_);
+ DeviceToAdapterMap::iterator it = device_to_adapter_map_.find(device_id);
+ if (it == device_to_adapter_map_.end()) {
+ LOG4CXX_ERROR(logger_, "No device adapter found by id " << device_id);
+ return;
+ }
+ transport_adapter::TransportAdapter* ta = it->second;
+
+ if (!ta) {
+ LOG4CXX_ERROR(logger_,
+ "Transport adapter for device: " << device_id << " is NULL");
+ return;
+ }
+
+ ta->RunAppOnDevice(device_id, bundle_id);
+
+ return;
+}
+
int TransportManagerImpl::ReceiveEventFromDevice(
const TransportAdapterEvent& event) {
LOG4CXX_TRACE(logger_, "enter. TransportAdapterEvent: " << &event);
diff --git a/src/components/transport_manager/test/include/transport_manager/device_mock.h b/src/components/transport_manager/test/include/transport_manager/device_mock.h
index aac28fac11..a77a715ac8 100644
--- a/src/components/transport_manager/test/include/transport_manager/device_mock.h
+++ b/src/components/transport_manager/test/include/transport_manager/device_mock.h
@@ -48,6 +48,7 @@ class MockDevice : public ::transport_manager::transport_adapter::Device {
: Device(name, unique_device_id) {}
MOCK_CONST_METHOD1(IsSameAs, bool(const Device* other_device));
MOCK_CONST_METHOD0(GetApplicationList, std::vector<int>());
+ MOCK_CONST_METHOD1(LaunchApp, void(const std::string& bundle_id));
MOCK_METHOD0(Stop, void());
};
diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter_mock.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter_mock.h
index d12741f49a..815b04930a 100644
--- a/src/components/transport_manager/test/include/transport_manager/transport_adapter_mock.h
+++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter_mock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_ADAPTER_MOCK_H_
-#define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_ADAPTER_MOCK_H_
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_H_
#include "gmock/gmock.h"
#include "transport_manager/transport_adapter/transport_adapter.h"
@@ -66,6 +66,7 @@ class MockTransportAdapter
MOCK_METHOD1(ConnectDevice,
::transport_manager::transport_adapter::TransportAdapter::Error(
const ::transport_manager::DeviceUID& device_handle));
+ MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&));
MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool());
MOCK_METHOD0(
StartClientListening,
@@ -105,4 +106,4 @@ class MockTransportAdapter
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_ADAPTER_MOCK_H_
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_H_
diff --git a/src/components/transport_manager/test/smartDeviceLink_test.ini b/src/components/transport_manager/test/smartDeviceLink_test.ini
index 40aeb5a019..6fc8ab63ec 100644
--- a/src/components/transport_manager/test/smartDeviceLink_test.ini
+++ b/src/components/transport_manager/test/smartDeviceLink_test.ini
@@ -53,3 +53,18 @@ ResumptionDelayAfterIgn = 30;
# Resumption ctrl uses JSON if UseDBForResumption=false for store data otherwise uses DB
UseDBForResumption = false
+[AppLaunch]
+; time in milliseconds started from device connection - after expiring SDL remotely launches all known not-yet-registered apps from this device
+AppLaunchWaitTime = 5000
+; the number of times SDL attempts to launch an application after device connection - applied separately to each application from the given device
+AppLaunchMaxRetryAttempt = 3
+; time in milliseconds started by SDL after app launch request. if expired and app did not register, SDL sends new launch request. applied separately to each app
+AppLaunchRetryWaitTime = 15000
+; the number of the given device connections that the requested application failed to register after SDL's launch attempts - SDL removes app's bundleID on "value + 1" device connection
+RemoveBundleIDattempts = 3
+; the maximum number of iOS devices for which entries can be remembered by SDL
+MaxNumberOfiOSDevice = 10
+; time in milliseconds started after request to launch the first app. after either expires or the first app registers SDL requests to launch the second app.
+WaitTimeBetweenApps = 4000
+; App Launch on iOS devices SDL feature enabler/disabler
+EnableAppLaunchIOS = true
diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc
index 5d34a2f02f..bd4c0a3bc1 100644
--- a/src/components/transport_manager/test/transport_adapter_test.cc
+++ b/src/components/transport_manager/test/transport_adapter_test.cc
@@ -54,6 +54,7 @@ namespace components {
namespace transport_manager_test {
using ::testing::Return;
+using ::testing::ReturnRef;
using ::testing::_;
using ::testing::NiceMock;
using namespace ::transport_manager;
@@ -739,6 +740,39 @@ TEST_F(TransportAdapterTest, FindEstablishedConnection) {
EXPECT_CALL(*serverMock, Terminate());
}
+TEST_F(TransportAdapterTest, RunAppOnDevice_NoDeviseWithAskedId_UNSUCCESS) {
+ const std::string bundle_id = "test_bundle_id";
+
+ MockTransportAdapterImpl transport_adapter(
+ NULL, NULL, NULL, last_state_, transport_manager_settings);
+
+ utils::SharedPtr<MockDevice> mock_device =
+ utils::MakeShared<MockDevice>("test_device_name", "test_device_uid0");
+
+ transport_adapter.AddDevice(mock_device);
+
+ EXPECT_CALL(*mock_device, LaunchApp(bundle_id)).Times(0);
+
+ transport_adapter.RunAppOnDevice("test_device_uid1", bundle_id);
+}
+
+TEST_F(TransportAdapterTest, RunAppOnDevice_DeviseWithAskedIdWasFound_SUCCESS) {
+ const std::string bundle_id = "test_bundle_id";
+ const std::string device_uid = "test_device_uid";
+
+ MockTransportAdapterImpl transport_adapter(
+ NULL, NULL, NULL, last_state_, transport_manager_settings);
+
+ utils::SharedPtr<MockDevice> mock_device =
+ utils::MakeShared<MockDevice>("test_device_name", device_uid);
+
+ transport_adapter.AddDevice(mock_device);
+
+ EXPECT_CALL(*mock_device, LaunchApp(bundle_id));
+
+ transport_adapter.RunAppOnDevice(device_uid, bundle_id);
+}
+
} // namespace transport_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc
index ddfd827358..110b41e08b 100644
--- a/src/components/transport_manager/test/transport_manager_impl_test.cc
+++ b/src/components/transport_manager/test/transport_manager_impl_test.cc
@@ -52,6 +52,7 @@
using ::testing::_;
using ::testing::AtLeast;
using ::testing::Return;
+using ::testing::ReturnRef;
using ::protocol_handler::RawMessage;
using ::protocol_handler::RawMessagePtr;
@@ -319,9 +320,7 @@ class TransportManagerImplTest : public ::testing::Test {
MockTransportAdapter* mock_adapter_;
utils::SharedPtr<TransportManagerListenerMock> tm_listener_;
-
const ApplicationHandle application_id_ = 1;
-
ConnectionUID connection_key_;
RawMessagePtr test_message_;
DeviceHandle device_handle_;
@@ -508,9 +507,9 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_SendingFailed) {
// Arrange
HandleConnection();
- MockTMTelemetryObserver* mock_metric_observer = new MockTMTelemetryObserver();
- tm_.SetTelemetryObserver(mock_metric_observer);
- EXPECT_CALL(*mock_metric_observer, StartRawMsg(_));
+#ifdef TELEMETRY_MONITOR
+ EXPECT_CALL(mock_metric_observer_, StartRawMsg(_));
+#endif // TELEMETRY_MONITOR
EXPECT_CALL(*mock_adapter_,
SendData(mac_address_, application_id_, test_message_))
@@ -518,26 +517,25 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_SendingFailed) {
EXPECT_CALL(*tm_listener_, OnTMMessageSendFailed(_, test_message_));
EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_));
+#ifdef TELEMETRY_MONITOR
+ EXPECT_CALL(mock_metric_observer_, StopRawMsg(_)).Times(0);
+#endif // TELEMETRY_MONITOR
- EXPECT_CALL(*mock_metric_observer, StopRawMsg(_)).Times(0);
-
- delete mock_metric_observer;
testing::Mock::AsyncVerifyAndClearExpectations(kAsyncExpectationsTimeout);
}
TEST_F(TransportManagerImplTest, SendMessageToDevice_StartTimeObserver) {
// Arrange
HandleConnection();
-
- MockTMTelemetryObserver* mock_metric_observer = new MockTMTelemetryObserver();
- tm_.SetTelemetryObserver(mock_metric_observer);
EXPECT_CALL(*mock_adapter_,
SendData(mac_address_, application_id_, test_message_))
.WillOnce(Return(TransportAdapter::OK));
- EXPECT_CALL(*mock_metric_observer, StartRawMsg(_));
+
+#ifdef TELEMETRY_MONITOR
+ EXPECT_CALL(mock_metric_observer_, StartRawMsg(_));
+#endif // TELEMETRY_MONITOR
EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_));
- delete mock_metric_observer;
testing::Mock::AsyncVerifyAndClearExpectations(kAsyncExpectationsTimeout);
}
@@ -548,7 +546,9 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_SendDone) {
EXPECT_CALL(*mock_adapter_,
SendData(mac_address_, application_id_, test_message_))
.WillOnce(Return(TransportAdapter::OK));
+#ifdef TELEMETRY_MONITOR
EXPECT_CALL(mock_metric_observer_, StartRawMsg(test_message_.get()));
+#endif // TELEMETRY_MONITOR
EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_));
HandleSendDone();
@@ -563,7 +563,9 @@ TEST_F(TransportManagerImplTest, SendMessageFailed_GetHandleSendFailed) {
EXPECT_CALL(*mock_adapter_,
SendData(mac_address_, application_id_, test_message_))
.WillOnce(Return(TransportAdapter::FAIL));
+#ifdef TELEMETRY_MONITOR
EXPECT_CALL(mock_metric_observer_, StartRawMsg(test_message_.get()));
+#endif // TELEMETRY_MONITOR
EXPECT_CALL(*tm_listener_, OnTMMessageSendFailed(_, test_message_));
EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_));
@@ -1068,6 +1070,13 @@ TEST_F(TransportManagerImplTest,
tm_.TestHandle(test_event);
}
+TEST_F(TransportManagerImplTest, RunAppOnDevice_TransportAdapterFound_SUCCESS) {
+ HandleDeviceListUpdated();
+ const std::string bundle_id = "test_bundle_id";
+ EXPECT_CALL(*mock_adapter_, RunAppOnDevice(mac_address_, bundle_id));
+ tm_.RunAppOnDevice(device_handle_, bundle_id);
+}
+
} // namespace transport_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/utils/include/utils/helpers.h b/src/components/utils/include/utils/helpers.h
index 17d4af27a1..f44bdfea9b 100644
--- a/src/components/utils/include/utils/helpers.h
+++ b/src/components/utils/include/utils/helpers.h
@@ -117,6 +117,15 @@ bool Compare(T what, T to, T to1, T to2, T to3, T to4) {
Compare<T, CompareType, CmpStrategy>(what, to4));
}
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1, T to2, T to3, T to4, T to5) {
+ return CmpStrategy(
+ Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3),
+ Compare<T, CompareType, CmpStrategy>(what, to4, to5));
+}
+
template <typename Container>
bool in_range(const Container& container,
const typename Container::value_type& value) {
diff --git a/src/components/utils/include/utils/timer.h b/src/components/utils/include/utils/timer.h
index 690c9df5dc..ab3d48ef6f 100644
--- a/src/components/utils/include/utils/timer.h
+++ b/src/components/utils/include/utils/timer.h
@@ -47,6 +47,23 @@ namespace timer {
typedef uint32_t Milliseconds;
/**
+ * @brief Enumeration listing of possible timer types.
+ * Single shot timer signals only once and then stops counting.
+ * Periodic timer signals every time specific value is reached
+ * and then restarts.
+ */
+enum TimerType {
+ /**
+ * @brief Periodic calls to task
+ */
+ kPeriodic = 0,
+ /**
+ * @brief Single call to task
+ */
+ kSingleShot = 1
+};
+
+/**
* @brief Timer calls custom callback function after
* specified timeout has been elapsed.
* Thread-safe class
@@ -70,9 +87,9 @@ class Timer {
/**
* @brief Starts timer with specified timeout
* @param timeout Timer timeout
- * @param single_shot Single shot flag for timer
+ * @param enum timer_type Timer type enum value.
*/
- void Start(const Milliseconds timeout, const bool single_shot);
+ void Start(const Milliseconds timeout, const TimerType timer_type);
/**
* @brief Stops timer if it's running
diff --git a/src/components/utils/src/timer.cc b/src/components/utils/src/timer.cc
index 00272a73eb..642f16e574 100644
--- a/src/components/utils/src/timer.cc
+++ b/src/components/utils/src/timer.cc
@@ -71,11 +71,22 @@ timer::Timer::~Timer() {
LOG4CXX_DEBUG(logger_, "Timer " << name_ << " has been destroyed");
}
-void timer::Timer::Start(const Milliseconds timeout, const bool single_shot) {
+void timer::Timer::Start(const Milliseconds timeout,
+ const TimerType timer_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(state_lock_);
StopThread();
- single_shot_ = single_shot;
+ switch (timer_type) {
+ case kSingleShot: {
+ single_shot_ = true;
+ break;
+ }
+ case kPeriodic: {
+ single_shot_ = false;
+ break;
+ }
+ default: { ASSERT("timer_type should be kSingleShot or kPeriodic"); }
+ };
StartDelegate(timeout);
StartThread();
LOG4CXX_DEBUG(logger_, "Timer " << name_ << " has been started");
diff --git a/src/components/utils/test/test_generator/MOBILE_API.xml b/src/components/utils/test/test_generator/MOBILE_API.xml
index fa93a910d4..f5d1c691b7 100644
--- a/src/components/utils/test/test_generator/MOBILE_API.xml
+++ b/src/components/utils/test/test_generator/MOBILE_API.xml
@@ -1518,6 +1518,26 @@
</struct>
+ <struct name="AppInfo">
+ <description>Contains detailed information about the registered application.</description>
+
+ <param name="appDisplayName" type="String" maxlength="100" mandatory="true">
+ <description>The name displayed for the mobile application on the mobile device (can differ from the app name set in the initial RAI request).</description>
+ </param>
+
+ <param name="appBundleID" type="String" maxlength="256" mandatory="true">
+ <description>The AppBundleID of an iOS application or package name of the Android application. This supports App Launch strategies for each platform.</description>
+ </param>
+
+ <param name="appVersion" type="String" maxlength="256" mandatory="true">
+ <description>Represents the build version number of this particular mobile app.</description>
+ </param>
+
+ <param name="appIcon" type="String" maxlength="500" mandatory="false">
+ <description>A file reference to the icon utilized by this app (simplifies the process of setting an app icon during app registration).</description>
+ </param>
+ </struct>
+
<enum name="FileType">
<description>Enumeration listing possible file types.</description>
<element name="GRAPHIC_BMP" />
@@ -2360,6 +2380,11 @@
<param name="appID" type="String" maxlength="100" mandatory="true">
<description>ID used to validate app with policy table entries</description>
</param>
+ <param name="appInfo" type="AppInfo" mandatory="false">
+ <description>
+ See AppInfo.
+ </description>
+ </param>
</function>
<function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="response">
diff --git a/src/components/utils/test/timer_test.cc b/src/components/utils/test/timer_test.cc
index 63b3c663c3..ea5c9f0b84 100644
--- a/src/components/utils/test/timer_test.cc
+++ b/src/components/utils/test/timer_test.cc
@@ -47,12 +47,11 @@ sync_primitives::Lock shot_lock;
sync_primitives::ConditionalVariable shot_condition;
const std::string kTimerName = "TestTimer";
-const bool kSingleShot = true;
/*
* Default timeout used during timer testing.
* Value should be greater than at least 30 ms
- * to avoid timer firing beetwen two sequental Start/Stop calls
+ * to avoid timer firing between two sequental Start/Stop calls
*/
const uint32_t kDefaultTimeoutMs = 30u;
const uint32_t kDefaultTimeoutRestartMs = 45u;
@@ -87,7 +86,7 @@ class TestTaskWithStart : public TestTask {
public:
void PerformTimer() const OVERRIDE {
if (timer_) {
- timer_->Start(kDefaultTimeoutRestartMs, !kSingleShot);
+ timer_->Start(kDefaultTimeoutRestartMs, timer::kPeriodic);
}
}
};
@@ -113,7 +112,7 @@ TEST(TimerTest, Start_Stop_NoLoop_NoCall) {
EXPECT_FALSE(timer.is_running());
EXPECT_EQ(0u, timer.timeout());
- timer.Start(kDefaultTimeoutMs, kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kSingleShot);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -130,7 +129,7 @@ TEST(TimerTest, Start_Stop_Loop_NoCall) {
EXPECT_FALSE(timer.is_running());
EXPECT_EQ(0u, timer.timeout());
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -147,7 +146,7 @@ TEST(TimerTest, Start_Stop_NoLoop_OneCall) {
EXPECT_FALSE(timer.is_running());
EXPECT_EQ(0u, timer.timeout());
- timer.Start(kDefaultTimeoutMs, kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kSingleShot);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -172,7 +171,7 @@ TEST(TimerTest, Start_Stop_Loop_3Calls) {
EXPECT_FALSE(timer.is_running());
EXPECT_EQ(0u, timer.timeout());
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -197,11 +196,11 @@ TEST(TimerTest, Restart_NoLoop_NoCall) {
timer::Timer timer(kTimerName, mock_task);
- timer.Start(kDefaultTimeoutMs, kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kSingleShot);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
- timer.Start(kDefaultTimeoutRestartMs, kSingleShot);
+ timer.Start(kDefaultTimeoutRestartMs, timer::kSingleShot);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutRestartMs, timer.timeout());
}
@@ -212,11 +211,11 @@ TEST(TimerTest, Restart_Loop_NoCall) {
timer::Timer timer(kTimerName, mock_task);
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
- timer.Start(kDefaultTimeoutRestartMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutRestartMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutRestartMs, timer.timeout());
}
@@ -228,7 +227,7 @@ TEST(TimerTest, Restart_Loop_3Calls) {
TestTask* task = new TestTask();
timer::Timer timer(kTimerName, task);
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -236,7 +235,7 @@ TEST(TimerTest, Restart_Loop_3Calls) {
for (size_t i = 0; i < loops_count; ++i) {
shot_condition.Wait(shot_lock);
}
- timer.Start(kDefaultTimeoutRestartMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutRestartMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutRestartMs, timer.timeout());
@@ -251,7 +250,7 @@ TEST(TimerTest, Restart_NoLoop_FromCall) {
timer::Timer timer(kTimerName, task);
task->set_timer(&timer);
- timer.Start(kDefaultTimeoutMs, kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kSingleShot);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -270,7 +269,7 @@ TEST(TimerTest, Restart_Loop_FromCall) {
timer::Timer timer(kTimerName, task);
task->set_timer(&timer);
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -291,7 +290,7 @@ TEST(TimerTest, Stop_Loop_FromCall) {
timer::Timer timer(kTimerName, task);
task->set_timer(&timer);
- timer.Start(kDefaultTimeoutMs, !kSingleShot);
+ timer.Start(kDefaultTimeoutMs, timer::kPeriodic);
EXPECT_TRUE(timer.is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer.timeout());
@@ -314,7 +313,7 @@ TEST(TimerTest, Delete_Running_NoLoop) {
EXPECT_FALSE(timer->is_running());
EXPECT_EQ(0u, timer->timeout());
- timer->Start(kDefaultTimeoutMs, kSingleShot);
+ timer->Start(kDefaultTimeoutMs, timer::kSingleShot);
EXPECT_TRUE(timer->is_running());
EXPECT_EQ(kDefaultTimeoutMs, timer->timeout());