Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 protected: 149 protected:
150 virtual void SetUp() OVERRIDE { 150 virtual void SetUp() OVERRIDE {
151 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); 151 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
152 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE, 152 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE,
153 message_loop_.get())); 153 message_loop_.get()));
154 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, 154 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO,
155 message_loop_.get())); 155 message_loop_.get()));
156 156
157 vcm_ = new MockVideoCaptureManager(); 157 vcm_ = new MockVideoCaptureManager();
158 vcm_->Init(); 158 vcm_->Init();
159 controller_ = new VideoCaptureController(vcm_); 159 controller_ = new VideoCaptureController(vcm_.get());
160 controller_handler_.reset( 160 controller_handler_.reset(new MockVideoCaptureControllerEventHandler(
161 new MockVideoCaptureControllerEventHandler(controller_.get(), 161 controller_.get(), message_loop_.get()));
162 message_loop_.get()));
163 } 162 }
164 163
165 virtual void TearDown() OVERRIDE {} 164 virtual void TearDown() OVERRIDE {}
166 165
167 scoped_ptr<base::MessageLoop> message_loop_; 166 scoped_ptr<base::MessageLoop> message_loop_;
168 scoped_ptr<BrowserThreadImpl> file_thread_; 167 scoped_ptr<BrowserThreadImpl> file_thread_;
169 scoped_ptr<BrowserThreadImpl> io_thread_; 168 scoped_ptr<BrowserThreadImpl> io_thread_;
170 scoped_refptr<MockVideoCaptureManager> vcm_; 169 scoped_refptr<MockVideoCaptureManager> vcm_;
171 scoped_ptr<MockVideoCaptureControllerEventHandler> controller_handler_; 170 scoped_ptr<MockVideoCaptureControllerEventHandler> controller_handler_;
172 scoped_refptr<VideoCaptureController> controller_; 171 scoped_refptr<VideoCaptureController> controller_;
173 172
174 private: 173 private:
175 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); 174 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest);
176 }; 175 };
177 176
178 // Try to start and stop capture. 177 // Try to start and stop capture.
179 TEST_F(VideoCaptureControllerTest, StartAndStop) { 178 TEST_F(VideoCaptureControllerTest, StartAndStop) {
180 media::VideoCaptureParams capture_params; 179 media::VideoCaptureParams capture_params;
181 capture_params.session_id = vcm_->video_session_id_; 180 capture_params.session_id = vcm_->video_session_id_;
182 capture_params.width = 320; 181 capture_params.width = 320;
183 capture_params.height = 240; 182 capture_params.height = 240;
184 capture_params.frame_per_second = 30; 183 capture_params.frame_per_second = 30;
185 184
186 InSequence s; 185 InSequence s;
187 EXPECT_CALL(*vcm_, 186 EXPECT_CALL(*vcm_.get(),
188 StartCapture(capture_params.width, 187 StartCapture(capture_params.width,
189 capture_params.height, 188 capture_params.height,
190 controller_.get())) 189 controller_.get())).Times(1);
191 .Times(1);
192 EXPECT_CALL(*controller_handler_, 190 EXPECT_CALL(*controller_handler_,
193 DoFrameInfo(controller_handler_->controller_id_)) 191 DoFrameInfo(controller_handler_->controller_id_))
194 .Times(AtLeast(1)); 192 .Times(AtLeast(1));
195 EXPECT_CALL(*controller_handler_, 193 EXPECT_CALL(*controller_handler_,
196 DoBufferCreated(controller_handler_->controller_id_)) 194 DoBufferCreated(controller_handler_->controller_id_))
197 .Times(AtLeast(1)); 195 .Times(AtLeast(1));
198 EXPECT_CALL(*controller_handler_, 196 EXPECT_CALL(*controller_handler_,
199 DoBufferReady(controller_handler_->controller_id_)) 197 DoBufferReady(controller_handler_->controller_id_))
200 .Times(AtLeast(1)) 198 .Times(AtLeast(1))
201 .WillOnce(StopCapture(controller_.get(), 199 .WillOnce(StopCapture(controller_.get(),
202 controller_handler_->controller_id_, 200 controller_handler_->controller_id_,
203 controller_handler_.get(), 201 controller_handler_.get(),
204 message_loop_.get())); 202 message_loop_.get()));
205 EXPECT_CALL(*vcm_, 203 EXPECT_CALL(*vcm_.get(), StopCapture(vcm_->video_session_id_)).Times(1);
206 StopCapture(vcm_->video_session_id_))
207 .Times(1);
208 204
209 controller_->StartCapture(controller_handler_->controller_id_, 205 controller_->StartCapture(controller_handler_->controller_id_,
210 controller_handler_.get(), 206 controller_handler_.get(),
211 controller_handler_->process_handle_, 207 controller_handler_->process_handle_,
212 capture_params); 208 capture_params);
213 message_loop_->Run(); 209 message_loop_->Run();
214 } 210 }
215 211
216 // Try to stop session before stopping capture. 212 // Try to stop session before stopping capture.
217 TEST_F(VideoCaptureControllerTest, StopSession) { 213 TEST_F(VideoCaptureControllerTest, StopSession) {
218 media::VideoCaptureParams capture_params; 214 media::VideoCaptureParams capture_params;
219 capture_params.session_id = vcm_->video_session_id_; 215 capture_params.session_id = vcm_->video_session_id_;
220 capture_params.width = 320; 216 capture_params.width = 320;
221 capture_params.height = 240; 217 capture_params.height = 240;
222 capture_params.frame_per_second = 30; 218 capture_params.frame_per_second = 30;
223 219
224 InSequence s; 220 InSequence s;
225 EXPECT_CALL(*vcm_, 221 EXPECT_CALL(*vcm_.get(),
226 StartCapture(capture_params.width, 222 StartCapture(capture_params.width,
227 capture_params.height, 223 capture_params.height,
228 controller_.get())) 224 controller_.get())).Times(1);
229 .Times(1);
230 EXPECT_CALL(*controller_handler_, 225 EXPECT_CALL(*controller_handler_,
231 DoFrameInfo(controller_handler_->controller_id_)) 226 DoFrameInfo(controller_handler_->controller_id_))
232 .Times(AtLeast(1)); 227 .Times(AtLeast(1));
233 EXPECT_CALL(*controller_handler_, 228 EXPECT_CALL(*controller_handler_,
234 DoBufferCreated(controller_handler_->controller_id_)) 229 DoBufferCreated(controller_handler_->controller_id_))
235 .Times(AtLeast(1)); 230 .Times(AtLeast(1));
236 EXPECT_CALL(*controller_handler_, 231 EXPECT_CALL(*controller_handler_,
237 DoBufferReady(controller_handler_->controller_id_)) 232 DoBufferReady(controller_handler_->controller_id_))
238 .Times(AtLeast(1)) 233 .Times(AtLeast(1))
239 .WillOnce(StopSession(controller_.get(), 234 .WillOnce(StopSession(controller_.get(),
(...skipping 11 matching lines...) Expand all
251 246
252 // The session is stopped now. There should be no buffer coming from 247 // The session is stopped now. There should be no buffer coming from
253 // controller. 248 // controller.
254 EXPECT_CALL(*controller_handler_, 249 EXPECT_CALL(*controller_handler_,
255 DoBufferReady(controller_handler_->controller_id_)) 250 DoBufferReady(controller_handler_->controller_id_))
256 .Times(0); 251 .Times(0);
257 message_loop_->PostDelayedTask(FROM_HERE, 252 message_loop_->PostDelayedTask(FROM_HERE,
258 base::MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); 253 base::MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1));
259 message_loop_->Run(); 254 message_loop_->Run();
260 255
261 EXPECT_CALL(*vcm_, 256 EXPECT_CALL(*vcm_.get(), StopCapture(vcm_->video_session_id_)).Times(1);
262 StopCapture(vcm_->video_session_id_))
263 .Times(1);
264 controller_->StopCapture(controller_handler_->controller_id_, 257 controller_->StopCapture(controller_handler_->controller_id_,
265 controller_handler_.get()); 258 controller_handler_.get());
266 } 259 }
267 260
268 } // namespace content 261 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698