summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2018-06-07 15:55:43 -0400
committerJacob Keeler <jacob.keeler@livioradio.com>2018-06-07 15:55:43 -0400
commit79012b26b614cdbe24be1859b308e8e9a96e4693 (patch)
tree5958ae3343f0c8dc24816af9760a974d38c3f9b4
parent8d85f7139a8ff4444c24e8b70f64b02539a45058 (diff)
downloadsdl_core-79012b26b614cdbe24be1859b308e8e9a96e4693.tar.gz
Fix test failures and add method descriptions
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h22
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc42
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc23
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc18
-rw-r--r--src/components/application_manager/test/commands/mobile/speak_request_test.cc10
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h4
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc8
7 files changed, 127 insertions, 0 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index 71e79e8338..de8d92d727 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -548,11 +548,33 @@ class MessageHelper {
const uint32_t correlation_id,
int32_t result_code);
+ /**
+ * @brief Verify that a file exists for a given application
+ *
+ * @param file_name The relative path of an application file
+ * @param app Current application
+ * @param app_mngr Application manager
+ *
+ * @return The full file path of the application file if found,
+ * NULL otherwise
+ */
static utils::SharedPtr<std::string> CheckAppFileExists(
std::string file_name,
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr);
+ /**
+ * @brief Verify that all ttsChunks with FILE type
+ * in an array include an existing file and set full path
+ *
+ * @param tts_chunks SmartObject with an array of TTSChunks
+ * @param app Current application
+ * @param app_mngr Application manager
+ *
+ * @return FILE_NOT_FOUND if one of the TTSChunks
+ * included a file which wasn't present on disk,
+ * SUCCESS otherwise
+ */
static mobile_apis::Result::eType VerifyTtsFiles(
smart_objects::SmartObject& tts_chunks,
ApplicationConstSharedPtr app,
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
index 5d9e507511..f4ad62f29a 100644
--- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
@@ -382,6 +382,12 @@ TEST_F(AlertRequestTest, Run_SUCCESS) {
SubscribeApplicationToSoftButton(
(*msg_)[am::strings::msg_params], _, kFunctionId));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
ExpectManageHmiCommandTTSAndUI();
CommandPtr command(CreateCommand<AlertRequest>(msg_));
command->Run();
@@ -435,6 +441,11 @@ TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_,
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
ExpectManageHmiCommandTTSAndUI();
@@ -465,6 +476,12 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) {
.WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
.WillOnce(Return(true));
@@ -492,6 +509,11 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) {
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
.WillOnce(Return(true));
@@ -524,6 +546,11 @@ TEST_F(AlertRequestTest,
EXPECT_CALL(mock_message_helper_,
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(mock_message_helper_,
SubscribeApplicationToSoftButton(
(*msg_)[am::strings::msg_params], _, kFunctionId));
@@ -566,6 +593,11 @@ TEST_F(AlertRequestTest, OnEvent_TTSUnsupportedResourceUiAlertSuccess_SUCCESS) {
EXPECT_CALL(mock_message_helper_,
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(mock_message_helper_,
SubscribeApplicationToSoftButton(
(*msg_)[am::strings::msg_params], _, kFunctionId));
@@ -611,6 +643,11 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) {
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
.WillOnce(Return(true));
@@ -656,6 +693,11 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) {
ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
.WillOnce(Return(true));
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 a27bac970c..ad15dca7eb 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
@@ -247,6 +247,12 @@ TEST_F(PerformAudioPassThruRequestTest,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
.WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+ EXPECT_CALL(mock_message_helper_,
+ VerifyTtsFiles((*mobile_request)[am::strings::msg_params]
+ [am::strings::initial_prompt],
+ _,
+ _)).WillOnce(Return(mobile_apis::Result::SUCCESS));
+
command->Run();
command->on_event(event_tts);
command->on_event(event_ui);
@@ -320,6 +326,10 @@ TEST_F(PerformAudioPassThruRequestTest,
kCorrectPrompt;
msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
+ EXPECT_CALL(mock_message_helper_,
+ VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
MessageSharedPtr speak_reqeust_result_msg;
MessageSharedPtr perform_result_msg;
{
@@ -405,6 +415,10 @@ TEST_F(PerformAudioPassThruRequestTest,
msg_params_[am::strings::audio_pass_display_text1] = kCorrectDisplayText1;
msg_params_[am::strings::audio_pass_display_text2] = kCorrectDisplayText2;
+ EXPECT_CALL(mock_message_helper_,
+ VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
MessageSharedPtr speak_reqeust_result_msg;
MessageSharedPtr perform_result_msg;
{
@@ -469,6 +483,10 @@ TEST_F(PerformAudioPassThruRequestTest,
kCorrectPrompt;
msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
+ EXPECT_CALL(mock_message_helper_,
+ VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
const bool muted = false;
msg_params_[am::strings::mute_audio] = muted;
@@ -743,6 +761,11 @@ TEST_F(PerformAudioPassThruRequestTest,
msg_params_[am::strings::initial_prompt][0][am::strings::text] =
kCorrectPrompt;
msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
+
+ EXPECT_CALL(mock_message_helper_,
+ VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
MessageSharedPtr speak_reqeust_result_msg;
MessageSharedPtr perform_result_msg;
ON_CALL(app_mngr_, GetNextHMICorrelationID())
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 641e5636a9..9ed459f799 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
@@ -154,6 +154,10 @@ class SetGlobalPropertiesRequestTest
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_,
RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
SmartObject vr_help_title("title");
@@ -288,6 +292,12 @@ TEST_F(SetGlobalPropertiesRequestTest,
ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillByDefault(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
(*msg_vr)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties);
@@ -763,6 +773,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
SmartObject vr_help_title("title");
EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
@@ -795,6 +809,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
SmartObject vr_help_title("title");
EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
@@ -825,6 +841,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
SmartObject vr_help_title("title");
EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
index f07012d315..36a9b85c6a 100644
--- a/src/components/application_manager/test/commands/mobile/speak_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
@@ -286,6 +286,11 @@ TEST_F(SpeakRequestTest, Run_MsgWithEmptyString_Success) {
[am::strings::text] = "";
CommandPtr command(CreateCommand<SpeakRequest>(request_));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId));
@@ -301,6 +306,11 @@ TEST_F(SpeakRequestTest, Run_MsgCorrect_Success) {
[am::strings::text] = "asda";
CommandPtr command(CreateCommand<SpeakRequest>(request_));
+ EXPECT_CALL(
+ mock_message_helper_,
+ VerifyTtsFiles(
+ (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId));
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 93db0d9795..e8a969718d 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -176,6 +176,10 @@ class MockMessageHelper {
MOCK_METHOD1(SendGlobalPropertiesToHMI, void(ApplicationConstSharedPtr app));
MOCK_METHOD1(GetIVISubscriptionRequests,
smart_objects::SmartObjectList(ApplicationSharedPtr app));
+ MOCK_METHOD3(VerifyTtsFiles,
+ mobile_apis::Result::eType(smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr));
MOCK_METHOD3(VerifyImageFiles,
mobile_apis::Result::eType(smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index 24bba63e71..8b0ec5b854 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -315,6 +315,14 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests(
app);
}
+mobile_apis::Result::eType MessageHelper::VerifyTtsFiles(
+ smart_objects::SmartObject& message,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
+ return MockMessageHelper::message_helper_mock()->VerifyTtsFiles(
+ message, app, app_mngr);
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImage(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,