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

Side by Side Diff: media/base/pipeline_unittest.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/base/pipeline.cc ('k') | media/base/serial_runner.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/pipeline.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8 #include <utility>
7 #include <vector> 9 #include <vector>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/test/simple_test_tick_clock.h" 15 #include "base/test/simple_test_tick_clock.h"
14 #include "base/threading/simple_thread.h" 16 #include "base/threading/simple_thread.h"
15 #include "base/time/clock.h" 17 #include "base/time/clock.h"
16 #include "media/base/fake_text_track_stream.h" 18 #include "media/base/fake_text_track_stream.h"
17 #include "media/base/gmock_callback_support.h" 19 #include "media/base/gmock_callback_support.h"
18 #include "media/base/media_log.h" 20 #include "media/base/media_log.h"
19 #include "media/base/mock_filters.h" 21 #include "media/base/mock_filters.h"
20 #include "media/base/pipeline.h"
21 #include "media/base/test_helpers.h" 22 #include "media/base/test_helpers.h"
22 #include "media/base/text_renderer.h" 23 #include "media/base/text_renderer.h"
23 #include "media/base/text_track_config.h" 24 #include "media/base/text_track_config.h"
24 #include "media/base/time_delta_interpolator.h" 25 #include "media/base/time_delta_interpolator.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
27 28
28 using ::testing::_; 29 using ::testing::_;
29 using ::testing::AnyNumber; 30 using ::testing::AnyNumber;
30 using ::testing::DeleteArg; 31 using ::testing::DeleteArg;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 163
163 void SetDemuxerExpectations(MockDemuxerStreamVector* streams) { 164 void SetDemuxerExpectations(MockDemuxerStreamVector* streams) {
164 // Initialize with a default non-zero duration. 165 // Initialize with a default non-zero duration.
165 SetDemuxerExpectations(streams, base::TimeDelta::FromSeconds(10)); 166 SetDemuxerExpectations(streams, base::TimeDelta::FromSeconds(10));
166 } 167 }
167 168
168 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream( 169 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream(
169 DemuxerStream::Type type) { 170 DemuxerStream::Type type) {
170 scoped_ptr<StrictMock<MockDemuxerStream> > stream( 171 scoped_ptr<StrictMock<MockDemuxerStream> > stream(
171 new StrictMock<MockDemuxerStream>(type)); 172 new StrictMock<MockDemuxerStream>(type));
172 return stream.Pass(); 173 return stream;
173 } 174 }
174 175
175 // Sets up expectations to allow the video renderer to initialize. 176 // Sets up expectations to allow the video renderer to initialize.
176 void SetRendererExpectations() { 177 void SetRendererExpectations() {
177 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _, _)) 178 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _, _))
178 .WillOnce(DoAll(SaveArg<3>(&buffering_state_cb_), 179 .WillOnce(DoAll(SaveArg<3>(&buffering_state_cb_),
179 SaveArg<4>(&ended_cb_), 180 SaveArg<4>(&ended_cb_),
180 PostCallback<1>(PIPELINE_OK))); 181 PostCallback<1>(PIPELINE_OK)));
181 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(audio_stream())); 182 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(audio_stream()));
182 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(video_stream())); 183 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(video_stream()));
183 } 184 }
184 185
185 void AddTextStream() { 186 void AddTextStream() {
186 EXPECT_CALL(*this, OnAddTextTrack(_,_)) 187 EXPECT_CALL(*this, OnAddTextTrack(_,_))
187 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack)); 188 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack));
188 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(), 189 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(),
189 TextTrackConfig(kTextSubtitles, "", "", "")); 190 TextTrackConfig(kTextSubtitles, "", "", ""));
190 message_loop_.RunUntilIdle(); 191 message_loop_.RunUntilIdle();
191 } 192 }
192 193
193 void StartPipeline() { 194 void StartPipeline() {
194 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 195 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
195 pipeline_->Start( 196 pipeline_->Start(
196 demuxer_.get(), scoped_renderer_.Pass(), 197 demuxer_.get(), std::move(scoped_renderer_),
197 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 198 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
198 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 199 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
199 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), 200 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
200 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), 201 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
201 base::Bind(&CallbackHelper::OnBufferingStateChange, 202 base::Bind(&CallbackHelper::OnBufferingStateChange,
202 base::Unretained(&callbacks_)), 203 base::Unretained(&callbacks_)),
203 base::Bind(&CallbackHelper::OnDurationChange, 204 base::Bind(&CallbackHelper::OnDurationChange,
204 base::Unretained(&callbacks_)), 205 base::Unretained(&callbacks_)),
205 base::Bind(&PipelineTest::OnAddTextTrack, base::Unretained(this)), 206 base::Bind(&PipelineTest::OnAddTextTrack, base::Unretained(this)),
206 base::Bind(&PipelineTest::OnWaitingForDecryptionKey, 207 base::Bind(&PipelineTest::OnWaitingForDecryptionKey,
(...skipping 24 matching lines...) Expand all
231 } 232 }
232 233
233 void CreateVideoStream() { 234 void CreateVideoStream() {
234 video_stream_ = CreateStream(DemuxerStream::VIDEO); 235 video_stream_ = CreateStream(DemuxerStream::VIDEO);
235 video_stream_->set_video_decoder_config(video_decoder_config_); 236 video_stream_->set_video_decoder_config(video_decoder_config_);
236 } 237 }
237 238
238 void CreateTextStream() { 239 void CreateTextStream() {
239 scoped_ptr<FakeTextTrackStream> text_stream(new FakeTextTrackStream()); 240 scoped_ptr<FakeTextTrackStream> text_stream(new FakeTextTrackStream());
240 EXPECT_CALL(*text_stream, OnRead()).Times(AnyNumber()); 241 EXPECT_CALL(*text_stream, OnRead()).Times(AnyNumber());
241 text_stream_ = text_stream.Pass(); 242 text_stream_ = std::move(text_stream);
242 } 243 }
243 244
244 MockDemuxerStream* audio_stream() { 245 MockDemuxerStream* audio_stream() {
245 return audio_stream_.get(); 246 return audio_stream_.get();
246 } 247 }
247 248
248 MockDemuxerStream* video_stream() { 249 MockDemuxerStream* video_stream() {
249 return video_stream_.get(); 250 return video_stream_.get();
250 } 251 }
251 252
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 EXPECT_CALL(*renderer_, SetVolume(_)); 309 EXPECT_CALL(*renderer_, SetVolume(_));
309 EXPECT_CALL(*renderer_, StartPlayingFrom(seek_time)) 310 EXPECT_CALL(*renderer_, StartPlayingFrom(seek_time))
310 .WillOnce( 311 .WillOnce(
311 SetBufferingState(&buffering_state_cb_, BUFFERING_HAVE_ENOUGH)); 312 SetBufferingState(&buffering_state_cb_, BUFFERING_HAVE_ENOUGH));
312 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 313 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
313 EXPECT_CALL(callbacks_, OnResume(PIPELINE_OK)); 314 EXPECT_CALL(callbacks_, OnResume(PIPELINE_OK));
314 } 315 }
315 316
316 void DoResume(const base::TimeDelta& seek_time) { 317 void DoResume(const base::TimeDelta& seek_time) {
317 pipeline_->Resume( 318 pipeline_->Resume(
318 scoped_renderer_.Pass(), seek_time, 319 std::move(scoped_renderer_), seek_time,
319 base::Bind(&CallbackHelper::OnResume, base::Unretained(&callbacks_))); 320 base::Bind(&CallbackHelper::OnResume, base::Unretained(&callbacks_)));
320 message_loop_.RunUntilIdle(); 321 message_loop_.RunUntilIdle();
321 } 322 }
322 323
323 void DestroyPipeline() { 324 void DestroyPipeline() {
324 // In real code Pipeline could be destroyed on a different thread. All weak 325 // In real code Pipeline could be destroyed on a different thread. All weak
325 // pointers must have been invalidated before the stop callback returns. 326 // pointers must have been invalidated before the stop callback returns.
326 DCHECK(!pipeline_->HasWeakPtrsForTesting()); 327 DCHECK(!pipeline_->HasWeakPtrsForTesting());
327 pipeline_.reset(); 328 pipeline_.reset();
328 } 329 }
(...skipping 10 matching lines...) Expand all
339 .WillOnce(Invoke(this, &PipelineTest::DestroyPipeline)); 340 .WillOnce(Invoke(this, &PipelineTest::DestroyPipeline));
340 } 341 }
341 342
342 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&, 343 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&,
343 const AddTextTrackDoneCB&)); 344 const AddTextTrackDoneCB&));
344 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); 345 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void));
345 346
346 void DoOnAddTextTrack(const TextTrackConfig& config, 347 void DoOnAddTextTrack(const TextTrackConfig& config,
347 const AddTextTrackDoneCB& done_cb) { 348 const AddTextTrackDoneCB& done_cb) {
348 scoped_ptr<TextTrack> text_track(new MockTextTrack); 349 scoped_ptr<TextTrack> text_track(new MockTextTrack);
349 done_cb.Run(text_track.Pass()); 350 done_cb.Run(std::move(text_track));
350 } 351 }
351 352
352 // Fixture members. 353 // Fixture members.
353 StrictMock<CallbackHelper> callbacks_; 354 StrictMock<CallbackHelper> callbacks_;
354 base::SimpleTestTickClock test_tick_clock_; 355 base::SimpleTestTickClock test_tick_clock_;
355 base::MessageLoop message_loop_; 356 base::MessageLoop message_loop_;
356 scoped_ptr<Pipeline> pipeline_; 357 scoped_ptr<Pipeline> pipeline_;
357 358
358 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; 359 scoped_ptr<StrictMock<MockDemuxer> > demuxer_;
359 scoped_ptr<StrictMock<MockRenderer> > scoped_renderer_; 360 scoped_ptr<StrictMock<MockRenderer> > scoped_renderer_;
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1155 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1155 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1156 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1156 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); 1157 INSTANTIATE_TEARDOWN_TEST(Error, Suspending);
1157 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); 1158 INSTANTIATE_TEARDOWN_TEST(Error, Suspended);
1158 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); 1159 INSTANTIATE_TEARDOWN_TEST(Error, Resuming);
1159 1160
1160 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1161 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1161 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); 1162 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended);
1162 1163
1163 } // namespace media 1164 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/base/serial_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698