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 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 // Tests the transient entry, making sure it goes away with all navigations. | 2157 // Tests the transient entry, making sure it goes away with all navigations. |
2158 TEST_F(NavigationControllerTest, TransientEntry) { | 2158 TEST_F(NavigationControllerTest, TransientEntry) { |
2159 NavigationControllerImpl& controller = controller_impl(); | 2159 NavigationControllerImpl& controller = controller_impl(); |
2160 TestNotificationTracker notifications; | 2160 TestNotificationTracker notifications; |
2161 RegisterForAllNavNotifications(¬ifications, &controller); | 2161 RegisterForAllNavNotifications(¬ifications, &controller); |
2162 | 2162 |
2163 const GURL url0("http://foo/0"); | 2163 const GURL url0("http://foo/0"); |
2164 const GURL url1("http://foo/1"); | 2164 const GURL url1("http://foo/1"); |
2165 const GURL url2("http://foo/2"); | 2165 const GURL url2("http://foo/2"); |
2166 const GURL url3("http://foo/3"); | 2166 const GURL url3("http://foo/3"); |
| 2167 const GURL url3_ref("http://foo/3#bar"); |
2167 const GURL url4("http://foo/4"); | 2168 const GURL url4("http://foo/4"); |
2168 const GURL transient_url("http://foo/transient"); | 2169 const GURL transient_url("http://foo/transient"); |
2169 | 2170 |
2170 controller.LoadURL( | 2171 controller.LoadURL( |
2171 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2172 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
2172 test_rvh()->SendNavigate(0, url0); | 2173 test_rvh()->SendNavigate(0, url0); |
2173 controller.LoadURL( | 2174 controller.LoadURL( |
2174 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2175 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
2175 test_rvh()->SendNavigate(1, url1); | 2176 test_rvh()->SendNavigate(1, url1); |
2176 | 2177 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 controller.AddTransientEntry(transient_entry); | 2272 controller.AddTransientEntry(transient_entry); |
2272 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 2273 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
2273 EXPECT_TRUE(controller.CanGoForward()); | 2274 EXPECT_TRUE(controller.CanGoForward()); |
2274 controller.GoForward(); | 2275 controller.GoForward(); |
2275 // We should have navigated, transient entry should be gone. | 2276 // We should have navigated, transient entry should be gone. |
2276 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); | 2277 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); |
2277 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2278 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
2278 test_rvh()->SendNavigate(3, url3); | 2279 test_rvh()->SendNavigate(3, url3); |
2279 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2280 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
2280 | 2281 |
| 2282 // Add a transient and do an in-page navigation, replacing the current entry. |
| 2283 transient_entry = new NavigationEntryImpl; |
| 2284 transient_entry->SetURL(transient_url); |
| 2285 controller.AddTransientEntry(transient_entry); |
| 2286 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
| 2287 test_rvh()->SendNavigate(3, url3_ref); |
| 2288 // Transient entry should be gone. |
| 2289 EXPECT_EQ(url3_ref, controller.GetActiveEntry()->GetURL()); |
| 2290 |
2281 // Ensure the URLs are correct. | 2291 // Ensure the URLs are correct. |
2282 EXPECT_EQ(controller.GetEntryCount(), 5); | 2292 EXPECT_EQ(controller.GetEntryCount(), 5); |
2283 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 2293 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
2284 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 2294 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
2285 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 2295 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
2286 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3); | 2296 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3_ref); |
2287 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); | 2297 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
2288 } | 2298 } |
2289 | 2299 |
2290 // Test that Reload initiates a new navigation to a transient entry's URL. | 2300 // Test that Reload initiates a new navigation to a transient entry's URL. |
2291 TEST_F(NavigationControllerTest, ReloadTransient) { | 2301 TEST_F(NavigationControllerTest, ReloadTransient) { |
2292 NavigationControllerImpl& controller = controller_impl(); | 2302 NavigationControllerImpl& controller = controller_impl(); |
2293 const GURL url0("http://foo/0"); | 2303 const GURL url0("http://foo/0"); |
2294 const GURL url1("http://foo/1"); | 2304 const GURL url1("http://foo/1"); |
2295 const GURL transient_url("http://foo/transient"); | 2305 const GURL transient_url("http://foo/transient"); |
2296 | 2306 |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3171 PAGE_TRANSITION_LINK); | 3181 PAGE_TRANSITION_LINK); |
3172 session_helper_.AssertNavigationEquals(nav, | 3182 session_helper_.AssertNavigationEquals(nav, |
3173 windows_[0]->tabs[0]->navigations[0]); | 3183 windows_[0]->tabs[0]->navigations[0]); |
3174 nav.set_url(url2); | 3184 nav.set_url(url2); |
3175 session_helper_.AssertNavigationEquals(nav, | 3185 session_helper_.AssertNavigationEquals(nav, |
3176 windows_[0]->tabs[0]->navigations[1]); | 3186 windows_[0]->tabs[0]->navigations[1]); |
3177 } | 3187 } |
3178 */ | 3188 */ |
3179 | 3189 |
3180 } // namespace content | 3190 } // namespace content |
OLD | NEW |