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