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

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

Issue 2834663003: Allow mocking SendSideCongestionController for Call tests. (Closed)
Patch Set: Add MockSendSideCongestionController constructor Created 3 years, 8 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
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_(
79 rtc::MakeUnique<SendSideCongestionController>(&simulated_clock_,
80 &event_log_,
81 &packet_router_)),
82 fake_transport_(send_side_cc_.get()),
103 bitrate_allocator_(&limit_observer_), 83 bitrate_allocator_(&limit_observer_),
104 worker_queue_("ConfigHelper_worker_queue") { 84 worker_queue_("ConfigHelper_worker_queue") {
105 using testing::Invoke; 85 using testing::Invoke;
106 86
107 EXPECT_CALL(voice_engine_, 87 EXPECT_CALL(voice_engine_,
108 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 88 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
109 EXPECT_CALL(voice_engine_, 89 EXPECT_CALL(voice_engine_,
110 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 90 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
111 EXPECT_CALL(voice_engine_, audio_device_module()); 91 EXPECT_CALL(voice_engine_, audio_device_module());
112 EXPECT_CALL(voice_engine_, audio_processing()); 92 EXPECT_CALL(voice_engine_, audio_processing());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 232
253 EXPECT_CALL(audio_processing_, GetStatistics()) 233 EXPECT_CALL(audio_processing_, GetStatistics())
254 .WillRepeatedly(Return(audio_processing_stats_)); 234 .WillRepeatedly(Return(audio_processing_stats_));
255 } 235 }
256 236
257 private: 237 private:
258 testing::StrictMock<MockVoiceEngine> voice_engine_; 238 testing::StrictMock<MockVoiceEngine> voice_engine_;
259 rtc::scoped_refptr<AudioState> audio_state_; 239 rtc::scoped_refptr<AudioState> audio_state_;
260 AudioSendStream::Config stream_config_; 240 AudioSendStream::Config stream_config_;
261 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 241 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
262 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
263 MockAudioProcessing audio_processing_; 242 MockAudioProcessing audio_processing_;
264 MockTransmitMixer transmit_mixer_; 243 MockTransmitMixer transmit_mixer_;
265 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; 244 AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
245 SimulatedClock simulated_clock_;
246 PacketRouter packet_router_;
247 std::unique_ptr<SendSideCongestionController> send_side_cc_;
266 FakeRtpTransportController fake_transport_; 248 FakeRtpTransportController fake_transport_;
267 MockRtcEventLog event_log_; 249 MockRtcEventLog event_log_;
268 MockRtcpRttStats rtcp_rtt_stats_; 250 MockRtcpRttStats rtcp_rtt_stats_;
269 testing::NiceMock<MockLimitObserver> limit_observer_; 251 testing::NiceMock<MockLimitObserver> limit_observer_;
270 BitrateAllocator bitrate_allocator_; 252 BitrateAllocator bitrate_allocator_;
271 // |worker_queue| is defined last to ensure all pending tasks are cancelled 253 // |worker_queue| is defined last to ensure all pending tasks are cancelled
272 // and deleted before any other members. 254 // and deleted before any other members.
273 rtc::TaskQueue worker_queue_; 255 rtc::TaskQueue worker_queue_;
274 }; 256 };
275 } // namespace 257 } // namespace
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 internal::AudioSendStream send_stream( 461 internal::AudioSendStream send_stream(
480 helper.config(), helper.audio_state(), helper.worker_queue(), 462 helper.config(), helper.audio_state(), helper.worker_queue(),
481 helper.transport(), helper.bitrate_allocator(), helper.event_log(), 463 helper.transport(), helper.bitrate_allocator(), helper.event_log(),
482 helper.rtcp_rtt_stats()); 464 helper.rtcp_rtt_stats());
483 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); 465 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000));
484 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); 466 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000);
485 } 467 }
486 468
487 } // namespace test 469 } // namespace test
488 } // namespace webrtc 470 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/call/call_unittest.cc » ('j') | webrtc/modules/congestion_controller/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698