| 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/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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 NotificationRegistrar registrar_; | 1380 NotificationRegistrar registrar_; |
| 1381 | 1381 |
| 1382 DISALLOW_COPY_AND_ASSIGN(PrunedListener); | 1382 DISALLOW_COPY_AND_ASSIGN(PrunedListener); |
| 1383 }; | 1383 }; |
| 1384 | 1384 |
| 1385 // Tests that we limit the number of navigation entries created correctly. | 1385 // Tests that we limit the number of navigation entries created correctly. |
| 1386 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { | 1386 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { |
| 1387 size_t original_count = NavigationController::max_entry_count(); | 1387 size_t original_count = NavigationController::max_entry_count(); |
| 1388 const int kMaxEntryCount = 5; | 1388 const int kMaxEntryCount = 5; |
| 1389 | 1389 |
| 1390 NavigationController::set_max_entry_count(kMaxEntryCount); | 1390 NavigationController::set_max_entry_count_for_testing(kMaxEntryCount); |
| 1391 | 1391 |
| 1392 int url_index; | 1392 int url_index; |
| 1393 // Load up to the max count, all entries should be there. | 1393 // Load up to the max count, all entries should be there. |
| 1394 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { | 1394 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { |
| 1395 GURL url(StringPrintf("http://www.a.com/%d", url_index)); | 1395 GURL url(StringPrintf("http://www.a.com/%d", url_index)); |
| 1396 controller().LoadURL(url, GURL(), PageTransition::TYPED, std::string()); | 1396 controller().LoadURL(url, GURL(), PageTransition::TYPED, std::string()); |
| 1397 rvh()->SendNavigate(url_index, url); | 1397 rvh()->SendNavigate(url_index, url); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 EXPECT_EQ(controller().entry_count(), kMaxEntryCount); | 1400 EXPECT_EQ(controller().entry_count(), kMaxEntryCount); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1422 for (int i = 0; i < 3; i++) { | 1422 for (int i = 0; i < 3; i++) { |
| 1423 url = GURL(StringPrintf("http:////www.a.com/%d", url_index)); | 1423 url = GURL(StringPrintf("http:////www.a.com/%d", url_index)); |
| 1424 controller().LoadURL(url, GURL(), PageTransition::TYPED, std::string()); | 1424 controller().LoadURL(url, GURL(), PageTransition::TYPED, std::string()); |
| 1425 rvh()->SendNavigate(url_index, url); | 1425 rvh()->SendNavigate(url_index, url); |
| 1426 url_index++; | 1426 url_index++; |
| 1427 } | 1427 } |
| 1428 EXPECT_EQ(controller().entry_count(), kMaxEntryCount); | 1428 EXPECT_EQ(controller().entry_count(), kMaxEntryCount); |
| 1429 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), | 1429 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), |
| 1430 GURL("http:////www.a.com/4")); | 1430 GURL("http:////www.a.com/4")); |
| 1431 | 1431 |
| 1432 NavigationController::set_max_entry_count(original_count); | 1432 NavigationController::set_max_entry_count_for_testing(original_count); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 // Tests that we can do a restore and navigate to the restored entries and | 1435 // Tests that we can do a restore and navigate to the restored entries and |
| 1436 // everything is updated properly. This can be tricky since there is no | 1436 // everything is updated properly. This can be tricky since there is no |
| 1437 // SiteInstance for the entries created initially. | 1437 // SiteInstance for the entries created initially. |
| 1438 TEST_F(NavigationControllerTest, RestoreNavigate) { | 1438 TEST_F(NavigationControllerTest, RestoreNavigate) { |
| 1439 // Create a NavigationController with a restored set of tabs. | 1439 // Create a NavigationController with a restored set of tabs. |
| 1440 GURL url("http://foo"); | 1440 GURL url("http://foo"); |
| 1441 std::vector<NavigationEntry*> entries; | 1441 std::vector<NavigationEntry*> entries; |
| 1442 NavigationEntry* entry = NavigationController::CreateNavigationEntry( | 1442 NavigationEntry* entry = NavigationController::CreateNavigationEntry( |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 TabNavigation nav(0, url0, GURL(), string16(), | 2307 TabNavigation nav(0, url0, GURL(), string16(), |
| 2308 webkit_glue::CreateHistoryStateForURL(url0), | 2308 webkit_glue::CreateHistoryStateForURL(url0), |
| 2309 PageTransition::LINK); | 2309 PageTransition::LINK); |
| 2310 session_helper_.AssertNavigationEquals(nav, | 2310 session_helper_.AssertNavigationEquals(nav, |
| 2311 windows_[0]->tabs[0]->navigations[0]); | 2311 windows_[0]->tabs[0]->navigations[0]); |
| 2312 nav.set_url(url2); | 2312 nav.set_url(url2); |
| 2313 session_helper_.AssertNavigationEquals(nav, | 2313 session_helper_.AssertNavigationEquals(nav, |
| 2314 windows_[0]->tabs[0]->navigations[1]); | 2314 windows_[0]->tabs[0]->navigations[1]); |
| 2315 } | 2315 } |
| 2316 */ | 2316 */ |
| OLD | NEW |