OLD | NEW |
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop/message_loop_proxy.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "content/browser/gpu/compositor_util.h" | 9 #include "content/browser/gpu/compositor_util.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 run_loop.Run(); | 204 run_loop.Run(); |
205 } | 205 } |
206 | 206 |
207 private: | 207 private: |
208 const gfx::Size frame_size_; | 208 const gfx::Size frame_size_; |
209 base::FilePath test_dir_; | 209 base::FilePath test_dir_; |
210 int callback_invoke_count_; | 210 int callback_invoke_count_; |
211 int frames_captured_; | 211 int frames_captured_; |
212 }; | 212 }; |
213 | 213 |
| 214 enum CompositingMode { |
| 215 GL_COMPOSITING, |
| 216 SOFTWARE_COMPOSITING, |
| 217 }; |
| 218 |
214 class CompositingRenderWidgetHostViewBrowserTest | 219 class CompositingRenderWidgetHostViewBrowserTest |
215 : public RenderWidgetHostViewBrowserTest { | 220 : public RenderWidgetHostViewBrowserTest, |
| 221 public testing::WithParamInterface<CompositingMode> { |
216 public: | 222 public: |
| 223 explicit CompositingRenderWidgetHostViewBrowserTest() |
| 224 : compositing_mode_(GetParam()) {} |
| 225 |
217 virtual void SetUp() OVERRIDE { | 226 virtual void SetUp() OVERRIDE { |
218 // We expect real pixel output for these tests. | 227 if (compositing_mode_ == SOFTWARE_COMPOSITING) { |
219 UseRealGLContexts(); | 228 UseSoftwareCompositing(); |
| 229 } else { |
| 230 // We expect real pixel output for these tests. |
| 231 UseRealGLContexts(); |
220 | 232 |
221 // On legacy windows, these tests need real GL bindings to pass. | |
222 #if defined(OS_WIN) && !defined(USE_AURA) | 233 #if defined(OS_WIN) && !defined(USE_AURA) |
223 UseRealGLBindings(); | 234 // On legacy windows, these tests need real GL bindings to pass. |
| 235 UseRealGLBindings(); |
224 #endif | 236 #endif |
| 237 } |
225 | 238 |
226 RenderWidgetHostViewBrowserTest::SetUp(); | 239 RenderWidgetHostViewBrowserTest::SetUp(); |
227 } | 240 } |
228 | 241 |
229 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 242 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
230 // Note: Not appending kForceCompositingMode switch here, since not all bots | 243 // Note: Not appending kForceCompositingMode switch here, since not all bots |
231 // support compositing. Some bots will run with compositing on, and others | 244 // support compositing. Some bots will run with compositing on, and others |
232 // won't. Therefore, the call to SetUpSourceSurface() later on will detect | 245 // won't. Therefore, the call to SetUpSourceSurface() later on will detect |
233 // whether compositing mode is actually on or not. If not, the tests will | 246 // whether compositing mode is actually on or not. If not, the tests will |
234 // pass blindly, logging a warning message, since we cannot test what the | 247 // pass blindly, logging a warning message, since we cannot test what the |
(...skipping 26 matching lines...) Expand all Loading... |
261 #if !defined(USE_AURA) | 274 #if !defined(USE_AURA) |
262 if (!GetRenderWidgetHost()->is_accelerated_compositing_active()) | 275 if (!GetRenderWidgetHost()->is_accelerated_compositing_active()) |
263 return false; // Renderer did not turn on accelerated compositing. | 276 return false; // Renderer did not turn on accelerated compositing. |
264 #endif | 277 #endif |
265 | 278 |
266 // Using accelerated compositing, but a compositing surface might not be | 279 // Using accelerated compositing, but a compositing surface might not be |
267 // available yet. So, wait for it. | 280 // available yet. So, wait for it. |
268 WaitForCopySourceReady(); | 281 WaitForCopySourceReady(); |
269 return true; | 282 return true; |
270 } | 283 } |
| 284 |
| 285 private: |
| 286 const CompositingMode compositing_mode_; |
| 287 |
| 288 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewBrowserTest); |
271 }; | 289 }; |
272 | 290 |
273 class NonCompositingRenderWidgetHostViewBrowserTest | 291 class NonCompositingRenderWidgetHostViewBrowserTest |
274 : public RenderWidgetHostViewBrowserTest { | 292 : public RenderWidgetHostViewBrowserTest { |
275 public: | 293 public: |
| 294 NonCompositingRenderWidgetHostViewBrowserTest() {} |
| 295 |
276 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 296 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
277 // Note: Appending the kDisableAcceleratedCompositing switch here, but there | 297 // Note: Appending the kDisableAcceleratedCompositing switch here, but there |
278 // are some builds that only use compositing and will ignore this switch. | 298 // are some builds that only use compositing and will ignore this switch. |
279 // Therefore, the call to SetUpSourceSurface() later on will detect whether | 299 // Therefore, the call to SetUpSourceSurface() later on will detect whether |
280 // compositing mode is actually off. If it's on, the tests will pass | 300 // compositing mode is actually off. If it's on, the tests will pass |
281 // blindly, logging a warning message, since we cannot test what the | 301 // blindly, logging a warning message, since we cannot test what the |
282 // platform/implementation does not support. | 302 // platform/implementation does not support. |
283 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); | 303 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); |
284 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); | 304 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); |
285 } | 305 } |
(...skipping 13 matching lines...) Expand all Loading... |
299 if (!message_queue.WaitForMessage(&result)) { | 319 if (!message_queue.WaitForMessage(&result)) { |
300 EXPECT_TRUE(false) << "WaitForMessage " << result << " failed."; | 320 EXPECT_TRUE(false) << "WaitForMessage " << result << " failed."; |
301 return false; | 321 return false; |
302 } | 322 } |
303 } | 323 } |
304 | 324 |
305 WaitForCopySourceReady(); | 325 WaitForCopySourceReady(); |
306 // Return whether the renderer left accelerated compositing turned off. | 326 // Return whether the renderer left accelerated compositing turned off. |
307 return !GetRenderWidgetHost()->is_accelerated_compositing_active(); | 327 return !GetRenderWidgetHost()->is_accelerated_compositing_active(); |
308 } | 328 } |
| 329 |
| 330 private: |
| 331 DISALLOW_COPY_AND_ASSIGN(NonCompositingRenderWidgetHostViewBrowserTest); |
309 }; | 332 }; |
310 | 333 |
311 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { | 334 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { |
312 public: | 335 public: |
313 FakeFrameSubscriber( | 336 FakeFrameSubscriber( |
314 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback) | 337 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback) |
315 : callback_(callback) { | 338 : callback_(callback) { |
316 } | 339 } |
317 | 340 |
318 virtual bool ShouldCaptureFrame( | 341 virtual bool ShouldCaptureFrame( |
(...skipping 16 matching lines...) Expand all Loading... |
335 private: | 358 private: |
336 DeliverFrameCallback callback_; | 359 DeliverFrameCallback callback_; |
337 }; | 360 }; |
338 | 361 |
339 // Disable tests for Android and IOS as these platforms have incomplete | 362 // Disable tests for Android and IOS as these platforms have incomplete |
340 // implementation. | 363 // implementation. |
341 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 364 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
342 | 365 |
343 // The CopyFromBackingStore() API should work on all platforms when compositing | 366 // The CopyFromBackingStore() API should work on all platforms when compositing |
344 // is enabled. | 367 // is enabled. |
345 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, | 368 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
346 CopyFromBackingStore) { | 369 CopyFromBackingStore) { |
347 RunBasicCopyFromBackingStoreTest(); | 370 RunBasicCopyFromBackingStoreTest(); |
348 } | 371 } |
349 | 372 |
350 // The CopyFromBackingStore() API should work on all platforms when compositing | 373 // The CopyFromBackingStore() API should work on all platforms when compositing |
351 // is disabled. | 374 // is disabled. |
352 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, | 375 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, |
353 CopyFromBackingStore) { | 376 CopyFromBackingStore) { |
354 RunBasicCopyFromBackingStoreTest(); | 377 RunBasicCopyFromBackingStoreTest(); |
355 } | 378 } |
356 | 379 |
357 // Tests that the callback passed to CopyFromBackingStore is always called, | 380 // Tests that the callback passed to CopyFromBackingStore is always called, |
358 // even when the RenderWidgetHost is deleting in the middle of an async copy. | 381 // even when the RenderWidgetHost is deleting in the middle of an async copy. |
359 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, | 382 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
360 CopyFromBackingStore_CallbackDespiteDelete) { | 383 CopyFromBackingStore_CallbackDespiteDelete) { |
361 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 384 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
362 | 385 |
363 base::RunLoop run_loop; | 386 base::RunLoop run_loop; |
364 GetRenderViewHost()->CopyFromBackingStore( | 387 GetRenderViewHost()->CopyFromBackingStore( |
365 gfx::Rect(), | 388 gfx::Rect(), |
366 frame_size(), | 389 frame_size(), |
367 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, | 390 base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore, |
368 base::Unretained(this), run_loop.QuitClosure())); | 391 base::Unretained(this), run_loop.QuitClosure())); |
369 // Delete the surface before the callback is run. | 392 // Delete the surface before the callback is run. |
370 GetRenderWidgetHostViewPort()->AcceleratedSurfaceRelease(); | 393 GetRenderWidgetHostViewPort()->AcceleratedSurfaceRelease(); |
371 run_loop.Run(); | 394 run_loop.Run(); |
372 | 395 |
373 EXPECT_EQ(1, callback_invoke_count()); | 396 EXPECT_EQ(1, callback_invoke_count()); |
374 } | 397 } |
375 | 398 |
376 // Tests that the callback passed to CopyFromCompositingSurfaceToVideoFrame is | 399 // Tests that the callback passed to CopyFromCompositingSurfaceToVideoFrame is |
377 // always called, even when the RenderWidgetHost is deleting in the middle of | 400 // always called, even when the RenderWidgetHost is deleting in the middle of |
378 // an async copy. | 401 // an async copy. |
379 // | 402 // |
380 // Test is flaky on Win Aura. http://crbug.com/276783 | 403 // Test is flaky on Win Aura. http://crbug.com/276783 |
381 #if (defined(OS_WIN) && defined(USE_AURA)) || \ | 404 #if (defined(OS_WIN) && defined(USE_AURA)) || \ |
382 (defined(OS_CHROMEOS) && !defined(NDEBUG)) | 405 (defined(OS_CHROMEOS) && !defined(NDEBUG)) |
383 #define MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete \ | 406 #define MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete \ |
384 DISABLED_CopyFromCompositingSurface_CallbackDespiteDelete | 407 DISABLED_CopyFromCompositingSurface_CallbackDespiteDelete |
385 #else | 408 #else |
386 #define MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete \ | 409 #define MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete \ |
387 CopyFromCompositingSurface_CallbackDespiteDelete | 410 CopyFromCompositingSurface_CallbackDespiteDelete |
388 #endif | 411 #endif |
389 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, | 412 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
390 MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete) { | 413 MAYBE_CopyFromCompositingSurface_CallbackDespiteDelete) { |
391 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 414 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
392 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); | 415 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); |
393 if (!view->CanCopyToVideoFrame()) { | 416 if (!view->CanCopyToVideoFrame()) { |
394 LOG(WARNING) << | 417 LOG(WARNING) << |
395 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() " | 418 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() " |
396 "not supported on this platform."); | 419 "not supported on this platform."); |
397 return; | 420 return; |
398 } | 421 } |
399 | 422 |
(...skipping 14 matching lines...) Expand all Loading... |
414 // With compositing turned off, no platforms should support the | 437 // With compositing turned off, no platforms should support the |
415 // CopyFromCompositingSurfaceToVideoFrame() API. | 438 // CopyFromCompositingSurfaceToVideoFrame() API. |
416 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, | 439 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, |
417 CopyFromCompositingSurfaceToVideoFrameCallbackTest) { | 440 CopyFromCompositingSurfaceToVideoFrameCallbackTest) { |
418 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 441 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
419 EXPECT_FALSE(GetRenderWidgetHostViewPort()->CanCopyToVideoFrame()); | 442 EXPECT_FALSE(GetRenderWidgetHostViewPort()->CanCopyToVideoFrame()); |
420 } | 443 } |
421 | 444 |
422 // Test basic frame subscription functionality. We subscribe, and then run | 445 // Test basic frame subscription functionality. We subscribe, and then run |
423 // until at least one DeliverFrameCallback has been invoked. | 446 // until at least one DeliverFrameCallback has been invoked. |
424 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, | 447 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, |
425 FrameSubscriberTest) { | 448 FrameSubscriberTest) { |
426 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 449 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
427 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); | 450 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); |
428 if (!view->CanSubscribeFrame()) { | 451 if (!view->CanSubscribeFrame()) { |
429 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " | 452 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " |
430 "supported on this platform."); | 453 "supported on this platform."); |
431 return; | 454 return; |
432 } | 455 } |
433 | 456 |
434 base::RunLoop run_loop; | 457 base::RunLoop run_loop; |
435 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( | 458 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( |
436 new FakeFrameSubscriber( | 459 new FakeFrameSubscriber( |
437 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 460 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
438 base::Unretained(this), | 461 base::Unretained(this), |
439 base::MessageLoopProxy::current(), | 462 base::MessageLoopProxy::current(), |
440 run_loop.QuitClosure()))); | 463 run_loop.QuitClosure()))); |
441 view->BeginFrameSubscription(subscriber.Pass()); | 464 view->BeginFrameSubscription(subscriber.Pass()); |
442 run_loop.Run(); | 465 run_loop.Run(); |
443 view->EndFrameSubscription(); | 466 view->EndFrameSubscription(); |
444 | 467 |
445 EXPECT_LE(1, callback_invoke_count()); | 468 EXPECT_LE(1, callback_invoke_count()); |
446 EXPECT_LE(1, frames_captured()); | 469 EXPECT_LE(1, frames_captured()); |
447 } | 470 } |
448 | 471 |
449 // Test that we can copy twice from an accelerated composited page. | 472 // Test that we can copy twice from an accelerated composited page. |
450 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { | 473 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { |
451 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 474 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
452 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); | 475 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); |
453 if (!view->CanCopyToVideoFrame()) { | 476 if (!view->CanCopyToVideoFrame()) { |
454 LOG(WARNING) << ("Blindly passing this test: " | 477 LOG(WARNING) << ("Blindly passing this test: " |
455 "CopyFromCompositingSurfaceToVideoFrame() not supported " | 478 "CopyFromCompositingSurfaceToVideoFrame() not supported " |
456 "on this platform."); | 479 "on this platform."); |
457 return; | 480 return; |
458 } | 481 } |
459 | 482 |
460 base::RunLoop run_loop; | 483 base::RunLoop run_loop; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 } | 769 } |
747 | 770 |
748 private: | 771 private: |
749 bool expected_copy_from_compositing_surface_result_; | 772 bool expected_copy_from_compositing_surface_result_; |
750 SkBitmap expected_copy_from_compositing_surface_bitmap_; | 773 SkBitmap expected_copy_from_compositing_surface_bitmap_; |
751 int allowable_error_; | 774 int allowable_error_; |
752 gfx::Rect exclude_rect_; | 775 gfx::Rect exclude_rect_; |
753 std::string test_url_; | 776 std::string test_url_; |
754 }; | 777 }; |
755 | 778 |
756 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 779 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
757 CopyFromCompositingSurface_Origin_Unscaled) { | 780 CopyFromCompositingSurface_Origin_Unscaled) { |
758 gfx::Rect copy_rect(400, 300); | 781 gfx::Rect copy_rect(400, 300); |
759 gfx::Size output_size = copy_rect.size(); | 782 gfx::Size output_size = copy_rect.size(); |
760 gfx::Size expected_bitmap_size = output_size; | 783 gfx::Size expected_bitmap_size = output_size; |
761 gfx::Size html_rect_size(400, 300); | 784 gfx::Size html_rect_size(400, 300); |
762 bool video_frame = false; | 785 bool video_frame = false; |
763 PerformTestWithLeftRightRects(html_rect_size, | 786 PerformTestWithLeftRightRects(html_rect_size, |
764 copy_rect, | 787 copy_rect, |
765 output_size, | 788 output_size, |
766 expected_bitmap_size, | 789 expected_bitmap_size, |
767 video_frame); | 790 video_frame); |
768 } | 791 } |
769 | 792 |
770 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 793 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
771 CopyFromCompositingSurface_Origin_Scaled) { | 794 CopyFromCompositingSurface_Origin_Scaled) { |
772 gfx::Rect copy_rect(400, 300); | 795 gfx::Rect copy_rect(400, 300); |
773 gfx::Size output_size(200, 100); | 796 gfx::Size output_size(200, 100); |
774 gfx::Size expected_bitmap_size = output_size; | 797 gfx::Size expected_bitmap_size = output_size; |
775 gfx::Size html_rect_size(400, 300); | 798 gfx::Size html_rect_size(400, 300); |
776 bool video_frame = false; | 799 bool video_frame = false; |
777 PerformTestWithLeftRightRects(html_rect_size, | 800 PerformTestWithLeftRightRects(html_rect_size, |
778 copy_rect, | 801 copy_rect, |
779 output_size, | 802 output_size, |
780 expected_bitmap_size, | 803 expected_bitmap_size, |
781 video_frame); | 804 video_frame); |
782 } | 805 } |
783 | 806 |
784 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 807 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
785 CopyFromCompositingSurface_Cropped_Unscaled) { | 808 CopyFromCompositingSurface_Cropped_Unscaled) { |
786 // Grab 60x60 pixels from the center of the tab contents. | 809 // Grab 60x60 pixels from the center of the tab contents. |
787 gfx::Rect copy_rect(400, 300); | 810 gfx::Rect copy_rect(400, 300); |
788 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 811 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
789 gfx::Size(60, 60)); | 812 gfx::Size(60, 60)); |
790 gfx::Size output_size = copy_rect.size(); | 813 gfx::Size output_size = copy_rect.size(); |
791 gfx::Size expected_bitmap_size = output_size; | 814 gfx::Size expected_bitmap_size = output_size; |
792 gfx::Size html_rect_size(400, 300); | 815 gfx::Size html_rect_size(400, 300); |
793 bool video_frame = false; | 816 bool video_frame = false; |
794 PerformTestWithLeftRightRects(html_rect_size, | 817 PerformTestWithLeftRightRects(html_rect_size, |
795 copy_rect, | 818 copy_rect, |
796 output_size, | 819 output_size, |
797 expected_bitmap_size, | 820 expected_bitmap_size, |
798 video_frame); | 821 video_frame); |
799 } | 822 } |
800 | 823 |
801 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 824 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
802 CopyFromCompositingSurface_Cropped_Scaled) { | 825 CopyFromCompositingSurface_Cropped_Scaled) { |
803 // Grab 60x60 pixels from the center of the tab contents. | 826 // Grab 60x60 pixels from the center of the tab contents. |
804 gfx::Rect copy_rect(400, 300); | 827 gfx::Rect copy_rect(400, 300); |
805 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 828 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
806 gfx::Size(60, 60)); | 829 gfx::Size(60, 60)); |
807 gfx::Size output_size(20, 10); | 830 gfx::Size output_size(20, 10); |
808 gfx::Size expected_bitmap_size = output_size; | 831 gfx::Size expected_bitmap_size = output_size; |
809 gfx::Size html_rect_size(400, 300); | 832 gfx::Size html_rect_size(400, 300); |
810 bool video_frame = false; | 833 bool video_frame = false; |
811 PerformTestWithLeftRightRects(html_rect_size, | 834 PerformTestWithLeftRightRects(html_rect_size, |
812 copy_rect, | 835 copy_rect, |
813 output_size, | 836 output_size, |
814 expected_bitmap_size, | 837 expected_bitmap_size, |
815 video_frame); | 838 video_frame); |
816 } | 839 } |
817 | 840 |
818 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 841 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
819 CopyFromCompositingSurface_ForVideoFrame) { | 842 CopyFromCompositingSurface_ForVideoFrame) { |
820 // Grab 90x60 pixels from the center of the tab contents. | 843 // Grab 90x60 pixels from the center of the tab contents. |
821 gfx::Rect copy_rect(400, 300); | 844 gfx::Rect copy_rect(400, 300); |
822 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 845 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
823 gfx::Size(90, 60)); | 846 gfx::Size(90, 60)); |
824 gfx::Size output_size = copy_rect.size(); | 847 gfx::Size output_size = copy_rect.size(); |
825 gfx::Size expected_bitmap_size = output_size; | 848 gfx::Size expected_bitmap_size = output_size; |
826 gfx::Size html_rect_size(400, 300); | 849 gfx::Size html_rect_size(400, 300); |
827 bool video_frame = true; | 850 bool video_frame = true; |
828 PerformTestWithLeftRightRects(html_rect_size, | 851 PerformTestWithLeftRightRects(html_rect_size, |
829 copy_rect, | 852 copy_rect, |
830 output_size, | 853 output_size, |
831 expected_bitmap_size, | 854 expected_bitmap_size, |
832 video_frame); | 855 video_frame); |
833 } | 856 } |
834 | 857 |
835 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 858 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
836 CopyFromCompositingSurface_ForVideoFrame_Scaled) { | 859 CopyFromCompositingSurface_ForVideoFrame_Scaled) { |
837 // Grab 90x60 pixels from the center of the tab contents. | 860 // Grab 90x60 pixels from the center of the tab contents. |
838 gfx::Rect copy_rect(400, 300); | 861 gfx::Rect copy_rect(400, 300); |
839 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 862 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
840 gfx::Size(90, 60)); | 863 gfx::Size(90, 60)); |
841 // Scale to 30 x 20 (preserve aspect ratio). | 864 // Scale to 30 x 20 (preserve aspect ratio). |
842 gfx::Size output_size(30, 20); | 865 gfx::Size output_size(30, 20); |
843 gfx::Size expected_bitmap_size = output_size; | 866 gfx::Size expected_bitmap_size = output_size; |
844 gfx::Size html_rect_size(400, 300); | 867 gfx::Size html_rect_size(400, 300); |
845 bool video_frame = true; | 868 bool video_frame = true; |
846 PerformTestWithLeftRightRects(html_rect_size, | 869 PerformTestWithLeftRightRects(html_rect_size, |
847 copy_rect, | 870 copy_rect, |
848 output_size, | 871 output_size, |
849 expected_bitmap_size, | 872 expected_bitmap_size, |
850 video_frame); | 873 video_frame); |
851 } | 874 } |
852 | 875 |
853 class CompositingRenderWidgetHostViewTabCaptureHighDPI | 876 class CompositingRenderWidgetHostViewTabCaptureHighDPI |
854 : public CompositingRenderWidgetHostViewBrowserTestTabCapture { | 877 : public CompositingRenderWidgetHostViewBrowserTestTabCapture { |
855 public: | 878 public: |
856 CompositingRenderWidgetHostViewTabCaptureHighDPI() | 879 CompositingRenderWidgetHostViewTabCaptureHighDPI() : kScale(2.f) {} |
857 : kScale(2.f) { | |
858 } | |
859 | 880 |
860 virtual void SetUpCommandLine(CommandLine* cmd) OVERRIDE { | 881 virtual void SetUpCommandLine(CommandLine* cmd) OVERRIDE { |
861 CompositingRenderWidgetHostViewBrowserTestTabCapture::SetUpCommandLine(cmd); | 882 CompositingRenderWidgetHostViewBrowserTestTabCapture::SetUpCommandLine(cmd); |
862 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | 883 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor, |
863 base::StringPrintf("%f", scale())); | 884 base::StringPrintf("%f", scale())); |
864 #if defined(OS_WIN) | 885 #if defined(OS_WIN) |
865 cmd->AppendSwitchASCII(switches::kHighDPISupport, "1"); | 886 cmd->AppendSwitchASCII(switches::kHighDPISupport, "1"); |
866 gfx::EnableHighDPISupport(); | 887 gfx::EnableHighDPISupport(); |
867 #endif | 888 #endif |
868 } | 889 } |
869 | 890 |
870 float scale() const { return kScale; } | 891 float scale() const { return kScale; } |
871 | 892 |
872 private: | 893 private: |
873 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { | 894 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { |
874 PASS_TEST_IF_SCALE_FACTOR_NOT_SUPPORTED(scale()); | 895 PASS_TEST_IF_SCALE_FACTOR_NOT_SUPPORTED(scale()); |
875 return true; | 896 return true; |
876 } | 897 } |
877 | 898 |
878 const float kScale; | 899 const float kScale; |
879 | 900 |
880 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI); | 901 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI); |
881 }; | 902 }; |
882 | 903 |
883 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewTabCaptureHighDPI, | 904 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, |
884 CopyFromCompositingSurface) { | 905 CopyFromCompositingSurface) { |
885 gfx::Rect copy_rect(200, 150); | 906 gfx::Rect copy_rect(200, 150); |
886 gfx::Size output_size = copy_rect.size(); | 907 gfx::Size output_size = copy_rect.size(); |
887 gfx::Size expected_bitmap_size = | 908 gfx::Size expected_bitmap_size = |
888 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); | 909 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); |
889 gfx::Size html_rect_size(200, 150); | 910 gfx::Size html_rect_size(200, 150); |
890 bool video_frame = false; | 911 bool video_frame = false; |
891 PerformTestWithLeftRightRects(html_rect_size, | 912 PerformTestWithLeftRightRects(html_rect_size, |
892 copy_rect, | 913 copy_rect, |
893 output_size, | 914 output_size, |
894 expected_bitmap_size, | 915 expected_bitmap_size, |
895 video_frame); | 916 video_frame); |
896 } | 917 } |
897 | 918 |
898 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewTabCaptureHighDPI, | 919 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, |
899 CopyFromCompositingSurfaceVideoFrame) { | 920 CopyFromCompositingSurfaceVideoFrame) { |
900 gfx::Size html_rect_size(200, 150); | 921 gfx::Size html_rect_size(200, 150); |
901 // Grab 90x60 pixels from the center of the tab contents. | 922 // Grab 90x60 pixels from the center of the tab contents. |
902 gfx::Rect copy_rect = | 923 gfx::Rect copy_rect = |
903 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), | 924 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), |
904 gfx::Size(90, 60)); | 925 gfx::Size(90, 60)); |
905 gfx::Size output_size = copy_rect.size(); | 926 gfx::Size output_size = copy_rect.size(); |
906 gfx::Size expected_bitmap_size = | 927 gfx::Size expected_bitmap_size = |
907 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); | 928 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); |
908 bool video_frame = true; | 929 bool video_frame = true; |
909 PerformTestWithLeftRightRects(html_rect_size, | 930 PerformTestWithLeftRightRects(html_rect_size, |
910 copy_rect, | 931 copy_rect, |
911 output_size, | 932 output_size, |
912 expected_bitmap_size, | 933 expected_bitmap_size, |
913 video_frame); | 934 video_frame); |
914 } | 935 } |
915 | 936 |
| 937 #if !defined(USE_AURA) && !defined(OS_MACOSX) |
| 938 // TODO(danakj): Remove this case when GTK linux is no more and move the |
| 939 // values inline to testing::Values() below. |
| 940 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING}; |
| 941 #else |
| 942 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING, |
| 943 SOFTWARE_COMPOSITING}; |
| 944 #endif |
| 945 |
| 946 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
| 947 CompositingRenderWidgetHostViewBrowserTest, |
| 948 testing::ValuesIn(kAllCompositingModes)); |
| 949 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
| 950 CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 951 testing::ValuesIn(kAllCompositingModes)); |
| 952 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
| 953 CompositingRenderWidgetHostViewTabCaptureHighDPI, |
| 954 testing::ValuesIn(kAllCompositingModes)); |
| 955 |
916 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 956 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
917 | 957 |
918 } // namespace | 958 } // namespace |
919 } // namespace content | 959 } // namespace content |
OLD | NEW |