OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/screen_capture_device_android.h" | 5 #include "content/browser/media/capture/screen_capture_device_android.h" |
6 | 6 |
7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using ::testing::_; | 10 using ::testing::_; |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 namespace { | 13 namespace { |
14 | 14 |
15 const int kFrameRate = 30; | 15 const int kFrameRate = 30; |
16 | 16 |
17 class MockDeviceClient : public media::VideoCaptureDevice::Client { | 17 class MockDeviceClient : public media::VideoCaptureDevice::Client { |
18 public: | 18 public: |
19 MOCK_METHOD6(OnIncomingCapturedData, | 19 MOCK_METHOD7(OnIncomingCapturedData, |
20 void(const uint8_t* data, | 20 void(const uint8_t* data, |
21 int length, | 21 int length, |
22 const media::VideoCaptureFormat& frame_format, | 22 const media::VideoCaptureFormat& frame_format, |
23 int rotation, | 23 int rotation, |
24 base::TimeTicks reference_time, | 24 base::TimeTicks reference_time, |
25 base::TimeDelta tiemstamp)); | 25 base::TimeDelta tiemstamp, |
| 26 int frame_feedback_id)); |
26 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 27 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
27 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 28 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
28 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 29 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
29 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); | 30 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); |
30 MOCK_METHOD2(OnError, | 31 MOCK_METHOD2(OnError, |
31 void(const tracked_objects::Location& from_here, | 32 void(const tracked_objects::Location& from_here, |
32 const std::string& reason)); | 33 const std::string& reason)); |
33 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); | 34 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); |
34 | 35 |
35 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 36 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
36 std::unique_ptr<Buffer> ReserveOutputBuffer( | 37 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, |
37 const gfx::Size& dimensions, | 38 media::VideoPixelFormat format, |
38 media::VideoPixelFormat format, | 39 media::VideoPixelStorage storage, |
39 media::VideoPixelStorage storage) override { | 40 int frame_feedback_id) override { |
40 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 41 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
41 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 42 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
42 DoReserveOutputBuffer(); | 43 DoReserveOutputBuffer(); |
43 return std::unique_ptr<Buffer>(); | 44 return std::unique_ptr<Buffer>(); |
44 } | 45 } |
45 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 46 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
46 const media::VideoCaptureFormat& frame_format, | 47 const media::VideoCaptureFormat& frame_format, |
47 base::TimeTicks reference_time, | 48 base::TimeTicks reference_time, |
48 base::TimeDelta timestamp) override { | 49 base::TimeDelta timestamp) override { |
49 DoOnIncomingCapturedBuffer(); | 50 DoOnIncomingCapturedBuffer(); |
50 } | 51 } |
51 void OnIncomingCapturedVideoFrame( | 52 void OnIncomingCapturedVideoFrame( |
52 std::unique_ptr<Buffer> buffer, | 53 std::unique_ptr<Buffer> buffer, |
53 scoped_refptr<media::VideoFrame> frame) override { | 54 scoped_refptr<media::VideoFrame> frame) override { |
54 DoOnIncomingCapturedVideoFrame(); | 55 DoOnIncomingCapturedVideoFrame(); |
55 } | 56 } |
56 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 57 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
57 const gfx::Size& dimensions, | 58 const gfx::Size& dimensions, |
58 media::VideoPixelFormat format, | 59 media::VideoPixelFormat format, |
59 media::VideoPixelStorage storage) override { | 60 media::VideoPixelStorage storage, |
| 61 int frame_feedback_id) override { |
60 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 62 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
61 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 63 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
62 DoResurrectLastOutputBuffer(); | 64 DoResurrectLastOutputBuffer(); |
63 return std::unique_ptr<Buffer>(); | 65 return std::unique_ptr<Buffer>(); |
64 } | 66 } |
65 }; | 67 }; |
66 | 68 |
67 class ScreenCaptureDeviceAndroidTest : public testing::Test { | 69 class ScreenCaptureDeviceAndroidTest : public testing::Test { |
68 public: | 70 public: |
69 ScreenCaptureDeviceAndroidTest() {} | 71 ScreenCaptureDeviceAndroidTest() {} |
(...skipping 20 matching lines...) Expand all Loading... |
90 media::VideoCaptureParams capture_params; | 92 media::VideoCaptureParams capture_params; |
91 capture_params.requested_format.frame_size.SetSize(640, 480); | 93 capture_params.requested_format.frame_size.SetSize(640, 480); |
92 capture_params.requested_format.frame_rate = kFrameRate; | 94 capture_params.requested_format.frame_rate = kFrameRate; |
93 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 95 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
94 capture_device->AllocateAndStart(capture_params, std::move(client)); | 96 capture_device->AllocateAndStart(capture_params, std::move(client)); |
95 capture_device->StopAndDeAllocate(); | 97 capture_device->StopAndDeAllocate(); |
96 } | 98 } |
97 | 99 |
98 } // namespace | 100 } // namespace |
99 } // namespace Content | 101 } // namespace Content |
OLD | NEW |