| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 28 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
| 29 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 29 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
| 30 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 30 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
| 31 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); | 31 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); |
| 32 MOCK_METHOD2(OnError, | 32 MOCK_METHOD2(OnError, |
| 33 void(const tracked_objects::Location& from_here, | 33 void(const tracked_objects::Location& from_here, |
| 34 const std::string& reason)); | 34 const std::string& reason)); |
| 35 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); | 35 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); |
| 36 | 36 |
| 37 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 37 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
| 38 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, | 38 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, |
| 39 media::VideoPixelFormat format, | 39 media::VideoPixelFormat format, |
| 40 media::VideoPixelStorage storage, | 40 media::VideoPixelStorage storage, |
| 41 int frame_feedback_id) override { | 41 int frame_feedback_id) override { |
| 42 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 42 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 43 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 43 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 44 DoReserveOutputBuffer(); | 44 DoReserveOutputBuffer(); |
| 45 return std::unique_ptr<Buffer>(); | 45 return Buffer(); |
| 46 } | 46 } |
| 47 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 47 void OnIncomingCapturedBuffer(Buffer buffer, |
| 48 const media::VideoCaptureFormat& frame_format, | 48 const media::VideoCaptureFormat& frame_format, |
| 49 base::TimeTicks reference_time, | 49 base::TimeTicks reference_time, |
| 50 base::TimeDelta timestamp) override { | 50 base::TimeDelta timestamp) override { |
| 51 DoOnIncomingCapturedBuffer(); | 51 DoOnIncomingCapturedBuffer(); |
| 52 } | 52 } |
| 53 void OnIncomingCapturedBufferExt( | 53 void OnIncomingCapturedBufferExt( |
| 54 std::unique_ptr<Buffer> buffer, | 54 Buffer buffer, |
| 55 const media::VideoCaptureFormat& format, | 55 const media::VideoCaptureFormat& format, |
| 56 base::TimeTicks reference_time, | 56 base::TimeTicks reference_time, |
| 57 base::TimeDelta timestamp, | 57 base::TimeDelta timestamp, |
| 58 gfx::Rect visible_rect, | 58 gfx::Rect visible_rect, |
| 59 const media::VideoFrameMetadata& additional_metadata) override { | 59 const media::VideoFrameMetadata& additional_metadata) override { |
| 60 DoOnIncomingCapturedVideoFrame(); | 60 DoOnIncomingCapturedVideoFrame(); |
| 61 } | 61 } |
| 62 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 62 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, |
| 63 const gfx::Size& dimensions, | 63 media::VideoPixelFormat format, |
| 64 media::VideoPixelFormat format, | 64 media::VideoPixelStorage storage, |
| 65 media::VideoPixelStorage storage, | 65 int frame_feedback_id) override { |
| 66 int frame_feedback_id) override { | |
| 67 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 66 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 68 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 67 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 69 DoResurrectLastOutputBuffer(); | 68 DoResurrectLastOutputBuffer(); |
| 70 return std::unique_ptr<Buffer>(); | 69 return Buffer(); |
| 71 } | 70 } |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 class ScreenCaptureDeviceAndroidTest : public testing::Test { | 73 class ScreenCaptureDeviceAndroidTest : public testing::Test { |
| 75 public: | 74 public: |
| 76 ScreenCaptureDeviceAndroidTest() {} | 75 ScreenCaptureDeviceAndroidTest() {} |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceAndroidTest); | 78 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceAndroidTest); |
| 80 }; | 79 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 97 media::VideoCaptureParams capture_params; | 96 media::VideoCaptureParams capture_params; |
| 98 capture_params.requested_format.frame_size.SetSize(640, 480); | 97 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 99 capture_params.requested_format.frame_rate = kFrameRate; | 98 capture_params.requested_format.frame_rate = kFrameRate; |
| 100 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 99 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
| 101 capture_device->AllocateAndStart(capture_params, std::move(client)); | 100 capture_device->AllocateAndStart(capture_params, std::move(client)); |
| 102 capture_device->StopAndDeAllocate(); | 101 capture_device->StopAndDeAllocate(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace | 104 } // namespace |
| 106 } // namespace Content | 105 } // namespace Content |
| OLD | NEW |