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" |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 632 |
633 WebContentsImpl* web_contents = | 633 WebContentsImpl* web_contents = |
634 static_cast<WebContentsImpl*>(shell()->web_contents()); | 634 static_cast<WebContentsImpl*>(shell()->web_contents()); |
635 set_min_screenshot_interval(0); | 635 set_min_screenshot_interval(0); |
636 | 636 |
637 struct { | 637 struct { |
638 GURL url; | 638 GURL url; |
639 int transition; | 639 int transition; |
640 } navigations[] = { | 640 } navigations[] = { |
641 { https_server.GetURL("files/title1.html"), | 641 { https_server.GetURL("files/title1.html"), |
642 PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR }, | 642 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR }, |
643 { test_server()->GetURL("files/title2.html"), | 643 { test_server()->GetURL("files/title2.html"), |
644 PAGE_TRANSITION_AUTO_BOOKMARK }, | 644 ui::PAGE_TRANSITION_AUTO_BOOKMARK }, |
645 { https_server.GetURL("files/title3.html"), | 645 { https_server.GetURL("files/title3.html"), |
646 PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR }, | 646 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR }, |
647 { GURL(), 0 } | 647 { GURL(), 0 } |
648 }; | 648 }; |
649 | 649 |
650 screenshot_manager()->Reset(); | 650 screenshot_manager()->Reset(); |
651 for (int i = 0; !navigations[i].url.is_empty(); ++i) { | 651 for (int i = 0; !navigations[i].url.is_empty(); ++i) { |
652 // Navigate via the user initiating a navigation from the UI. | 652 // Navigate via the user initiating a navigation from the UI. |
653 NavigationController::LoadURLParams params(navigations[i].url); | 653 NavigationController::LoadURLParams params(navigations[i].url); |
654 params.transition_type = PageTransitionFromInt(navigations[i].transition); | 654 params.transition_type = |
| 655 ui::PageTransitionFromInt(navigations[i].transition); |
655 | 656 |
656 RenderViewHost* old_host = web_contents->GetRenderViewHost(); | 657 RenderViewHost* old_host = web_contents->GetRenderViewHost(); |
657 web_contents->GetController().LoadURLWithParams(params); | 658 web_contents->GetController().LoadURLWithParams(params); |
658 WaitForLoadStop(web_contents); | 659 WaitForLoadStop(web_contents); |
659 screenshot_manager()->WaitUntilScreenshotIsReady(); | 660 screenshot_manager()->WaitUntilScreenshotIsReady(); |
660 | 661 |
661 EXPECT_NE(old_host, web_contents->GetRenderViewHost()) | 662 EXPECT_NE(old_host, web_contents->GetRenderViewHost()) |
662 << navigations[i].url.spec(); | 663 << navigations[i].url.spec(); |
663 EXPECT_EQ(old_host, screenshot_manager()->screenshot_taken_for()); | 664 EXPECT_EQ(old_host, screenshot_manager()->screenshot_taken_for()); |
664 | 665 |
665 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 666 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
666 web_contents->GetController().GetEntryAtOffset(-1)); | 667 web_contents->GetController().GetEntryAtOffset(-1)); |
667 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); | 668 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); |
668 | 669 |
669 entry = NavigationEntryImpl::FromNavigationEntry( | 670 entry = NavigationEntryImpl::FromNavigationEntry( |
670 web_contents->GetController().GetLastCommittedEntry()); | 671 web_contents->GetController().GetLastCommittedEntry()); |
671 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); | 672 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); |
672 EXPECT_FALSE(entry->screenshot().get()); | 673 EXPECT_FALSE(entry->screenshot().get()); |
673 screenshot_manager()->Reset(); | 674 screenshot_manager()->Reset(); |
674 } | 675 } |
675 | 676 |
676 // Increase the minimum interval between taking screenshots. | 677 // Increase the minimum interval between taking screenshots. |
677 set_min_screenshot_interval(60000); | 678 set_min_screenshot_interval(60000); |
678 | 679 |
679 // Navigate again. This should not take any screenshot because of the | 680 // Navigate again. This should not take any screenshot because of the |
680 // increased screenshot interval. | 681 // increased screenshot interval. |
681 NavigationController::LoadURLParams params(navigations[0].url); | 682 NavigationController::LoadURLParams params(navigations[0].url); |
682 params.transition_type = PageTransitionFromInt(navigations[0].transition); | 683 params.transition_type = ui::PageTransitionFromInt(navigations[0].transition); |
683 web_contents->GetController().LoadURLWithParams(params); | 684 web_contents->GetController().LoadURLWithParams(params); |
684 WaitForLoadStop(web_contents); | 685 WaitForLoadStop(web_contents); |
685 screenshot_manager()->WaitUntilScreenshotIsReady(); | 686 screenshot_manager()->WaitUntilScreenshotIsReady(); |
686 | 687 |
687 EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); | 688 EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); |
688 } | 689 } |
689 | 690 |
690 // Tests that navigations resulting from reloads, history.replaceState, | 691 // Tests that navigations resulting from reloads, history.replaceState, |
691 // and history.pushState do not capture screenshots. | 692 // and history.pushState do not capture screenshots. |
692 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ReplaceStateReloadPushState) { | 693 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ReplaceStateReloadPushState) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 WaitAFrame(); | 964 WaitAFrame(); |
964 | 965 |
965 if (!navigated) | 966 if (!navigated) |
966 EXPECT_EQ(10, ExecuteScriptAndExtractInt("touchmoveCount")); | 967 EXPECT_EQ(10, ExecuteScriptAndExtractInt("touchmoveCount")); |
967 else | 968 else |
968 EXPECT_GT(10, ExecuteScriptAndExtractInt("touchmoveCount")); | 969 EXPECT_GT(10, ExecuteScriptAndExtractInt("touchmoveCount")); |
969 } | 970 } |
970 } | 971 } |
971 | 972 |
972 } // namespace content | 973 } // namespace content |
OLD | NEW |