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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 78 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
79 message_loop_.get())); | 79 message_loop_.get())); |
80 vcm_ = new VideoCaptureManager(); | 80 vcm_ = new VideoCaptureManager(); |
81 vcm_->UseFakeDevice(); | 81 vcm_->UseFakeDevice(); |
82 vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().get()); | 82 vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().get()); |
83 frame_observer_.reset(new MockFrameObserver()); | 83 frame_observer_.reset(new MockFrameObserver()); |
84 } | 84 } |
85 | 85 |
86 virtual void TearDown() OVERRIDE {} | 86 virtual void TearDown() OVERRIDE {} |
87 | 87 |
88 void OnGotControllerCallback(VideoCaptureControllerID id, | 88 void OnGotControllerCallback( |
89 base::Closure quit_closure, | 89 VideoCaptureControllerID id, |
90 bool expect_success, | 90 base::Closure quit_closure, |
91 VideoCaptureController* controller) { | 91 bool expect_success, |
| 92 const base::WeakPtr<VideoCaptureController>& controller) { |
92 if (expect_success) { | 93 if (expect_success) { |
93 ASSERT_TRUE(NULL != controller); | 94 ASSERT_TRUE(controller); |
94 ASSERT_TRUE(0 == controllers_.count(id)); | 95 ASSERT_TRUE(0 == controllers_.count(id)); |
95 controllers_[id] = controller; | 96 controllers_[id] = controller.get(); |
96 } else { | 97 } else { |
97 ASSERT_TRUE(NULL == controller); | 98 ASSERT_TRUE(NULL == controller); |
98 } | 99 } |
99 quit_closure.Run(); | 100 quit_closure.Run(); |
100 } | 101 } |
101 | 102 |
102 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { | 103 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { |
103 media::VideoCaptureParams params; | 104 media::VideoCaptureParams params; |
104 params.session_id = session_id; | 105 params.session_id = session_id; |
105 params.width = 320; | 106 params.width = 320; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // VideoCaptureManager destructor otherwise. | 307 // VideoCaptureManager destructor otherwise. |
307 vcm_->Close(video_session_id); | 308 vcm_->Close(video_session_id); |
308 StopClient(client_id); | 309 StopClient(client_id); |
309 | 310 |
310 // Wait to check callbacks before removing the listener | 311 // Wait to check callbacks before removing the listener |
311 message_loop_->RunUntilIdle(); | 312 message_loop_->RunUntilIdle(); |
312 vcm_->Unregister(); | 313 vcm_->Unregister(); |
313 } | 314 } |
314 | 315 |
315 } // namespace content | 316 } // namespace content |
OLD | NEW |