Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: webrtc/audio/audio_send_stream_unittest.cc

Issue 2834663003: Allow mocking SendSideCongestionController for Call tests. (Closed)
Patch Set: Replace observer argument and add a motivating example for MockSendSideCC. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/call/call.h » ('j') | webrtc/call/call.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "webrtc/audio/audio_send_stream.h" 14 #include "webrtc/audio/audio_send_stream.h"
15 #include "webrtc/audio/audio_state.h" 15 #include "webrtc/audio/audio_state.h"
16 #include "webrtc/audio/conversion.h" 16 #include "webrtc/audio/conversion.h"
17 #include "webrtc/base/ptr_util.h"
17 #include "webrtc/base/task_queue.h" 18 #include "webrtc/base/task_queue.h"
19 #include "webrtc/call/fake_rtp_transport_controller_send.h"
18 #include "webrtc/call/rtp_transport_controller_send_interface.h" 20 #include "webrtc/call/rtp_transport_controller_send_interface.h"
19 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" 21 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
20 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" 22 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
21 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" 23 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h"
22 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_obse rver.h" 24 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_obse rver.h"
23 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 25 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
24 #include "webrtc/modules/pacing/paced_sender.h" 26 #include "webrtc/modules/pacing/paced_sender.h"
25 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" 27 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h"
26 #include "webrtc/test/gtest.h" 28 #include "webrtc/test/gtest.h"
27 #include "webrtc/test/mock_voe_channel_proxy.h" 29 #include "webrtc/test/mock_voe_channel_proxy.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void(uint32_t min_send_bitrate_bps, 65 void(uint32_t min_send_bitrate_bps,
64 uint32_t max_padding_bitrate_bps)); 66 uint32_t max_padding_bitrate_bps));
65 }; 67 };
66 68
67 class MockTransmitMixer : public voe::TransmitMixer { 69 class MockTransmitMixer : public voe::TransmitMixer {
68 public: 70 public:
69 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t()); 71 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t());
70 }; 72 };
71 73
72 struct ConfigHelper { 74 struct ConfigHelper {
73 class FakeRtpTransportController
74 : public RtpTransportControllerSendInterface {
75 public:
76 explicit FakeRtpTransportController(RtcEventLog* event_log)
77 : simulated_clock_(123456),
78 send_side_cc_(&simulated_clock_,
79 &bitrate_observer_,
80 event_log,
81 &packet_router_) {}
82 PacketRouter* packet_router() override { return &packet_router_; }
83
84 SendSideCongestionController* send_side_cc() override {
85 return &send_side_cc_;
86 }
87 TransportFeedbackObserver* transport_feedback_observer() override {
88 return &send_side_cc_;
89 }
90
91 RtpPacketSender* packet_sender() override { return send_side_cc_.pacer(); }
92
93 private:
94 SimulatedClock simulated_clock_;
95 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
96 PacketRouter packet_router_;
97 SendSideCongestionController send_side_cc_;
98 };
99
100 explicit ConfigHelper(bool audio_bwe_enabled) 75 explicit ConfigHelper(bool audio_bwe_enabled)
101 : stream_config_(nullptr), 76 : stream_config_(nullptr),
102 fake_transport_(&event_log_), 77 simulated_clock_(123456),
78 send_side_cc_(rtc::MakeUnique<SendSideCongestionController>(
79 &simulated_clock_,
80 nullptr /* observer */,
81 &event_log_,
82 &packet_router_)),
83 fake_transport_(send_side_cc_.get()),
103 bitrate_allocator_(&limit_observer_), 84 bitrate_allocator_(&limit_observer_),
104 worker_queue_("ConfigHelper_worker_queue") { 85 worker_queue_("ConfigHelper_worker_queue") {
105 using testing::Invoke; 86 using testing::Invoke;
106 87
107 EXPECT_CALL(voice_engine_, 88 EXPECT_CALL(voice_engine_,
108 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 89 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
109 EXPECT_CALL(voice_engine_, 90 EXPECT_CALL(voice_engine_,
110 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 91 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
111 EXPECT_CALL(voice_engine_, audio_device_module()); 92 EXPECT_CALL(voice_engine_, audio_device_module());
112 EXPECT_CALL(voice_engine_, audio_processing()); 93 EXPECT_CALL(voice_engine_, audio_processing());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 233
253 EXPECT_CALL(audio_processing_, GetStatistics()) 234 EXPECT_CALL(audio_processing_, GetStatistics())
254 .WillRepeatedly(Return(audio_processing_stats_)); 235 .WillRepeatedly(Return(audio_processing_stats_));
255 } 236 }
256 237
257 private: 238 private:
258 testing::StrictMock<MockVoiceEngine> voice_engine_; 239 testing::StrictMock<MockVoiceEngine> voice_engine_;
259 rtc::scoped_refptr<AudioState> audio_state_; 240 rtc::scoped_refptr<AudioState> audio_state_;
260 AudioSendStream::Config stream_config_; 241 AudioSendStream::Config stream_config_;
261 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 242 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
262 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
263 MockAudioProcessing audio_processing_; 243 MockAudioProcessing audio_processing_;
264 MockTransmitMixer transmit_mixer_; 244 MockTransmitMixer transmit_mixer_;
265 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; 245 AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
246 SimulatedClock simulated_clock_;
247 PacketRouter packet_router_;
248 std::unique_ptr<SendSideCongestionController> send_side_cc_;
266 FakeRtpTransportController fake_transport_; 249 FakeRtpTransportController fake_transport_;
267 MockRtcEventLog event_log_; 250 MockRtcEventLog event_log_;
268 MockRtcpRttStats rtcp_rtt_stats_; 251 MockRtcpRttStats rtcp_rtt_stats_;
269 testing::NiceMock<MockLimitObserver> limit_observer_; 252 testing::NiceMock<MockLimitObserver> limit_observer_;
270 BitrateAllocator bitrate_allocator_; 253 BitrateAllocator bitrate_allocator_;
271 // |worker_queue| is defined last to ensure all pending tasks are cancelled 254 // |worker_queue| is defined last to ensure all pending tasks are cancelled
272 // and deleted before any other members. 255 // and deleted before any other members.
273 rtc::TaskQueue worker_queue_; 256 rtc::TaskQueue worker_queue_;
274 }; 257 };
275 } // namespace 258 } // namespace
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 internal::AudioSendStream send_stream( 462 internal::AudioSendStream send_stream(
480 helper.config(), helper.audio_state(), helper.worker_queue(), 463 helper.config(), helper.audio_state(), helper.worker_queue(),
481 helper.transport(), helper.bitrate_allocator(), helper.event_log(), 464 helper.transport(), helper.bitrate_allocator(), helper.event_log(),
482 helper.rtcp_rtt_stats()); 465 helper.rtcp_rtt_stats());
483 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); 466 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000));
484 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); 467 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000);
485 } 468 }
486 469
487 } // namespace test 470 } // namespace test
488 } // namespace webrtc 471 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/call/call.h » ('j') | webrtc/call/call.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698