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