From 558bbe28dac48af20aef7ae350d290aaf8dd0d1f Mon Sep 17 00:00:00 2001 From: Frank Ronneburg Date: Wed, 4 Jul 2018 01:33:03 +0900 Subject: Merge pull request #296 in NAR/sdl-core from bugfux/handle_review_20180702 to feature/Ford-WiFi * commit 'dcdc9f62eaa094292332b52846694bcf2a0e591d': fix: remove "2" from audio/videoServiceTransports when secondary transport is disabled and servicesMap is empty --- .../protocol_handler/protocol_handler_impl.h | 1 + .../protocol_handler/src/protocol_handler_impl.cc | 17 ++++++--- .../test/protocol_handler_tm_test.cc | 41 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) (limited to 'src/components/protocol_handler') diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index a0fd436f98..fb685f33d3 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -700,6 +700,7 @@ class ProtocolHandlerImpl std::vector& secondaryTransports) const; void GenerateServiceTransportsForStartSessionAck( + bool secondary_enabled, const std::vector& service_transports, const std::string& primary_connection_type, const impl::TransportType primary_transport_type, diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index ffbd4b89e0..daad7a3bf1 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -2458,6 +2458,7 @@ const bool ProtocolHandlerImpl::ParseSecondaryTransportConfiguration( // Next, figure out which connections audio or video services are allowed on GenerateServiceTransportsForStartSessionAck( + settings_.multiple_transports_enabled(), settings_.audio_service_transports(), connection_type, td.transport_type_, @@ -2465,6 +2466,7 @@ const bool ProtocolHandlerImpl::ParseSecondaryTransportConfiguration( audioServiceTransports); GenerateServiceTransportsForStartSessionAck( + settings_.multiple_transports_enabled(), settings_.video_service_transports(), connection_type, td.transport_type_, @@ -2527,6 +2529,7 @@ void ProtocolHandlerImpl::GenerateSecondaryTransportsForStartSessionAck( } void ProtocolHandlerImpl::GenerateServiceTransportsForStartSessionAck( + bool secondary_enabled, const std::vector& service_transports, const std::string& primary_connection_type, const impl::TransportType primary_transport_type, @@ -2535,11 +2538,15 @@ void ProtocolHandlerImpl::GenerateServiceTransportsForStartSessionAck( LOG4CXX_AUTO_TRACE(logger_); if (service_transports.size() == 0) { - LOG4CXX_TRACE(logger_, - "Empty Service Transports. Allowing service to run on both " - "connections"); - serviceTransports.push_back(1); - serviceTransports.push_back(2); + if (secondary_enabled) { + LOG4CXX_TRACE(logger_, + "Empty Service Transports. Allowing service to run on both " + "connections"); + serviceTransports.push_back(1); + serviceTransports.push_back(2); + } else { + serviceTransports.push_back(1); + } } else { bool fPrimaryAdded = false; bool fSecondaryAdded = false; diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc index f840a3f258..8f95a6d088 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -1985,6 +1985,47 @@ TEST_F(ProtocolHandlerImplTest, expected_video_service_transports); } +TEST_F( + ProtocolHandlerImplTest, + StartSessionAck_SecondaryTransportParams_SecondaryDisabled_ServicesMapEmpty) { + std::vector secondary_transports_for_usb; // empty + std::vector secondary_transports_for_bluetooth; // empty + std::vector secondary_transports_for_wifi; // empty + // config does not specify video and audio services + std::vector audio_service_transports; // empty + std::vector video_service_transports; // empty + + std::string connection_type_string("IAP_BLUETOOTH"); + + // Core should not offer any secondary transport. It should still send + // the video/audio service transport lists. + std::vector expected_transport_strings; // empty + std::vector expected_audio_service_transports; + expected_audio_service_transports.push_back(1); + std::vector expected_video_service_transports; + expected_video_service_transports.push_back(1); + + connection_handler::SessionTransports dummy_st = {0, 0}; + EXPECT_CALL(connection_handler_mock, + SetSecondaryTransportID(_, kDisabledSecondary)) + .WillOnce(Return(dummy_st)); + + EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, _)) + .WillRepeatedly(Return(false)); + + VerifySecondaryTransportParamsInStartSessionAck( + false, /* disabled */ + secondary_transports_for_usb, + secondary_transports_for_bluetooth, + secondary_transports_for_wifi, + audio_service_transports, + video_service_transports, + connection_type_string, + expected_transport_strings, + expected_audio_service_transports, + expected_video_service_transports); +} + // Secondary transport param should not be included for apps with v5.0.0 TEST_F(ProtocolHandlerImplTest, StartSessionAck_Unprotected_NoSecondaryTransportParamsForV5) { -- cgit v1.2.1