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

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

Issue 10537057: refactor VideoCaptureHost and VideoCaptureController. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 13 matching lines...) Expand all
24 using ::testing::_; 24 using ::testing::_;
25 using ::testing::AnyNumber; 25 using ::testing::AnyNumber;
26 using ::testing::AtLeast; 26 using ::testing::AtLeast;
27 using ::testing::InSequence; 27 using ::testing::InSequence;
28 using ::testing::Return; 28 using ::testing::Return;
29 using content::BrowserThread; 29 using content::BrowserThread;
30 using content::BrowserThreadImpl; 30 using content::BrowserThreadImpl;
31 31
32 enum { kDeviceId = 1 }; 32 enum { kDeviceId = 1 };
33 33
34 ACTION_P5(StopCapture, controller, controller_id, controller_handler, flag, 34 ACTION_P4(StopCapture, controller, controller_id, controller_handler,
35 message_loop) { 35 message_loop) {
36 message_loop->PostTask(FROM_HERE, 36 message_loop->PostTask(FROM_HERE,
37 base::Bind(&VideoCaptureController::StopCapture, 37 base::Bind(&VideoCaptureController::StopCapture,
38 controller, controller_id, controller_handler, flag)); 38 controller, controller_id, controller_handler));
39 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 39 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
40 } 40 }
41 41
42 ACTION_P3(StopSession, controller, session_id, message_loop) { 42 ACTION_P3(StopSession, controller, session_id, message_loop) {
43 message_loop->PostTask(FROM_HERE, 43 message_loop->PostTask(FROM_HERE,
44 base::Bind(&VideoCaptureController::StopSession, 44 base::Bind(&VideoCaptureController::StopSession,
45 controller, session_id)); 45 controller, session_id));
46 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 46 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
47 } 47 }
48 48
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int width, 83 int width,
84 int height, 84 int height,
85 int frame_per_second) OVERRIDE { 85 int frame_per_second) OVERRIDE {
86 EXPECT_EQ(id, controller_id_); 86 EXPECT_EQ(id, controller_id_);
87 DoFrameInfo(id); 87 DoFrameInfo(id);
88 } 88 }
89 virtual void OnPaused(const VideoCaptureControllerID& id) OVERRIDE { 89 virtual void OnPaused(const VideoCaptureControllerID& id) OVERRIDE {
90 EXPECT_EQ(id, controller_id_); 90 EXPECT_EQ(id, controller_id_);
91 DoPaused(id); 91 DoPaused(id);
92 } 92 }
93 virtual void OnReadyToDelete(const VideoCaptureControllerID& id) OVERRIDE {}
94 93
95 scoped_refptr<VideoCaptureController> controller_; 94 scoped_refptr<VideoCaptureController> controller_;
96 MessageLoop* message_loop_; 95 MessageLoop* message_loop_;
97 VideoCaptureControllerID controller_id_; 96 VideoCaptureControllerID controller_id_;
98 base::ProcessHandle process_handle_; 97 base::ProcessHandle process_handle_;
99 }; 98 };
100 99
101 class MockVideoCaptureManager 100 class MockVideoCaptureManager
102 : public media_stream::VideoCaptureManager { 101 : public media_stream::VideoCaptureManager {
103 public: 102 public:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 DoFrameInfo(controller_handler_->controller_id_)) 198 DoFrameInfo(controller_handler_->controller_id_))
200 .Times(AtLeast(1)); 199 .Times(AtLeast(1));
201 EXPECT_CALL(*controller_handler_, 200 EXPECT_CALL(*controller_handler_,
202 DoBufferCreated(controller_handler_->controller_id_)) 201 DoBufferCreated(controller_handler_->controller_id_))
203 .Times(AtLeast(1)); 202 .Times(AtLeast(1));
204 EXPECT_CALL(*controller_handler_, 203 EXPECT_CALL(*controller_handler_,
205 DoBufferReady(controller_handler_->controller_id_)) 204 DoBufferReady(controller_handler_->controller_id_))
206 .Times(AtLeast(1)) 205 .Times(AtLeast(1))
207 .WillOnce(StopCapture(controller_.get(), 206 .WillOnce(StopCapture(controller_.get(),
208 controller_handler_->controller_id_, 207 controller_handler_->controller_id_,
209 controller_handler_.get(), true, 208 controller_handler_.get(),
210 message_loop_.get())); 209 message_loop_.get()));
211 EXPECT_CALL(*vcm_, 210 EXPECT_CALL(*vcm_,
212 StopCapture(vcm_->video_session_id_)) 211 StopCapture(vcm_->video_session_id_))
213 .Times(1); 212 .Times(1);
214 213
215 controller_->StartCapture(controller_handler_->controller_id_, 214 controller_->StartCapture(controller_handler_->controller_id_,
216 controller_handler_.get(), 215 controller_handler_.get(),
217 controller_handler_->process_handle_, 216 controller_handler_->process_handle_,
218 capture_params); 217 capture_params);
219 message_loop_->Run(); 218 message_loop_->Run();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 DoBufferReady(controller_handler_->controller_id_)) 260 DoBufferReady(controller_handler_->controller_id_))
262 .Times(0); 261 .Times(0);
263 message_loop_->PostDelayedTask( 262 message_loop_->PostDelayedTask(
264 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); 263 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1));
265 message_loop_->Run(); 264 message_loop_->Run();
266 265
267 EXPECT_CALL(*vcm_, 266 EXPECT_CALL(*vcm_,
268 StopCapture(vcm_->video_session_id_)) 267 StopCapture(vcm_->video_session_id_))
269 .Times(1); 268 .Times(1);
270 controller_->StopCapture(controller_handler_->controller_id_, 269 controller_->StopCapture(controller_handler_->controller_id_,
271 controller_handler_.get(), true); 270 controller_handler_.get());
272 } 271 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698