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

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

Issue 140633004: Reland CL to implement browser-side logging to WebRtc log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: These are the changes that should fix crbug.com/338848 Created 6 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/renderer_host/media/desktop_capture_device.h" 5 #include "content/browser/renderer_host/media/desktop_capture_device.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 25 matching lines...) Expand all
36 const int kTestFrameWidth2 = 200; 36 const int kTestFrameWidth2 = 200;
37 const int kTestFrameHeight2 = 150; 37 const int kTestFrameHeight2 = 150;
38 38
39 const int kFrameRate = 30; 39 const int kFrameRate = 30;
40 40
41 class MockDeviceClient : public media::VideoCaptureDevice::Client { 41 class MockDeviceClient : public media::VideoCaptureDevice::Client {
42 public: 42 public:
43 MOCK_METHOD2(ReserveOutputBuffer, 43 MOCK_METHOD2(ReserveOutputBuffer,
44 scoped_refptr<Buffer>(media::VideoFrame::Format format, 44 scoped_refptr<Buffer>(media::VideoFrame::Format format,
45 const gfx::Size& dimensions)); 45 const gfx::Size& dimensions));
46 MOCK_METHOD0(OnError, void()); 46 MOCK_METHOD1(OnError, void(const std::string& reason));
47 MOCK_METHOD5(OnIncomingCapturedFrame, 47 MOCK_METHOD5(OnIncomingCapturedFrame,
48 void(const uint8* data, 48 void(const uint8* data,
49 int length, 49 int length,
50 base::TimeTicks timestamp, 50 base::TimeTicks timestamp,
51 int rotation, 51 int rotation,
52 const media::VideoCaptureFormat& frame_format)); 52 const media::VideoCaptureFormat& frame_format));
53 MOCK_METHOD5(OnIncomingCapturedBuffer, 53 MOCK_METHOD5(OnIncomingCapturedBuffer,
54 void(const scoped_refptr<Buffer>& buffer, 54 void(const scoped_refptr<Buffer>& buffer,
55 media::VideoFrame::Format format, 55 media::VideoFrame::Format format,
56 const gfx::Size& dimensions, 56 const gfx::Size& dimensions,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 scoped_ptr<webrtc::DesktopCapturer> capturer( 157 scoped_ptr<webrtc::DesktopCapturer> capturer(
158 webrtc::ScreenCapturer::Create()); 158 webrtc::ScreenCapturer::Create());
159 DesktopCaptureDevice capture_device( 159 DesktopCaptureDevice capture_device(
160 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()), 160 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()),
161 capturer.Pass()); 161 capturer.Pass());
162 media::VideoCaptureFormat format; 162 media::VideoCaptureFormat format;
163 base::WaitableEvent done_event(false, false); 163 base::WaitableEvent done_event(false, false);
164 int frame_size; 164 int frame_size;
165 165
166 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 166 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
167 EXPECT_CALL(*client, OnError()).Times(0); 167 EXPECT_CALL(*client, OnError(_)).Times(0);
168 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) 168 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _))
169 .WillRepeatedly( 169 .WillRepeatedly(
170 DoAll(SaveArg<1>(&frame_size), 170 DoAll(SaveArg<1>(&frame_size),
171 SaveArg<4>(&format), 171 SaveArg<4>(&format),
172 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 172 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
173 173
174 media::VideoCaptureParams capture_params; 174 media::VideoCaptureParams capture_params;
175 capture_params.requested_format.frame_size.SetSize(640, 480); 175 capture_params.requested_format.frame_size.SetSize(640, 480);
176 capture_params.requested_format.frame_rate = kFrameRate; 176 capture_params.requested_format.frame_rate = kFrameRate;
177 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 177 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 19 matching lines...) Expand all
197 197
198 DesktopCaptureDevice capture_device( 198 DesktopCaptureDevice capture_device(
199 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()), 199 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()),
200 scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 200 scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
201 201
202 media::VideoCaptureFormat format; 202 media::VideoCaptureFormat format;
203 base::WaitableEvent done_event(false, false); 203 base::WaitableEvent done_event(false, false);
204 int frame_size; 204 int frame_size;
205 205
206 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 206 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
207 EXPECT_CALL(*client, OnError()).Times(0); 207 EXPECT_CALL(*client, OnError(_)).Times(0);
208 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) 208 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _))
209 .WillRepeatedly( 209 .WillRepeatedly(
210 DoAll(SaveArg<1>(&frame_size), 210 DoAll(SaveArg<1>(&frame_size),
211 SaveArg<4>(&format), 211 SaveArg<4>(&format),
212 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 212 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
213 213
214 media::VideoCaptureParams capture_params; 214 media::VideoCaptureParams capture_params;
215 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 215 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
216 kTestFrameHeight1); 216 kTestFrameHeight1);
217 capture_params.requested_format.frame_rate = kFrameRate; 217 capture_params.requested_format.frame_rate = kFrameRate;
(...skipping 26 matching lines...) Expand all
244 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); 244 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer();
245 245
246 DesktopCaptureDevice capture_device( 246 DesktopCaptureDevice capture_device(
247 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()), 247 worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()),
248 scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 248 scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
249 249
250 media::VideoCaptureFormat format; 250 media::VideoCaptureFormat format;
251 base::WaitableEvent done_event(false, false); 251 base::WaitableEvent done_event(false, false);
252 252
253 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 253 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
254 EXPECT_CALL(*client, OnError()).Times(0); 254 EXPECT_CALL(*client, OnError(_)).Times(0);
255 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _)) 255 EXPECT_CALL(*client, OnIncomingCapturedFrame(_, _, _, _, _))
256 .WillRepeatedly( 256 .WillRepeatedly(
257 DoAll(SaveArg<4>(&format), 257 DoAll(SaveArg<4>(&format),
258 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 258 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
259 259
260 media::VideoCaptureParams capture_params; 260 media::VideoCaptureParams capture_params;
261 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth2, 261 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth2,
262 kTestFrameHeight2); 262 kTestFrameHeight2);
263 capture_params.requested_format.frame_rate = kFrameRate; 263 capture_params.requested_format.frame_rate = kFrameRate;
264 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 264 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 13 matching lines...) Expand all
278 capture_device.StopAndDeAllocate(); 278 capture_device.StopAndDeAllocate();
279 279
280 EXPECT_EQ(kTestFrameWidth1, format.frame_size.width()); 280 EXPECT_EQ(kTestFrameWidth1, format.frame_size.width());
281 EXPECT_EQ(kTestFrameHeight1, format.frame_size.height()); 281 EXPECT_EQ(kTestFrameHeight1, format.frame_size.height());
282 EXPECT_EQ(kFrameRate, format.frame_rate); 282 EXPECT_EQ(kFrameRate, format.frame_rate);
283 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format); 283 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
284 worker_pool_->FlushForTesting(); 284 worker_pool_->FlushForTesting();
285 } 285 }
286 286
287 } // namespace content 287 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698