| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "content/browser/renderer_host/render_view_host_impl.h" | 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 13 #include "content/browser/web_contents/navigation_controller_impl.h" | 13 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 14 #include "content/browser/web_contents/navigation_entry_impl.h" | 14 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/browser/web_contents/web_contents_screenshot_manager.h" | 16 #include "content/browser/web_contents/web_contents_screenshot_manager.h" |
| 17 #include "content/public/browser/web_contents_view.h" | 17 #include "content/public/browser/web_contents_view.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/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
| 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 "ui/aura/root_window.h" | 24 #include "ui/aura/root_window.h" |
| 25 #include "ui/aura/test/event_generator.h" | 25 #include "ui/aura/test/event_generator.h" |
| 26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 27 #include "ui/compositor/compositor_setup.h" |
| 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 28 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 | 31 |
| 31 // This class keeps track of the RenderViewHost whose screenshot was captured. | 32 // This class keeps track of the RenderViewHost whose screenshot was captured. |
| 32 class ScreenshotTracker : public WebContentsScreenshotManager { | 33 class ScreenshotTracker : public WebContentsScreenshotManager { |
| 33 public: | 34 public: |
| 34 explicit ScreenshotTracker(NavigationControllerImpl* controller) | 35 explicit ScreenshotTracker(NavigationControllerImpl* controller) |
| 35 : WebContentsScreenshotManager(controller), | 36 : WebContentsScreenshotManager(controller), |
| 36 screenshot_taken_for_(NULL), | 37 screenshot_taken_for_(NULL), |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // Do not end the overscroll sequence. | 319 // Do not end the overscroll sequence. |
| 319 } | 320 } |
| 320 | 321 |
| 321 // Tests that the page has has a screenshot when navigation happens: | 322 // Tests that the page has has a screenshot when navigation happens: |
| 322 // - from within the page (from a JS function) | 323 // - from within the page (from a JS function) |
| 323 // - interactively, when user does an overscroll gesture | 324 // - interactively, when user does an overscroll gesture |
| 324 // - interactively, when user navigates in history without the overscroll | 325 // - interactively, when user navigates in history without the overscroll |
| 325 // gesture. | 326 // gesture. |
| 326 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 327 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
| 327 OverscrollScreenshot) { | 328 OverscrollScreenshot) { |
| 329 // http://crbug.com/268644 |
| 330 if (ui::IsTestCompositorEnabled()) |
| 331 return; |
| 328 ASSERT_NO_FATAL_FAILURE( | 332 ASSERT_NO_FATAL_FAILURE( |
| 329 StartTestWithPage("files/overscroll_navigation.html")); | 333 StartTestWithPage("files/overscroll_navigation.html")); |
| 330 WebContentsImpl* web_contents = | 334 WebContentsImpl* web_contents = |
| 331 static_cast<WebContentsImpl*>(shell()->web_contents()); | 335 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 332 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( | 336 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 333 web_contents->GetRenderViewHost()); | 337 web_contents->GetRenderViewHost()); |
| 334 | 338 |
| 335 set_min_screenshot_interval(0); | 339 set_min_screenshot_interval(0); |
| 336 | 340 |
| 337 // Do a few navigations initiated by the page. | 341 // Do a few navigations initiated by the page. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 entry = NavigationEntryImpl::FromNavigationEntry( | 416 entry = NavigationEntryImpl::FromNavigationEntry( |
| 413 web_contents->GetController().GetEntryAtIndex(4)); | 417 web_contents->GetController().GetEntryAtIndex(4)); |
| 414 EXPECT_TRUE(entry->screenshot().get()); | 418 EXPECT_TRUE(entry->screenshot().get()); |
| 415 } | 419 } |
| 416 } | 420 } |
| 417 | 421 |
| 418 // Tests that screenshot is taken correctly when navigation causes a | 422 // Tests that screenshot is taken correctly when navigation causes a |
| 419 // RenderViewHost to be swapped out. | 423 // RenderViewHost to be swapped out. |
| 420 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 424 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
| 421 ScreenshotForSwappedOutRenderViews) { | 425 ScreenshotForSwappedOutRenderViews) { |
| 426 // http://crbug.com/268644 |
| 427 if (ui::IsTestCompositorEnabled()) |
| 428 return; |
| 422 ASSERT_NO_FATAL_FAILURE( | 429 ASSERT_NO_FATAL_FAILURE( |
| 423 StartTestWithPage("files/overscroll_navigation.html")); | 430 StartTestWithPage("files/overscroll_navigation.html")); |
| 424 // Create a new server with a different site. | 431 // Create a new server with a different site. |
| 425 net::SpawnedTestServer https_server( | 432 net::SpawnedTestServer https_server( |
| 426 net::SpawnedTestServer::TYPE_HTTPS, | 433 net::SpawnedTestServer::TYPE_HTTPS, |
| 427 net::SpawnedTestServer::kLocalhost, | 434 net::SpawnedTestServer::kLocalhost, |
| 428 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 435 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| 429 ASSERT_TRUE(https_server.Start()); | 436 ASSERT_TRUE(https_server.Start()); |
| 430 | 437 |
| 431 WebContentsImpl* web_contents = | 438 WebContentsImpl* web_contents = |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 10); | 600 10); |
| 594 string16 actual_title = title_watcher.WaitAndGetTitle(); | 601 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 595 EXPECT_EQ(expected_title, actual_title); | 602 EXPECT_EQ(expected_title, actual_title); |
| 596 | 603 |
| 597 EXPECT_EQ(2, GetCurrentIndex()); | 604 EXPECT_EQ(2, GetCurrentIndex()); |
| 598 EXPECT_TRUE(controller.CanGoBack()); | 605 EXPECT_TRUE(controller.CanGoBack()); |
| 599 EXPECT_FALSE(controller.CanGoForward()); | 606 EXPECT_FALSE(controller.CanGoForward()); |
| 600 } | 607 } |
| 601 | 608 |
| 602 } // namespace content | 609 } // namespace content |
| OLD | NEW |