| 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/gpu_data_manager_impl.h" | 9 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 10 #include "content/browser/renderer_host/dip_util.h" | 10 #include "content/browser/renderer_host/dip_util.h" |
| 11 #include "content/browser/renderer_host/render_widget_host_impl.h" | 11 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 12 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 12 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
| 13 #include "content/port/browser/render_widget_host_view_port.h" | 13 #include "content/port/browser/render_widget_host_view_port.h" |
| 14 #include "content/public/browser/compositor_util.h" | 14 #include "content/public/browser/compositor_util.h" |
| 15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/content_paths.h" | 17 #include "content/public/common/content_paths.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
| 20 #include "content/shell/shell.h" | 20 #include "content/shell/shell.h" |
| 21 #include "content/test/content_browser_test.h" | 21 #include "content/test/content_browser_test.h" |
| 22 #include "content/test/content_browser_test_utils.h" | 22 #include "content/test/content_browser_test_utils.h" |
| 23 #include "media/base/video_frame.h" | 23 #include "media/base/video_frame.h" |
| 24 #include "media/filters/skcanvas_video_renderer.h" | 24 #include "media/filters/skcanvas_video_renderer.h" |
| 25 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
| 27 #include "third_party/skia/include/core/SkCanvas.h" | 27 #include "third_party/skia/include/core/SkCanvas.h" |
| 28 #include "third_party/skia/include/core/SkDevice.h" | 28 #include "third_party/skia/include/core/SkDevice.h" |
| 29 #include "ui/base/ui_base_switches.h" | 29 #include "ui/base/ui_base_switches.h" |
| 30 #include "ui/compositor/compositor_setup.h" | |
| 31 #include "ui/gfx/size_conversions.h" | 30 #include "ui/gfx/size_conversions.h" |
| 32 #include "ui/gl/gl_switches.h" | 31 #include "ui/gl/gl_switches.h" |
| 33 | 32 |
| 34 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
| 35 #include "ui/gl/io_surface_support_mac.h" | 34 #include "ui/gl/io_surface_support_mac.h" |
| 36 #endif | 35 #endif |
| 37 | 36 |
| 38 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 39 #include "ui/base/win/dpi.h" | 38 #include "ui/base/win/dpi.h" |
| 40 #endif | 39 #endif |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 private: | 203 private: |
| 205 const gfx::Size frame_size_; | 204 const gfx::Size frame_size_; |
| 206 base::FilePath test_dir_; | 205 base::FilePath test_dir_; |
| 207 int callback_invoke_count_; | 206 int callback_invoke_count_; |
| 208 int frames_captured_; | 207 int frames_captured_; |
| 209 }; | 208 }; |
| 210 | 209 |
| 211 class CompositingRenderWidgetHostViewBrowserTest | 210 class CompositingRenderWidgetHostViewBrowserTest |
| 212 : public RenderWidgetHostViewBrowserTest { | 211 : public RenderWidgetHostViewBrowserTest { |
| 213 public: | 212 public: |
| 213 virtual void SetUp() OVERRIDE { |
| 214 // We expect real pixel output for these tests. |
| 215 UseRealGLContexts(); |
| 216 |
| 217 RenderWidgetHostViewBrowserTest::SetUp(); |
| 218 } |
| 219 |
| 214 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 220 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 215 // Note: Not appending kForceCompositingMode switch here, since not all bots | 221 // Note: Not appending kForceCompositingMode switch here, since not all bots |
| 216 // support compositing. Some bots will run with compositing on, and others | 222 // support compositing. Some bots will run with compositing on, and others |
| 217 // won't. Therefore, the call to SetUpSourceSurface() later on will detect | 223 // won't. Therefore, the call to SetUpSourceSurface() later on will detect |
| 218 // whether compositing mode is actually on or not. If not, the tests will | 224 // whether compositing mode is actually on or not. If not, the tests will |
| 219 // pass blindly, logging a warning message, since we cannot test what the | 225 // pass blindly, logging a warning message, since we cannot test what the |
| 220 // platform/implementation does not support. | 226 // platform/implementation does not support. |
| 221 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); | 227 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); |
| 222 } | 228 } |
| 223 | 229 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // until at least one DeliverFrameCallback has been invoked. | 404 // until at least one DeliverFrameCallback has been invoked. |
| 399 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, | 405 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, |
| 400 FrameSubscriberTest) { | 406 FrameSubscriberTest) { |
| 401 SET_UP_SURFACE_OR_PASS_TEST(NULL); | 407 SET_UP_SURFACE_OR_PASS_TEST(NULL); |
| 402 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); | 408 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); |
| 403 if (!view->CanSubscribeFrame()) { | 409 if (!view->CanSubscribeFrame()) { |
| 404 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " | 410 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " |
| 405 "supported on this platform."); | 411 "supported on this platform."); |
| 406 return; | 412 return; |
| 407 } | 413 } |
| 408 #if defined(USE_AURA) | |
| 409 if (ui::IsTestCompositorEnabled()) { | |
| 410 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't " | |
| 411 "support frame subscription."); | |
| 412 // TODO(miu): Aura test compositor should support frame subscription for | |
| 413 // testing. http://crbug.com/240572 | |
| 414 return; | |
| 415 } | |
| 416 #endif | |
| 417 | 414 |
| 418 base::RunLoop run_loop; | 415 base::RunLoop run_loop; |
| 419 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( | 416 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( |
| 420 new FakeFrameSubscriber( | 417 new FakeFrameSubscriber( |
| 421 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, | 418 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, |
| 422 base::Unretained(this), | 419 base::Unretained(this), |
| 423 base::MessageLoopProxy::current(), | 420 base::MessageLoopProxy::current(), |
| 424 run_loop.QuitClosure()))); | 421 run_loop.QuitClosure()))); |
| 425 view->BeginFrameSubscription(subscriber.Pass()); | 422 view->BeginFrameSubscription(subscriber.Pass()); |
| 426 run_loop.Run(); | 423 run_loop.Run(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 468 |
| 472 class CompositingRenderWidgetHostViewBrowserTestTabCapture | 469 class CompositingRenderWidgetHostViewBrowserTestTabCapture |
| 473 : public CompositingRenderWidgetHostViewBrowserTest { | 470 : public CompositingRenderWidgetHostViewBrowserTest { |
| 474 public: | 471 public: |
| 475 CompositingRenderWidgetHostViewBrowserTestTabCapture() | 472 CompositingRenderWidgetHostViewBrowserTestTabCapture() |
| 476 : expected_copy_from_compositing_surface_result_(false), | 473 : expected_copy_from_compositing_surface_result_(false), |
| 477 allowable_error_(0), | 474 allowable_error_(0), |
| 478 test_url_("data:text/html,<!doctype html>") {} | 475 test_url_("data:text/html,<!doctype html>") {} |
| 479 | 476 |
| 480 virtual void SetUp() OVERRIDE { | 477 virtual void SetUp() OVERRIDE { |
| 481 ui::DisableTestCompositor(); | 478 // We expect real pixel output for these tests. |
| 479 UseRealGLContexts(); |
| 480 |
| 481 // On legacy windows, these tests need real GL bindings to pass. |
| 482 #if defined(OS_WIN) && !defined(USE_AURA) |
| 483 UseRealGLBindings(); |
| 484 #endif |
| 485 |
| 482 CompositingRenderWidgetHostViewBrowserTest::SetUp(); | 486 CompositingRenderWidgetHostViewBrowserTest::SetUp(); |
| 483 } | 487 } |
| 484 | 488 |
| 485 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 486 // TODO(Hubbe): This code is very similar to some code in | |
| 487 // gpu_feature_browsertest.cc, and should really be shared in a common | |
| 488 // location. | |
| 489 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { | |
| 490 CHECK(!command_line->HasSwitch(switches::kUseGL)) | |
| 491 << "kUseGL must not be set by test framework code!"; | |
| 492 command_line->AppendSwitchASCII(switches::kUseGL, | |
| 493 gfx::kGLImplementationOSMesaName); | |
| 494 } | |
| 495 } | |
| 496 | |
| 497 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback, | 489 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback, |
| 498 bool result, | 490 bool result, |
| 499 const SkBitmap& bitmap) { | 491 const SkBitmap& bitmap) { |
| 500 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result); | 492 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result); |
| 501 if (!result) { | 493 if (!result) { |
| 502 quit_callback.Run(); | 494 quit_callback.Run(); |
| 503 return; | 495 return; |
| 504 } | 496 } |
| 505 | 497 |
| 506 const SkBitmap& expected_bitmap = | 498 const SkBitmap& expected_bitmap = |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 copy_rect, | 877 copy_rect, |
| 886 output_size, | 878 output_size, |
| 887 expected_bitmap_size, | 879 expected_bitmap_size, |
| 888 video_frame); | 880 video_frame); |
| 889 } | 881 } |
| 890 | 882 |
| 891 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 883 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 892 | 884 |
| 893 } // namespace | 885 } // namespace |
| 894 } // namespace content | 886 } // namespace content |
| OLD | NEW |