| 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 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2391 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2392 test_rvh()->SendNavigate(2, url3); | 2392 test_rvh()->SendNavigate(2, url3); |
| 2393 controller.LoadURL( | 2393 controller.LoadURL( |
| 2394 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2394 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2395 test_rvh()->SendNavigate(3, url4); | 2395 test_rvh()->SendNavigate(3, url4); |
| 2396 controller.LoadURL( | 2396 controller.LoadURL( |
| 2397 url5, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2397 url5, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2398 test_rvh()->SendNavigate(4, url5); | 2398 test_rvh()->SendNavigate(4, url5); |
| 2399 | 2399 |
| 2400 // Try to remove the last entry. Will fail because it is the current entry. | 2400 // Try to remove the last entry. Will fail because it is the current entry. |
| 2401 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); | 2401 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2402 EXPECT_EQ(5, controller.GetEntryCount()); | 2402 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2403 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 2403 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
| 2404 | 2404 |
| 2405 // Go back and remove the last entry. | 2405 // Go back, but don't commit yet. Check that we can't delete the current |
| 2406 // and pending entries. |
| 2406 controller.GoBack(); | 2407 controller.GoBack(); |
| 2408 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2409 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2)); |
| 2410 |
| 2411 // Now commit and delete the last entry. |
| 2407 test_rvh()->SendNavigate(3, url4); | 2412 test_rvh()->SendNavigate(3, url4); |
| 2408 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); | 2413 EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| 2409 EXPECT_EQ(4, controller.GetEntryCount()); | 2414 EXPECT_EQ(4, controller.GetEntryCount()); |
| 2410 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2415 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2411 EXPECT_FALSE(controller.GetPendingEntry()); | 2416 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2412 | 2417 |
| 2413 // Remove an entry which is not the last committed one. | 2418 // Remove an entry which is not the last committed one. |
| 2414 controller.RemoveEntryAtIndex(0); | 2419 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); |
| 2415 EXPECT_EQ(3, controller.GetEntryCount()); | 2420 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2416 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2421 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 2417 EXPECT_FALSE(controller.GetPendingEntry()); | 2422 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2418 | 2423 |
| 2419 // Remove the 2 remaining entries. | 2424 // Remove the 2 remaining entries. |
| 2420 controller.RemoveEntryAtIndex(1); | 2425 controller.RemoveEntryAtIndex(1); |
| 2421 controller.RemoveEntryAtIndex(0); | 2426 controller.RemoveEntryAtIndex(0); |
| 2422 | 2427 |
| 2423 // This should leave us with only the last committed entry. | 2428 // This should leave us with only the last committed entry. |
| 2424 EXPECT_EQ(1, controller.GetEntryCount()); | 2429 EXPECT_EQ(1, controller.GetEntryCount()); |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3891 PAGE_TRANSITION_LINK); | 3896 PAGE_TRANSITION_LINK); |
| 3892 session_helper_.AssertNavigationEquals(nav, | 3897 session_helper_.AssertNavigationEquals(nav, |
| 3893 windows_[0]->tabs[0]->navigations[0]); | 3898 windows_[0]->tabs[0]->navigations[0]); |
| 3894 nav.set_url(url2); | 3899 nav.set_url(url2); |
| 3895 session_helper_.AssertNavigationEquals(nav, | 3900 session_helper_.AssertNavigationEquals(nav, |
| 3896 windows_[0]->tabs[0]->navigations[1]); | 3901 windows_[0]->tabs[0]->navigations[1]); |
| 3897 } | 3902 } |
| 3898 */ | 3903 */ |
| 3899 | 3904 |
| 3900 } // namespace content | 3905 } // namespace content |
| OLD | NEW |