diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc | 496 |
1 files changed, 452 insertions, 44 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc index f1f7c4c907..193229eeb0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc @@ -70,35 +70,107 @@ namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; namespace { +const int32_t kCorrelationId = 1u; const int32_t kCommandId = 1; const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 2u; +const int32_t kUiChoiceID = 1u; +const int32_t kVrChoiceID = 2u; +const int32_t kInvalidChoiceId = -1; } // namespace class PerformInteractionRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: - PerformInteractionRequestTest() : mock_app_(CreateMockApp()) {} + PerformInteractionRequestTest() + : mock_app_(CreateMockApp()) + , performinteraction_choice_set_lock_ptr_( + std::make_shared<sync_primitives::RecursiveLock>()) {} void SetUp() OVERRIDE { + smart_objects::SmartObject choice_set1( + smart_objects::SmartType::SmartType_Map); + smart_objects::SmartObject choice_set2( + smart_objects::SmartType::SmartType_Map); + + choice_set1[strings::choice_set] = + smart_objects::SmartType::SmartType_Array; + choice_set2[strings::choice_set] = + smart_objects::SmartType::SmartType_Array; + + choice_set1[strings::choice_set][0][strings::choice_id] = kUiChoiceID; + choice_set2[strings::choice_set][0][strings::choice_id] = kVrChoiceID; + + choice_set_map_[kCorrelationId].insert(std::make_pair( + kUiChoiceID, new smart_objects::SmartObject(choice_set1))); + choice_set_map_[kCorrelationId].insert(std::make_pair( + kVrChoiceID, new smart_objects::SmartObject(choice_set2))); + ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, performinteraction_choice_set_map()) + .WillByDefault(Return(DataAccessor<app_mngr::PerformChoiceSetMap>( + choice_set_map_, performinteraction_choice_set_lock_ptr_))); } void ResultCommandExpectations(MessageSharedPtr msg, + bool success, + hmi_apis::Common_Result::eType result_code, const std::string& info) { - EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), - true); + EXPECT_EQ((*msg)[strings::msg_params][strings::success].asBool(), success); + EXPECT_EQ((*msg)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(result_code)); + EXPECT_EQ((*msg)[strings::msg_params][strings::info].asString(), info); + } + + void HMIRequestExpectations(MessageSharedPtr msg, + hmi_apis::FunctionID::eType function_id, + const std::string& method_name) { + EXPECT_EQ((*msg)[strings::params][strings::function_id].asInt(), + static_cast<int32_t>(function_id)); 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); + (*msg)[strings::msg_params][am::hmi_request::method_name].asString(), + method_name); + } + + MessageSharedPtr CreateRequestMessage( + const mobile_apis::InteractionMode::eType& interaction_mode) { + MessageSharedPtr request_msg = CreateMessage(smart_objects::SmartType_Map); + (*request_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*request_msg)[strings::params][strings::correlation_id] = kCorrelationId; + (*request_msg)[strings::msg_params][strings::interaction_mode] = + interaction_mode; + return request_msg; + } + + MessageSharedPtr CreateHMIResponseMessage( + const hmi_apis::Common_Result::eType& response_code, + const std::string& message_info, + const int32_t command_id = kCommandId) { + MessageSharedPtr response_msg = CreateMessage(smart_objects::SmartType_Map); + (*response_msg)[strings::params][hmi_response::code] = response_code; + (*response_msg)[strings::msg_params][strings::cmd_id] = command_id; + (*response_msg)[strings::msg_params][strings::info] = message_info; + return response_msg; + } + + MessageSharedPtr CreateHMIResponseMessageWithChoiceID( + const hmi_apis::Common_Result::eType& response_code, + const std::string& message_info, + const int32_t choice_id, + const int32_t command_id = kCommandId) { + MessageSharedPtr response_msg = + CreateHMIResponseMessage(response_code, message_info, kCommandId); + (*response_msg)[strings::msg_params][strings::choice_id] = choice_id; + return response_msg; } sync_primitives::Lock lock_; MockAppPtr mock_app_; + app_mngr::PerformChoiceSetMap choice_set_map_; + mutable std::shared_ptr<sync_primitives::RecursiveLock> + performinteraction_choice_set_lock_ptr_; }; TEST_F(PerformInteractionRequestTest, OnTimeout_VR_GENERIC_ERROR) { @@ -147,35 +219,101 @@ TEST_F(PerformInteractionRequestTest, OnTimeout_VR_GENERIC_ERROR) { } TEST_F(PerformInteractionRequestTest, + OnEvent_BOTHMode_UIChoiceIdReceivedFirst) { + MessageSharedPtr msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MessageSharedPtr response_msg_vr = CreateHMIResponseMessage( + hmi_apis::Common_Result::SUCCESS, "", kInvalidChoiceId); + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + MessageSharedPtr response_msg_ui = CreateHMIResponseMessageWithChoiceID( + hmi_apis::Common_Result::SUCCESS, "", kUiChoiceID); + 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_ui); + command->on_event(event_vr); + + EXPECT_EQ( + kUiChoiceID, + (*response_to_mobile)[strings::msg_params][strings::choice_id].asInt()); +} + +TEST_F(PerformInteractionRequestTest, + OnEvent_BOTHMode_VRChoiceIdReceivedFirst) { + MessageSharedPtr msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MessageSharedPtr response_msg_vr = CreateHMIResponseMessageWithChoiceID( + hmi_apis::Common_Result::SUCCESS, "", kVrChoiceID); + MessageSharedPtr response_msg_ui = CreateHMIResponseMessageWithChoiceID( + hmi_apis::Common_Result::SUCCESS, "", kInvalidChoiceId); + + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction); + event_ui.set_smart_object(*response_msg_ui); + + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + + command->on_event(event_vr); + EXPECT_EQ(hmi_apis::FunctionID::UI_ClosePopUp, + (*request_to_hmi)[strings::params][strings::function_id].asInt()); + + MessageSharedPtr response_to_mobile; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + command->on_event(event_ui); + + EXPECT_EQ( + kVrChoiceID, + (*response_to_mobile)[strings::msg_params][strings::choice_id].asInt()); +} + +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; + CreateRequestMessage(mobile_apis::InteractionMode::VR_ONLY); std::shared_ptr<PerformInteractionRequest> command = CreateCommand<PerformInteractionRequest>(msg_from_mobile); - command->Init(); + + ASSERT_TRUE(command->Init()); MockAppPtr mock_app; EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app)); 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"; - + CreateHMIResponseMessage(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "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; - + CreateHMIResponseMessage(hmi_apis::Common_Result::SUCCESS, ""); am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction); event_ui.set_smart_object(*response_msg_ui); @@ -197,61 +335,331 @@ TEST_F(PerformInteractionRequestTest, command->on_event(event_ui); ResultCommandExpectations(response_to_mobile, + false, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, "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; + CreateRequestMessage(mobile_apis::InteractionMode::VR_ONLY); std::shared_ptr<PerformInteractionRequest> command = CreateCommand<PerformInteractionRequest>(msg_from_mobile); - ON_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + ASSERT_TRUE(command->Init()); + + MockAppPtr mock_app; + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app)); + + MessageSharedPtr response_msg_vr = + CreateHMIResponseMessage(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 = + CreateHMIResponseMessage(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_vr); + command->on_event(event_ui); + + ResultCommandExpectations(response_to_mobile, + true, + hmi_apis::Common_Result::SUCCESS, + "UI is not supported by system"); +} + +TEST_F( + PerformInteractionRequestTest, + PrepareResultCodeAndResponseForMobile_GetVRResultCodeOnly_InVR_OnlyMode_SUCCESS) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - ON_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + + MessageSharedPtr msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::VR_ONLY); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MockAppPtr mock_app; + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app)); + + MessageSharedPtr response_msg_vr = + CreateHMIResponseMessage(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "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 = + CreateHMIResponseMessage(hmi_apis::Common_Result::SUCCESS, ""); + 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_vr); + command->on_event(event_ui); + + ResultCommandExpectations(response_to_mobile, + false, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "VR is not supported by system"); +} + +TEST_F( + PerformInteractionRequestTest, + PrepareResultCodeAndResponseForMobile_GetVR_ErrorInfoAndCode_InBOTH_Mode_With_UI_success_result_code) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + auto msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + MessageSharedPtr response_msg_vr = - CreateMessage(smart_objects::SmartType_Map); - (*response_msg_vr)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; + CreateHMIResponseMessage(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "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::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"; + CreateHMIResponseMessage(hmi_apis::Common_Result::SUCCESS, ""); + 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + + command->on_event(event_vr); + command->on_event(event_ui); + + HMIRequestExpectations(request_to_hmi, + hmi_apis::FunctionID::UI_ClosePopUp, + "UI.PerformInteraction"); + + ResultCommandExpectations(response_to_mobile, + true, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "VR is not supported by system"); +} +TEST_F( + PerformInteractionRequestTest, + PrepareResultCodeAndResponseForMobile_Send_GENERIC_ERROR_To_Mobile_When_different_valid_choice_ids_received_in_BOTH_mode_SUCCESS) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MessageSharedPtr msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MessageSharedPtr response_msg_vr = CreateHMIResponseMessageWithChoiceID( + hmi_apis::Common_Result::SUCCESS, "", kVrChoiceID); + MessageSharedPtr response_msg_ui = CreateHMIResponseMessageWithChoiceID( + hmi_apis::Common_Result::SUCCESS, "", kUiChoiceID); + + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + command->on_event(event_vr); + command->on_event(event_ui); + + HMIRequestExpectations(request_to_hmi, + hmi_apis::FunctionID::UI_ClosePopUp, + "UI.PerformInteraction"); + + ResultCommandExpectations(response_to_mobile, + false, + hmi_apis::Common_Result::GENERIC_ERROR, + "Received two different choice IDs"); +} + +TEST_F( + PerformInteractionRequestTest, + VR_response_WARNINGS_UI_response_SUCCESS_MobileResponseContains_true_WARNINGS_warnings_info) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + auto msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::VR_ONLY); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MessageSharedPtr response_msg_vr = CreateHMIResponseMessage( + hmi_apis::Common_Result::WARNINGS, "WARNING MESSAGE"); + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + MessageSharedPtr response_msg_ui = + CreateHMIResponseMessage(hmi_apis::Common_Result::SUCCESS, ""); + 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + + command->on_event(event_vr); + command->on_event(event_ui); + + HMIRequestExpectations(request_to_hmi, + hmi_apis::FunctionID::UI_ClosePopUp, + "UI.PerformInteraction"); + + ResultCommandExpectations(response_to_mobile, + true, + hmi_apis::Common_Result::WARNINGS, + "WARNING MESSAGE"); +} + +TEST_F( + PerformInteractionRequestTest, + VR_response_SUCCESS_UI_response_WARNINGS_MobileResponseContains_true_WARNINGS_warnings_info) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + auto msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); + + MessageSharedPtr response_msg_vr = + CreateHMIResponseMessage(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 = CreateHMIResponseMessage( + hmi_apis::Common_Result::WARNINGS, "WARNING MESSAGE"); + 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( mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + command->on_event(event_vr); + command->on_event(event_ui); + + HMIRequestExpectations(request_to_hmi, + hmi_apis::FunctionID::UI_ClosePopUp, + "UI.PerformInteraction"); + + ResultCommandExpectations(response_to_mobile, + true, + hmi_apis::Common_Result::WARNINGS, + "WARNING MESSAGE"); +} + +TEST_F( + PerformInteractionRequestTest, + VR_response_UNSUPPORTED_RESOURCE_UI_response_WARNINGS_MobileResponseContains_false_UNSUPPORTED_RESOURSE_error_info) { + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + auto msg_from_mobile = + CreateRequestMessage(mobile_apis::InteractionMode::BOTH); + std::shared_ptr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ASSERT_TRUE(command->Init()); - EXPECT_CALL(*mock_app_, is_perform_interaction_active()) - .WillOnce(Return(false)); - EXPECT_CALL(*mock_app_, DeletePerformInteractionChoiceSet(_)); + MessageSharedPtr response_msg_vr = CreateHMIResponseMessage( + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, "VR error message"); + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + MessageSharedPtr response_msg_ui = CreateHMIResponseMessage( + hmi_apis::Common_Result::WARNINGS, "UI warning message"); + 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( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + MessageSharedPtr request_to_hmi; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + _, am::commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(DoAll(SaveArg<0>(&request_to_hmi), Return(true))); + + command->on_event(event_vr); command->on_event(event_ui); + HMIRequestExpectations(request_to_hmi, + hmi_apis::FunctionID::UI_ClosePopUp, + "UI.PerformInteraction"); + ResultCommandExpectations(response_to_mobile, - "UI is not supported by system"); + true, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "UI warning message, VR error message"); } } // namespace perform_interaction_request |