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

Side by Side Diff: trunk/src/content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 22648006: Revert 216780 "Clean up compositor initialization/destruction." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 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 "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"
(...skipping 10 matching lines...) Expand all
21 #include "content/shell/shell.h" 21 #include "content/shell/shell.h"
22 #include "content/test/content_browser_test.h" 22 #include "content/test/content_browser_test.h"
23 #include "content/test/content_browser_test_utils.h" 23 #include "content/test/content_browser_test_utils.h"
24 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
25 #include "media/filters/skcanvas_video_renderer.h" 25 #include "media/filters/skcanvas_video_renderer.h"
26 #include "net/base/net_util.h" 26 #include "net/base/net_util.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 27 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "third_party/skia/include/core/SkCanvas.h" 28 #include "third_party/skia/include/core/SkCanvas.h"
29 #include "third_party/skia/include/core/SkDevice.h" 29 #include "third_party/skia/include/core/SkDevice.h"
30 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
31 #include "ui/compositor/compositor_setup.h"
31 #include "ui/gfx/size_conversions.h" 32 #include "ui/gfx/size_conversions.h"
32 #include "ui/gl/gl_switches.h" 33 #include "ui/gl/gl_switches.h"
33 34
34 #if defined(OS_MACOSX) 35 #if defined(OS_MACOSX)
35 #include "ui/gl/io_surface_support_mac.h" 36 #include "ui/gl/io_surface_support_mac.h"
36 #endif 37 #endif
37 38
38 #if defined(OS_WIN) 39 #if defined(OS_WIN)
39 #include "ui/base/win/dpi.h" 40 #include "ui/base/win/dpi.h"
40 #endif 41 #endif
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 private: 205 private:
205 const gfx::Size frame_size_; 206 const gfx::Size frame_size_;
206 base::FilePath test_dir_; 207 base::FilePath test_dir_;
207 int callback_invoke_count_; 208 int callback_invoke_count_;
208 int frames_captured_; 209 int frames_captured_;
209 }; 210 };
210 211
211 class CompositingRenderWidgetHostViewBrowserTest 212 class CompositingRenderWidgetHostViewBrowserTest
212 : public RenderWidgetHostViewBrowserTest { 213 : public RenderWidgetHostViewBrowserTest {
213 public: 214 public:
214 virtual void SetUp() OVERRIDE {
215 // We expect real pixel output for these tests.
216 UseRealGLContexts();
217
218 // On legacy windows, these tests need real GL bindings to pass.
219 #if defined(OS_WIN) && !defined(USE_AURA)
220 UseRealGLBindings();
221 #endif
222
223 RenderWidgetHostViewBrowserTest::SetUp();
224 }
225
226 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 215 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
227 // Note: Not appending kForceCompositingMode switch here, since not all bots 216 // Note: Not appending kForceCompositingMode switch here, since not all bots
228 // support compositing. Some bots will run with compositing on, and others 217 // support compositing. Some bots will run with compositing on, and others
229 // won't. Therefore, the call to SetUpSourceSurface() later on will detect 218 // won't. Therefore, the call to SetUpSourceSurface() later on will detect
230 // whether compositing mode is actually on or not. If not, the tests will 219 // whether compositing mode is actually on or not. If not, the tests will
231 // pass blindly, logging a warning message, since we cannot test what the 220 // pass blindly, logging a warning message, since we cannot test what the
232 // platform/implementation does not support. 221 // platform/implementation does not support.
233 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); 222 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line);
234 } 223 }
235 224
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 }; 323 };
335 324
336 // Disable tests for Android and IOS as these platforms have incomplete 325 // Disable tests for Android and IOS as these platforms have incomplete
337 // implementation. 326 // implementation.
338 #if !defined(OS_ANDROID) && !defined(OS_IOS) 327 #if !defined(OS_ANDROID) && !defined(OS_IOS)
339 328
340 // The CopyFromBackingStore() API should work on all platforms when compositing 329 // The CopyFromBackingStore() API should work on all platforms when compositing
341 // is enabled. 330 // is enabled.
342 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 331 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
343 CopyFromBackingStore) { 332 CopyFromBackingStore) {
333 #if defined(USE_AURA)
334 if (ui::IsTestCompositorEnabled()) {
335 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
336 "support copying from backing store.");
337 // TODO(jbauman): Aura test compositor should support copying from backing
338 // store. http://crbug.com/268644
339 return;
340 }
341 #endif
344 RunBasicCopyFromBackingStoreTest(); 342 RunBasicCopyFromBackingStoreTest();
345 } 343 }
346 344
347 // The CopyFromBackingStore() API should work on all platforms when compositing 345 // The CopyFromBackingStore() API should work on all platforms when compositing
348 // is disabled. 346 // is disabled.
349 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, 347 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest,
350 CopyFromBackingStore) { 348 CopyFromBackingStore) {
351 RunBasicCopyFromBackingStoreTest(); 349 RunBasicCopyFromBackingStoreTest();
352 } 350 }
353 351
(...skipping 22 matching lines...) Expand all
376 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 374 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
377 CopyFromCompositingSurface_CallbackDespiteDelete) { 375 CopyFromCompositingSurface_CallbackDespiteDelete) {
378 SET_UP_SURFACE_OR_PASS_TEST(NULL); 376 SET_UP_SURFACE_OR_PASS_TEST(NULL);
379 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 377 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
380 if (!view->CanCopyToVideoFrame()) { 378 if (!view->CanCopyToVideoFrame()) {
381 LOG(WARNING) << 379 LOG(WARNING) <<
382 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() " 380 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() "
383 "not supported on this platform."); 381 "not supported on this platform.");
384 return; 382 return;
385 } 383 }
386
387 base::RunLoop run_loop; 384 base::RunLoop run_loop;
388 scoped_refptr<media::VideoFrame> dest = 385 scoped_refptr<media::VideoFrame> dest =
389 media::VideoFrame::CreateBlackFrame(frame_size()); 386 media::VideoFrame::CreateBlackFrame(frame_size());
390 view->CopyFromCompositingSurfaceToVideoFrame( 387 view->CopyFromCompositingSurfaceToVideoFrame(
391 gfx::Rect(view->GetViewBounds().size()), dest, base::Bind( 388 gfx::Rect(view->GetViewBounds().size()), dest, base::Bind(
392 &RenderWidgetHostViewBrowserTest::FinishCopyFromCompositingSurface, 389 &RenderWidgetHostViewBrowserTest::FinishCopyFromCompositingSurface,
393 base::Unretained(this), run_loop.QuitClosure())); 390 base::Unretained(this), run_loop.QuitClosure()));
394 // Delete the surface before the callback is run. 391 // Delete the surface before the callback is run.
395 view->AcceleratedSurfaceRelease(); 392 view->AcceleratedSurfaceRelease();
396 run_loop.Run(); 393 run_loop.Run();
(...skipping 13 matching lines...) Expand all
410 // until at least one DeliverFrameCallback has been invoked. 407 // until at least one DeliverFrameCallback has been invoked.
411 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 408 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
412 FrameSubscriberTest) { 409 FrameSubscriberTest) {
413 SET_UP_SURFACE_OR_PASS_TEST(NULL); 410 SET_UP_SURFACE_OR_PASS_TEST(NULL);
414 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 411 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
415 if (!view->CanSubscribeFrame()) { 412 if (!view->CanSubscribeFrame()) {
416 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " 413 LOG(WARNING) << ("Blindly passing this test: Frame subscription not "
417 "supported on this platform."); 414 "supported on this platform.");
418 return; 415 return;
419 } 416 }
417 #if defined(USE_AURA)
418 if (ui::IsTestCompositorEnabled()) {
419 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
420 "support frame subscription.");
421 // TODO(miu): Aura test compositor should support frame subscription for
422 // testing. http://crbug.com/240572
423 return;
424 }
425 #endif
420 426
421 base::RunLoop run_loop; 427 base::RunLoop run_loop;
422 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( 428 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber(
423 new FakeFrameSubscriber( 429 new FakeFrameSubscriber(
424 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, 430 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered,
425 base::Unretained(this), 431 base::Unretained(this),
426 base::MessageLoopProxy::current(), 432 base::MessageLoopProxy::current(),
427 run_loop.QuitClosure()))); 433 run_loop.QuitClosure())));
428 view->BeginFrameSubscription(subscriber.Pass()); 434 view->BeginFrameSubscription(subscriber.Pass());
429 run_loop.Run(); 435 run_loop.Run();
430 view->EndFrameSubscription(); 436 view->EndFrameSubscription();
431 437
432 EXPECT_LE(1, callback_invoke_count()); 438 EXPECT_LE(1, callback_invoke_count());
433 EXPECT_LE(1, frames_captured()); 439 EXPECT_LE(1, frames_captured());
434 } 440 }
435 441
436 // Test that we can copy twice from an accelerated composited page. 442 // Test that we can copy twice from an accelerated composited page.
437 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { 443 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) {
438 SET_UP_SURFACE_OR_PASS_TEST(NULL); 444 SET_UP_SURFACE_OR_PASS_TEST(NULL);
439 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 445 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
440 if (!view->CanCopyToVideoFrame()) { 446 if (!view->CanCopyToVideoFrame()) {
441 LOG(WARNING) << ("Blindly passing this test: " 447 LOG(WARNING) << ("Blindly passing this test: "
442 "CopyFromCompositingSurfaceToVideoFrame() not supported " 448 "CopyFromCompositingSurfaceToVideoFrame() not supported "
443 "on this platform."); 449 "on this platform.");
444 return; 450 return;
445 } 451 }
446 452
453 #if defined(USE_AURA)
454 if (ui::IsTestCompositorEnabled()) {
455 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
456 "support copying to video frame.");
457 // TODO(jbauman): Aura test compositor should support copying to video
458 // frame. http://crbug.com/268644
459 return;
460 }
461 #endif
462
447 base::RunLoop run_loop; 463 base::RunLoop run_loop;
448 scoped_refptr<media::VideoFrame> first_output = 464 scoped_refptr<media::VideoFrame> first_output =
449 media::VideoFrame::CreateBlackFrame(frame_size()); 465 media::VideoFrame::CreateBlackFrame(frame_size());
450 ASSERT_TRUE(first_output.get()); 466 ASSERT_TRUE(first_output.get());
451 scoped_refptr<media::VideoFrame> second_output = 467 scoped_refptr<media::VideoFrame> second_output =
452 media::VideoFrame::CreateBlackFrame(frame_size()); 468 media::VideoFrame::CreateBlackFrame(frame_size());
453 ASSERT_TRUE(second_output.get()); 469 ASSERT_TRUE(second_output.get());
454 view->CopyFromCompositingSurfaceToVideoFrame( 470 view->CopyFromCompositingSurfaceToVideoFrame(
455 gfx::Rect(view->GetViewBounds().size()), 471 gfx::Rect(view->GetViewBounds().size()),
456 first_output, 472 first_output,
(...skipping 16 matching lines...) Expand all
473 } 489 }
474 490
475 class CompositingRenderWidgetHostViewBrowserTestTabCapture 491 class CompositingRenderWidgetHostViewBrowserTestTabCapture
476 : public CompositingRenderWidgetHostViewBrowserTest { 492 : public CompositingRenderWidgetHostViewBrowserTest {
477 public: 493 public:
478 CompositingRenderWidgetHostViewBrowserTestTabCapture() 494 CompositingRenderWidgetHostViewBrowserTestTabCapture()
479 : expected_copy_from_compositing_surface_result_(false), 495 : expected_copy_from_compositing_surface_result_(false),
480 allowable_error_(0), 496 allowable_error_(0),
481 test_url_("data:text/html,<!doctype html>") {} 497 test_url_("data:text/html,<!doctype html>") {}
482 498
499 virtual void SetUp() OVERRIDE {
500 ui::DisableTestCompositor();
501 CompositingRenderWidgetHostViewBrowserTest::SetUp();
502 }
503
504 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
505 // TODO(Hubbe): This code is very similar to some code in
506 // gpu_feature_browsertest.cc, and should really be shared in a common
507 // location.
508 if (!command_line->HasSwitch(switches::kUseGpuInTests)) {
509 CHECK(!command_line->HasSwitch(switches::kUseGL))
510 << "kUseGL must not be set by test framework code!";
511 command_line->AppendSwitchASCII(switches::kUseGL,
512 gfx::kGLImplementationOSMesaName);
513 }
514 }
515
483 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback, 516 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback,
484 bool result, 517 bool result,
485 const SkBitmap& bitmap) { 518 const SkBitmap& bitmap) {
486 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result); 519 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result);
487 if (!result) { 520 if (!result) {
488 quit_callback.Run(); 521 quit_callback.Run();
489 return; 522 return;
490 } 523 }
491 524
492 const SkBitmap& expected_bitmap = 525 const SkBitmap& expected_bitmap =
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 copy_rect, 904 copy_rect,
872 output_size, 905 output_size,
873 expected_bitmap_size, 906 expected_bitmap_size,
874 video_frame); 907 video_frame);
875 } 908 }
876 909
877 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 910 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
878 911
879 } // namespace 912 } // namespace
880 } // namespace content 913 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698