diff options
author | Alexander Kutsan <akutsan@luxoft.com> | 2017-11-13 14:49:05 +0200 |
---|---|---|
committer | Alexander Kutsan <akutsan@luxoft.com> | 2017-11-13 19:41:23 +0200 |
commit | 4fbdbd227b6b1ede4a3c2aa524f0ac688b40b430 (patch) | |
tree | 99513d66c062fe0957b6064c65d4965ea5ea94c4 | |
parent | 88c44f4cc1f732fec9cb1756feb53eaf82947f0e (diff) | |
download | sdl_core-4fbdbd227b6b1ede4a3c2aa524f0ac688b40b430.tar.gz |
Unit tests fixes
7 files changed, 47 insertions, 40 deletions
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 index fd577621cd..d892b18020 100644 --- 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 @@ -91,11 +91,6 @@ class AlertManeuverRequestTest MockAppPtr mock_app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); - if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != hmi_response) { - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response)) - .WillOnce(Return(mobile_response)); - } - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(state)); 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 index a63591318c..432e4fadc1 100644 --- a/src/components/application_manager/test/commands/mobile/change_registration_test.cc +++ b/src/components/application_manager/test/commands/mobile/change_registration_test.cc @@ -172,6 +172,8 @@ class ChangeRegistrationRequestTest EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); PrepareExpectationBeforeRun(); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(state)); command->Run(); MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map); @@ -183,9 +185,6 @@ class ChangeRegistrationRequestTest (*tts_response)[strings::params][hmi_response::code] = hmi_response; (*tts_response)[strings::msg_params] = 0; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) - .WillRepeatedly(Return(state)); - am::event_engine::Event event_ui( hmi_apis::FunctionID::UI_ChangeRegistration); event_ui.set_smart_object(*ui_response); 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 index 19765357ce..b7f1e146b4 100644 --- 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 @@ -61,6 +61,7 @@ using am::commands::DeleteCommandRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; using am::MockMessageHelper; +using am::MockHmiInterfaces; typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr; @@ -129,12 +130,15 @@ class DeleteCommandRequestTest 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_; }; @@ -154,7 +158,7 @@ TEST_F(DeleteCommandRequestTest, (*test_msg)[am::strings::vr_commands] = 0; (*test_msg)[am::strings::menu_params] = 0; - ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) @@ -171,7 +175,7 @@ TEST_F(DeleteCommandRequestTest, hmi_apis::Common_Result::SUCCESS; Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand); event_ui.set_smart_object(*msg); - + command->Init(); command->Run(); command->on_event(event_ui); @@ -185,6 +189,8 @@ TEST_F(DeleteCommandRequestTest, EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId)); + EXPECT_CALL(*mock_app_, UpdateHash()); + MessageSharedPtr vr_command_result; EXPECT_CALL( app_mngr_, @@ -212,7 +218,7 @@ TEST_F(DeleteCommandRequestTest, (*test_msg)[am::strings::vr_commands] = 0; (*test_msg)[am::strings::menu_params] = 0; - ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); ON_CALL(hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) @@ -229,6 +235,7 @@ TEST_F(DeleteCommandRequestTest, Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand); event_vr.set_smart_object(*msg); + command->Init(); command->Run(); command->on_event(event_vr); @@ -242,6 +249,11 @@ TEST_F(DeleteCommandRequestTest, EXPECT_CALL(*app, RemoveCommand(kCommandId)); + EXPECT_CALL(*app, UpdateHash()); + EXPECT_CALL(mock_message_helper_, + HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS)) + .WillRepeatedly(Return(am::mobile_api::Result::SUCCESS)); + MessageSharedPtr result_msg( CatchMobileCommandResult(CallOnEvent(*command, event_ui))); diff --git a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc index c7a4ff9852..e660723b1e 100644 --- a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc @@ -61,6 +61,7 @@ using application_manager::MockHmiInterfaces; typedef SharedPtr<GetWayPointsRequest> CommandPtr; typedef mobile_apis::Result::eType MobileResult; +typedef hmi_apis::Common_Result::eType HmiResult; namespace { const uint32_t kCorrelationId = 2u; @@ -73,10 +74,10 @@ class GetWayPointsRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: GetWayPointsRequestTest() - : message_helper_mock_(*am::MockMessageHelper::message_helper_mock()) { + : message_helper_mock_(*am::MockMessageHelper::message_helper_mock()) + , mock_app_(CreateMockApp()) { Mock::VerifyAndClearExpectations(&message_helper_mock_); } - ~GetWayPointsRequestTest() { Mock::VerifyAndClearExpectations(&message_helper_mock_); } @@ -89,11 +90,7 @@ class GetWayPointsRequestTest command_sptr_ = CreateCommand<application_manager::commands::GetWayPointsRequest>( message_); - mock_app_ = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - - ON_CALL(message_helper_mock_, HMIToMobileResult(_)) - .WillByDefault(Return(mobile_apis::Result::SUCCESS)); } MockMessageHelper& message_helper_mock_; @@ -116,7 +113,7 @@ class GetWayPointsRequestOnEventTest } void CheckOnEventResponse(const std::string& wayPointsParam, - const MobileResult ResultCode, + const HmiResult ResultCode, const bool success) { Event event(Event::EventID::Navigation_GetWayPoints); CommandPtr command(CreateCommand<GetWayPointsRequest>()); @@ -131,17 +128,15 @@ class GetWayPointsRequestOnEventTest event.set_smart_object(*event_msg); - EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_)) - .WillOnce(Return(ResultCode)); - - MockAppPtr app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); + const MobileResult mobile_result = static_cast<MobileResult>(ResultCode); + ON_CALL(message_helper_mock_, HMIToMobileResult(ResultCode)) + .WillByDefault(Return(mobile_result)); MessageSharedPtr result_msg( CatchMobileCommandResult(CallOnEvent(*command, event))); EXPECT_EQ( - ResultCode, - static_cast<mobile_apis::Result::eType>( + mobile_result, + static_cast<MobileResult>( (*result_msg)[am::strings::msg_params][am::strings::result_code] .asInt())); EXPECT_EQ( @@ -212,6 +207,8 @@ TEST_F(GetWayPointsRequestTest, hmi_apis::Common_Result::SUCCESS; event.set_smart_object(*message_); + EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_)) + .WillOnce(Return(MobileResult::SUCCESS)); CallOnEvent caller(*command_sptr_, event); 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 index 68aa76010f..ff3d686642 100644 --- 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 @@ -245,17 +245,15 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { (*dispaly_capabilities_msg)[am::hmi_response::templates_available] = "templates_available"; - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) .WillOnce(ReturnRef(hmi_capabilities)); EXPECT_CALL(hmi_capabilities, display_capabilities()) .WillOnce(Return(dispaly_capabilities_msg.get())); ON_CALL(mock_message_helper_, - HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS)) - .WillByDefault(Return(am::mobile_api::Result::SUCCESS)); + HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) + .WillByDefault(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), 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 index 2ad76f462d..a0027adba2 100644 --- 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 @@ -118,6 +118,8 @@ class SetGlobalPropertiesRequestTest vr_help_array[0][am::strings::text] = kText; vr_help_array[0][am::strings::position] = kPosition; (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); } void OnEventUISetupHelper(MessageSharedPtr msg, @@ -152,6 +154,8 @@ class SetGlobalPropertiesRequestTest (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); @@ -323,6 +327,9 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) { 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)) @@ -1063,6 +1070,8 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) { EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); @@ -1091,15 +1100,14 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) { .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); OnEventUISetupHelper(msg, command); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); event.set_smart_object(*msg); EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL)) .WillOnce(Return(true)); @@ -1126,9 +1134,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) { EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(MockAppPtr())); @@ -1182,6 +1187,8 @@ TEST_F(SetGlobalPropertiesRequestTest, EXPECT_CALL(mock_message_helper_, HMIToMobileResult(response_code)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); event.set_smart_object(*msg); @@ -1192,7 +1199,7 @@ TEST_F(SetGlobalPropertiesRequestTest, TEST_F(SetGlobalPropertiesRequestTest, OnEvent_TTSAndWarningsResultCode_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); - hmi_apis::Common_Result::eType response_code = + const hmi_apis::Common_Result::eType response_code = hmi_apis::Common_Result::WARNINGS; (*msg)[am::strings::params][am::hmi_response::code] = response_code; ON_CALL( 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 index d91087acae..5ee92cae72 100644 --- 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 @@ -328,8 +328,8 @@ TEST_F(SetMediaClockRequestTest, Run_InvalidApp_Canceled) { TEST_F(SetMediaClockRequestTest, OnEvent_Success) { MessageSharedPtr msg = CreateMessage(); (*msg)[am::strings::params][am::hmi_response::code] = - mobile_apis::Result::SUCCESS; - (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Null); EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) @@ -342,7 +342,6 @@ TEST_F(SetMediaClockRequestTest, OnEvent_Success) { Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); event.set_smart_object(*msg); - SharedPtr<SetMediaClockRequest> command( CreateCommand<SetMediaClockRequest>(msg)); command->on_event(event); |