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