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