| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Unit test for VideoCaptureController. | 5 // Unit test for VideoCaptureController. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/video_capture_controller.h" | 7 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 explicit MockVideoCaptureControllerEventHandler( | 45 explicit MockVideoCaptureControllerEventHandler( |
| 46 VideoCaptureController* controller) | 46 VideoCaptureController* controller) |
| 47 : controller_(controller), | 47 : controller_(controller), |
| 48 resource_utilization_(-1.0) {} | 48 resource_utilization_(-1.0) {} |
| 49 ~MockVideoCaptureControllerEventHandler() override {} | 49 ~MockVideoCaptureControllerEventHandler() override {} |
| 50 | 50 |
| 51 // These mock methods are delegated to by our fake implementation of | 51 // These mock methods are delegated to by our fake implementation of |
| 52 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). | 52 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). |
| 53 MOCK_METHOD1(DoBufferCreated, void(VideoCaptureControllerID)); | 53 MOCK_METHOD1(DoBufferCreated, void(VideoCaptureControllerID)); |
| 54 MOCK_METHOD1(DoBufferCreated2, void(VideoCaptureControllerID)); | |
| 55 MOCK_METHOD1(DoBufferDestroyed, void(VideoCaptureControllerID)); | 54 MOCK_METHOD1(DoBufferDestroyed, void(VideoCaptureControllerID)); |
| 56 MOCK_METHOD2(DoI420BufferReady, | 55 MOCK_METHOD2(DoI420BufferReady, |
| 57 void(VideoCaptureControllerID, const gfx::Size&)); | 56 void(VideoCaptureControllerID, const gfx::Size&)); |
| 58 MOCK_METHOD1(DoEnded, void(VideoCaptureControllerID)); | 57 MOCK_METHOD1(DoEnded, void(VideoCaptureControllerID)); |
| 59 MOCK_METHOD1(DoError, void(VideoCaptureControllerID)); | 58 MOCK_METHOD1(DoError, void(VideoCaptureControllerID)); |
| 60 | 59 |
| 61 void OnError(VideoCaptureControllerID id) override { | 60 void OnError(VideoCaptureControllerID id) override { |
| 62 DoError(id); | 61 DoError(id); |
| 63 } | 62 } |
| 64 void OnBufferCreated(VideoCaptureControllerID id, | 63 void OnBufferCreated(VideoCaptureControllerID id, |
| 65 base::SharedMemoryHandle handle, | 64 base::SharedMemoryHandle handle, |
| 66 int length, int buffer_id) override { | 65 int length, int buffer_id) override { |
| 67 DoBufferCreated(id); | 66 DoBufferCreated(id); |
| 68 } | 67 } |
| 69 void OnBufferCreated2( | |
| 70 VideoCaptureControllerID id, | |
| 71 const std::vector<gfx::GpuMemoryBufferHandle>& handles, | |
| 72 const gfx::Size& size, | |
| 73 int buffer_id) override { | |
| 74 DoBufferCreated2(id); | |
| 75 } | |
| 76 void OnBufferDestroyed(VideoCaptureControllerID id, int buffer_id) override { | 68 void OnBufferDestroyed(VideoCaptureControllerID id, int buffer_id) override { |
| 77 DoBufferDestroyed(id); | 69 DoBufferDestroyed(id); |
| 78 } | 70 } |
| 79 void OnBufferReady(VideoCaptureControllerID id, | 71 void OnBufferReady(VideoCaptureControllerID id, |
| 80 int buffer_id, | 72 int buffer_id, |
| 81 const scoped_refptr<media::VideoFrame>& frame) override { | 73 const scoped_refptr<media::VideoFrame>& frame) override { |
| 82 EXPECT_EQ(frame->format(), media::PIXEL_FORMAT_I420); | 74 EXPECT_EQ(frame->format(), media::PIXEL_FORMAT_I420); |
| 83 base::TimeTicks reference_time; | 75 base::TimeTicks reference_time; |
| 84 EXPECT_TRUE(frame->metadata()->GetTimeTicks( | 76 EXPECT_TRUE(frame->metadata()->GetTimeTicks( |
| 85 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time)); | 77 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time)); |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 573 |
| 582 // Second client connects after the error state. It also should get told of | 574 // Second client connects after the error state. It also should get told of |
| 583 // the error. | 575 // the error. |
| 584 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 576 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 585 controller_->AddClient( | 577 controller_->AddClient( |
| 586 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); | 578 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 587 Mock::VerifyAndClearExpectations(client_b_.get()); | 579 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 588 } | 580 } |
| 589 | 581 |
| 590 } // namespace content | 582 } // namespace content |
| OLD | NEW |