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

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

Issue 541163002: Clarify resolution change behaviors of video capture devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 6 years, 3 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/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 EXPECT_CALL(*client, OnError(_)).Times(0); 165 EXPECT_CALL(*client, OnError(_)).Times(0);
166 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 166 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
167 DoAll(SaveArg<1>(&frame_size), 167 DoAll(SaveArg<1>(&frame_size),
168 SaveArg<2>(&format), 168 SaveArg<2>(&format),
169 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 169 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
170 170
171 media::VideoCaptureParams capture_params; 171 media::VideoCaptureParams capture_params;
172 capture_params.requested_format.frame_size.SetSize(640, 480); 172 capture_params.requested_format.frame_size.SetSize(640, 480);
173 capture_params.requested_format.frame_rate = kFrameRate; 173 capture_params.requested_format.frame_rate = kFrameRate;
174 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 174 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
175 capture_params.allow_resolution_change = false;
176 capture_device_->AllocateAndStart( 175 capture_device_->AllocateAndStart(
177 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); 176 capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
178 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 177 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
179 capture_device_->StopAndDeAllocate(); 178 capture_device_->StopAndDeAllocate();
180 179
181 EXPECT_GT(format.frame_size.width(), 0); 180 EXPECT_GT(format.frame_size.width(), 0);
182 EXPECT_GT(format.frame_size.height(), 0); 181 EXPECT_GT(format.frame_size.height(), 0);
183 EXPECT_EQ(kFrameRate, format.frame_rate); 182 EXPECT_EQ(kFrameRate, format.frame_rate);
184 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format); 183 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
185 184
(...skipping 16 matching lines...) Expand all
202 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 201 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
203 DoAll(SaveArg<1>(&frame_size), 202 DoAll(SaveArg<1>(&frame_size),
204 SaveArg<2>(&format), 203 SaveArg<2>(&format),
205 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 204 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
206 205
207 media::VideoCaptureParams capture_params; 206 media::VideoCaptureParams capture_params;
208 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 207 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
209 kTestFrameHeight1); 208 kTestFrameHeight1);
210 capture_params.requested_format.frame_rate = kFrameRate; 209 capture_params.requested_format.frame_rate = kFrameRate;
211 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 210 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
212 capture_params.allow_resolution_change = false;
213 211
214 capture_device_->AllocateAndStart( 212 capture_device_->AllocateAndStart(
215 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); 213 capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
216 214
217 // Capture at least two frames, to ensure that the source frame size has 215 // Capture at least two frames, to ensure that the source frame size has
218 // changed while capturing. 216 // changed while capturing.
219 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 217 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
220 done_event.Reset(); 218 done_event.Reset();
221 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 219 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
222 220
(...skipping 21 matching lines...) Expand all
244 EXPECT_CALL(*client, OnError(_)).Times(0); 242 EXPECT_CALL(*client, OnError(_)).Times(0);
245 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 243 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
246 DoAll(SaveArg<2>(&format), 244 DoAll(SaveArg<2>(&format),
247 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 245 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
248 246
249 media::VideoCaptureParams capture_params; 247 media::VideoCaptureParams capture_params;
250 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth2, 248 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth2,
251 kTestFrameHeight2); 249 kTestFrameHeight2);
252 capture_params.requested_format.frame_rate = kFrameRate; 250 capture_params.requested_format.frame_rate = kFrameRate;
253 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 251 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
254 capture_params.allow_resolution_change = false;
255 252
256 capture_device_->AllocateAndStart( 253 capture_device_->AllocateAndStart(
257 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); 254 capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
258 255
259 // Capture at least three frames, to ensure that the source frame size has 256 // Capture at least three frames, to ensure that the source frame size has
260 // changed at least twice while capturing. 257 // changed at least twice while capturing.
261 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 258 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
262 done_event.Reset(); 259 done_event.Reset();
263 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 260 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
264 done_event.Reset(); 261 done_event.Reset();
265 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 262 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
266 263
267 capture_device_->StopAndDeAllocate(); 264 capture_device_->StopAndDeAllocate();
268 265
269 EXPECT_EQ(kTestFrameWidth1, format.frame_size.width()); 266 EXPECT_EQ(kTestFrameWidth1, format.frame_size.width());
270 EXPECT_EQ(kTestFrameHeight1, format.frame_size.height()); 267 EXPECT_EQ(kTestFrameHeight1, format.frame_size.height());
271 EXPECT_EQ(kFrameRate, format.frame_rate); 268 EXPECT_EQ(kFrameRate, format.frame_rate);
272 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format); 269 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
273 } 270 }
274 271
275 } // namespace content 272 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698