| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/renderer_host/media/desktop_capture_device.h" | 5 #include "content/browser/renderer_host/media/desktop_capture_device.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 const int kTestFrameWidth1 = 100; | 34 const int kTestFrameWidth1 = 100; |
| 35 const int kTestFrameHeight1 = 100; | 35 const int kTestFrameHeight1 = 100; |
| 36 const int kTestFrameWidth2 = 200; | 36 const int kTestFrameWidth2 = 200; |
| 37 const int kTestFrameHeight2 = 150; | 37 const int kTestFrameHeight2 = 150; |
| 38 | 38 |
| 39 const int kFrameRate = 30; | 39 const int kFrameRate = 30; |
| 40 | 40 |
| 41 class MockDeviceClient : public media::VideoCaptureDevice::Client { | 41 class MockDeviceClient : public media::VideoCaptureDevice::Client { |
| 42 public: | 42 public: |
| 43 MOCK_METHOD1(ReserveOutputBuffer, | 43 MOCK_METHOD0(DoReserveOutputBuffer, void()); |
| 44 scoped_refptr<media::VideoFrame>(const gfx::Size& size)); | |
| 45 MOCK_METHOD0(OnError, void()); | 44 MOCK_METHOD0(OnError, void()); |
| 46 MOCK_METHOD1(OnFrameInfo, void(const media::VideoCaptureCapability& info)); | 45 MOCK_METHOD1(OnFrameInfo, void(const media::VideoCaptureCapability& info)); |
| 47 MOCK_METHOD1(OnFrameInfoChanged, | 46 MOCK_METHOD1(OnFrameInfoChanged, |
| 48 void(const media::VideoCaptureCapability& info)); | 47 void(const media::VideoCaptureCapability& info)); |
| 49 MOCK_METHOD6(OnIncomingCapturedFrame, void(const uint8* data, | 48 MOCK_METHOD6(OnIncomingCapturedFrame, void(const uint8* data, |
| 50 int length, | 49 int length, |
| 51 base::Time timestamp, | 50 base::Time timestamp, |
| 52 int rotation, | 51 int rotation, |
| 53 bool flip_vert, | 52 bool flip_vert, |
| 54 bool flip_horiz)); | 53 bool flip_horiz)); |
| 55 MOCK_METHOD2(OnIncomingCapturedVideoFrame, | 54 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void()); |
| 56 void(const scoped_refptr<media::VideoFrame>& frame, | 55 |
| 57 base::Time timestamp)); | 56 virtual scoped_ptr<media::VideoCaptureDevice::Client::Buffer> |
| 57 ReserveOutputBuffer(media::VideoFrame::Format format, |
| 58 const gfx::Size& dimensions) OVERRIDE { |
| 59 DoReserveOutputBuffer(); |
| 60 return scoped_ptr<media::VideoCaptureDevice::Client::Buffer>(); |
| 61 } |
| 62 |
| 63 virtual void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer, |
| 64 media::VideoFrame::Format format, |
| 65 const gfx::Size& dimensions, |
| 66 base::Time timestamp) { |
| 67 DoOnIncomingCapturedBuffer(); |
| 68 } |
| 58 }; | 69 }; |
| 59 | 70 |
| 60 // TODO(sergeyu): Move this to a separate file where it can be reused. | 71 // TODO(sergeyu): Move this to a separate file where it can be reused. |
| 61 class FakeScreenCapturer : public webrtc::ScreenCapturer { | 72 class FakeScreenCapturer : public webrtc::ScreenCapturer { |
| 62 public: | 73 public: |
| 63 FakeScreenCapturer() | 74 FakeScreenCapturer() |
| 64 : callback_(NULL), | 75 : callback_(NULL), |
| 65 frame_index_(0) { | 76 frame_index_(0) { |
| 66 } | 77 } |
| 67 virtual ~FakeScreenCapturer() {} | 78 virtual ~FakeScreenCapturer() {} |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 capture_device.StopAndDeAllocate(); | 260 capture_device.StopAndDeAllocate(); |
| 250 | 261 |
| 251 EXPECT_EQ(kTestFrameWidth1, caps.width); | 262 EXPECT_EQ(kTestFrameWidth1, caps.width); |
| 252 EXPECT_EQ(kTestFrameHeight1, caps.height); | 263 EXPECT_EQ(kTestFrameHeight1, caps.height); |
| 253 EXPECT_EQ(kFrameRate, caps.frame_rate); | 264 EXPECT_EQ(kFrameRate, caps.frame_rate); |
| 254 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, caps.color); | 265 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, caps.color); |
| 255 worker_pool_->FlushForTesting(); | 266 worker_pool_->FlushForTesting(); |
| 256 } | 267 } |
| 257 | 268 |
| 258 } // namespace content | 269 } // namespace content |
| OLD | NEW |