OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/media/capture_video_decoder.h" | 6 #include "content/renderer/media/capture_video_decoder.h" |
7 #include "content/renderer/media/video_capture_impl.h" | 7 #include "content/renderer/media/video_capture_impl.h" |
8 #include "content/renderer/media/video_capture_impl_manager.h" | 8 #include "content/renderer/media/video_capture_impl_manager.h" |
9 #include "media/base/filters.h" | 9 #include "media/base/filters.h" |
10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 decoder_->Seek(base::TimeDelta(), | 145 decoder_->Seek(base::TimeDelta(), |
146 media::NewExpectedStatusCB(media::PIPELINE_OK)); | 146 media::NewExpectedStatusCB(media::PIPELINE_OK)); |
147 message_loop_->RunAllPending(); | 147 message_loop_->RunAllPending(); |
148 } | 148 } |
149 | 149 |
150 void Play() { | 150 void Play() { |
151 decoder_->Play(media::NewExpectedClosure()); | 151 decoder_->Play(media::NewExpectedClosure()); |
152 message_loop_->RunAllPending(); | 152 message_loop_->RunAllPending(); |
153 } | 153 } |
154 | 154 |
| 155 void Flush() { |
| 156 // Issue a read. |
| 157 EXPECT_CALL(*this, FrameReady(_)); |
| 158 decoder_->Read(read_cb_); |
| 159 |
| 160 decoder_->Pause(media::NewExpectedClosure()); |
| 161 decoder_->Flush(media::NewExpectedClosure()); |
| 162 message_loop_->RunAllPending(); |
| 163 } |
| 164 |
155 void Stop() { | 165 void Stop() { |
156 EXPECT_CALL(*vc_impl_, StopCapture(capture_client())) | 166 EXPECT_CALL(*vc_impl_, StopCapture(capture_client())) |
157 .Times(1) | 167 .Times(1) |
158 .WillOnce(CaptureStopped(capture_client(), vc_impl_.get())); | 168 .WillOnce(CaptureStopped(capture_client(), vc_impl_.get())); |
159 EXPECT_CALL(*vc_manager_, RemoveDevice(_, _)) | 169 EXPECT_CALL(*vc_manager_, RemoveDevice(_, _)) |
160 .WillOnce(Return()); | 170 .WillOnce(Return()); |
161 decoder_->Stop(media::NewExpectedClosure()); | 171 decoder_->Stop(media::NewExpectedClosure()); |
162 message_loop_->RunAllPending(); | 172 message_loop_->RunAllPending(); |
163 } | 173 } |
164 | 174 |
(...skipping 26 matching lines...) Expand all Loading... |
191 EXPECT_EQ(kHeight, decoder_->natural_size().height()); | 201 EXPECT_EQ(kHeight, decoder_->natural_size().height()); |
192 | 202 |
193 Stop(); | 203 Stop(); |
194 } | 204 } |
195 | 205 |
196 TEST_F(CaptureVideoDecoderTest, Play) { | 206 TEST_F(CaptureVideoDecoderTest, Play) { |
197 // Test basic initialize, play, and teardown sequence. | 207 // Test basic initialize, play, and teardown sequence. |
198 Initialize(); | 208 Initialize(); |
199 Start(); | 209 Start(); |
200 Play(); | 210 Play(); |
| 211 Flush(); |
201 Stop(); | 212 Stop(); |
202 } | 213 } |
203 | 214 |
204 TEST_F(CaptureVideoDecoderTest, OnDeviceInfoReceived) { | 215 TEST_F(CaptureVideoDecoderTest, OnDeviceInfoReceived) { |
205 // Test that natural size gets updated as device information is sent. | 216 // Test that natural size gets updated as device information is sent. |
206 Initialize(); | 217 Initialize(); |
207 Start(); | 218 Start(); |
208 | 219 |
209 gfx::Size expected_size(kWidth * 2, kHeight * 2); | 220 gfx::Size expected_size(kWidth * 2, kHeight * 2); |
210 | 221 |
211 media::VideoCaptureParams params; | 222 media::VideoCaptureParams params; |
212 params.width = expected_size.width(); | 223 params.width = expected_size.width(); |
213 params.height = expected_size.height(); | 224 params.height = expected_size.height(); |
214 params.frame_per_second = kFPS; | 225 params.frame_per_second = kFPS; |
215 params.session_id = kVideoStreamId; | 226 params.session_id = kVideoStreamId; |
216 | 227 |
217 EXPECT_CALL(host_, SetNaturalVideoSize(expected_size)); | 228 EXPECT_CALL(host_, SetNaturalVideoSize(expected_size)); |
218 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params); | 229 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params); |
219 message_loop_->RunAllPending(); | 230 message_loop_->RunAllPending(); |
220 | 231 |
221 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width()); | 232 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width()); |
222 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height()); | 233 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height()); |
223 | 234 |
224 Stop(); | 235 Stop(); |
225 } | 236 } |
OLD | NEW |