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

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_unittest.cc

Issue 2409833002: Remove DesktopRegion parameter in DesktopCapturer::Capture. (Closed)
Patch Set: Change Capture2 to CaptureFrame Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 ASSERT_EQ(succeeded_capturers, capturers.size()); 198 ASSERT_EQ(succeeded_capturers, capturers.size());
199 } 199 }
200 200
201 // Expects |capturer| to successfully capture a frame, and returns it. 201 // Expects |capturer| to successfully capture a frame, and returns it.
202 std::unique_ptr<DesktopFrame> CaptureFrame(ScreenCapturer* capturer) { 202 std::unique_ptr<DesktopFrame> CaptureFrame(ScreenCapturer* capturer) {
203 std::unique_ptr<DesktopFrame> frame; 203 std::unique_ptr<DesktopFrame> frame;
204 EXPECT_CALL(callback_, 204 EXPECT_CALL(callback_,
205 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 205 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
206 .WillOnce(SaveUniquePtrArg(&frame)); 206 .WillOnce(SaveUniquePtrArg(&frame));
207 capturer->Capture(DesktopRegion()); 207 capturer->CaptureFrame();
208 EXPECT_TRUE(frame); 208 EXPECT_TRUE(frame);
209 return frame; 209 return frame;
210 } 210 }
211 }; 211 };
212 212
213 class FakeSharedMemory : public SharedMemory { 213 class FakeSharedMemory : public SharedMemory {
214 public: 214 public:
215 FakeSharedMemory(char* buffer, size_t size) 215 FakeSharedMemory(char* buffer, size_t size)
216 : SharedMemory(buffer, size, 0, kTestSharedMemoryId), 216 : SharedMemory(buffer, size, 0, kTestSharedMemoryId),
217 buffer_(buffer) { 217 buffer_(buffer) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 252 }
253 253
254 TEST_F(ScreenCapturerTest, Capture) { 254 TEST_F(ScreenCapturerTest, Capture) {
255 // Assume that Start() treats the screen as invalid initially. 255 // Assume that Start() treats the screen as invalid initially.
256 std::unique_ptr<DesktopFrame> frame; 256 std::unique_ptr<DesktopFrame> frame;
257 EXPECT_CALL(callback_, 257 EXPECT_CALL(callback_,
258 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 258 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
259 .WillOnce(SaveUniquePtrArg(&frame)); 259 .WillOnce(SaveUniquePtrArg(&frame));
260 260
261 capturer_->Start(&callback_); 261 capturer_->Start(&callback_);
262 capturer_->Capture(DesktopRegion()); 262 capturer_->CaptureFrame();
263 263
264 ASSERT_TRUE(frame); 264 ASSERT_TRUE(frame);
265 EXPECT_GT(frame->size().width(), 0); 265 EXPECT_GT(frame->size().width(), 0);
266 EXPECT_GT(frame->size().height(), 0); 266 EXPECT_GT(frame->size().height(), 0);
267 EXPECT_GE(frame->stride(), 267 EXPECT_GE(frame->stride(),
268 frame->size().width() * DesktopFrame::kBytesPerPixel); 268 frame->size().width() * DesktopFrame::kBytesPerPixel);
269 EXPECT_TRUE(frame->shared_memory() == NULL); 269 EXPECT_TRUE(frame->shared_memory() == NULL);
270 270
271 // Verify that the region contains whole screen. 271 // Verify that the region contains whole screen.
272 EXPECT_FALSE(frame->updated_region().is_empty()); 272 EXPECT_FALSE(frame->updated_region().is_empty());
(...skipping 22 matching lines...) Expand all
295 295
296 TEST_F(ScreenCapturerTest, UseSharedBuffers) { 296 TEST_F(ScreenCapturerTest, UseSharedBuffers) {
297 std::unique_ptr<DesktopFrame> frame; 297 std::unique_ptr<DesktopFrame> frame;
298 EXPECT_CALL(callback_, 298 EXPECT_CALL(callback_,
299 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 299 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
300 .WillOnce(SaveUniquePtrArg(&frame)); 300 .WillOnce(SaveUniquePtrArg(&frame));
301 301
302 capturer_->Start(&callback_); 302 capturer_->Start(&callback_);
303 capturer_->SetSharedMemoryFactory( 303 capturer_->SetSharedMemoryFactory(
304 std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory())); 304 std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory()));
305 capturer_->Capture(DesktopRegion()); 305 capturer_->CaptureFrame();
306 306
307 ASSERT_TRUE(frame); 307 ASSERT_TRUE(frame);
308 ASSERT_TRUE(frame->shared_memory()); 308 ASSERT_TRUE(frame->shared_memory());
309 EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId); 309 EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId);
310 } 310 }
311 311
312 TEST_F(ScreenCapturerTest, UseMagnifier) { 312 TEST_F(ScreenCapturerTest, UseMagnifier) {
313 CreateMagnifierCapturer(); 313 CreateMagnifierCapturer();
314 314
315 std::unique_ptr<DesktopFrame> frame; 315 std::unique_ptr<DesktopFrame> frame;
316 EXPECT_CALL(callback_, 316 EXPECT_CALL(callback_,
317 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 317 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
318 .WillOnce(SaveUniquePtrArg(&frame)); 318 .WillOnce(SaveUniquePtrArg(&frame));
319 319
320 capturer_->Start(&callback_); 320 capturer_->Start(&callback_);
321 capturer_->Capture(DesktopRegion()); 321 capturer_->CaptureFrame();
322 ASSERT_TRUE(frame); 322 ASSERT_TRUE(frame);
323 } 323 }
324 324
325 TEST_F(ScreenCapturerTest, UseDirectxCapturer) { 325 TEST_F(ScreenCapturerTest, UseDirectxCapturer) {
326 if (!CreateDirectxCapturer()) { 326 if (!CreateDirectxCapturer()) {
327 return; 327 return;
328 } 328 }
329 329
330 std::unique_ptr<DesktopFrame> frame; 330 std::unique_ptr<DesktopFrame> frame;
331 EXPECT_CALL(callback_, 331 EXPECT_CALL(callback_,
332 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 332 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
333 .WillOnce(SaveUniquePtrArg(&frame)); 333 .WillOnce(SaveUniquePtrArg(&frame));
334 334
335 capturer_->Start(&callback_); 335 capturer_->Start(&callback_);
336 capturer_->Capture(DesktopRegion()); 336 capturer_->CaptureFrame();
337 ASSERT_TRUE(frame); 337 ASSERT_TRUE(frame);
338 } 338 }
339 339
340 TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) { 340 TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) {
341 if (!CreateDirectxCapturer()) { 341 if (!CreateDirectxCapturer()) {
342 return; 342 return;
343 } 343 }
344 344
345 std::unique_ptr<DesktopFrame> frame; 345 std::unique_ptr<DesktopFrame> frame;
346 EXPECT_CALL(callback_, 346 EXPECT_CALL(callback_,
347 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 347 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
348 .WillOnce(SaveUniquePtrArg(&frame)); 348 .WillOnce(SaveUniquePtrArg(&frame));
349 349
350 capturer_->Start(&callback_); 350 capturer_->Start(&callback_);
351 capturer_->SetSharedMemoryFactory( 351 capturer_->SetSharedMemoryFactory(
352 std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory())); 352 std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory()));
353 capturer_->Capture(DesktopRegion()); 353 capturer_->CaptureFrame();
354 ASSERT_TRUE(frame); 354 ASSERT_TRUE(frame);
355 ASSERT_TRUE(frame->shared_memory()); 355 ASSERT_TRUE(frame->shared_memory());
356 EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId); 356 EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId);
357 } 357 }
358 358
359 // Disabled due to being flaky due to the fact that it uses rendering / UI, see 359 // Disabled due to being flaky due to the fact that it uses rendering / UI, see
360 // webrtc/6366. 360 // webrtc/6366.
361 TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) { 361 TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) {
362 if (!CreateDirectxCapturer()) { 362 if (!CreateDirectxCapturer()) {
363 return; 363 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { 400 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) {
401 // Even DirectX capturer is not supported in current system, we should be able 401 // Even DirectX capturer is not supported in current system, we should be able
402 // to select a usable capturer. 402 // to select a usable capturer.
403 MaybeCreateDirectxCapturer(); 403 MaybeCreateDirectxCapturer();
404 TestCaptureUpdatedRegion(); 404 TestCaptureUpdatedRegion();
405 } 405 }
406 406
407 #endif // defined(WEBRTC_WIN) 407 #endif // defined(WEBRTC_WIN)
408 408
409 } // namespace webrtc 409 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/screen_capturer_mock_objects.h ('k') | webrtc/modules/desktop_capture/screen_capturer_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698