summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc')
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc88
1 files changed, 44 insertions, 44 deletions
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 e2adc38f50..6c35a5372a 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
@@ -57,7 +57,6 @@ using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
using ::utils::SharedPtr;
using ::testing::_;
-using ::testing::Mock;
using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::InSequence;
@@ -80,8 +79,7 @@ class PerformAudioPassThruRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
PerformAudioPassThruRequestTest()
- : mock_message_helper_(*MockMessageHelper::message_helper_mock())
- , mock_app_(CreateMockApp())
+ : mock_app_(CreateMockApp())
, message_(utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map))
, msg_params_((*message_)[am::strings::msg_params]) {}
@@ -137,10 +135,6 @@ class PerformAudioPassThruRequestTest
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(application_sptr_));
}
- void TearDown() OVERRIDE {
- Mock::VerifyAndClearExpectations(&mock_message_helper_);
- }
-
void ResultCommandExpectations(MessageSharedPtr msg,
const std::string& info) {
EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
@@ -153,7 +147,6 @@ class PerformAudioPassThruRequestTest
}
sync_primitives::Lock lock_;
- MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
MessageSharedPtr message_;
::smart_objects::SmartObject& msg_params_;
@@ -192,33 +185,33 @@ TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) {
(*vr_command_result)[am::strings::msg_params][am::strings::result_code]
.asInt(),
static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
- Mock::VerifyAndClearExpectations(&mock_message_helper_);
}
TEST_F(PerformAudioPassThruRequestTest,
OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_ui = CreateFullParamsUISO();
- (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ MessageSharedPtr mobile_request = CreateFullParamsUISO();
+ (*mobile_request)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ smart_objects::SmartObject initial_prompt =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ initial_prompt[0] = smart_objects::SmartObject(smart_objects::SmartType_Map);
+ initial_prompt[0][am::strings::text] = "tts chunk text";
+ initial_prompt[0][am::strings::type] = 0;
+ (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] =
+ initial_prompt;
+ EXPECT_CALL(*application_sptr_, hmi_level())
+ .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
utils::SharedPtr<PerformAudioPassThruRequest> command =
- CreateCommand<PerformAudioPassThruRequest>(msg_ui);
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru);
- event.set_smart_object(*msg);
+ CreateCommand<PerformAudioPassThruRequest>(mobile_request);
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
MessageSharedPtr response_msg_tts =
CreateMessage(smart_objects::SmartType_Map);
@@ -227,21 +220,39 @@ 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(am::mobile_api::Result::SUCCESS));
- command->on_event(event_tts);
- MessageSharedPtr ui_command_result;
+ MessageSharedPtr response_ui = CreateMessage(smart_objects::SmartType_Map);
+ (*response_ui)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ (*response_ui)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
+ (*response_ui)[am::strings::msg_params][am::strings::info] =
+ "UI is not supported by system";
+ am::event_engine::Event event_ui(
+ hmi_apis::FunctionID::UI_PerformAudioPassThru);
+ event_ui.set_smart_object(*response_ui);
+
+ MessageSharedPtr response_to_mobile;
EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true));
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
- command->on_event(event);
+ command->Run();
+ command->on_event(event_tts);
+ command->on_event(event_ui);
- ResultCommandExpectations(ui_command_result, "UI is not supported by system");
+ EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ false);
+ EXPECT_EQ(
+ (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
+ EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::info]
+ .asString(),
+ "UI is not supported by system");
}
TEST_F(PerformAudioPassThruRequestTest,
@@ -546,10 +557,6 @@ TEST_F(PerformAudioPassThruRequestTest, OnEvent_UIPAPT_Rejected) {
hmi_apis::Common_Result::REJECTED;
event.set_smart_object(*message_);
- EXPECT_CALL(mock_message_helper_,
- HMIToMobileResult(hmi_apis::Common_Result::REJECTED))
- .WillOnce(Return(am::mobile_api::Result::REJECTED));
-
CallOnEvent caller(*command_sptr_, event);
MessageSharedPtr result_message = CatchMobileCommandResult(caller);
@@ -582,15 +589,12 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(am::mobile_api::Result::SUCCESS));
-
CallOnEvent caller(*command_sptr_, event);
caller();
}
TEST_F(PerformAudioPassThruRequestTest,
- OnEvent_PAPTunsupportedResource_CorrectInfo) {
+ DISABLED_OnEvent_PAPTunsupportedResource_CorrectInfo) {
const std::string return_info = "Unsupported phoneme type sent in a prompt";
am::event_engine::Event event_speak(hmi_apis::FunctionID::TTS_Speak);
@@ -646,8 +650,6 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
CallOnEvent caller(*command_sptr_, event);
caller();
@@ -771,8 +773,6 @@ TEST_F(PerformAudioPassThruRequestTest,
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
.WillOnce(Return(false));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(am::mobile_api::Result::SUCCESS));
command_sptr_->onTimeOut();
}