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 <henrik.lundin@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22161}
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 59302ea..618ec84 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -125,9 +125,9 @@
":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 43e6c47..4130e68 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 @@
ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call)
: stream_config_(nullptr),
audio_processing_(new rtc::RefCountedObject<MockAudioProcessing>()),
- 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 @@
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 @@
testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
rtc::scoped_refptr<MockAudioProcessing> audio_processing_;
AudioProcessingStats audio_processing_stats_;
- SimulatedClock simulated_clock_;
TimeInterval active_lifetime_;
+ testing::StrictMock<MockRtcpBandwidthObserver> bandwidth_observer_;
testing::NiceMock<MockRtcEventLog> event_log_;
- RtpTransportControllerSend rtp_transport_;
+ testing::NiceMock<MockRtpTransportControllerSend> rtp_transport_;
testing::NiceMock<MockRtpRtcp> rtp_rtcp_;
MockRtcpRttStats rtcp_rtt_stats_;
testing::NiceMock<MockLimitObserver> limit_observer_;
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 799d646..e53001b 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -272,6 +272,7 @@
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 0000000..76b40e6
--- /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 85337a9..5faf7ed 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 @@
MOCK_CONST_METHOD0(GetTransportFeedbackVector, std::vector<PacketFeedback>());
};
-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<rtcp::TmmbItem>));