| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 static const gfx::Rect kVisibleRect(16u, 16u); | 38 static const gfx::Rect kVisibleRect(16u, 16u); |
| 39 static const gfx::Size kNaturalSize(16u, 16u); | 39 static const gfx::Size kNaturalSize(16u, 16u); |
| 40 | 40 |
| 41 class VideoRendererBaseTest : public ::testing::Test { | 41 class VideoRendererBaseTest : public ::testing::Test { |
| 42 public: | 42 public: |
| 43 VideoRendererBaseTest() | 43 VideoRendererBaseTest() |
| 44 : decoder_(new MockVideoDecoder()), | 44 : decoder_(new MockVideoDecoder()), |
| 45 demuxer_stream_(new MockDemuxerStream()), | 45 demuxer_stream_(new MockDemuxerStream()), |
| 46 video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, | 46 video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
| 47 kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, false) { | 47 kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, false) { |
| 48 ScopedVector<VideoDecoder> decoders; |
| 49 decoders.push_back(decoder_); |
| 50 |
| 48 renderer_.reset(new VideoRendererBase( | 51 renderer_.reset(new VideoRendererBase( |
| 49 message_loop_.message_loop_proxy(), | 52 message_loop_.message_loop_proxy(), |
| 53 decoders.Pass(), |
| 50 media::SetDecryptorReadyCB(), | 54 media::SetDecryptorReadyCB(), |
| 51 base::Bind(&VideoRendererBaseTest::OnPaint, base::Unretained(this)), | 55 base::Bind(&VideoRendererBaseTest::OnPaint, base::Unretained(this)), |
| 52 base::Bind(&VideoRendererBaseTest::OnSetOpaque, base::Unretained(this)), | 56 base::Bind(&VideoRendererBaseTest::OnSetOpaque, base::Unretained(this)), |
| 53 true)); | 57 true)); |
| 54 | 58 |
| 55 EXPECT_CALL(*demuxer_stream_, type()) | 59 EXPECT_CALL(*demuxer_stream_, type()) |
| 56 .WillRepeatedly(Return(DemuxerStream::VIDEO)); | 60 .WillRepeatedly(Return(DemuxerStream::VIDEO)); |
| 57 EXPECT_CALL(*demuxer_stream_, video_decoder_config()) | 61 EXPECT_CALL(*demuxer_stream_, video_decoder_config()) |
| 58 .WillRepeatedly(ReturnRef(video_config_)); | 62 .WillRepeatedly(ReturnRef(video_config_)); |
| 59 | 63 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 115 } |
| 112 | 116 |
| 113 void InitializeRenderer(PipelineStatus expected) { | 117 void InitializeRenderer(PipelineStatus expected) { |
| 114 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); | 118 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); |
| 115 WaitableMessageLoopEvent event; | 119 WaitableMessageLoopEvent event; |
| 116 CallInitialize(event.GetPipelineStatusCB()); | 120 CallInitialize(event.GetPipelineStatusCB()); |
| 117 event.RunAndWaitForStatus(expected); | 121 event.RunAndWaitForStatus(expected); |
| 118 } | 122 } |
| 119 | 123 |
| 120 void CallInitialize(const PipelineStatusCB& status_cb) { | 124 void CallInitialize(const PipelineStatusCB& status_cb) { |
| 121 VideoRendererBase::VideoDecoderList decoders; | |
| 122 decoders.push_back(decoder_); | |
| 123 renderer_->Initialize( | 125 renderer_->Initialize( |
| 124 demuxer_stream_, | 126 demuxer_stream_, |
| 125 decoders, | |
| 126 status_cb, | 127 status_cb, |
| 127 base::Bind(&MockStatisticsCB::OnStatistics, | 128 base::Bind(&MockStatisticsCB::OnStatistics, |
| 128 base::Unretained(&statistics_cb_object_)), | 129 base::Unretained(&statistics_cb_object_)), |
| 129 base::Bind(&VideoRendererBaseTest::OnTimeUpdate, | 130 base::Bind(&VideoRendererBaseTest::OnTimeUpdate, |
| 130 base::Unretained(this)), | 131 base::Unretained(this)), |
| 131 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged, | 132 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged, |
| 132 base::Unretained(this)), | 133 base::Unretained(this)), |
| 133 ended_event_.GetClosure(), | 134 ended_event_.GetClosure(), |
| 134 error_event_.GetPipelineStatusCB(), | 135 error_event_.GetPipelineStatusCB(), |
| 135 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)), | 136 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 void AdvanceTimeInMs(int time_ms) { | 289 void AdvanceTimeInMs(int time_ms) { |
| 289 DCHECK_EQ(&message_loop_, MessageLoop::current()); | 290 DCHECK_EQ(&message_loop_, MessageLoop::current()); |
| 290 base::AutoLock l(lock_); | 291 base::AutoLock l(lock_); |
| 291 time_ += base::TimeDelta::FromMilliseconds(time_ms); | 292 time_ += base::TimeDelta::FromMilliseconds(time_ms); |
| 292 DCHECK_LE(time_.InMicroseconds(), duration_.InMicroseconds()); | 293 DCHECK_LE(time_.InMicroseconds(), duration_.InMicroseconds()); |
| 293 } | 294 } |
| 294 | 295 |
| 295 protected: | 296 protected: |
| 296 // Fixture members. | 297 // Fixture members. |
| 297 scoped_ptr<VideoRendererBase> renderer_; | 298 scoped_ptr<VideoRendererBase> renderer_; |
| 298 scoped_refptr<MockVideoDecoder> decoder_; | 299 MockVideoDecoder* decoder_; // Owned by |renderer_|. |
| 299 scoped_refptr<MockDemuxerStream> demuxer_stream_; | 300 scoped_refptr<MockDemuxerStream> demuxer_stream_; |
| 300 MockStatisticsCB statistics_cb_object_; | 301 MockStatisticsCB statistics_cb_object_; |
| 301 | 302 |
| 302 private: | 303 private: |
| 303 base::TimeDelta GetTime() { | 304 base::TimeDelta GetTime() { |
| 304 base::AutoLock l(lock_); | 305 base::AutoLock l(lock_); |
| 305 return time_; | 306 return time_; |
| 306 } | 307 } |
| 307 | 308 |
| 308 base::TimeDelta GetDuration() { | 309 base::TimeDelta GetDuration() { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 InSequence s; | 652 InSequence s; |
| 652 | 653 |
| 653 EXPECT_CALL(*decoder_, Initialize(_, _, _)) | 654 EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| 654 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); | 655 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); |
| 655 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); | 656 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); |
| 656 | 657 |
| 657 Stop(); | 658 Stop(); |
| 658 } | 659 } |
| 659 | 660 |
| 660 } // namespace media | 661 } // namespace media |
| OLD | NEW |