| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 // Create a NavigationController with a restored set of tabs. | 1535 // Create a NavigationController with a restored set of tabs. |
| 1536 GURL url("http://foo"); | 1536 GURL url("http://foo"); |
| 1537 std::vector<NavigationEntry*> entries; | 1537 std::vector<NavigationEntry*> entries; |
| 1538 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 1538 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
| 1539 url, content::Referrer(), content::PAGE_TRANSITION_RELOAD, false, | 1539 url, content::Referrer(), content::PAGE_TRANSITION_RELOAD, false, |
| 1540 std::string(), browser_context()); | 1540 std::string(), browser_context()); |
| 1541 entry->SetPageID(0); | 1541 entry->SetPageID(0); |
| 1542 entry->SetTitle(ASCIIToUTF16("Title")); | 1542 entry->SetTitle(ASCIIToUTF16("Title")); |
| 1543 entry->SetContentState("state"); | 1543 entry->SetContentState("state"); |
| 1544 entries.push_back(entry); | 1544 entries.push_back(entry); |
| 1545 TabContents our_contents( | 1545 WebContentsImpl our_contents( |
| 1546 browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 1546 browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
| 1547 NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); | 1547 NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); |
| 1548 our_controller.Restore(0, true, &entries); | 1548 our_controller.Restore(0, true, &entries); |
| 1549 ASSERT_EQ(0u, entries.size()); | 1549 ASSERT_EQ(0u, entries.size()); |
| 1550 | 1550 |
| 1551 // Before navigating to the restored entry, it should have a restore_type | 1551 // Before navigating to the restored entry, it should have a restore_type |
| 1552 // and no SiteInstance. | 1552 // and no SiteInstance. |
| 1553 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, | 1553 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, |
| 1554 NavigationEntryImpl::FromNavigationEntry( | 1554 NavigationEntryImpl::FromNavigationEntry( |
| 1555 our_controller.GetEntryAtIndex(0))->restore_type()); | 1555 our_controller.GetEntryAtIndex(0))->restore_type()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 // Create a NavigationController with a restored set of tabs. | 1602 // Create a NavigationController with a restored set of tabs. |
| 1603 GURL url("http://foo"); | 1603 GURL url("http://foo"); |
| 1604 std::vector<NavigationEntry*> entries; | 1604 std::vector<NavigationEntry*> entries; |
| 1605 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 1605 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
| 1606 url, content::Referrer(), content::PAGE_TRANSITION_RELOAD, false, | 1606 url, content::Referrer(), content::PAGE_TRANSITION_RELOAD, false, |
| 1607 std::string(), browser_context()); | 1607 std::string(), browser_context()); |
| 1608 entry->SetPageID(0); | 1608 entry->SetPageID(0); |
| 1609 entry->SetTitle(ASCIIToUTF16("Title")); | 1609 entry->SetTitle(ASCIIToUTF16("Title")); |
| 1610 entry->SetContentState("state"); | 1610 entry->SetContentState("state"); |
| 1611 entries.push_back(entry); | 1611 entries.push_back(entry); |
| 1612 TabContents our_contents( | 1612 WebContentsImpl our_contents( |
| 1613 browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 1613 browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
| 1614 NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); | 1614 NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); |
| 1615 our_controller.Restore(0, true, &entries); | 1615 our_controller.Restore(0, true, &entries); |
| 1616 ASSERT_EQ(0u, entries.size()); | 1616 ASSERT_EQ(0u, entries.size()); |
| 1617 | 1617 |
| 1618 // Before navigating to the restored entry, it should have a restore_type | 1618 // Before navigating to the restored entry, it should have a restore_type |
| 1619 // and no SiteInstance. | 1619 // and no SiteInstance. |
| 1620 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, | 1620 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, |
| 1621 NavigationEntryImpl::FromNavigationEntry( | 1621 NavigationEntryImpl::FromNavigationEntry( |
| 1622 our_controller.GetEntryAtIndex(0))->restore_type()); | 1622 our_controller.GetEntryAtIndex(0))->restore_type()); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 params.is_post = false; | 1983 params.is_post = false; |
| 1984 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(subframe)); | 1984 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(subframe)); |
| 1985 content::LoadCommittedDetails details; | 1985 content::LoadCommittedDetails details; |
| 1986 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); | 1986 EXPECT_FALSE(controller.RendererDidNavigate(params, &details)); |
| 1987 | 1987 |
| 1988 // Nothing should have changed. | 1988 // Nothing should have changed. |
| 1989 EXPECT_EQ(controller.GetEntryCount(), 1); | 1989 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1990 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1990 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1991 } | 1991 } |
| 1992 | 1992 |
| 1993 // Make sure that on cloning a tabcontents and going back needs_reload is false. | 1993 // Make sure that on cloning a WebContentsImpl and going back needs_reload is |
| 1994 // false. |
| 1994 TEST_F(NavigationControllerTest, CloneAndGoBack) { | 1995 TEST_F(NavigationControllerTest, CloneAndGoBack) { |
| 1995 NavigationControllerImpl& controller = controller_impl(); | 1996 NavigationControllerImpl& controller = controller_impl(); |
| 1996 const GURL url1("http://foo1"); | 1997 const GURL url1("http://foo1"); |
| 1997 const GURL url2("http://foo2"); | 1998 const GURL url2("http://foo2"); |
| 1998 | 1999 |
| 1999 NavigateAndCommit(url1); | 2000 NavigateAndCommit(url1); |
| 2000 NavigateAndCommit(url2); | 2001 NavigateAndCommit(url2); |
| 2001 | 2002 |
| 2002 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone()); | 2003 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone()); |
| 2003 | 2004 |
| 2004 ASSERT_EQ(2, clone->GetController().GetEntryCount()); | 2005 ASSERT_EQ(2, clone->GetController().GetEntryCount()); |
| 2005 EXPECT_TRUE(clone->GetController().NeedsReload()); | 2006 EXPECT_TRUE(clone->GetController().NeedsReload()); |
| 2006 clone->GetController().GoBack(); | 2007 clone->GetController().GoBack(); |
| 2007 // Navigating back should have triggered needs_reload_ to go false. | 2008 // Navigating back should have triggered needs_reload_ to go false. |
| 2008 EXPECT_FALSE(clone->GetController().NeedsReload()); | 2009 EXPECT_FALSE(clone->GetController().NeedsReload()); |
| 2009 } | 2010 } |
| 2010 | 2011 |
| 2011 // Make sure that cloning a tabcontents doesn't copy interstitials. | 2012 // Make sure that cloning a WebContentsImpl doesn't copy interstitials. |
| 2012 TEST_F(NavigationControllerTest, CloneOmitsInterstitials) { | 2013 TEST_F(NavigationControllerTest, CloneOmitsInterstitials) { |
| 2013 NavigationControllerImpl& controller = controller_impl(); | 2014 NavigationControllerImpl& controller = controller_impl(); |
| 2014 const GURL url1("http://foo1"); | 2015 const GURL url1("http://foo1"); |
| 2015 const GURL url2("http://foo2"); | 2016 const GURL url2("http://foo2"); |
| 2016 | 2017 |
| 2017 NavigateAndCommit(url1); | 2018 NavigateAndCommit(url1); |
| 2018 NavigateAndCommit(url2); | 2019 NavigateAndCommit(url2); |
| 2019 | 2020 |
| 2020 // Add an interstitial entry. Should be deleted with controller. | 2021 // Add an interstitial entry. Should be deleted with controller. |
| 2021 NavigationEntryImpl* interstitial_entry = new NavigationEntryImpl(); | 2022 NavigationEntryImpl* interstitial_entry = new NavigationEntryImpl(); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2618 TabNavigation nav(0, url0, GURL(), string16(), | 2619 TabNavigation nav(0, url0, GURL(), string16(), |
| 2619 webkit_glue::CreateHistoryStateForURL(url0), | 2620 webkit_glue::CreateHistoryStateForURL(url0), |
| 2620 content::PAGE_TRANSITION_LINK); | 2621 content::PAGE_TRANSITION_LINK); |
| 2621 session_helper_.AssertNavigationEquals(nav, | 2622 session_helper_.AssertNavigationEquals(nav, |
| 2622 windows_[0]->tabs[0]->navigations[0]); | 2623 windows_[0]->tabs[0]->navigations[0]); |
| 2623 nav.set_url(url2); | 2624 nav.set_url(url2); |
| 2624 session_helper_.AssertNavigationEquals(nav, | 2625 session_helper_.AssertNavigationEquals(nav, |
| 2625 windows_[0]->tabs[0]->navigations[1]); | 2626 windows_[0]->tabs[0]->navigations[1]); |
| 2626 } | 2627 } |
| 2627 */ | 2628 */ |
| OLD | NEW |