| 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; | |
| 103 params.requested_format = media::VideoCaptureFormat( | 102 params.requested_format = media::VideoCaptureFormat( |
| 104 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 103 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 105 | 104 |
| 106 VideoCaptureControllerID client_id(next_client_id_++); | 105 VideoCaptureControllerID client_id(next_client_id_++); |
| 107 base::RunLoop run_loop; | 106 base::RunLoop run_loop; |
| 108 vcm_->StartCaptureForClient( | 107 vcm_->StartCaptureForClient( |
| 109 params, base::kNullProcessHandle, client_id, frame_observer_.get(), | 108 session_id, |
| 109 params, |
| 110 base::kNullProcessHandle, |
| 111 client_id, |
| 112 frame_observer_.get(), |
| 110 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, | 113 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, |
| 111 base::Unretained(this), client_id, run_loop.QuitClosure(), | 114 base::Unretained(this), |
| 115 client_id, |
| 116 run_loop.QuitClosure(), |
| 112 expect_success)); | 117 expect_success)); |
| 113 run_loop.Run(); | 118 run_loop.Run(); |
| 114 return client_id; | 119 return client_id; |
| 115 } | 120 } |
| 116 | 121 |
| 117 void StopClient(VideoCaptureControllerID client_id) { | 122 void StopClient(VideoCaptureControllerID client_id) { |
| 118 ASSERT_TRUE(1 == controllers_.count(client_id)); | 123 ASSERT_TRUE(1 == controllers_.count(client_id)); |
| 119 vcm_->StopCaptureForClient(controllers_[client_id], client_id, | 124 vcm_->StopCaptureForClient(controllers_[client_id], client_id, |
| 120 frame_observer_.get()); | 125 frame_observer_.get()); |
| 121 controllers_.erase(client_id); | 126 controllers_.erase(client_id); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // VideoCaptureManager destructor otherwise. | 290 // VideoCaptureManager destructor otherwise. |
| 286 vcm_->Close(video_session_id); | 291 vcm_->Close(video_session_id); |
| 287 StopClient(client_id); | 292 StopClient(client_id); |
| 288 | 293 |
| 289 // Wait to check callbacks before removing the listener | 294 // Wait to check callbacks before removing the listener |
| 290 message_loop_->RunUntilIdle(); | 295 message_loop_->RunUntilIdle(); |
| 291 vcm_->Unregister(); | 296 vcm_->Unregister(); |
| 292 } | 297 } |
| 293 | 298 |
| 294 } // namespace content | 299 } // namespace content |
| OLD | NEW |