diff options
Diffstat (limited to 'src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc')
-rw-r--r-- | src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc | 128 |
1 files changed, 110 insertions, 18 deletions
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 index 831c5cd91c..d80a7e0551 100644 --- 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 @@ -34,25 +34,46 @@ #include <string> #include "gtest/gtest.h" +#include "utils/helpers.h" #include "utils/shared_ptr.h" -#include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "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" +#include "mobile/read_did_response.h" +#include "mobile/delete_command_response.h" +#include "mobile/alert_maneuver_response.h" +#include "mobile/alert_response.h" +#include "mobile/list_files_response.h" +#include "mobile/subscribe_button_response.h" +#include "mobile/add_sub_menu_response.h" +#include "mobile/diagnostic_message_response.h" +#include "mobile/dial_number_response.h" +#include "mobile/end_audio_pass_thru_response.h" +#include "mobile/get_dtcs_response.h" +#include "mobile/get_vehicle_data_response.h" +#include "mobile/unregister_app_interface_response.h" +#include "mobile/unsubscribe_button_response.h" +#include "mobile/unsubscribe_way_points_response.h" +#include "mobile/update_turn_list_response.h" +#include "mobile/slider_response.h" +#include "mobile/speak_response.h" +#include "mobile/subscribe_vehicle_data_response.h" +#include "mobile/subscribe_way_points_response.h" +#include "mobile/system_response.h" +#include "mobile/get_way_points_response.h" +#include "mobile/perform_interaction_response.h" +#include "mobile/perform_audio_pass_thru_response.h" +#include "mobile/set_global_properties_response.h" +#include "mobile/set_media_clock_timer_response.h" +#include "mobile/show_constant_tbt_response.h" +#include "mobile/show_response.h" +#include "mobile/add_command_response.h" +#include "mobile/send_location_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/set_display_layout_response.h" +#include "mobile/generic_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/scrollable_message_response.h" +#include "mobile/change_registration_response.h" namespace test { namespace components { @@ -61,6 +82,7 @@ namespace mobile_commands_test { namespace simple_response_commands_test { namespace commands = ::application_manager::commands; +namespace am = ::application_manager; using ::testing::_; using ::testing::NotNull; @@ -90,7 +112,26 @@ typedef Types<commands::ListFilesResponse, commands::UnregisterAppInterfaceResponse, commands::UnsubscribeWayPointsResponse, commands::UpdateTurnListResponse, - commands::UnsubscribeButtonResponse> ResponseCommandsList; + commands::UnsubscribeButtonResponse, + commands::SliderResponse, + commands::SpeakResponse, + commands::SubscribeVehicleDataResponse, + commands::SubscribeWayPointsResponse, + commands::SystemResponse, + commands::GetWayPointsResponse, + commands::PerformInteractionResponse, + commands::PerformAudioPassThruResponse, + commands::SetGlobalPropertiesResponse, + commands::SetMediaClockTimerResponse, + commands::ShowConstantTBTResponse, + commands::ShowResponse, + commands::SystemResponse, + commands::AddCommandResponse, + commands::SendLocationResponse, + commands::SetAppIconResponse, + commands::SetDisplayLayoutResponse, + commands::ChangeRegistrationResponse> ResponseCommandsList; + TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList); TYPED_TEST(MobileResponseCommandsTest, Run_SendResponseToMobile_SUCCESS) { @@ -100,6 +141,57 @@ TYPED_TEST(MobileResponseCommandsTest, Run_SendResponseToMobile_SUCCESS) { command->Run(); } +class GenericResponseFromHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P2(CheckMessageParams, success, result, "") { + const bool is_msg_type_correct = + (am::MessageType::kResponse) == + static_cast<int32_t>( + (*arg)[am::strings::params][am::strings::message_type].asInt()); + const bool is_success_correct = + success == (*arg)[am::strings::msg_params][am::strings::success].asBool(); + const bool is_result_code_correct = + result == + static_cast<int32_t>( + (*arg)[am::strings::msg_params][am::strings::result_code].asInt()); + + using namespace helpers; + return Compare<bool, EQ, ALL>( + true, is_msg_type_correct, is_success_correct, is_result_code_correct); +} + +TEST_F(GenericResponseFromHMICommandsTest, Run_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + + SharedPtr<commands::GenericResponse> command( + CreateCommand<commands::GenericResponse>(command_msg)); + + EXPECT_CALL( + app_mngr_, + SendMessageToMobile( + CheckMessageParams(false, mobile_apis::Result::INVALID_DATA), false)); + + command->Run(); +} + +class ScrollableMessageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(ScrollableMessageResponseTest, Run_SUCCESS) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::SUCCESS; + + MockAppPtr app(CreateMockApp()); + + SharedPtr<am::commands::ScrollableMessageResponse> command( + CreateCommand<am::commands::ScrollableMessageResponse>(message)); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app)); + EXPECT_CALL(*app, UnsubscribeFromSoftButtons(_)); + command->Run(); +} + } // namespace simple_response_commands_test } // namespace mobile_commands_test } // namespace commands_test |