diff options
author | Andriy Byzhynar (GitHub) <AByzhynar@luxoft.com> | 2016-11-21 15:28:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-21 15:28:17 +0200 |
commit | cd9c239076b02435572a2753abc25d848d833cfd (patch) | |
tree | 44862ba8e89c7d2e9a6156f9741fda4cd27862ac | |
parent | d98c8a8b40942efc4c0cee159687ee4c6c1317f6 (diff) | |
parent | e0a812a4ef741a8e2ece4854951165056b6954c3 (diff) | |
download | sdl_core-cd9c239076b02435572a2753abc25d848d833cfd.tar.gz |
Merge pull request #1041 from LevchenkoS/fix/Fix_test_failure
Fix test failure
12 files changed, 144 insertions, 68 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc index 64043d2a88..82836717a3 100644 --- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc @@ -56,8 +56,7 @@ void OnButtonEventNotification::Run() { const bool is_app_id_exists = (*message_)[strings::msg_params].keyExists(strings::app_id); - const ApplicationSharedPtr app = application_manager_.application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); + ApplicationSharedPtr app; // CUSTOM_BUTTON notification if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { @@ -67,6 +66,9 @@ void OnButtonEventNotification::Run() { return; } + app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + // custom_button_id is mandatory for CUSTOM_BUTTON notification if (false == (*message_)[strings::msg_params].keyExists( diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc index b789b7c7e9..c77cd9fbba 100755..100644 --- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc @@ -56,8 +56,7 @@ void OnButtonPressNotification::Run() { const bool is_app_id_exists = (*message_)[strings::msg_params].keyExists(strings::app_id); - const ApplicationSharedPtr app = application_manager_.application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); + ApplicationSharedPtr app; // CUSTOM_BUTTON notification if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { @@ -67,6 +66,9 @@ void OnButtonPressNotification::Run() { return; } + app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + // custom_button_id is mandatory for CUSTOM_BUTTON notification if (false == (*message_)[strings::msg_params].keyExists( 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 d4a25ee112..3bf9ea0f07 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 @@ -89,7 +89,8 @@ class ChangeRegistrationRequestTest public: ChangeRegistrationRequestTest() : mock_message_helper_(*MockMessageHelper::message_helper_mock()) - , mock_app_(CreateMockApp()) {} + , mock_app_(CreateMockApp()) + , supported_languages_(CreateMessage(smart_objects::SmartType_Array)) {} MessageSharedPtr CreateMsgFromMobile() { MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); @@ -104,15 +105,14 @@ class ChangeRegistrationRequestTest 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); + (*supported_languages_)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); EXPECT_CALL(hmi_capabilities_, ui_supported_languages()) - .WillOnce(Return(&supported_languages)); + .WillOnce(Return(supported_languages_.get())); EXPECT_CALL(hmi_capabilities_, vr_supported_languages()) - .WillOnce(Return(&supported_languages)); + .WillOnce(Return(supported_languages_.get())); EXPECT_CALL(hmi_capabilities_, tts_supported_languages()) - .WillOnce(Return(&supported_languages)); + .WillOnce(Return(supported_languages_.get())); EXPECT_CALL(app_mngr_, hmi_interfaces()) .WillRepeatedly(ReturnRef(hmi_interfaces_)); @@ -288,6 +288,7 @@ class ChangeRegistrationRequestTest NiceMock<MockHmiInterfaces> hmi_interfaces_; MockMessageHelper& mock_message_helper_; MockAppPtr mock_app_; + MessageSharedPtr supported_languages_; }; typedef ChangeRegistrationRequestTest::MockHMICapabilities MockHMICapabilities; 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 index 4f401bcefc..60697446f2 100644 --- 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 @@ -44,6 +44,7 @@ #include "application_manager/mock_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/commands/mobile/diagnostic_message_request.h" #include "interfaces/MOBILE_API.h" @@ -70,7 +71,17 @@ const uint32_t kDiagnosticMode = 5u; } // namespace class DiagnosticMessageRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DiagnosticMessageRequestTest() + : mock_message_helper_(*am::MockMessageHelper::message_helper_mock()) { + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + ~DiagnosticMessageRequestTest() { + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + am::MockMessageHelper& mock_message_helper_; +}; TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); @@ -170,6 +181,10 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) { DiagnosticMessageRequestPtr command( CreateCommand<DiagnosticMessageRequest>()); + EXPECT_CALL(mock_message_helper_, + HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); 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 index 1f851dd8a7..61f6c60b2d 100644 --- 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 @@ -70,7 +70,19 @@ const uint32_t kConnectionKey = 2u; } // namespace class GetVehicleDataRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + GetVehicleDataRequestTest() + : mock_message_helper_(*am::MockMessageHelper::message_helper_mock()) { + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + + ~GetVehicleDataRequestTest() { + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + + am::MockMessageHelper& mock_message_helper_; +}; class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { public: @@ -138,7 +150,7 @@ TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) { CreateCommand<GetVehicleDataRequest>(command_msg)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data()) + EXPECT_CALL(mock_message_helper_, vehicle_data()) .WillOnce(ReturnRef(kEmptyVehicleData)); MockAppPtr app(CreateMockApp()); @@ -161,7 +173,7 @@ TEST_F(GetVehicleDataRequestTest, CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data()) + EXPECT_CALL(mock_message_helper_, vehicle_data()) .WillRepeatedly(ReturnRef(kEmptyVehicleData)); std::vector<std::string>& disallowed_params = @@ -192,7 +204,7 @@ TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) { am::VehicleData vehicle_data; vehicle_data.insert( am::VehicleData::value_type(kMsgParamKey, am::VehicleDataType::SPEED)); - EXPECT_CALL(*am::MockMessageHelper::message_helper_mock(), vehicle_data()) + EXPECT_CALL(mock_message_helper_, vehicle_data()) .WillOnce(ReturnRef(vehicle_data)); MockAppPtr app(CreateMockApp()); @@ -221,6 +233,11 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { } TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + const mobile_result::eType mobile_response_code = + mobile_result::VEHICLE_DATA_NOT_AVAILABLE; + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; @@ -229,18 +246,18 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { 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::hmi_response::code] = hmi_response_code; (*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), _)); + EXPECT_CALL(mock_message_helper_, HMIToMobileResult(hmi_response_code)) + .WillOnce(Return(mobile_response_code)); + + EXPECT_CALL(app_mngr_, + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); command->on_event(event); } 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 index 8efb3498cc..793f379286 100644 --- 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 @@ -78,7 +78,7 @@ struct NotificationData { template <class NotificationDataT> class OnButtonNotificationCommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice>, + : public CommandsTest<CommandsTestMocks::kNotNice>, public NotificationDataT {}; typedef Types<NotificationData<commands::mobile::OnButtonEventNotification, @@ -152,6 +152,9 @@ TYPED_TEST(OnButtonNotificationCommandsTest, 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(this->app_mngr_, SendMessageToMobile(_, _)).Times(0); command->Run(); @@ -318,6 +321,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { MessageSharedPtr notification_msg( this->CreateMessage(smart_objects::SmartType_Map)); + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = kButtonName; @@ -331,6 +335,8 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { EXPECT_CALL(*mock_app, hmi_level()) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + ON_CALL(*mock_app, IsFullscreen()).WillByDefault(Return(true)); + EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) .WillOnce(Return(subscribed_apps_list)); 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 index 61dcc35d5a..fe8a42b1cc 100644 --- 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 @@ -191,6 +191,9 @@ TEST_F(PerformAudioPassThruRequestTest, (*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); + ON_CALL(mock_message_helper_, + HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) + .WillByDefault(Return(mobile_apis::Result::SUCCESS)); command->on_event(event_tts); MessageSharedPtr ui_command_result; 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 index 89b65323ca..111dbf4e27 100644 --- 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 @@ -41,6 +41,7 @@ #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/commands/mobile/read_did_request.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" @@ -79,19 +80,27 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); - const mobile_apis::Result::eType kResultCode = mobile_apis::Result::SUCCESS; + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::SUCCESS; + const mobile_apis::Result::eType mobile_response_code = + 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::params][am::hmi_response::code] = hmi_response_code; (*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())); + am::MockMessageHelper& mock_message_helper( + *am::MockMessageHelper::message_helper_mock()); + EXPECT_CALL(mock_message_helper, HMIToMobileResult(hmi_response_code)) + .WillOnce(Return(mobile_response_code)); + + EXPECT_CALL(app_mngr_, + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); + + command->on_event(event); + + testing::Mock::VerifyAndClearExpectations(&mock_message_helper); } TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) { 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 1052352272..2e09839fc4 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 @@ -74,7 +74,19 @@ class SetDisplayLayoutRequestTest public: SetDisplayLayoutRequestTest() : mock_message_helper_(*MockMessageHelper::message_helper_mock()) - , mock_app_(CreateMockApp()) {} + , mock_app_(CreateMockApp()) { + Mock::VerifyAndClearExpectations(&mock_message_helper_); + + 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_)); + } + + ~SetDisplayLayoutRequestTest() { + Mock::VerifyAndClearExpectations(&mock_message_helper_); + } MessageSharedPtr CreateFullParamsUISO() { MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); @@ -95,18 +107,6 @@ class SetDisplayLayoutRequestTest 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 diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc index 32d7179afd..738cf35553 100644 --- a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -43,6 +43,7 @@ #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/smart_object_keys.h" #include "application_manager/event_engine/event.h" @@ -71,13 +72,20 @@ class UnSubscribeWayPointsRequestTest public: UnSubscribeWayPointsRequestTest() : command_msg_(CreateMessage(smart_objects::SmartType_Map)) - , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) { + , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) + , mock_message_helper_(*am::MockMessageHelper::message_helper_mock()) { (*command_msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + + ~UnSubscribeWayPointsRequestTest() { + testing::Mock::VerifyAndClearExpectations(&mock_message_helper_); } MessageSharedPtr command_msg_; ::utils::SharedPtr<UnSubscribeWayPointsRequest> command_; + am::MockMessageHelper& mock_message_helper_; }; TEST_F(UnSubscribeWayPointsRequestTest, @@ -157,6 +165,10 @@ TEST_F(UnSubscribeWayPointsRequestTest, EXPECT_CALL(app_mngr_, UnsubscribeAppFromWayPoints(kAppId)); + EXPECT_CALL(mock_message_helper_, + HMIToMobileResult(hmi_apis::Common_Result::SUCCESS)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); 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 index 5127324f28..cab67e641c 100644 --- 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 @@ -265,46 +265,43 @@ TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { TEST_F(UpdateTurnListRequestTest, OnEvent_UnsupportedResource_SUCCESS) { MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); - (*event_msg)[am::strings::params][am::hmi_response::code] = + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + const mobile_result::eType mobile_response_code = mobile_result::UNSUPPORTED_RESOURCE; + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code; (*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(mock_message_helper_, HMIToMobileResult(hmi_response_code)) + .WillOnce(Return(mobile_response_code)); EXPECT_CALL(app_mngr_, - ManageMobileCommand( - MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _)); + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); command_->on_event(event); } TEST_F(UpdateTurnListRequestTest, OnEvent_ReceivedNavigationUpdateTurnListEvent_SUCCESS) { + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::SUCCESS; + const mobile_result::eType mobile_response_code = mobile_result::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::params][am::hmi_response::code] = hmi_response_code; (*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(mock_message_helper_, HMIToMobileResult(hmi_response_code)) + .WillOnce(Return(mobile_response_code)); - EXPECT_CALL( - app_mngr_, - ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + EXPECT_CALL(app_mngr_, + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); command_->on_event(event); } 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 index 232b8fef0b..399b76e3f3 100644 --- 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 @@ -42,22 +42,27 @@ #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_hmi_interface.h" #include "application_manager/mock_application.h" namespace test { namespace components { namespace commands_test { +namespace am = ::application_manager; + using ::testing::ReturnRef; +using ::testing::Return; using ::testing::NiceMock; +using ::testing::_; using ::utils::SharedPtr; using ::smart_objects::SmartObject; -using ::application_manager::commands::MessageSharedPtr; +using am::commands::MessageSharedPtr; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; +using am::ApplicationSharedPtr; using ::test::components::application_manager_test::MockApplication; // Depending on the value type will be selected @@ -93,7 +98,6 @@ class CommandsTest : public ::testing::Test { typedef typename TypeIf<kIsNice, NiceMock<MockApplication>, MockApplication>::Result MockApp; - typedef SharedPtr<MockApp> MockAppPtr; virtual ~CommandsTest() {} @@ -131,6 +135,7 @@ class CommandsTest : public ::testing::Test { MockAppManager app_mngr_; MockAppManagerSettings app_mngr_settings_; + MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_; protected: virtual void InitCommand(const uint32_t& timeout) { @@ -140,7 +145,14 @@ class CommandsTest : public ::testing::Test { .WillByDefault(ReturnRef(timeout)); } - CommandsTest() {} + CommandsTest() { + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(mock_hmi_interfaces_)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_SDL)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + } }; } // namespace commands_test |