| 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 "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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public: | 50 public: |
| 51 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, | 51 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, |
| 52 scoped_refptr<base::MessageLoopProxy> ml_proxy, | 52 scoped_refptr<base::MessageLoopProxy> ml_proxy, |
| 53 VideoCaptureMessageFilter* filter) | 53 VideoCaptureMessageFilter* filter) |
| 54 : VideoCaptureImpl(id, ml_proxy, filter) { | 54 : VideoCaptureImpl(id, ml_proxy, filter) { |
| 55 } | 55 } |
| 56 virtual ~MockVideoCaptureImpl() {} | 56 virtual ~MockVideoCaptureImpl() {} |
| 57 | 57 |
| 58 MOCK_METHOD2(StartCapture, | 58 MOCK_METHOD2(StartCapture, |
| 59 void(media::VideoCapture::EventHandler* handler, | 59 void(media::VideoCapture::EventHandler* handler, |
| 60 const VideoCaptureCapability& capability)); | 60 const media::VideoCaptureCapability& capability)); |
| 61 MOCK_METHOD1(StopCapture, void(media::VideoCapture::EventHandler* handler)); | 61 MOCK_METHOD1(StopCapture, void(media::VideoCapture::EventHandler* handler)); |
| 62 MOCK_METHOD1(FeedBuffer, void(scoped_refptr<VideoFrameBuffer> buffer)); | 62 MOCK_METHOD1(FeedBuffer, void(scoped_refptr<VideoFrameBuffer> buffer)); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImpl); | 65 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImpl); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class MockVideoCaptureImplManager : public VideoCaptureImplManager { | 68 class MockVideoCaptureImplManager : public VideoCaptureImplManager { |
| 69 public: | 69 public: |
| 70 MockVideoCaptureImplManager() {} | 70 MockVideoCaptureImplManager() {} |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImplManager); | 81 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImplManager); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 class CaptureVideoDecoderTest : public ::testing::Test { | 84 class CaptureVideoDecoderTest : public ::testing::Test { |
| 85 protected: | 85 protected: |
| 86 CaptureVideoDecoderTest() { | 86 CaptureVideoDecoderTest() { |
| 87 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 87 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
| 88 message_loop_proxy_ = | 88 message_loop_proxy_ = |
| 89 base::MessageLoopProxy::current().get(); | 89 base::MessageLoopProxy::current().get(); |
| 90 vc_manager_ = new MockVideoCaptureImplManager(); | 90 vc_manager_ = new MockVideoCaptureImplManager(); |
| 91 media::VideoCapture::VideoCaptureCapability capability; | 91 media::VideoCaptureCapability capability; |
| 92 capability.width = kWidth; | 92 capability.width = kWidth; |
| 93 capability.height = kHeight; | 93 capability.height = kHeight; |
| 94 capability.max_fps = kFPS; | 94 capability.frame_rate = kFPS; |
| 95 capability.expected_capture_delay = 0; | 95 capability.expected_capture_delay = 0; |
| 96 capability.raw_type = media::VideoFrame::I420; | 96 capability.color = media::VideoFrame::I420; |
| 97 capability.interlaced = false; | 97 capability.interlaced = false; |
| 98 | 98 |
| 99 decoder_ = new CaptureVideoDecoder(message_loop_proxy_, | 99 decoder_ = new CaptureVideoDecoder(message_loop_proxy_, |
| 100 kVideoStreamId, vc_manager_, capability); | 100 kVideoStreamId, vc_manager_, capability); |
| 101 decoder_->set_host(&host_); | 101 decoder_->set_host(&host_); |
| 102 EXPECT_CALL(statistics_cb_object_, OnStatistics(_)) | 102 EXPECT_CALL(statistics_cb_object_, OnStatistics(_)) |
| 103 .Times(AnyNumber()); | 103 .Times(AnyNumber()); |
| 104 | 104 |
| 105 read_cb_ = base::Bind(&CaptureVideoDecoderTest::FrameReady, | 105 read_cb_ = base::Bind(&CaptureVideoDecoderTest::FrameReady, |
| 106 base::Unretained(this)); | 106 base::Unretained(this)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 params.session_id = kVideoStreamId; | 210 params.session_id = kVideoStreamId; |
| 211 | 211 |
| 212 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params); | 212 decoder_->OnDeviceInfoReceived(vc_impl_.get(), params); |
| 213 message_loop_->RunAllPending(); | 213 message_loop_->RunAllPending(); |
| 214 | 214 |
| 215 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width()); | 215 EXPECT_EQ(expected_size.width(), decoder_->natural_size().width()); |
| 216 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height()); | 216 EXPECT_EQ(expected_size.height(), decoder_->natural_size().height()); |
| 217 | 217 |
| 218 Stop(); | 218 Stop(); |
| 219 } | 219 } |
| OLD | NEW |