| 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 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 // Tests the transient entry, making sure it goes away with all navigations. | 2146 // Tests the transient entry, making sure it goes away with all navigations. |
| 2147 TEST_F(NavigationControllerTest, TransientEntry) { | 2147 TEST_F(NavigationControllerTest, TransientEntry) { |
| 2148 NavigationControllerImpl& controller = controller_impl(); | 2148 NavigationControllerImpl& controller = controller_impl(); |
| 2149 TestNotificationTracker notifications; | 2149 TestNotificationTracker notifications; |
| 2150 RegisterForAllNavNotifications(¬ifications, &controller); | 2150 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2151 | 2151 |
| 2152 const GURL url0("http://foo/0"); | 2152 const GURL url0("http://foo/0"); |
| 2153 const GURL url1("http://foo/1"); | 2153 const GURL url1("http://foo/1"); |
| 2154 const GURL url2("http://foo/2"); | 2154 const GURL url2("http://foo/2"); |
| 2155 const GURL url3("http://foo/3"); | 2155 const GURL url3("http://foo/3"); |
| 2156 const GURL url3_ref("http://foo/3#bar"); |
| 2156 const GURL url4("http://foo/4"); | 2157 const GURL url4("http://foo/4"); |
| 2157 const GURL transient_url("http://foo/transient"); | 2158 const GURL transient_url("http://foo/transient"); |
| 2158 | 2159 |
| 2159 controller.LoadURL( | 2160 controller.LoadURL( |
| 2160 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2161 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2161 test_rvh()->SendNavigate(0, url0); | 2162 test_rvh()->SendNavigate(0, url0); |
| 2162 controller.LoadURL( | 2163 controller.LoadURL( |
| 2163 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2164 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 2164 test_rvh()->SendNavigate(1, url1); | 2165 test_rvh()->SendNavigate(1, url1); |
| 2165 | 2166 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 controller.AddTransientEntry(transient_entry); | 2261 controller.AddTransientEntry(transient_entry); |
| 2261 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 2262 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
| 2262 EXPECT_TRUE(controller.CanGoForward()); | 2263 EXPECT_TRUE(controller.CanGoForward()); |
| 2263 controller.GoForward(); | 2264 controller.GoForward(); |
| 2264 // We should have navigated, transient entry should be gone. | 2265 // We should have navigated, transient entry should be gone. |
| 2265 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); | 2266 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); |
| 2266 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2267 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2267 test_rvh()->SendNavigate(3, url3); | 2268 test_rvh()->SendNavigate(3, url3); |
| 2268 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2269 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 2269 | 2270 |
| 2271 // Add a transient and do an in-page navigation, replacing the current entry. |
| 2272 transient_entry = new NavigationEntryImpl; |
| 2273 transient_entry->SetURL(transient_url); |
| 2274 controller.AddTransientEntry(transient_entry); |
| 2275 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
| 2276 test_rvh()->SendNavigate(3, url3_ref); |
| 2277 // Transient entry should be gone. |
| 2278 EXPECT_EQ(url3_ref, controller.GetActiveEntry()->GetURL()); |
| 2279 |
| 2270 // Ensure the URLs are correct. | 2280 // Ensure the URLs are correct. |
| 2271 EXPECT_EQ(controller.GetEntryCount(), 5); | 2281 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 2272 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2282 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| 2273 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 2283 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
| 2274 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 2284 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
| 2275 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3); | 2285 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3_ref); |
| 2276 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); | 2286 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
| 2277 } | 2287 } |
| 2278 | 2288 |
| 2279 // Test that Reload initiates a new navigation to a transient entry's URL. | 2289 // Test that Reload initiates a new navigation to a transient entry's URL. |
| 2280 TEST_F(NavigationControllerTest, ReloadTransient) { | 2290 TEST_F(NavigationControllerTest, ReloadTransient) { |
| 2281 NavigationControllerImpl& controller = controller_impl(); | 2291 NavigationControllerImpl& controller = controller_impl(); |
| 2282 const GURL url0("http://foo/0"); | 2292 const GURL url0("http://foo/0"); |
| 2283 const GURL url1("http://foo/1"); | 2293 const GURL url1("http://foo/1"); |
| 2284 const GURL transient_url("http://foo/transient"); | 2294 const GURL transient_url("http://foo/transient"); |
| 2285 | 2295 |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 PAGE_TRANSITION_LINK); | 3179 PAGE_TRANSITION_LINK); |
| 3170 session_helper_.AssertNavigationEquals(nav, | 3180 session_helper_.AssertNavigationEquals(nav, |
| 3171 windows_[0]->tabs[0]->navigations[0]); | 3181 windows_[0]->tabs[0]->navigations[0]); |
| 3172 nav.set_url(url2); | 3182 nav.set_url(url2); |
| 3173 session_helper_.AssertNavigationEquals(nav, | 3183 session_helper_.AssertNavigationEquals(nav, |
| 3174 windows_[0]->tabs[0]->navigations[1]); | 3184 windows_[0]->tabs[0]->navigations[1]); |
| 3175 } | 3185 } |
| 3176 */ | 3186 */ |
| 3177 | 3187 |
| 3178 } // namespace content | 3188 } // namespace content |
| OLD | NEW |