| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
| 8 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
| (...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1748 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
| 1749 TestInterstitialPageStateGuard state_guard(interstitial); | 1749 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1750 interstitial->Show(); | 1750 interstitial->Show(); |
| 1751 interstitial->TestDidNavigate(1, url2); | 1751 interstitial->TestDidNavigate(1, url2); |
| 1752 EXPECT_TRUE(interstitial->is_showing()); | 1752 EXPECT_TRUE(interstitial->is_showing()); |
| 1753 EXPECT_EQ(2, controller().GetEntryCount()); | 1753 EXPECT_EQ(2, controller().GetEntryCount()); |
| 1754 | 1754 |
| 1755 // Create another NavigationController. | 1755 // Create another NavigationController. |
| 1756 GURL url3("http://foo2"); | 1756 GURL url3("http://foo2"); |
| 1757 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 1757 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); |
| 1758 NavigationController& other_controller = other_contents->GetController(); | 1758 NavigationController& other_controller = other_contents->GetControllerImpl(); |
| 1759 other_contents->NavigateAndCommit(url3); | 1759 other_contents->NavigateAndCommit(url3); |
| 1760 other_contents->ExpectSetHistoryLengthAndPrune( | 1760 other_contents->ExpectSetHistoryLengthAndPrune( |
| 1761 NavigationEntryImpl::FromNavigationEntry( | 1761 NavigationEntryImpl::FromNavigationEntry( |
| 1762 other_controller.GetEntryAtIndex(0))->site_instance(), 1, | 1762 other_controller.GetEntryAtIndex(0))->site_instance(), 1, |
| 1763 other_controller.GetEntryAtIndex(0)->GetPageID()); | 1763 other_controller.GetEntryAtIndex(0)->GetPageID()); |
| 1764 other_controller.CopyStateFromAndPrune(&controller()); | 1764 other_controller.CopyStateFromAndPrune(&controller()); |
| 1765 | 1765 |
| 1766 // The merged controller should only have two entries: url1 and url2. | 1766 // The merged controller should only have two entries: url1 and url2. |
| 1767 ASSERT_EQ(2, other_controller.GetEntryCount()); | 1767 ASSERT_EQ(2, other_controller.GetEntryCount()); |
| 1768 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 1768 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
| 1769 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 1769 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
| 1770 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 1770 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
| 1771 | 1771 |
| 1772 // And the merged controller shouldn't be showing an interstitial. | 1772 // And the merged controller shouldn't be showing an interstitial. |
| 1773 EXPECT_FALSE(other_contents->ShowingInterstitialPage()); | 1773 EXPECT_FALSE(other_contents->ShowingInterstitialPage()); |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 // Makes sure that CopyStateFromAndPrune does the right thing if the object | 1776 // Makes sure that CopyStateFromAndPrune does the right thing if the object |
| 1777 // CopyStateFromAndPrune is invoked on is showing an interstitial. | 1777 // CopyStateFromAndPrune is invoked on is showing an interstitial. |
| 1778 TEST_F(TabContentsTest, CopyStateFromAndPruneTargetInterstitial) { | 1778 TEST_F(TabContentsTest, CopyStateFromAndPruneTargetInterstitial) { |
| 1779 // Navigate to a page. | 1779 // Navigate to a page. |
| 1780 GURL url1("http://www.google.com"); | 1780 GURL url1("http://www.google.com"); |
| 1781 contents()->NavigateAndCommit(url1); | 1781 contents()->NavigateAndCommit(url1); |
| 1782 | 1782 |
| 1783 // Create another NavigationController. | 1783 // Create another NavigationController. |
| 1784 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 1784 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); |
| 1785 NavigationController& other_controller = other_contents->GetController(); | 1785 NavigationController& other_controller = other_contents->GetControllerImpl(); |
| 1786 | 1786 |
| 1787 // Navigate it to url2. | 1787 // Navigate it to url2. |
| 1788 GURL url2("http://foo2"); | 1788 GURL url2("http://foo2"); |
| 1789 other_contents->NavigateAndCommit(url2); | 1789 other_contents->NavigateAndCommit(url2); |
| 1790 | 1790 |
| 1791 // Show an interstitial. | 1791 // Show an interstitial. |
| 1792 TestInterstitialPage::InterstitialState state = | 1792 TestInterstitialPage::InterstitialState state = |
| 1793 TestInterstitialPage::UNDECIDED; | 1793 TestInterstitialPage::UNDECIDED; |
| 1794 bool deleted = false; | 1794 bool deleted = false; |
| 1795 GURL url3("http://interstitial"); | 1795 GURL url3("http://interstitial"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1815 | 1815 |
| 1816 // It should have a transient entry. | 1816 // It should have a transient entry. |
| 1817 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1817 EXPECT_TRUE(other_controller.GetTransientEntry()); |
| 1818 | 1818 |
| 1819 // And the interstitial should be showing. | 1819 // And the interstitial should be showing. |
| 1820 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); | 1820 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); |
| 1821 | 1821 |
| 1822 // And the interstitial should do a reload on don't proceed. | 1822 // And the interstitial should do a reload on don't proceed. |
| 1823 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); | 1823 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); |
| 1824 } | 1824 } |
| OLD | NEW |