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 "media/base/mock_filters.h" | 5 #include "media/base/mock_filters.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 if (buffered_bytes_ > 0) | 31 if (buffered_bytes_ > 0) |
32 host()->SetBufferedBytes(buffered_bytes_); | 32 host()->SetBufferedBytes(buffered_bytes_); |
33 } | 33 } |
34 | 34 |
35 void MockDataSource::SetTotalAndBufferedBytes(int64 total_bytes, | 35 void MockDataSource::SetTotalAndBufferedBytes(int64 total_bytes, |
36 int64 buffered_bytes) { | 36 int64 buffered_bytes) { |
37 total_bytes_ = total_bytes; | 37 total_bytes_ = total_bytes; |
38 buffered_bytes_ = buffered_bytes; | 38 buffered_bytes_ = buffered_bytes; |
39 } | 39 } |
40 | 40 |
41 MockDemuxerFactory::MockDemuxerFactory(MockDemuxer* demuxer) | |
42 : demuxer_(demuxer), status_(PIPELINE_OK) { | |
43 } | |
44 | |
45 MockDemuxerFactory::~MockDemuxerFactory() {} | |
46 | |
47 void MockDemuxerFactory::SetError(PipelineStatus error) { | |
48 DCHECK_NE(error, PIPELINE_OK); | |
49 status_ = error; | |
50 } | |
51 | |
52 void MockDemuxerFactory::RunBuildCallback(const std::string& url, | |
53 const BuildCallback& callback) { | |
54 if (!demuxer_.get()) { | |
55 callback.Run(PIPELINE_ERROR_REQUIRED_FILTER_MISSING, NULL); | |
56 return; | |
57 } | |
58 | |
59 scoped_refptr<MockDemuxer> demuxer = demuxer_; | |
60 demuxer_ = NULL; | |
61 | |
62 if (status_ == PIPELINE_OK) { | |
63 callback.Run(PIPELINE_OK, demuxer.get()); | |
64 return; | |
65 } | |
66 | |
67 callback.Run(status_, NULL); | |
68 } | |
69 | |
70 MockDemuxer::MockDemuxer() | 41 MockDemuxer::MockDemuxer() |
71 : total_bytes_(-1), buffered_bytes_(-1), duration_() { | 42 : total_bytes_(-1), buffered_bytes_(-1), duration_() { |
72 EXPECT_CALL(*this, GetBitrate()).WillRepeatedly(Return(0)); | 43 EXPECT_CALL(*this, GetBitrate()).WillRepeatedly(Return(0)); |
73 EXPECT_CALL(*this, IsLocalSource()).WillRepeatedly(Return(false)); | 44 EXPECT_CALL(*this, IsLocalSource()).WillRepeatedly(Return(false)); |
74 EXPECT_CALL(*this, IsSeekable()).WillRepeatedly(Return(false)); | 45 EXPECT_CALL(*this, IsSeekable()).WillRepeatedly(Return(false)); |
75 } | 46 } |
76 | 47 |
77 MockDemuxer::~MockDemuxer() {} | 48 MockDemuxer::~MockDemuxer() {} |
78 | 49 |
79 void MockDemuxer::set_host(DemuxerHost* demuxer_host) { | 50 void MockDemuxer::set_host(DemuxerHost* demuxer_host) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 MockFilterCollection::MockFilterCollection() | 92 MockFilterCollection::MockFilterCollection() |
122 : demuxer_(new MockDemuxer()), | 93 : demuxer_(new MockDemuxer()), |
123 video_decoder_(new MockVideoDecoder()), | 94 video_decoder_(new MockVideoDecoder()), |
124 audio_decoder_(new MockAudioDecoder()), | 95 audio_decoder_(new MockAudioDecoder()), |
125 video_renderer_(new MockVideoRenderer()), | 96 video_renderer_(new MockVideoRenderer()), |
126 audio_renderer_(new MockAudioRenderer()) { | 97 audio_renderer_(new MockAudioRenderer()) { |
127 } | 98 } |
128 | 99 |
129 MockFilterCollection::~MockFilterCollection() {} | 100 MockFilterCollection::~MockFilterCollection() {} |
130 | 101 |
131 scoped_ptr<FilterCollection> MockFilterCollection::filter_collection( | 102 scoped_ptr<FilterCollection> MockFilterCollection::Create() { |
132 bool include_demuxer, | |
133 bool run_build_cb, | |
134 bool run_build, | |
135 PipelineStatus build_status) const { | |
136 scoped_ptr<FilterCollection> collection(new FilterCollection()); | 103 scoped_ptr<FilterCollection> collection(new FilterCollection()); |
137 | 104 collection->SetDemuxer(demuxer_); |
138 scoped_ptr<MockDemuxerFactory> demuxer_factory( | |
139 new MockDemuxerFactory(include_demuxer ? demuxer_ : NULL)); | |
140 | |
141 if (build_status != PIPELINE_OK) | |
142 demuxer_factory->SetError(build_status); | |
143 | |
144 if (run_build_cb) { | |
145 ON_CALL(*demuxer_factory, Build(_, _)).WillByDefault(Invoke( | |
146 demuxer_factory.get(), &MockDemuxerFactory::RunBuildCallback)); | |
147 } // else ignore Build calls. | |
148 | |
149 if (run_build) | |
150 EXPECT_CALL(*demuxer_factory, Build(_, _)); | |
151 | |
152 collection->SetDemuxerFactory(demuxer_factory.PassAs<DemuxerFactory>()); | |
153 collection->AddVideoDecoder(video_decoder_); | 105 collection->AddVideoDecoder(video_decoder_); |
154 collection->AddAudioDecoder(audio_decoder_); | 106 collection->AddAudioDecoder(audio_decoder_); |
155 collection->AddVideoRenderer(video_renderer_); | 107 collection->AddVideoRenderer(video_renderer_); |
156 collection->AddAudioRenderer(audio_renderer_); | 108 collection->AddAudioRenderer(audio_renderer_); |
157 return collection.Pass(); | 109 return collection.Pass(); |
158 } | 110 } |
159 | 111 |
160 void RunFilterCallback(::testing::Unused, const base::Closure& closure) { | 112 void RunFilterCallback(::testing::Unused, const base::Closure& closure) { |
161 closure.Run(); | 113 closure.Run(); |
162 } | 114 } |
163 | 115 |
164 void RunPipelineStatusCB(::testing::Unused, const PipelineStatusCB& status_cb) { | 116 void RunPipelineStatusCB(const PipelineStatusCB& status_cb) { |
165 status_cb.Run(PIPELINE_OK); | 117 status_cb.Run(PIPELINE_OK); |
166 } | 118 } |
167 | 119 |
| 120 void RunPipelineStatusCB2(::testing::Unused, |
| 121 const PipelineStatusCB& status_cb) { |
| 122 status_cb.Run(PIPELINE_OK); |
| 123 } |
| 124 |
168 void RunPipelineStatusCB3(::testing::Unused, const PipelineStatusCB& status_cb, | 125 void RunPipelineStatusCB3(::testing::Unused, const PipelineStatusCB& status_cb, |
169 ::testing::Unused) { | 126 ::testing::Unused) { |
170 status_cb.Run(PIPELINE_OK); | 127 status_cb.Run(PIPELINE_OK); |
171 } | 128 } |
172 | 129 |
173 void RunPipelineStatusCB4(::testing::Unused, const PipelineStatusCB& status_cb, | 130 void RunPipelineStatusCB4(::testing::Unused, const PipelineStatusCB& status_cb, |
174 ::testing::Unused, ::testing::Unused) { | 131 ::testing::Unused, ::testing::Unused) { |
175 status_cb.Run(PIPELINE_OK); | 132 status_cb.Run(PIPELINE_OK); |
176 } | 133 } |
177 | 134 |
178 void RunStopFilterCallback(const base::Closure& closure) { | 135 void RunStopFilterCallback(const base::Closure& closure) { |
179 closure.Run(); | 136 closure.Run(); |
180 } | 137 } |
181 | 138 |
182 MockFilter::MockFilter() {} | 139 MockFilter::MockFilter() {} |
183 | 140 |
184 MockFilter::~MockFilter() {} | 141 MockFilter::~MockFilter() {} |
185 | 142 |
186 MockStatisticsCB::MockStatisticsCB() {} | 143 MockStatisticsCB::MockStatisticsCB() {} |
187 | 144 |
188 MockStatisticsCB::~MockStatisticsCB() {} | 145 MockStatisticsCB::~MockStatisticsCB() {} |
189 | 146 |
190 } // namespace media | 147 } // namespace media |
OLD | NEW |