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}
This commit is contained in:
Sebastian Jansson
2018-02-22 14:49:02 +01:00
committed by Commit Bot
parent 89c79383e4
commit ef9daee934
5 changed files with 38 additions and 15 deletions

View File

@ -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",

View File

@ -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<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 @@ 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<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_;

View File

@ -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",
]

View File

@ -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_

View File

@ -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<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>));