OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/media/capture/desktop_capture_device_aura.h" | 5 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/public/browser/desktop_media_id.h" | 9 #include "content/public/browser/desktop_media_id.h" |
10 #include "media/video/capture/video_capture_types.h" | 10 #include "media/video/capture/video_capture_types.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/aura/client/window_tree_client.h" | 13 #include "ui/aura/client/window_tree_client.h" |
14 #include "ui/aura/test/aura_test_helper.h" | 14 #include "ui/aura/test/aura_test_helper.h" |
15 #include "ui/aura/test/test_window_delegate.h" | 15 #include "ui/aura/test/test_window_delegate.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/compositor/test/context_factories_for_test.h" | 17 #include "ui/compositor/test/context_factories_for_test.h" |
18 | 18 |
19 using ::testing::_; | 19 using ::testing::_; |
20 using ::testing::AnyNumber; | 20 using ::testing::AnyNumber; |
21 using ::testing::DoAll; | 21 using ::testing::DoAll; |
22 using ::testing::Expectation; | 22 using ::testing::Expectation; |
23 using ::testing::InvokeWithoutArgs; | 23 using ::testing::InvokeWithoutArgs; |
24 using ::testing::SaveArg; | 24 using ::testing::SaveArg; |
25 | 25 |
| 26 namespace media { |
| 27 class VideoFrame; |
| 28 } // namespace media |
| 29 |
26 namespace content { | 30 namespace content { |
27 namespace { | 31 namespace { |
28 | 32 |
29 const int kFrameRate = 30; | 33 const int kFrameRate = 30; |
30 | 34 |
31 class MockDeviceClient : public media::VideoCaptureDevice::Client { | 35 class MockDeviceClient : public media::VideoCaptureDevice::Client { |
32 public: | 36 public: |
33 MOCK_METHOD2(ReserveOutputBuffer, | 37 MOCK_METHOD2(ReserveOutputBuffer, |
34 scoped_refptr<Buffer>(media::VideoFrame::Format format, | 38 scoped_refptr<Buffer>(media::VideoFrame::Format format, |
35 const gfx::Size& dimensions)); | 39 const gfx::Size& dimensions)); |
36 MOCK_METHOD1(OnError, void(const std::string& reason)); | 40 MOCK_METHOD1(OnError, void(const std::string& reason)); |
37 MOCK_METHOD5(OnIncomingCapturedFrame, | 41 MOCK_METHOD5(OnIncomingCapturedData, |
38 void(const uint8* data, | 42 void(const uint8* data, |
39 int length, | 43 int length, |
40 base::TimeTicks timestamp, | 44 const media::VideoCaptureFormat& frame_format, |
41 int rotation, | 45 int rotation, |
42 const media::VideoCaptureFormat& frame_format)); | 46 base::TimeTicks timestamp)); |
43 MOCK_METHOD5(OnIncomingCapturedBuffer, | 47 MOCK_METHOD4(OnIncomingCapturedVideoFrame, |
44 void(const scoped_refptr<Buffer>& buffer, | 48 void(const scoped_refptr<Buffer>& buffer, |
45 media::VideoFrame::Format format, | 49 const media::VideoCaptureFormat& buffer_format, |
46 const gfx::Size& dimensions, | 50 const scoped_refptr<media::VideoFrame>& frame, |
47 base::TimeTicks timestamp, | 51 base::TimeTicks timestamp)); |
48 int frame_rate)); | |
49 }; | 52 }; |
50 | 53 |
51 // Test harness that sets up a minimal environment with necessary stubs. | 54 // Test harness that sets up a minimal environment with necessary stubs. |
52 class DesktopCaptureDeviceAuraTest : public testing::Test { | 55 class DesktopCaptureDeviceAuraTest : public testing::Test { |
53 public: | 56 public: |
54 DesktopCaptureDeviceAuraTest() | 57 DesktopCaptureDeviceAuraTest() |
55 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} | 58 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} |
56 virtual ~DesktopCaptureDeviceAuraTest() {} | 59 virtual ~DesktopCaptureDeviceAuraTest() {} |
57 | 60 |
58 protected: | 61 protected: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 capture_params.requested_format.frame_rate = kFrameRate; | 113 capture_params.requested_format.frame_rate = kFrameRate; |
111 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 114 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
112 capture_params.allow_resolution_change = false; | 115 capture_params.allow_resolution_change = false; |
113 capture_device->AllocateAndStart( | 116 capture_device->AllocateAndStart( |
114 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); | 117 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); |
115 capture_device->StopAndDeAllocate(); | 118 capture_device->StopAndDeAllocate(); |
116 } | 119 } |
117 | 120 |
118 } // namespace | 121 } // namespace |
119 } // namespace content | 122 } // namespace content |
OLD | NEW |