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 VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 ASSERT_TRUE(0 == controllers_.count(id)); | 92 ASSERT_TRUE(0 == controllers_.count(id)); |
93 controllers_[id] = controller.get(); | 93 controllers_[id] = controller.get(); |
94 } else { | 94 } else { |
95 ASSERT_TRUE(NULL == controller); | 95 ASSERT_TRUE(NULL == controller); |
96 } | 96 } |
97 quit_closure.Run(); | 97 quit_closure.Run(); |
98 } | 98 } |
99 | 99 |
100 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { | 100 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { |
101 media::VideoCaptureParams params; | 101 media::VideoCaptureParams params; |
| 102 params.session_id = session_id; |
102 params.requested_format = media::VideoCaptureFormat( | 103 params.requested_format = media::VideoCaptureFormat( |
103 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); | 104 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); |
104 | 105 |
105 VideoCaptureControllerID client_id(next_client_id_++); | 106 VideoCaptureControllerID client_id(next_client_id_++); |
106 base::RunLoop run_loop; | 107 base::RunLoop run_loop; |
107 vcm_->StartCaptureForClient( | 108 vcm_->StartCaptureForClient( |
108 session_id, | 109 params, base::kNullProcessHandle, client_id, frame_observer_.get(), |
109 params, | |
110 base::kNullProcessHandle, | |
111 client_id, | |
112 frame_observer_.get(), | |
113 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, | 110 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, |
114 base::Unretained(this), | 111 base::Unretained(this), client_id, run_loop.QuitClosure(), |
115 client_id, | |
116 run_loop.QuitClosure(), | |
117 expect_success)); | 112 expect_success)); |
118 run_loop.Run(); | 113 run_loop.Run(); |
119 return client_id; | 114 return client_id; |
120 } | 115 } |
121 | 116 |
122 void StopClient(VideoCaptureControllerID client_id) { | 117 void StopClient(VideoCaptureControllerID client_id) { |
123 ASSERT_TRUE(1 == controllers_.count(client_id)); | 118 ASSERT_TRUE(1 == controllers_.count(client_id)); |
124 vcm_->StopCaptureForClient(controllers_[client_id], client_id, | 119 vcm_->StopCaptureForClient(controllers_[client_id], client_id, |
125 frame_observer_.get()); | 120 frame_observer_.get()); |
126 controllers_.erase(client_id); | 121 controllers_.erase(client_id); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // VideoCaptureManager destructor otherwise. | 285 // VideoCaptureManager destructor otherwise. |
291 vcm_->Close(video_session_id); | 286 vcm_->Close(video_session_id); |
292 StopClient(client_id); | 287 StopClient(client_id); |
293 | 288 |
294 // Wait to check callbacks before removing the listener | 289 // Wait to check callbacks before removing the listener |
295 message_loop_->RunUntilIdle(); | 290 message_loop_->RunUntilIdle(); |
296 vcm_->Unregister(); | 291 vcm_->Unregister(); |
297 } | 292 } |
298 | 293 |
299 } // namespace content | 294 } // namespace content |
OLD | NEW |