From ef9daee934107d9ff911a0db3b4582fd6a62d4ec Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 22 Feb 2018 14:49:02 +0100 Subject: [PATCH] Using mock transport controller in audio unit tests. Using a mock of rtp transport controller send in audio send stream unit tests. This reduces the dependencies and makes the tests more focused on testing the functionality of audio send stream itself. Bug: webrtc:8415 Change-Id: Ia8d9cf47d93decc74b10ca75a6771f39df658dc2 Reviewed-on: https://webrtc-review.googlesource.com/56600 Reviewed-by: Henrik Lundin Reviewed-by: Oskar Sundbom Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#22161} --- audio/BUILD.gn | 2 +- audio/audio_send_stream_unittest.cc | 16 +++++++----- modules/rtp_rtcp/BUILD.gn | 1 + .../mocks/mock_rtcp_bandwidth_observer.h | 26 +++++++++++++++++++ .../rtp_rtcp/source/rtcp_receiver_unittest.cc | 8 +----- 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 59302eae2d..618ec847e6 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -125,9 +125,9 @@ if (rtc_include_tests) { ":audio_end_to_end_test", "../api:mock_audio_mixer", "../call:mock_call_interfaces", + "../call:mock_rtp_interfaces", "../call:rtp_interfaces", "../call:rtp_receiver", - "../call:rtp_sender", "../common_audio", "../logging:mocks", "../modules:module_api", diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 43e6c47865..4130e68b4f 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -16,12 +16,13 @@ #include "audio/audio_state.h" #include "audio/conversion.h" #include "audio/mock_voe_channel_proxy.h" -#include "call/rtp_transport_controller_send.h" +#include "call/test/mock_rtp_transport_controller_send.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_processing/include/audio_processing_statistics.h" #include "modules/audio_processing/include/mock_audio_processing.h" +#include "modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h" #include "modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "rtc_base/fakeclock.h" @@ -126,8 +127,6 @@ struct ConfigHelper { ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call) : stream_config_(nullptr), audio_processing_(new rtc::RefCountedObject()), - simulated_clock_(123456), - rtp_transport_(&simulated_clock_, &event_log_, BitrateConstraints()), bitrate_allocator_(&limit_observer_), worker_queue_("ConfigHelper_worker_queue"), audio_encoder_(nullptr) { @@ -201,12 +200,15 @@ struct ConfigHelper { EXPECT_CALL(*channel_proxy_, SetSendAudioLevelIndicationStatus(true, kAudioLevelId)) .Times(1); + EXPECT_CALL(rtp_transport_, GetBandwidthObserver()) + .WillRepeatedly(Return(&bandwidth_observer_)); if (audio_bwe_enabled) { EXPECT_CALL(*channel_proxy_, EnableSendTransportSequenceNumber(kTransportSequenceNumberId)) .Times(1); - EXPECT_CALL(*channel_proxy_, RegisterSenderCongestionControlObjects( - &rtp_transport_, Ne(nullptr))) + EXPECT_CALL(*channel_proxy_, + RegisterSenderCongestionControlObjects( + &rtp_transport_, Eq(&bandwidth_observer_))) .Times(1); } else { EXPECT_CALL(*channel_proxy_, RegisterSenderCongestionControlObjects( @@ -303,10 +305,10 @@ struct ConfigHelper { testing::StrictMock* channel_proxy_ = nullptr; rtc::scoped_refptr audio_processing_; AudioProcessingStats audio_processing_stats_; - SimulatedClock simulated_clock_; TimeInterval active_lifetime_; + testing::StrictMock bandwidth_observer_; testing::NiceMock event_log_; - RtpTransportControllerSend rtp_transport_; + testing::NiceMock rtp_transport_; testing::NiceMock rtp_rtcp_; MockRtcpRttStats rtcp_rtt_stats_; testing::NiceMock limit_observer_; diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 799d6466f7..e53001b6bc 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -272,6 +272,7 @@ rtc_source_set("mock_rtp_rtcp") { testonly = true sources = [ "mocks/mock_recovered_packet_receiver.h", + "mocks/mock_rtcp_bandwidth_observer.h", "mocks/mock_rtcp_rtt_stats.h", "mocks/mock_rtp_rtcp.h", ] diff --git a/modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h b/modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h new file mode 100644 index 0000000000..76b40e6299 --- /dev/null +++ b/modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef MODULES_RTP_RTCP_MOCKS_MOCK_RTCP_BANDWIDTH_OBSERVER_H_ +#define MODULES_RTP_RTCP_MOCKS_MOCK_RTCP_BANDWIDTH_OBSERVER_H_ + +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "test/gmock.h" + +namespace webrtc { + +class MockRtcpBandwidthObserver : public RtcpBandwidthObserver { + public: + MOCK_METHOD1(OnReceivedEstimatedBitrate, void(uint32_t)); + MOCK_METHOD3(OnReceivedRtcpReceiverReport, + void(const ReportBlockList&, int64_t, int64_t)); +}; +} // namespace webrtc +#endif // MODULES_RTP_RTCP_MOCKS_MOCK_RTCP_BANDWIDTH_OBSERVER_H_ diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 85337a9bbb..5faf7ed112 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -13,6 +13,7 @@ #include "api/array_view.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/include/video_bitrate_allocator.h" +#include "modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtcp_packet.h" #include "modules/rtp_rtcp/source/rtcp_packet/app.h" @@ -80,13 +81,6 @@ class MockTransportFeedbackObserver : public TransportFeedbackObserver { MOCK_CONST_METHOD0(GetTransportFeedbackVector, std::vector()); }; -class MockRtcpBandwidthObserver : public RtcpBandwidthObserver { - public: - MOCK_METHOD1(OnReceivedEstimatedBitrate, void(uint32_t)); - MOCK_METHOD3(OnReceivedRtcpReceiverReport, - void(const ReportBlockList&, int64_t, int64_t)); -}; - class MockModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp { public: MOCK_METHOD1(SetTmmbn, void(std::vector));