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

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

Issue 13616004: Switch event type when a capture device has been stopped from the render process. This make sure th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed code review comments. Created 7 years, 8 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 : controller_(controller), 54 : controller_(controller),
55 message_loop_(message_loop), 55 message_loop_(message_loop),
56 controller_id_(kDeviceId), 56 controller_id_(kDeviceId),
57 process_handle_(base::kNullProcessHandle) { 57 process_handle_(base::kNullProcessHandle) {
58 } 58 }
59 virtual ~MockVideoCaptureControllerEventHandler() {} 59 virtual ~MockVideoCaptureControllerEventHandler() {}
60 60
61 MOCK_METHOD1(DoBufferCreated, void(const VideoCaptureControllerID&)); 61 MOCK_METHOD1(DoBufferCreated, void(const VideoCaptureControllerID&));
62 MOCK_METHOD1(DoBufferReady, void(const VideoCaptureControllerID&)); 62 MOCK_METHOD1(DoBufferReady, void(const VideoCaptureControllerID&));
63 MOCK_METHOD1(DoFrameInfo, void(const VideoCaptureControllerID&)); 63 MOCK_METHOD1(DoFrameInfo, void(const VideoCaptureControllerID&));
64 MOCK_METHOD1(DoPaused, void(const VideoCaptureControllerID&)); 64 MOCK_METHOD1(DoEnded, void(const VideoCaptureControllerID&));
65 65
66 virtual void OnError(const VideoCaptureControllerID& id) OVERRIDE {} 66 virtual void OnError(const VideoCaptureControllerID& id) OVERRIDE {}
67 virtual void OnBufferCreated(const VideoCaptureControllerID& id, 67 virtual void OnBufferCreated(const VideoCaptureControllerID& id,
68 base::SharedMemoryHandle handle, 68 base::SharedMemoryHandle handle,
69 int length, int buffer_id) OVERRIDE { 69 int length, int buffer_id) OVERRIDE {
70 EXPECT_EQ(id, controller_id_); 70 EXPECT_EQ(id, controller_id_);
71 DoBufferCreated(id); 71 DoBufferCreated(id);
72 } 72 }
73 virtual void OnBufferReady(const VideoCaptureControllerID& id, 73 virtual void OnBufferReady(const VideoCaptureControllerID& id,
74 int buffer_id, 74 int buffer_id,
75 base::Time timestamp) OVERRIDE { 75 base::Time timestamp) OVERRIDE {
76 EXPECT_EQ(id, controller_id_); 76 EXPECT_EQ(id, controller_id_);
77 DoBufferReady(id); 77 DoBufferReady(id);
78 message_loop_->PostTask(FROM_HERE, 78 message_loop_->PostTask(FROM_HERE,
79 base::Bind(&VideoCaptureController::ReturnBuffer, 79 base::Bind(&VideoCaptureController::ReturnBuffer,
80 controller_, controller_id_, this, buffer_id)); 80 controller_, controller_id_, this, buffer_id));
81 } 81 }
82 virtual void OnFrameInfo(const VideoCaptureControllerID& id, 82 virtual void OnFrameInfo(const VideoCaptureControllerID& id,
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 OnEnded(const VideoCaptureControllerID& id) OVERRIDE {
90 EXPECT_EQ(id, controller_id_); 90 EXPECT_EQ(id, controller_id_);
91 DoPaused(id); 91 DoEnded(id);
92 } 92 }
93 93
94 scoped_refptr<VideoCaptureController> controller_; 94 scoped_refptr<VideoCaptureController> controller_;
95 MessageLoop* message_loop_; 95 MessageLoop* message_loop_;
96 VideoCaptureControllerID controller_id_; 96 VideoCaptureControllerID controller_id_;
97 base::ProcessHandle process_handle_; 97 base::ProcessHandle process_handle_;
98 }; 98 };
99 99
100 class MockVideoCaptureManager : public VideoCaptureManager { 100 class MockVideoCaptureManager : public VideoCaptureManager {
101 public: 101 public:
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_CALL(*controller_handler_, 233 EXPECT_CALL(*controller_handler_,
234 DoBufferCreated(controller_handler_->controller_id_)) 234 DoBufferCreated(controller_handler_->controller_id_))
235 .Times(AtLeast(1)); 235 .Times(AtLeast(1));
236 EXPECT_CALL(*controller_handler_, 236 EXPECT_CALL(*controller_handler_,
237 DoBufferReady(controller_handler_->controller_id_)) 237 DoBufferReady(controller_handler_->controller_id_))
238 .Times(AtLeast(1)) 238 .Times(AtLeast(1))
239 .WillOnce(StopSession(controller_.get(), 239 .WillOnce(StopSession(controller_.get(),
240 vcm_->video_session_id_, 240 vcm_->video_session_id_,
241 message_loop_.get())); 241 message_loop_.get()));
242 EXPECT_CALL(*controller_handler_, 242 EXPECT_CALL(*controller_handler_,
243 DoPaused(controller_handler_->controller_id_)) 243 DoEnded(controller_handler_->controller_id_))
244 .Times(1); 244 .Times(1);
245 245
246 controller_->StartCapture(controller_handler_->controller_id_, 246 controller_->StartCapture(controller_handler_->controller_id_,
247 controller_handler_.get(), 247 controller_handler_.get(),
248 controller_handler_->process_handle_, 248 controller_handler_->process_handle_,
249 capture_params); 249 capture_params);
250 message_loop_->Run(); 250 message_loop_->Run();
251 251
252 // The session is stopped now. There should be no buffer coming from 252 // The session is stopped now. There should be no buffer coming from
253 // controller. 253 // controller.
254 EXPECT_CALL(*controller_handler_, 254 EXPECT_CALL(*controller_handler_,
255 DoBufferReady(controller_handler_->controller_id_)) 255 DoBufferReady(controller_handler_->controller_id_))
256 .Times(0); 256 .Times(0);
257 message_loop_->PostDelayedTask( 257 message_loop_->PostDelayedTask(
258 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); 258 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1));
259 message_loop_->Run(); 259 message_loop_->Run();
260 260
261 EXPECT_CALL(*vcm_, 261 EXPECT_CALL(*vcm_,
262 StopCapture(vcm_->video_session_id_)) 262 StopCapture(vcm_->video_session_id_))
263 .Times(1); 263 .Times(1);
264 controller_->StopCapture(controller_handler_->controller_id_, 264 controller_->StopCapture(controller_handler_->controller_id_,
265 controller_handler_.get()); 265 controller_handler_.get());
266 } 266 }
267 267
268 } // namespace content 268 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698