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 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 contents()->ExpectSetHistoryLengthAndPrune( | 2963 contents()->ExpectSetHistoryLengthAndPrune( |
2964 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, | 2964 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, |
2965 controller.GetEntryAtIndex(1)->GetPageID()); | 2965 controller.GetEntryAtIndex(1)->GetPageID()); |
2966 | 2966 |
2967 controller.PruneAllButActive(); | 2967 controller.PruneAllButActive(); |
2968 | 2968 |
2969 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2969 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2970 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); | 2970 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); |
2971 } | 2971 } |
2972 | 2972 |
2973 // Test call to PruneAllButActive for intermediate entry. | 2973 // Test call to PruneAllButActive for a pending entry. |
2974 TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { | 2974 TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { |
2975 NavigationControllerImpl& controller = controller_impl(); | 2975 NavigationControllerImpl& controller = controller_impl(); |
2976 const GURL url1("http://foo/1"); | 2976 const GURL url1("http://foo/1"); |
2977 const GURL url2("http://foo/2"); | 2977 const GURL url2("http://foo/2"); |
2978 const GURL url3("http://foo/3"); | 2978 const GURL url3("http://foo/3"); |
2979 | 2979 |
2980 NavigateAndCommit(url1); | 2980 NavigateAndCommit(url1); |
2981 NavigateAndCommit(url2); | 2981 NavigateAndCommit(url2); |
2982 NavigateAndCommit(url3); | 2982 NavigateAndCommit(url3); |
2983 controller.GoBack(); | 2983 controller.GoBack(); |
2984 | 2984 |
2985 contents()->ExpectSetHistoryLengthAndPrune( | 2985 contents()->ExpectSetHistoryLengthAndPrune( |
2986 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, | 2986 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, |
2987 controller.GetEntryAtIndex(1)->GetPageID()); | 2987 controller.GetEntryAtIndex(1)->GetPageID()); |
2988 | 2988 |
2989 controller.PruneAllButActive(); | 2989 controller.PruneAllButActive(); |
2990 | 2990 |
2991 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 2991 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
2992 } | 2992 } |
2993 | 2993 |
| 2994 // Test call to PruneAllButActive for a pending entry that is not yet in the |
| 2995 // list of entries. |
| 2996 TEST_F(NavigationControllerTest, PruneAllButActiveForPendingNotInList) { |
| 2997 NavigationControllerImpl& controller = controller_impl(); |
| 2998 const GURL url1("http://foo/1"); |
| 2999 const GURL url2("http://foo/2"); |
| 3000 const GURL url3("http://foo/3"); |
| 3001 |
| 3002 NavigateAndCommit(url1); |
| 3003 NavigateAndCommit(url2); |
| 3004 |
| 3005 // Create a pending entry that is not in the entry list. |
| 3006 controller.LoadURL( |
| 3007 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 3008 EXPECT_TRUE(controller.GetPendingEntry()); |
| 3009 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3010 |
| 3011 contents()->ExpectSetHistoryLengthAndPrune( |
| 3012 NULL, 0, controller.GetPendingEntry()->GetPageID()); |
| 3013 controller.PruneAllButActive(); |
| 3014 |
| 3015 // We should only have the pending entry at this point, and it should still |
| 3016 // not be in the entry list. |
| 3017 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 3018 EXPECT_TRUE(controller.GetPendingEntry()); |
| 3019 EXPECT_EQ(0, controller.GetEntryCount()); |
| 3020 |
| 3021 // Try to commit the pending entry. |
| 3022 test_rvh()->SendNavigate(2, url3); |
| 3023 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 3024 EXPECT_FALSE(controller.GetPendingEntry()); |
| 3025 EXPECT_EQ(1, controller.GetEntryCount()); |
| 3026 EXPECT_EQ(url3, controller.GetEntryAtIndex(0)->GetURL()); |
| 3027 } |
| 3028 |
2994 // Test call to PruneAllButActive for transient entry. | 3029 // Test call to PruneAllButActive for transient entry. |
2995 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { | 3030 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { |
2996 NavigationControllerImpl& controller = controller_impl(); | 3031 NavigationControllerImpl& controller = controller_impl(); |
2997 const GURL url0("http://foo/0"); | 3032 const GURL url0("http://foo/0"); |
2998 const GURL url1("http://foo/1"); | 3033 const GURL url1("http://foo/1"); |
2999 const GURL transient_url("http://foo/transient"); | 3034 const GURL transient_url("http://foo/transient"); |
3000 | 3035 |
3001 controller.LoadURL( | 3036 controller.LoadURL( |
3002 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 3037 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
3003 test_rvh()->SendNavigate(0, url0); | 3038 test_rvh()->SendNavigate(0, url0); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3411 PAGE_TRANSITION_LINK); | 3446 PAGE_TRANSITION_LINK); |
3412 session_helper_.AssertNavigationEquals(nav, | 3447 session_helper_.AssertNavigationEquals(nav, |
3413 windows_[0]->tabs[0]->navigations[0]); | 3448 windows_[0]->tabs[0]->navigations[0]); |
3414 nav.set_url(url2); | 3449 nav.set_url(url2); |
3415 session_helper_.AssertNavigationEquals(nav, | 3450 session_helper_.AssertNavigationEquals(nav, |
3416 windows_[0]->tabs[0]->navigations[1]); | 3451 windows_[0]->tabs[0]->navigations[1]); |
3417 } | 3452 } |
3418 */ | 3453 */ |
3419 | 3454 |
3420 } // namespace content | 3455 } // namespace content |
OLD | NEW |