| 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 26 matching lines...) Expand all Loading... |
| 37 class MockVideoCaptureControllerEventHandler | 37 class MockVideoCaptureControllerEventHandler |
| 38 : public VideoCaptureControllerEventHandler { | 38 : public VideoCaptureControllerEventHandler { |
| 39 public: | 39 public: |
| 40 explicit MockVideoCaptureControllerEventHandler( | 40 explicit MockVideoCaptureControllerEventHandler( |
| 41 VideoCaptureController* controller) | 41 VideoCaptureController* controller) |
| 42 : controller_(controller) {} | 42 : controller_(controller) {} |
| 43 virtual ~MockVideoCaptureControllerEventHandler() {} | 43 virtual ~MockVideoCaptureControllerEventHandler() {} |
| 44 | 44 |
| 45 // These mock methods are delegated to by our fake implementation of | 45 // These mock methods are delegated to by our fake implementation of |
| 46 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). | 46 // VideoCaptureControllerEventHandler, to be used in EXPECT_CALL(). |
| 47 MOCK_METHOD1(DoBufferCreated, void(const VideoCaptureControllerID&)); | 47 MOCK_METHOD1(DoBufferCreated, void(VideoCaptureControllerID)); |
| 48 MOCK_METHOD1(DoBufferDestroyed, void(const VideoCaptureControllerID&)); | 48 MOCK_METHOD1(DoBufferDestroyed, void(VideoCaptureControllerID)); |
| 49 MOCK_METHOD1(DoBufferReady, void(const VideoCaptureControllerID&)); | 49 MOCK_METHOD1(DoBufferReady, void(VideoCaptureControllerID)); |
| 50 MOCK_METHOD1(DoMailboxBufferReady, void(const VideoCaptureControllerID&)); | 50 MOCK_METHOD1(DoMailboxBufferReady, void(VideoCaptureControllerID)); |
| 51 MOCK_METHOD1(DoEnded, void(const VideoCaptureControllerID&)); | 51 MOCK_METHOD1(DoEnded, void(VideoCaptureControllerID)); |
| 52 MOCK_METHOD1(DoError, void(const VideoCaptureControllerID&)); | 52 MOCK_METHOD1(DoError, void(VideoCaptureControllerID)); |
| 53 | 53 |
| 54 virtual void OnError(const VideoCaptureControllerID& id) override { | 54 virtual void OnError(VideoCaptureControllerID id) override { |
| 55 DoError(id); | 55 DoError(id); |
| 56 } | 56 } |
| 57 virtual void OnBufferCreated(const VideoCaptureControllerID& id, | 57 virtual void OnBufferCreated(VideoCaptureControllerID id, |
| 58 base::SharedMemoryHandle handle, | 58 base::SharedMemoryHandle handle, |
| 59 int length, int buffer_id) override { | 59 int length, int buffer_id) override { |
| 60 DoBufferCreated(id); | 60 DoBufferCreated(id); |
| 61 } | 61 } |
| 62 virtual void OnBufferDestroyed(const VideoCaptureControllerID& id, | 62 virtual void OnBufferDestroyed(VideoCaptureControllerID id, |
| 63 int buffer_id) override { | 63 int buffer_id) override { |
| 64 DoBufferDestroyed(id); | 64 DoBufferDestroyed(id); |
| 65 } | 65 } |
| 66 virtual void OnBufferReady( | 66 virtual void OnBufferReady( |
| 67 const VideoCaptureControllerID& id, | 67 VideoCaptureControllerID id, |
| 68 int buffer_id, | 68 int buffer_id, |
| 69 const gfx::Size& coded_size, | 69 const gfx::Size& coded_size, |
| 70 const gfx::Rect& visible_rect, | 70 const gfx::Rect& visible_rect, |
| 71 base::TimeTicks timestamp, | 71 const base::TimeTicks& timestamp, |
| 72 scoped_ptr<base::DictionaryValue> metadata) override { | 72 scoped_ptr<base::DictionaryValue> metadata) override { |
| 73 DoBufferReady(id); | 73 DoBufferReady(id); |
| 74 base::MessageLoop::current()->PostTask( | 74 base::MessageLoop::current()->PostTask( |
| 75 FROM_HERE, | 75 FROM_HERE, |
| 76 base::Bind(&VideoCaptureController::ReturnBuffer, | 76 base::Bind(&VideoCaptureController::ReturnBuffer, |
| 77 base::Unretained(controller_), | 77 base::Unretained(controller_), |
| 78 id, | 78 id, |
| 79 this, | 79 this, |
| 80 buffer_id, | 80 buffer_id, |
| 81 0)); | 81 0)); |
| 82 } | 82 } |
| 83 virtual void OnMailboxBufferReady( | 83 virtual void OnMailboxBufferReady( |
| 84 const VideoCaptureControllerID& id, | 84 VideoCaptureControllerID id, |
| 85 int buffer_id, | 85 int buffer_id, |
| 86 const gpu::MailboxHolder& mailbox_holder, | 86 const gpu::MailboxHolder& mailbox_holder, |
| 87 const gfx::Size& packed_frame_size, | 87 const gfx::Size& packed_frame_size, |
| 88 base::TimeTicks timestamp, | 88 const base::TimeTicks& timestamp, |
| 89 scoped_ptr<base::DictionaryValue> metadata) override { | 89 scoped_ptr<base::DictionaryValue> metadata) override { |
| 90 DoMailboxBufferReady(id); | 90 DoMailboxBufferReady(id); |
| 91 base::MessageLoop::current()->PostTask( | 91 base::MessageLoop::current()->PostTask( |
| 92 FROM_HERE, | 92 FROM_HERE, |
| 93 base::Bind(&VideoCaptureController::ReturnBuffer, | 93 base::Bind(&VideoCaptureController::ReturnBuffer, |
| 94 base::Unretained(controller_), | 94 base::Unretained(controller_), |
| 95 id, | 95 id, |
| 96 this, | 96 this, |
| 97 buffer_id, | 97 buffer_id, |
| 98 mailbox_holder.sync_point)); | 98 mailbox_holder.sync_point)); |
| 99 } | 99 } |
| 100 virtual void OnEnded(const VideoCaptureControllerID& id) override { | 100 virtual void OnEnded(VideoCaptureControllerID id) override { |
| 101 DoEnded(id); | 101 DoEnded(id); |
| 102 // OnEnded() must respond by (eventually) unregistering the client. | 102 // OnEnded() must respond by (eventually) unregistering the client. |
| 103 base::MessageLoop::current()->PostTask(FROM_HERE, | 103 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 104 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), | 104 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), |
| 105 base::Unretained(controller_), id, this)); | 105 base::Unretained(controller_), id, this)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 VideoCaptureController* controller_; | 108 VideoCaptureController* controller_; |
| 109 }; | 109 }; |
| 110 | 110 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 params.requested_format.ImageAllocationSize(), | 640 params.requested_format.ImageAllocationSize(), |
| 641 params.requested_format, | 641 params.requested_format, |
| 642 0 /* rotation */, | 642 0 /* rotation */, |
| 643 base::TimeTicks()); | 643 base::TimeTicks()); |
| 644 EXPECT_EQ(100, controller_->RemoveClient(route, client_a_.get())); | 644 EXPECT_EQ(100, controller_->RemoveClient(route, client_a_.get())); |
| 645 Mock::VerifyAndClearExpectations(client_a_.get()); | 645 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 } // namespace content | 649 } // namespace content |
| OLD | NEW |