| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 using ::testing::SaveArg; | 36 using ::testing::SaveArg; |
| 37 | 37 |
| 38 namespace content { | 38 namespace content { |
| 39 | 39 |
| 40 class MockVideoCaptureControllerEventHandler | 40 class MockVideoCaptureControllerEventHandler |
| 41 : public VideoCaptureControllerEventHandler { | 41 : public VideoCaptureControllerEventHandler { |
| 42 public: | 42 public: |
| 43 explicit MockVideoCaptureControllerEventHandler( | 43 explicit MockVideoCaptureControllerEventHandler( |
| 44 VideoCaptureController* controller) | 44 VideoCaptureController* controller) |
| 45 : controller_(controller) {} | 45 : controller_(controller) {} |
| 46 virtual ~MockVideoCaptureControllerEventHandler() {} | 46 ~MockVideoCaptureControllerEventHandler() override {} |
| 47 | 47 |
| 48 // These mock methods are delegated to by our fake implementation of | 48 // These mock methods are delegated to by our fake implementation of |
| 49 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). | 49 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). |
| 50 MOCK_METHOD1(DoBufferCreated, void(VideoCaptureControllerID)); | 50 MOCK_METHOD1(DoBufferCreated, void(VideoCaptureControllerID)); |
| 51 MOCK_METHOD1(DoBufferDestroyed, void(VideoCaptureControllerID)); | 51 MOCK_METHOD1(DoBufferDestroyed, void(VideoCaptureControllerID)); |
| 52 MOCK_METHOD2(DoBufferReady, void(VideoCaptureControllerID, const gfx::Size&)); | 52 MOCK_METHOD2(DoBufferReady, void(VideoCaptureControllerID, const gfx::Size&)); |
| 53 MOCK_METHOD1(DoMailboxBufferReady, void(VideoCaptureControllerID)); | 53 MOCK_METHOD1(DoMailboxBufferReady, void(VideoCaptureControllerID)); |
| 54 MOCK_METHOD1(DoEnded, void(VideoCaptureControllerID)); | 54 MOCK_METHOD1(DoEnded, void(VideoCaptureControllerID)); |
| 55 MOCK_METHOD1(DoError, void(VideoCaptureControllerID)); | 55 MOCK_METHOD1(DoError, void(VideoCaptureControllerID)); |
| 56 | 56 |
| 57 virtual void OnError(VideoCaptureControllerID id) override { | 57 void OnError(VideoCaptureControllerID id) override { |
| 58 DoError(id); | 58 DoError(id); |
| 59 } | 59 } |
| 60 virtual void OnBufferCreated(VideoCaptureControllerID id, | 60 void OnBufferCreated(VideoCaptureControllerID id, |
| 61 base::SharedMemoryHandle handle, | 61 base::SharedMemoryHandle handle, |
| 62 int length, int buffer_id) override { | 62 int length, int buffer_id) override { |
| 63 DoBufferCreated(id); | 63 DoBufferCreated(id); |
| 64 } | 64 } |
| 65 virtual void OnBufferDestroyed(VideoCaptureControllerID id, | 65 void OnBufferDestroyed(VideoCaptureControllerID id, int buffer_id) override { |
| 66 int buffer_id) override { | |
| 67 DoBufferDestroyed(id); | 66 DoBufferDestroyed(id); |
| 68 } | 67 } |
| 69 virtual void OnBufferReady( | 68 void OnBufferReady( |
| 70 VideoCaptureControllerID id, | 69 VideoCaptureControllerID id, |
| 71 int buffer_id, | 70 int buffer_id, |
| 72 const gfx::Size& coded_size, | 71 const gfx::Size& coded_size, |
| 73 const gfx::Rect& visible_rect, | 72 const gfx::Rect& visible_rect, |
| 74 const base::TimeTicks& timestamp, | 73 const base::TimeTicks& timestamp, |
| 75 scoped_ptr<base::DictionaryValue> metadata) override { | 74 scoped_ptr<base::DictionaryValue> metadata) override { |
| 76 DoBufferReady(id, coded_size); | 75 DoBufferReady(id, coded_size); |
| 77 base::MessageLoop::current()->PostTask( | 76 base::MessageLoop::current()->PostTask( |
| 78 FROM_HERE, | 77 FROM_HERE, |
| 79 base::Bind(&VideoCaptureController::ReturnBuffer, | 78 base::Bind(&VideoCaptureController::ReturnBuffer, |
| 80 base::Unretained(controller_), | 79 base::Unretained(controller_), |
| 81 id, | 80 id, |
| 82 this, | 81 this, |
| 83 buffer_id, | 82 buffer_id, |
| 84 0)); | 83 0)); |
| 85 } | 84 } |
| 86 virtual void OnMailboxBufferReady( | 85 void OnMailboxBufferReady( |
| 87 VideoCaptureControllerID id, | 86 VideoCaptureControllerID id, |
| 88 int buffer_id, | 87 int buffer_id, |
| 89 const gpu::MailboxHolder& mailbox_holder, | 88 const gpu::MailboxHolder& mailbox_holder, |
| 90 const gfx::Size& packed_frame_size, | 89 const gfx::Size& packed_frame_size, |
| 91 const base::TimeTicks& timestamp, | 90 const base::TimeTicks& timestamp, |
| 92 scoped_ptr<base::DictionaryValue> metadata) override { | 91 scoped_ptr<base::DictionaryValue> metadata) override { |
| 93 DoMailboxBufferReady(id); | 92 DoMailboxBufferReady(id); |
| 94 base::MessageLoop::current()->PostTask( | 93 base::MessageLoop::current()->PostTask( |
| 95 FROM_HERE, | 94 FROM_HERE, |
| 96 base::Bind(&VideoCaptureController::ReturnBuffer, | 95 base::Bind(&VideoCaptureController::ReturnBuffer, |
| 97 base::Unretained(controller_), | 96 base::Unretained(controller_), |
| 98 id, | 97 id, |
| 99 this, | 98 this, |
| 100 buffer_id, | 99 buffer_id, |
| 101 mailbox_holder.sync_point)); | 100 mailbox_holder.sync_point)); |
| 102 } | 101 } |
| 103 virtual void OnEnded(VideoCaptureControllerID id) override { | 102 void OnEnded(VideoCaptureControllerID id) override { |
| 104 DoEnded(id); | 103 DoEnded(id); |
| 105 // OnEnded() must respond by (eventually) unregistering the client. | 104 // OnEnded() must respond by (eventually) unregistering the client. |
| 106 base::MessageLoop::current()->PostTask(FROM_HERE, | 105 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 107 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), | 106 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), |
| 108 base::Unretained(controller_), id, this)); | 107 base::Unretained(controller_), id, this)); |
| 109 } | 108 } |
| 110 | 109 |
| 111 VideoCaptureController* controller_; | 110 VideoCaptureController* controller_; |
| 112 }; | 111 }; |
| 113 | 112 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); | 701 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); |
| 703 EXPECT_EQ(coded_size.height(), | 702 EXPECT_EQ(coded_size.height(), |
| 704 size_and_rotation.output_resolution.height()); | 703 size_and_rotation.output_resolution.height()); |
| 705 | 704 |
| 706 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); | 705 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); |
| 707 Mock::VerifyAndClearExpectations(client_a_.get()); | 706 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 708 } | 707 } |
| 709 } | 708 } |
| 710 | 709 |
| 711 } // namespace content | 710 } // namespace content |
| OLD | NEW |