diff options
author | Yevhenii Dementieiev (GitHub) <ydementieiev@luxoft.com> | 2020-03-18 19:52:09 +0200 |
---|---|---|
committer | Yevhenii Dementieiev (GitHub) <ydementieiev@luxoft.com> | 2020-03-19 17:45:47 +0200 |
commit | b1127177808f4b1f34cebf6a5303931ce00d4f02 (patch) | |
tree | 5692b481373f465d46de9e122f6b50ebd6e29a83 | |
parent | 94d876abe38aac207b42ed707c90171bfb393f2d (diff) | |
download | sdl_core-impl/persisting_hmi_capabilities_after_SW_update.tar.gz |
Created unit tests for implementation on HMI capabilities persistence after SW updateimpl/persisting_hmi_capabilities_after_SW_update
21 files changed, 347 insertions, 5 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc index 7d9ed899a6..9a2a2ba882 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc @@ -86,6 +86,7 @@ TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeSuccess_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)); EXPECT_CALL(mock_hmi_capabilities_, set_preset_bank_capabilities(preset_bank_capabilities_)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -102,6 +103,23 @@ TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeAborted_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_preset_bank_capabilities(preset_bank_capabilities_)) .Times(0); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(ButtonGetCapabilitiesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ResponsePtr command(CreateCommand<ButtonGetCapabilitiesResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::Buttons_GetCapabilities)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc index 11589683be..70e788f533 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc @@ -131,6 +131,21 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { command->Run(); } +TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, OnSoftwareVersionReceived(ccpu_version)); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace get_system_info_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index 26f7a63872..3819c720f8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -545,7 +545,7 @@ TEST_F(HMICommandsNotificationsTest, OnReadyNotificationEventDispatcher) { std::shared_ptr<Command> command = CreateCommand<OnReadyNotification>(message); - EXPECT_CALL(app_mngr_, OnHMIStartedCooperation()); + EXPECT_CALL(app_mngr_, OnHMIReady()); EXPECT_CALL(app_mngr_, event_dispatcher()); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc index 67c36dce9c..ea3c992b86 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc @@ -166,6 +166,24 @@ TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) { EXPECT_CALL(mock_hmi_capabilities_, set_rc_capability(rc_capability_so)); EXPECT_CALL(mock_hmi_capabilities_, set_rc_supported(true)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(RCGetCapabilitiesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + RCGetCapabilitiesResponsePtr command( + CreateCommand<RCGetCapabilitiesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::RC_GetCapabilities)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc index fcb806fc68..b3e061aed2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc @@ -79,6 +79,7 @@ TEST_F(TTSGetCapabilitiesResponseTest, Run_BothExist_SUCCESS) { std::shared_ptr<TTSGetCapabilitiesResponse> command( CreateCommand<TTSGetCapabilitiesResponse>(msg)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -96,6 +97,7 @@ TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlySpeech_SUCCESS) { std::shared_ptr<TTSGetCapabilitiesResponse> command( CreateCommand<TTSGetCapabilitiesResponse>(msg)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -114,6 +116,7 @@ TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlyPrerecorded_SUCCESS) { std::shared_ptr<TTSGetCapabilitiesResponse> command( CreateCommand<TTSGetCapabilitiesResponse>(msg)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -129,6 +132,24 @@ TEST_F(TTSGetCapabilitiesResponseTest, Run_Nothing_SUCCESS) { std::shared_ptr<TTSGetCapabilitiesResponse> command( CreateCommand<TTSGetCapabilitiesResponse>(msg)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(TTSGetCapabilitiesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + std::shared_ptr<TTSGetCapabilitiesResponse> command( + CreateCommand<TTSGetCapabilitiesResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::TTS_GetCapabilities)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc index d7a41466f6..3ecc30af47 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc @@ -80,6 +80,7 @@ TEST_F(TTSGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -101,6 +102,24 @@ TEST_F(TTSGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(TTSGetLanguageResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + std::shared_ptr<TTSGetLanguageResponse> command( + CreateCommand<TTSGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::TTS_GetLanguage)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc index c0f187a85f..df2b952b6d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc @@ -57,6 +57,7 @@ using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +namespace hmi_interface = ::application_manager::hmi_interface; using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::TTSGetSupportedLanguagesResponse; @@ -95,6 +96,9 @@ TEST_F(TTSGetSupportedLanguageResponseTest, RUN_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_tts_supported_languages(( *command_msg)[strings::msg_params][hmi_response::languages])); + EXPECT_CALL(mock_hmi_capabilities_, + SaveCachedCapabilitiesToFile(hmi_interface::tts, _, _)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -115,6 +119,7 @@ TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_tts_supported_languages(supported_languages)) .Times(0); + ASSERT_TRUE(command->Init()); command->Run(); @@ -122,6 +127,23 @@ TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { am::hmi_response::languages)); } +TEST_F(TTSGetSupportedLanguageResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ResponseFromHMIPtr command( + CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::TTS_GetSupportedLanguages)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + } // namespace tts_get_supported_languages_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc index 4683fc62c7..9183c88d53 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -51,6 +51,7 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +namespace hmi_interface = ::application_manager::hmi_interface; using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::UIGetCapabilitiesResponse; @@ -99,6 +100,7 @@ TEST_F(UIGetCapabilitiesResponseTest, RUN_SetDisplay_SUCCESSS) { EXPECT_CALL(mock_hmi_capabilities_, set_display_capabilities(display_capabilities_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -119,6 +121,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetSoftButton_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_soft_button_capabilities(soft_button_capabilities_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -138,6 +141,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetHmiZone_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_hmi_zone_capabilities(hmi_zone_capabilities_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -162,6 +166,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThru_SUCCESS) { EXPECT_CALL( mock_hmi_capabilities_, set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -187,6 +192,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThruList_SUCCESS) { EXPECT_CALL( mock_hmi_capabilities_, set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -206,6 +212,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetNavigation_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_navigation_supported( hmi_capabilities_so[strings::navigation].asBool())); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -225,6 +232,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetPhoneCall_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_phone_call_supported( hmi_capabilities_so[strings::phone_call].asBool())); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -244,6 +252,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreaming_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_video_streaming_supported( hmi_capabilities_so[strings::video_streaming].asBool())); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -268,6 +277,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetNavigationCapability_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_navigation_capability(navigation_capability_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -289,6 +299,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetPhonenCapability_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_phone_capability(phone_capability_so)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -339,6 +350,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_video_streaming_capability(video_streaming_capability)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -362,6 +374,39 @@ TEST_F(UIGetCapabilitiesResponseTest, SetSystemDisplayCapabilities_SUCCESS) { command->Run(); } +TEST_F(UIGetCapabilitiesResponseTest, + SaveCachedCapabilitiesToFileCall_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + SaveCachedCapabilitiesToFile(hmi_interface::ui, _, _)); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::UI_GetCapabilities)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + } // namespace ui_get_capabilities_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc index bc15fa57a2..bd6ba0e3b0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc @@ -84,6 +84,7 @@ TEST_F(UIGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -104,6 +105,24 @@ TEST_F(UIGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(UIGetLanguageResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + std::shared_ptr<UIGetLanguageResponse> command( + CreateCommand<UIGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::UI_GetLanguage)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc index 10cf244bcf..d56c9e8090 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc @@ -54,6 +54,7 @@ using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +namespace hmi_interface = ::application_manager::hmi_interface; using sdl_rpc_plugin::commands::UIGetSupportedLanguagesResponse; typedef std::shared_ptr<UIGetSupportedLanguagesResponse> @@ -91,6 +92,9 @@ TEST_F(UIGetSupportedLanguagesResponseTest, RUN_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_ui_supported_languages((supported_languages))); + EXPECT_CALL(mock_hmi_capabilities_, + SaveCachedCapabilitiesToFile(hmi_interface::ui, _, _)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -109,6 +113,7 @@ TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_ui_supported_languages(supported_languages)) .Times(0); + ASSERT_TRUE(command->Init()); command->Run(); @@ -116,6 +121,23 @@ TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { am::hmi_response::languages)); } +TEST_F(UIGetSupportedLanguagesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + UIGetSupportedLanguagesResponsePtr command( + CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::UI_GetSupportedLanguages)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + } // namespace ui_get_supported_languages_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc index 21acf2bb70..603f6d9262 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc @@ -51,6 +51,7 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +namespace hmi_interface = ::application_manager::hmi_interface; using am::commands::CommandImpl; using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; @@ -95,6 +96,26 @@ TEST_F(VRGetCapabilitiesResponseTest, RUN_SUCCESSS) { (*command_msg)[strings::msg_params][strings::vr_capabilities]; EXPECT_CALL(mock_hmi_capabilities_, set_vr_capabilities(vr_capabilities_so)); + EXPECT_CALL(mock_hmi_capabilities_, + SaveCachedCapabilitiesToFile(hmi_interface::vr, _, _)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(VRGetCapabilitiesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + VRGetCapabilitiesResponsePtr command( + CreateCommand<VRGetCapabilitiesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::VR_GetCapabilities)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc index 9a289f9bc9..d30b349254 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc @@ -85,6 +85,7 @@ TEST_F(VRGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -106,6 +107,24 @@ TEST_F(VRGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { EXPECT_CALL(app_mngr_, event_dispatcher()) .WillOnce(ReturnRef(mock_event_dispatcher)); EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + +TEST_F(VRGetLanguageResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + std::shared_ptr<VRGetLanguageResponse> command( + CreateCommand<VRGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::VR_GetLanguage)); + ASSERT_TRUE(command->Init()); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc index b81823624c..72b7b98ad4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc @@ -54,6 +54,7 @@ using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +namespace hmi_interface = ::application_manager::hmi_interface; using sdl_rpc_plugin::commands::VRGetSupportedLanguagesResponse; typedef std::shared_ptr<VRGetSupportedLanguagesResponse> @@ -91,6 +92,9 @@ TEST_F(VRGetSupportedLanguagesResponseTest, RUN_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_vr_supported_languages((supported_languages))); + EXPECT_CALL(mock_hmi_capabilities_, + SaveCachedCapabilitiesToFile(hmi_interface::vr, _, _)); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -109,6 +113,7 @@ TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_vr_supported_languages(supported_languages)) .Times(0); + ASSERT_TRUE(command->Init()); command->Run(); @@ -116,6 +121,23 @@ TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { am::hmi_response::languages)); } +TEST_F(VRGetSupportedLanguagesResponseTest, + onTimeOut_Run_ResponseForInterface_ReceivedError) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + VRGetSupportedLanguagesResponsePtr command( + CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + OnCapabilityInitialized( + hmi_apis::FunctionID::VR_GetSupportedLanguages)); + ASSERT_TRUE(command->Init()); + + command->Run(); +} + } // namespace vr_get_supported_languages_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index 7381161039..ffc1d2bb54 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -522,7 +522,7 @@ TEST_F(HMICapabilitiesTest, EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); } - std::shared_ptr<HMICapabilitiesForTesting> hmi_capabilities = + auto hmi_capabilities = std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); hmi_capabilities->Init(last_state_wrapper_); @@ -565,7 +565,7 @@ TEST_F(HMICapabilitiesTest, EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); } - std::shared_ptr<HMICapabilitiesForTesting> hmi_capabilities = + auto hmi_capabilities = std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); hmi_capabilities->Init(last_state_wrapper_); @@ -614,7 +614,7 @@ TEST_F(HMICapabilitiesTest, EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); } - std::shared_ptr<HMICapabilitiesForTesting> hmi_capabilities = + auto hmi_capabilities = std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); hmi_capabilities->Init(last_state_wrapper_); @@ -683,6 +683,75 @@ TEST_F(HMICapabilitiesTest, SetIviCooperating) { EXPECT_EQ(true, hmi_capabilities_test->is_ivi_cooperating()); } +TEST_F( + HMICapabilitiesTest, + UpdateCapabilitiesDependingOn_ccpuVersion_FromCacheForOld_RequestForNew) { + MockApplicationManager mock_app_mngr; + event_engine_test::MockEventDispatcher mock_dispatcher; + MockApplicationManagerSettings mock_application_manager_settings; + const std::string ccpu_version = "4.1.3.B_EB355B"; + const std::string ccpu_version_new = "5.1.3.B_EB355B"; + const std::string hmi_capabilities_invalid_file = + "hmi_capabilities_invalid_file.json"; + + EXPECT_CALL(mock_application_manager_settings, hmi_capabilities_file_name()) + .WillOnce(ReturnRef(hmi_capabilities_invalid_file)); + EXPECT_CALL(mock_app_mngr, event_dispatcher()) + .WillOnce(ReturnRef(mock_dispatcher)); + EXPECT_CALL(mock_app_mngr, get_settings()) + .WillRepeatedly(ReturnRef(mock_application_manager_settings)); + EXPECT_CALL(mock_application_manager_settings, + hmi_capabilities_cache_file_name()) + .WillOnce(ReturnRef(file_cache_name_)); + + auto hmi_capabilities = + std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); + + EXPECT_CALL(mock_app_mngr, SetHMICooperating(true)); + EXPECT_CALL(mock_app_mngr, RequestForInterfacesAvailability()).Times(2); + + hmi_capabilities->set_ccpu_version(ccpu_version); + hmi_capabilities->OnSoftwareVersionReceived(ccpu_version); + + EXPECT_EQ(ccpu_version, hmi_capabilities->ccpu_version()); + + hmi_capabilities->OnSoftwareVersionReceived(ccpu_version_new); + EXPECT_EQ(ccpu_version_new, hmi_capabilities->ccpu_version()); +} + +TEST_F(HMICapabilitiesTest, + UpdateCapabilitiesForNew_ccpuVersion_DeleteCacheFile) { + MockApplicationManager mock_app_mngr; + event_engine_test::MockEventDispatcher mock_dispatcher; + MockApplicationManagerSettings mock_application_manager_settings; + const std::string ccpu_version = "4.1.3.B_EB355B"; + const std::string ccpu_version_new = "5.1.3.B_EB355B"; + const std::string hmi_capabilities_invalid_file = + "hmi_capabilities_invalid_file.json"; + + file_system::CreateFile(file_cache_name_); + EXPECT_TRUE(file_system::FileExists(file_cache_name_)); + + EXPECT_CALL(mock_application_manager_settings, hmi_capabilities_file_name()) + .WillOnce(ReturnRef(hmi_capabilities_invalid_file)); + EXPECT_CALL(mock_app_mngr, event_dispatcher()) + .WillOnce(ReturnRef(mock_dispatcher)); + EXPECT_CALL(mock_app_mngr, get_settings()) + .WillRepeatedly(ReturnRef(mock_application_manager_settings)); + EXPECT_CALL(mock_application_manager_settings, + hmi_capabilities_cache_file_name()) + .WillOnce(ReturnRef(file_cache_name_)); + + auto hmi_capabilities = + std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); + + hmi_capabilities->set_ccpu_version(ccpu_version); + hmi_capabilities->OnSoftwareVersionReceived(ccpu_version_new); + EXPECT_EQ(ccpu_version_new, hmi_capabilities->ccpu_version()); + + EXPECT_FALSE(file_system::FileExists(file_cache_name_)); +} + } // namespace application_manager_test } // namespace components } // namespace test 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 index 600b9f9d4d..10fa5466a0 100644 --- 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 @@ -203,6 +203,9 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_CONST_METHOD0(ccpu_version, const std::string&()); MOCK_METHOD1(set_ccpu_version, void(const std::string& ccpu_version)); + MOCK_CONST_METHOD1(MatchesCCPUVersion, bool(const std::string& ccpu_version)); + MOCK_METHOD1(OnSoftwareVersionReceived, + void(const std::string& ccpu_version)); MOCK_METHOD0(get_hmi_language_handler, application_manager::HMILanguageHandler&()); MOCK_METHOD1(set_handle_response_for, @@ -214,6 +217,8 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_CONST_METHOD0(DeleteCachedCapabilitiesFile, bool()); MOCK_CONST_METHOD0(GetDefaultInitializedCapabilities, std::set<hmi_apis::FunctionID::eType>()); + MOCK_METHOD1(OnCapabilityInitialized, + void(hmi_apis::FunctionID::eType requested_interface)); }; } // namespace application_manager_test diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index b2de63252e..daaf2ac4cb 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -201,7 +201,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(BeginAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac)); - MOCK_METHOD0(OnHMIStartedCooperation, void()); + MOCK_METHOD0(OnHMIReady, void()); + MOCK_METHOD0(RequestForInterfacesAvailability, void()); MOCK_METHOD1(DisconnectCloudApp, void(application_manager::ApplicationSharedPtr app)); MOCK_METHOD0(RefreshCloudAppInformation, void()); @@ -211,6 +212,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(PolicyIDByIconUrl, std::string(const std::string url)); MOCK_METHOD1(SetIconFileFromSystemRequest, void(const std::string policy_id)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); + MOCK_METHOD1(SetHMICooperating, void(const bool hmi_cooperating)); MOCK_METHOD2(IviInfoUpdated, void(const std::string& vehicle_info, int value)); MOCK_METHOD1(RegisterApplication, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index f6e0b3cb0f..6e24b9b121 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -181,6 +181,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD0(OnVIIsReady, void()); MOCK_METHOD1(OnVehicleDataUpdated, diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index b74ddbd13c..8a55e1b86c 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -210,6 +210,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index d2023fd3d4..4f8a348c97 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -305,6 +305,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(OnSystemRequestReceived, void()); MOCK_METHOD0(RetrySequenceFailed, void()); MOCK_METHOD0(ResetTimeout, void()); + MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); }; } // namespace policy_manager_test } // namespace components diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index e592caf3bc..5bba7034f8 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -184,6 +184,7 @@ class MockCacheManagerInterface : public CacheManagerInterface { bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index da9edb9fe5..4d7d9d78b8 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -307,6 +307,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD1(GetAppRequestSubTypesState, RequestSubType::State(const std::string& policy_app_id)); MOCK_METHOD0(ResetTimeout, void()); + MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); }; } // namespace policy_manager_test |