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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 80 |
80 DISALLOW_COPY_AND_ASSIGN(ScreenshotTracker); | 81 DISALLOW_COPY_AND_ASSIGN(ScreenshotTracker); |
81 }; | 82 }; |
82 | 83 |
83 class WebContentsViewAuraTest : public ContentBrowserTest { | 84 class WebContentsViewAuraTest : public ContentBrowserTest { |
84 public: | 85 public: |
85 WebContentsViewAuraTest() | 86 WebContentsViewAuraTest() |
86 : screenshot_manager_(NULL) { | 87 : screenshot_manager_(NULL) { |
87 } | 88 } |
88 | 89 |
89 virtual void SetUp() OVERRIDE { | |
90 // TODO(jbauman): Remove this. http://crbug.com/268644 | |
91 UseRealGLContexts(); | |
92 } | |
93 | |
94 // Executes the javascript synchronously and makes sure the returned value is | 90 // Executes the javascript synchronously and makes sure the returned value is |
95 // freed properly. | 91 // freed properly. |
96 void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) { | 92 void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) { |
97 scoped_ptr<base::Value> value = | 93 scoped_ptr<base::Value> value = |
98 content::ExecuteScriptAndGetValue(rvh, jscript); | 94 content::ExecuteScriptAndGetValue(rvh, jscript); |
99 } | 95 } |
100 | 96 |
101 // Starts the test server and navigates to the given url. Sets a large enough | 97 // Starts the test server and navigates to the given url. Sets a large enough |
102 // size to the root window. Returns after the navigation to the url is | 98 // size to the root window. Returns after the navigation to the url is |
103 // complete. | 99 // complete. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // Do not end the overscroll sequence. | 319 // Do not end the overscroll sequence. |
324 } | 320 } |
325 | 321 |
326 // Tests that the page has has a screenshot when navigation happens: | 322 // Tests that the page has has a screenshot when navigation happens: |
327 // - from within the page (from a JS function) | 323 // - from within the page (from a JS function) |
328 // - interactively, when user does an overscroll gesture | 324 // - interactively, when user does an overscroll gesture |
329 // - interactively, when user navigates in history without the overscroll | 325 // - interactively, when user navigates in history without the overscroll |
330 // gesture. | 326 // gesture. |
331 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 327 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
332 OverscrollScreenshot) { | 328 OverscrollScreenshot) { |
| 329 // http://crbug.com/268644 |
| 330 if (ui::IsTestCompositorEnabled()) |
| 331 return; |
333 ASSERT_NO_FATAL_FAILURE( | 332 ASSERT_NO_FATAL_FAILURE( |
334 StartTestWithPage("files/overscroll_navigation.html")); | 333 StartTestWithPage("files/overscroll_navigation.html")); |
335 WebContentsImpl* web_contents = | 334 WebContentsImpl* web_contents = |
336 static_cast<WebContentsImpl*>(shell()->web_contents()); | 335 static_cast<WebContentsImpl*>(shell()->web_contents()); |
337 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( | 336 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
338 web_contents->GetRenderViewHost()); | 337 web_contents->GetRenderViewHost()); |
339 | 338 |
340 set_min_screenshot_interval(0); | 339 set_min_screenshot_interval(0); |
341 | 340 |
342 // 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... |
417 entry = NavigationEntryImpl::FromNavigationEntry( | 416 entry = NavigationEntryImpl::FromNavigationEntry( |
418 web_contents->GetController().GetEntryAtIndex(4)); | 417 web_contents->GetController().GetEntryAtIndex(4)); |
419 EXPECT_TRUE(entry->screenshot().get()); | 418 EXPECT_TRUE(entry->screenshot().get()); |
420 } | 419 } |
421 } | 420 } |
422 | 421 |
423 // Tests that screenshot is taken correctly when navigation causes a | 422 // Tests that screenshot is taken correctly when navigation causes a |
424 // RenderViewHost to be swapped out. | 423 // RenderViewHost to be swapped out. |
425 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 424 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
426 ScreenshotForSwappedOutRenderViews) { | 425 ScreenshotForSwappedOutRenderViews) { |
| 426 // http://crbug.com/268644 |
| 427 if (ui::IsTestCompositorEnabled()) |
| 428 return; |
427 ASSERT_NO_FATAL_FAILURE( | 429 ASSERT_NO_FATAL_FAILURE( |
428 StartTestWithPage("files/overscroll_navigation.html")); | 430 StartTestWithPage("files/overscroll_navigation.html")); |
429 // Create a new server with a different site. | 431 // Create a new server with a different site. |
430 net::SpawnedTestServer https_server( | 432 net::SpawnedTestServer https_server( |
431 net::SpawnedTestServer::TYPE_HTTPS, | 433 net::SpawnedTestServer::TYPE_HTTPS, |
432 net::SpawnedTestServer::kLocalhost, | 434 net::SpawnedTestServer::kLocalhost, |
433 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 435 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
434 ASSERT_TRUE(https_server.Start()); | 436 ASSERT_TRUE(https_server.Start()); |
435 | 437 |
436 WebContentsImpl* web_contents = | 438 WebContentsImpl* web_contents = |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 10); | 600 10); |
599 string16 actual_title = title_watcher.WaitAndGetTitle(); | 601 string16 actual_title = title_watcher.WaitAndGetTitle(); |
600 EXPECT_EQ(expected_title, actual_title); | 602 EXPECT_EQ(expected_title, actual_title); |
601 | 603 |
602 EXPECT_EQ(2, GetCurrentIndex()); | 604 EXPECT_EQ(2, GetCurrentIndex()); |
603 EXPECT_TRUE(controller.CanGoBack()); | 605 EXPECT_TRUE(controller.CanGoBack()); |
604 EXPECT_FALSE(controller.CanGoForward()); | 606 EXPECT_FALSE(controller.CanGoForward()); |
605 } | 607 } |
606 | 608 |
607 } // namespace content | 609 } // namespace content |
OLD | NEW |