diff options
author | JackLivio <jack@livio.io> | 2018-04-18 10:55:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-18 10:55:48 -0400 |
commit | 7f7fcbb998fb17f2954fd103349af67ea9b71a3f (patch) | |
tree | 55640424c5774fce04f01876fa1a4d281002c52e /src/components/application_manager/test | |
parent | 61fd83fed0dc584019b305bebc82512d2c42b9e7 (diff) | |
parent | 11ffe206ea3c114da3f45a5cbb9b23834d2996c8 (diff) | |
download | sdl_core-7f7fcbb998fb17f2954fd103349af67ea9b71a3f.tar.gz |
Merge pull request #2133 from smartdevicelink/release/4.5.14.5.1success,-HMI-show-radio-screenfix/check_transport_manager_initfeature/external_proprietary_policy
Release/4.5.1
Diffstat (limited to 'src/components/application_manager/test')
4 files changed, 148 insertions, 14 deletions
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index e54bc612ca..c922c227bb 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -47,6 +47,7 @@ #include "application_manager/test/include/application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler.h" #include "hmi_message_handler/mock_hmi_message_handler.h" +#include "media_manager/mock_media_manager.h" #include "policy/mock_policy_settings.h" #include "policy/usage_statistics/mock_statistics_manager.h" #include "protocol/bson_object_keys.h" @@ -824,6 +825,122 @@ TEST_F(ApplicationManagerImplTest, EXPECT_EQ(new_application_id, app_impl->app_id()); } +TEST_F(ApplicationManagerImplTest, StartStopAudioPassThru) { + std::string dummy_file_name; + ON_CALL(mock_application_manager_settings_, recording_file_name()) + .WillByDefault(ReturnRef(dummy_file_name)); + + NiceMock<test::components::media_manager_test::MockMediaManager> + mock_media_manager; + app_manager_impl_->SetMockMediaManager(&mock_media_manager); + + const uint32_t app_id = 65537; + const int32_t max_duration = 1000; + // below are not used + const int32_t correlation_id = 0; + const int32_t sampling_rate = 0; + const int32_t bits_per_sample = 0; + const int32_t audio_type = 0; + + EXPECT_CALL(mock_media_manager, + StartMicrophoneRecording(app_id, _, max_duration)) + .WillOnce(Return()); + EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id)) + .WillOnce(Return()); + + bool result = app_manager_impl_->BeginAudioPassThru(app_id); + EXPECT_TRUE(result); + if (result) { + app_manager_impl_->StartAudioPassThruThread(app_id, + correlation_id, + max_duration, + sampling_rate, + bits_per_sample, + audio_type); + } + + result = app_manager_impl_->EndAudioPassThru(app_id); + EXPECT_TRUE(result); + if (result) { + app_manager_impl_->StopAudioPassThru(app_id); + } +} + +TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) { + std::string dummy_file_name; + ON_CALL(mock_application_manager_settings_, recording_file_name()) + .WillByDefault(ReturnRef(dummy_file_name)); + + const uint32_t app_id_1 = 65537; + const uint32_t app_id_2 = 65538; + + std::string dummy_mac_address; + utils::SharedPtr<MockApplication> mock_app_1 = + utils::SharedPtr<MockApplication>(new MockApplication()); + EXPECT_CALL(*mock_app_1, app_id()).WillRepeatedly(Return(app_id_1)); + EXPECT_CALL(*mock_app_1, device()).WillRepeatedly(Return(0)); + EXPECT_CALL(*mock_app_1, mac_address()) + .WillRepeatedly(ReturnRef(dummy_mac_address)); + EXPECT_CALL(*mock_app_1, policy_app_id()).WillRepeatedly(Return("")); + EXPECT_CALL(*mock_app_1, protocol_version()) + .WillRepeatedly( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); + + utils::SharedPtr<MockApplication> mock_app_2 = + utils::SharedPtr<MockApplication>(new MockApplication()); + EXPECT_CALL(*mock_app_2, app_id()).WillRepeatedly(Return(app_id_2)); + EXPECT_CALL(*mock_app_2, device()).WillRepeatedly(Return(0)); + EXPECT_CALL(*mock_app_2, mac_address()) + .WillRepeatedly(ReturnRef(dummy_mac_address)); + EXPECT_CALL(*mock_app_2, policy_app_id()).WillRepeatedly(Return("")); + EXPECT_CALL(*mock_app_2, protocol_version()) + .WillRepeatedly( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); + + NiceMock<test::components::media_manager_test::MockMediaManager> + mock_media_manager; + app_manager_impl_->SetMockMediaManager(&mock_media_manager); + + app_manager_impl_->AddMockApplication(mock_app_1); + app_manager_impl_->AddMockApplication(mock_app_2); + + const int32_t max_duration = 1000; + // below are not used + const int32_t correlation_id = 0; + const int32_t sampling_rate = 0; + const int32_t bits_per_sample = 0; + const int32_t audio_type = 0; + + EXPECT_CALL(mock_media_manager, + StartMicrophoneRecording(app_id_2, _, max_duration)) + .WillOnce(Return()); + EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id_2)) + .WillOnce(Return()); + + // app 2 starts Audio Pass Thru + bool result = app_manager_impl_->BeginAudioPassThru(app_id_2); + EXPECT_TRUE(result); + if (result) { + app_manager_impl_->StartAudioPassThruThread(app_id_2, + correlation_id, + max_duration, + sampling_rate, + bits_per_sample, + audio_type); + } + + // while running APT, app 1 is unregistered + app_manager_impl_->UnregisterApplication( + app_id_1, mobile_apis::Result::SUCCESS, false, true); + + // confirm that APT is still running + result = app_manager_impl_->EndAudioPassThru(app_id_2); + EXPECT_TRUE(result); + if (result) { + app_manager_impl_->StopAudioPassThru(app_id_2); + } +} + } // application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc index 33733f63ed..6b1d909121 100644 --- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc @@ -67,6 +67,7 @@ class EndAudioPassThruRequestTest TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) { const uint32_t kConnectionKey = 2u; + const uint32_t app_id = kConnectionKey; MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = @@ -83,7 +84,7 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) { Event event(hmi_apis::FunctionID::UI_EndAudioPassThru); event.set_smart_object(*event_msg); - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); MessageSharedPtr ui_command_result; EXPECT_CALL( 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 6c35a5372a..a27bac970c 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 @@ -128,6 +128,8 @@ class PerformAudioPassThruRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; command_sptr_ = CreateCommand<am::commands::PerformAudioPassThruRequest>(message_); @@ -160,10 +162,15 @@ TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) { am::mobile_api::Result::GENERIC_ERROR; (*msg_ui)[am::strings::msg_params][am::strings::success] = false; + MessageSharedPtr message = + utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map); + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; + utils::SharedPtr<PerformAudioPassThruRequest> command = - CreateCommand<PerformAudioPassThruRequest>(); + CreateCommand<PerformAudioPassThruRequest>(message); - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); EXPECT_CALL( @@ -232,7 +239,8 @@ TEST_F(PerformAudioPassThruRequestTest, event_ui.set_smart_object(*response_ui); MessageSharedPtr response_to_mobile; - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true)); EXPECT_CALL( app_mngr_, @@ -362,7 +370,8 @@ TEST_F(PerformAudioPassThruRequestTest, hmi_apis::Common_Result::GENERIC_ERROR; event.set_smart_object(*message_); - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) .WillByDefault(Return(kCorrelationId)); @@ -536,7 +545,8 @@ TEST_F( } // Start microphone recording cals - EXPECT_CALL(app_mngr_, BeginAudioPassThrough()); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)); EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _)); CallRun caller(*command_sptr_); @@ -581,7 +591,8 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true)); // Start microphone recording cals - EXPECT_CALL(app_mngr_, BeginAudioPassThrough()); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)); EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _)); EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); @@ -617,7 +628,8 @@ TEST_F(PerformAudioPassThruRequestTest, caller_speak(); // Second call for test correct behavior of UI_PerformAudioPassThru event - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); @@ -641,7 +653,8 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true)); - EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL( app_mngr_, @@ -664,8 +677,9 @@ TEST_F(PerformAudioPassThruRequestTest, msg_params_[am::strings::connection_key] = kConnectionKey; msg_params_[am::strings::function_id] = kFunctionId; + uint32_t app_id = kConnectionKey; EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true)); - EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL( app_mngr_, @@ -683,8 +697,9 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) { am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); + uint32_t app_id = kConnectionKey; EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).Times(0); + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0); CallOnEvent caller(*command_sptr_, event); caller(); @@ -703,7 +718,8 @@ TEST_F(PerformAudioPassThruRequestTest, Init_CorrectTimeout) { TEST_F(PerformAudioPassThruRequestTest, onTimeOut_ttsSpeakNotActive_DontSendHMIReqeust) { - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); // For setting current_state_ -> kCompleted @@ -717,7 +733,8 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, DISABLED_onTimeOut_ttsSpeakActive_SendHMIReqeust) { - EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true)); + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); EXPECT_CALL(*application_sptr_, hmi_level()) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 77500fd238..d9e1cefa01 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -408,7 +408,6 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK_PTNotLoaded) { // Checks EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(false)); - EXPECT_CALL(*mock_policy_manager_, ForcePTExchange()).WillOnce(Return("")); EXPECT_CALL(app_manager_, GetNextHMICorrelationID()).Times(0); EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _)) .Times(0); |