| 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" |
| 11 #include "base/location.h" | |
| 12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | |
| 16 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 17 #include "content/browser/renderer_host/media/media_stream_provider.h" | 16 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 18 #include "content/browser/renderer_host/media/video_capture_controller.h" | 17 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 19 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 18 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
| 20 #include "content/browser/renderer_host/media/video_capture_manager.h" | 19 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 21 #include "content/common/gpu/client/gl_helper.h" | 20 #include "content/common/gpu/client/gl_helper.h" |
| 22 #include "content/common/media/media_stream_options.h" | 21 #include "content/common/media/media_stream_options.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "gpu/command_buffer/common/mailbox_holder.h" | 23 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 25 #include "media/base/video_capture_types.h" | 24 #include "media/base/video_capture_types.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 DoBufferDestroyed(id); | 66 DoBufferDestroyed(id); |
| 68 } | 67 } |
| 69 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::ThreadTaskRunnerHandle::Get()->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_), id, this, buffer_id, 0)); | 79 base::Unretained(controller_), |
| 80 id, |
| 81 this, |
| 82 buffer_id, |
| 83 0)); |
| 81 } | 84 } |
| 82 void OnMailboxBufferReady( | 85 void OnMailboxBufferReady( |
| 83 VideoCaptureControllerID id, | 86 VideoCaptureControllerID id, |
| 84 int buffer_id, | 87 int buffer_id, |
| 85 const gpu::MailboxHolder& mailbox_holder, | 88 const gpu::MailboxHolder& mailbox_holder, |
| 86 const gfx::Size& packed_frame_size, | 89 const gfx::Size& packed_frame_size, |
| 87 const base::TimeTicks& timestamp, | 90 const base::TimeTicks& timestamp, |
| 88 scoped_ptr<base::DictionaryValue> metadata) override { | 91 scoped_ptr<base::DictionaryValue> metadata) override { |
| 89 DoMailboxBufferReady(id); | 92 DoMailboxBufferReady(id); |
| 90 base::ThreadTaskRunnerHandle::Get()->PostTask( | 93 base::MessageLoop::current()->PostTask( |
| 91 FROM_HERE, base::Bind(&VideoCaptureController::ReturnBuffer, | 94 FROM_HERE, |
| 92 base::Unretained(controller_), id, this, | 95 base::Bind(&VideoCaptureController::ReturnBuffer, |
| 93 buffer_id, mailbox_holder.sync_point)); | 96 base::Unretained(controller_), |
| 97 id, |
| 98 this, |
| 99 buffer_id, |
| 100 mailbox_holder.sync_point)); |
| 94 } | 101 } |
| 95 void OnEnded(VideoCaptureControllerID id) override { | 102 void OnEnded(VideoCaptureControllerID id) override { |
| 96 DoEnded(id); | 103 DoEnded(id); |
| 97 // OnEnded() must respond by (eventually) unregistering the client. | 104 // OnEnded() must respond by (eventually) unregistering the client. |
| 98 base::ThreadTaskRunnerHandle::Get()->PostTask( | 105 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 99 FROM_HERE, | |
| 100 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), | 106 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), |
| 101 base::Unretained(controller_), id, this)); | 107 base::Unretained(controller_), id, this)); |
| 102 } | 108 } |
| 103 | 109 |
| 104 VideoCaptureController* controller_; | 110 VideoCaptureController* controller_; |
| 105 }; | 111 }; |
| 106 | 112 |
| 107 // Test class. | 113 // Test class. |
| 108 class VideoCaptureControllerTest : public testing::Test { | 114 class VideoCaptureControllerTest : public testing::Test { |
| 109 public: | 115 public: |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); | 698 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); |
| 693 EXPECT_EQ(coded_size.height(), | 699 EXPECT_EQ(coded_size.height(), |
| 694 size_and_rotation.output_resolution.height()); | 700 size_and_rotation.output_resolution.height()); |
| 695 | 701 |
| 696 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); | 702 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); |
| 697 Mock::VerifyAndClearExpectations(client_a_.get()); | 703 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 698 } | 704 } |
| 699 } | 705 } |
| 700 | 706 |
| 701 } // namespace content | 707 } // namespace content |
| OLD | NEW |