| 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 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 // Tests the transient entry, making sure it goes away with all navigations. | 1964 // Tests the transient entry, making sure it goes away with all navigations. |
| 1965 TEST_F(NavigationControllerTest, TransientEntry) { | 1965 TEST_F(NavigationControllerTest, TransientEntry) { |
| 1966 NavigationControllerImpl& controller = controller_impl(); | 1966 NavigationControllerImpl& controller = controller_impl(); |
| 1967 TestNotificationTracker notifications; | 1967 TestNotificationTracker notifications; |
| 1968 RegisterForAllNavNotifications(¬ifications, &controller); | 1968 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1969 | 1969 |
| 1970 const GURL url0("http://foo/0"); | 1970 const GURL url0("http://foo/0"); |
| 1971 const GURL url1("http://foo/1"); | 1971 const GURL url1("http://foo/1"); |
| 1972 const GURL url2("http://foo/2"); | 1972 const GURL url2("http://foo/2"); |
| 1973 const GURL url3("http://foo/3"); | 1973 const GURL url3("http://foo/3"); |
| 1974 const GURL url3_ref("http://foo/3#bar"); |
| 1974 const GURL url4("http://foo/4"); | 1975 const GURL url4("http://foo/4"); |
| 1975 const GURL transient_url("http://foo/transient"); | 1976 const GURL transient_url("http://foo/transient"); |
| 1976 | 1977 |
| 1977 controller.LoadURL( | 1978 controller.LoadURL( |
| 1978 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1979 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 1979 test_rvh()->SendNavigate(0, url0); | 1980 test_rvh()->SendNavigate(0, url0); |
| 1980 controller.LoadURL( | 1981 controller.LoadURL( |
| 1981 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1982 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 1982 test_rvh()->SendNavigate(1, url1); | 1983 test_rvh()->SendNavigate(1, url1); |
| 1983 | 1984 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 controller.AddTransientEntry(transient_entry); | 2079 controller.AddTransientEntry(transient_entry); |
| 2079 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 2080 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
| 2080 EXPECT_TRUE(controller.CanGoForward()); | 2081 EXPECT_TRUE(controller.CanGoForward()); |
| 2081 controller.GoForward(); | 2082 controller.GoForward(); |
| 2082 // We should have navigated, transient entry should be gone. | 2083 // We should have navigated, transient entry should be gone. |
| 2083 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); | 2084 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); |
| 2084 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2085 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2085 test_rvh()->SendNavigate(3, url3); | 2086 test_rvh()->SendNavigate(3, url3); |
| 2086 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2087 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 2087 | 2088 |
| 2089 // Add a transient and do an in-page navigation, replacing the current entry. |
| 2090 transient_entry = new NavigationEntryImpl; |
| 2091 transient_entry->SetURL(transient_url); |
| 2092 controller.AddTransientEntry(transient_entry); |
| 2093 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
| 2094 test_rvh()->SendNavigate(3, url3_ref); |
| 2095 // Transient entry should be gone. |
| 2096 EXPECT_EQ(url3_ref, controller.GetActiveEntry()->GetURL()); |
| 2097 |
| 2088 // Ensure the URLs are correct. | 2098 // Ensure the URLs are correct. |
| 2089 EXPECT_EQ(controller.GetEntryCount(), 5); | 2099 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 2090 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2100 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 2091 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 2101 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
| 2092 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 2102 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
| 2093 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3); | 2103 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3_ref); |
| 2094 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); | 2104 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
| 2095 } | 2105 } |
| 2096 | 2106 |
| 2097 // Test that Reload initiates a new navigation to a transient entry's URL. | 2107 // Test that Reload initiates a new navigation to a transient entry's URL. |
| 2098 TEST_F(NavigationControllerTest, ReloadTransient) { | 2108 TEST_F(NavigationControllerTest, ReloadTransient) { |
| 2099 NavigationControllerImpl& controller = controller_impl(); | 2109 NavigationControllerImpl& controller = controller_impl(); |
| 2100 const GURL url0("http://foo/0"); | 2110 const GURL url0("http://foo/0"); |
| 2101 const GURL url1("http://foo/1"); | 2111 const GURL url1("http://foo/1"); |
| 2102 const GURL transient_url("http://foo/transient"); | 2112 const GURL transient_url("http://foo/transient"); |
| 2103 | 2113 |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2898 TabNavigation nav(0, url0, GURL(), string16(), | 2908 TabNavigation nav(0, url0, GURL(), string16(), |
| 2899 webkit_glue::CreateHistoryStateForURL(url0), | 2909 webkit_glue::CreateHistoryStateForURL(url0), |
| 2900 content::PAGE_TRANSITION_LINK); | 2910 content::PAGE_TRANSITION_LINK); |
| 2901 session_helper_.AssertNavigationEquals(nav, | 2911 session_helper_.AssertNavigationEquals(nav, |
| 2902 windows_[0]->tabs[0]->navigations[0]); | 2912 windows_[0]->tabs[0]->navigations[0]); |
| 2903 nav.set_url(url2); | 2913 nav.set_url(url2); |
| 2904 session_helper_.AssertNavigationEquals(nav, | 2914 session_helper_.AssertNavigationEquals(nav, |
| 2905 windows_[0]->tabs[0]->navigations[1]); | 2915 windows_[0]->tabs[0]->navigations[1]); |
| 2906 } | 2916 } |
| 2907 */ | 2917 */ |
| OLD | NEW |