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

Side by Side Diff: media/cast/net/cast_transport_impl_unittest.cc

Issue 2048033003: Refactoring: CastTransport InitializeAudio/InitializeVideo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments. Created 4 years, 5 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 | « media/cast/net/cast_transport_impl.cc ('k') | media/cast/net/pacing/paced_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/net/cast_transport_impl.h" 5 #include "media/cast/net/cast_transport_impl.h"
6 6
7 #include <gtest/gtest.h> 7 #include <gtest/gtest.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 void InitWithoutLogging(); 101 void InitWithoutLogging();
102 void InitWithOptions(); 102 void InitWithOptions();
103 void InitWithLogging(); 103 void InitWithLogging();
104 104
105 void InitializeVideo() { 105 void InitializeVideo() {
106 CastTransportRtpConfig rtp_config; 106 CastTransportRtpConfig rtp_config;
107 rtp_config.ssrc = kVideoSsrc; 107 rtp_config.ssrc = kVideoSsrc;
108 rtp_config.feedback_ssrc = 2; 108 rtp_config.feedback_ssrc = 2;
109 rtp_config.rtp_payload_type = RtpPayloadType::VIDEO_VP8; 109 rtp_config.rtp_payload_type = RtpPayloadType::VIDEO_VP8;
110 transport_sender_->InitializeVideo( 110 transport_sender_->InitializeStream(rtp_config,
111 rtp_config, base::WrapUnique(new StubRtcpObserver())); 111 base::MakeUnique<StubRtcpObserver>());
112 } 112 }
113 113
114 void InitializeAudio() { 114 void InitializeAudio() {
115 CastTransportRtpConfig rtp_config; 115 CastTransportRtpConfig rtp_config;
116 rtp_config.ssrc = kAudioSsrc; 116 rtp_config.ssrc = kAudioSsrc;
117 rtp_config.feedback_ssrc = 3; 117 rtp_config.feedback_ssrc = 3;
118 rtp_config.rtp_payload_type = RtpPayloadType::AUDIO_OPUS; 118 rtp_config.rtp_payload_type = RtpPayloadType::AUDIO_OPUS;
119 transport_sender_->InitializeAudio( 119 transport_sender_->InitializeStream(rtp_config,
120 rtp_config, base::WrapUnique(new StubRtcpObserver())); 120 base::MakeUnique<StubRtcpObserver>());
121 } 121 }
122 122
123 base::SimpleTestTickClock testing_clock_; 123 base::SimpleTestTickClock testing_clock_;
124 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; 124 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
125 std::unique_ptr<CastTransportImpl> transport_sender_; 125 std::unique_ptr<CastTransportImpl> transport_sender_;
126 FakePacketSender* transport_; // Owned by CastTransport. 126 FakePacketSender* transport_; // Owned by CastTransport.
127 int num_times_logging_callback_called_; 127 int num_times_logging_callback_called_;
128 }; 128 };
129 129
130 namespace { 130 namespace {
(...skipping 18 matching lines...) Expand all
149 149
150 DISALLOW_COPY_AND_ASSIGN(TransportClient); 150 DISALLOW_COPY_AND_ASSIGN(TransportClient);
151 }; 151 };
152 152
153 } // namespace 153 } // namespace
154 154
155 void CastTransportImplTest::InitWithoutLogging() { 155 void CastTransportImplTest::InitWithoutLogging() {
156 transport_ = new FakePacketSender(); 156 transport_ = new FakePacketSender();
157 transport_sender_.reset( 157 transport_sender_.reset(
158 new CastTransportImpl(&testing_clock_, base::TimeDelta(), 158 new CastTransportImpl(&testing_clock_, base::TimeDelta(),
159 base::WrapUnique(new TransportClient(nullptr)), 159 base::MakeUnique<TransportClient>(nullptr),
160 base::WrapUnique(transport_), task_runner_)); 160 base::WrapUnique(transport_), task_runner_));
161 task_runner_->RunTasks(); 161 task_runner_->RunTasks();
162 } 162 }
163 163
164 void CastTransportImplTest::InitWithOptions() { 164 void CastTransportImplTest::InitWithOptions() {
165 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); 165 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue);
166 options->SetBoolean("disable_wifi_scan", true); 166 options->SetBoolean("disable_wifi_scan", true);
167 options->SetBoolean("media_streaming_mode", true); 167 options->SetBoolean("media_streaming_mode", true);
168 options->SetInteger("pacer_target_burst_size", 20); 168 options->SetInteger("pacer_target_burst_size", 20);
169 options->SetInteger("pacer_max_burst_size", 100); 169 options->SetInteger("pacer_max_burst_size", 100);
170 transport_ = new FakePacketSender(); 170 transport_ = new FakePacketSender();
171 transport_sender_.reset( 171 transport_sender_.reset(
172 new CastTransportImpl(&testing_clock_, base::TimeDelta(), 172 new CastTransportImpl(&testing_clock_, base::TimeDelta(),
173 base::WrapUnique(new TransportClient(nullptr)), 173 base::MakeUnique<TransportClient>(nullptr),
174 base::WrapUnique(transport_), task_runner_)); 174 base::WrapUnique(transport_), task_runner_));
175 transport_sender_->SetOptions(*options); 175 transport_sender_->SetOptions(*options);
176 task_runner_->RunTasks(); 176 task_runner_->RunTasks();
177 } 177 }
178 178
179 void CastTransportImplTest::InitWithLogging() { 179 void CastTransportImplTest::InitWithLogging() {
180 transport_ = new FakePacketSender(); 180 transport_ = new FakePacketSender();
181 transport_sender_.reset(new CastTransportImpl( 181 transport_sender_.reset(new CastTransportImpl(
182 &testing_clock_, base::TimeDelta::FromMilliseconds(10), 182 &testing_clock_, base::TimeDelta::FromMilliseconds(10),
183 base::WrapUnique(new TransportClient(this)), base::WrapUnique(transport_), 183 base::MakeUnique<TransportClient>(this), base::WrapUnique(transport_),
184 task_runner_)); 184 task_runner_));
185 task_runner_->RunTasks(); 185 task_runner_->RunTasks();
186 } 186 }
187 187
188 TEST_F(CastTransportImplTest, InitWithoutLogging) { 188 TEST_F(CastTransportImplTest, InitWithoutLogging) {
189 InitWithoutLogging(); 189 InitWithoutLogging();
190 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); 190 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50));
191 EXPECT_EQ(0, num_times_logging_callback_called_); 191 EXPECT_EQ(0, num_times_logging_callback_called_);
192 } 192 }
193 193
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 task_runner_->RunTasks(); 401 task_runner_->RunTasks();
402 EXPECT_EQ(7, transport_->packets_sent()); 402 EXPECT_EQ(7, transport_->packets_sent());
403 EXPECT_EQ(1, num_times_logging_callback_called_); // Only 8 ms since last. 403 EXPECT_EQ(1, num_times_logging_callback_called_); // Only 8 ms since last.
404 404
405 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2)); 405 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2));
406 EXPECT_EQ(2, num_times_logging_callback_called_); 406 EXPECT_EQ(2, num_times_logging_callback_called_);
407 } 407 }
408 408
409 } // namespace cast 409 } // namespace cast
410 } // namespace media 410 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/cast_transport_impl.cc ('k') | media/cast/net/pacing/paced_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698