| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { | 1978 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { |
| 1979 NavigationControllerImpl& controller = controller_impl(); | 1979 NavigationControllerImpl& controller = controller_impl(); |
| 1980 size_t original_count = NavigationControllerImpl::max_entry_count(); | 1980 size_t original_count = NavigationControllerImpl::max_entry_count(); |
| 1981 const int kMaxEntryCount = 5; | 1981 const int kMaxEntryCount = 5; |
| 1982 | 1982 |
| 1983 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); | 1983 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); |
| 1984 | 1984 |
| 1985 int url_index; | 1985 int url_index; |
| 1986 // Load up to the max count, all entries should be there. | 1986 // Load up to the max count, all entries should be there. |
| 1987 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { | 1987 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { |
| 1988 GURL url(StringPrintf("http://www.a.com/%d", url_index)); | 1988 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| 1989 controller.LoadURL( | 1989 controller.LoadURL( |
| 1990 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1990 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 1991 test_rvh()->SendNavigate(url_index, url); | 1991 test_rvh()->SendNavigate(url_index, url); |
| 1992 } | 1992 } |
| 1993 | 1993 |
| 1994 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 1994 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 1995 | 1995 |
| 1996 // Created a PrunedListener to observe prune notifications. | 1996 // Created a PrunedListener to observe prune notifications. |
| 1997 PrunedListener listener(&controller); | 1997 PrunedListener listener(&controller); |
| 1998 | 1998 |
| 1999 // Navigate some more. | 1999 // Navigate some more. |
| 2000 GURL url(StringPrintf("http://www.a.com/%d", url_index)); | 2000 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| 2001 controller.LoadURL( | 2001 controller.LoadURL( |
| 2002 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2002 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2003 test_rvh()->SendNavigate(url_index, url); | 2003 test_rvh()->SendNavigate(url_index, url); |
| 2004 url_index++; | 2004 url_index++; |
| 2005 | 2005 |
| 2006 // We should have got a pruned navigation. | 2006 // We should have got a pruned navigation. |
| 2007 EXPECT_EQ(1, listener.notification_count_); | 2007 EXPECT_EQ(1, listener.notification_count_); |
| 2008 EXPECT_TRUE(listener.details_.from_front); | 2008 EXPECT_TRUE(listener.details_.from_front); |
| 2009 EXPECT_EQ(1, listener.details_.count); | 2009 EXPECT_EQ(1, listener.details_.count); |
| 2010 | 2010 |
| 2011 // We expect http://www.a.com/0 to be gone. | 2011 // We expect http://www.a.com/0 to be gone. |
| 2012 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2012 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 2013 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2013 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
| 2014 GURL("http:////www.a.com/1")); | 2014 GURL("http:////www.a.com/1")); |
| 2015 | 2015 |
| 2016 // More navigations. | 2016 // More navigations. |
| 2017 for (int i = 0; i < 3; i++) { | 2017 for (int i = 0; i < 3; i++) { |
| 2018 url = GURL(StringPrintf("http:////www.a.com/%d", url_index)); | 2018 url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); |
| 2019 controller.LoadURL( | 2019 controller.LoadURL( |
| 2020 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2020 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2021 test_rvh()->SendNavigate(url_index, url); | 2021 test_rvh()->SendNavigate(url_index, url); |
| 2022 url_index++; | 2022 url_index++; |
| 2023 } | 2023 } |
| 2024 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2024 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
| 2025 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2025 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
| 2026 GURL("http:////www.a.com/4")); | 2026 GURL("http:////www.a.com/4")); |
| 2027 | 2027 |
| 2028 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); | 2028 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 PAGE_TRANSITION_LINK); | 3411 PAGE_TRANSITION_LINK); |
| 3412 session_helper_.AssertNavigationEquals(nav, | 3412 session_helper_.AssertNavigationEquals(nav, |
| 3413 windows_[0]->tabs[0]->navigations[0]); | 3413 windows_[0]->tabs[0]->navigations[0]); |
| 3414 nav.set_url(url2); | 3414 nav.set_url(url2); |
| 3415 session_helper_.AssertNavigationEquals(nav, | 3415 session_helper_.AssertNavigationEquals(nav, |
| 3416 windows_[0]->tabs[0]->navigations[1]); | 3416 windows_[0]->tabs[0]->navigations[1]); |
| 3417 } | 3417 } |
| 3418 */ | 3418 */ |
| 3419 | 3419 |
| 3420 } // namespace content | 3420 } // namespace content |
| OLD | NEW |