OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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-inl.h" | 8 #include "base/stl_util-inl.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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 // There should no longer be any pending entry, and the third navigation we | 382 // There should no longer be any pending entry, and the third navigation we |
383 // just made should be committed. | 383 // just made should be committed. |
384 EXPECT_TRUE(notifications.Check1AndReset( | 384 EXPECT_TRUE(notifications.Check1AndReset( |
385 NotificationType::NAV_ENTRY_COMMITTED)); | 385 NotificationType::NAV_ENTRY_COMMITTED)); |
386 EXPECT_EQ(-1, controller().pending_entry_index()); | 386 EXPECT_EQ(-1, controller().pending_entry_index()); |
387 EXPECT_EQ(2, controller().last_committed_entry_index()); | 387 EXPECT_EQ(2, controller().last_committed_entry_index()); |
388 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); | 388 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); |
389 } | 389 } |
390 | 390 |
| 391 // Tests navigating to an existing URL when there is a pending new navigation. |
| 392 // This will happen if the user enters a URL, but before that commits, the |
| 393 // current page fires history.back(). |
| 394 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| 395 TestNotificationTracker notifications; |
| 396 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 397 |
| 398 // First make some history. |
| 399 const GURL kExistingURL1("http://eh"); |
| 400 controller().LoadURL(kExistingURL1, GURL(), PageTransition::TYPED); |
| 401 rvh()->SendNavigate(0, kExistingURL1); |
| 402 EXPECT_TRUE(notifications.Check1AndReset( |
| 403 NotificationType::NAV_ENTRY_COMMITTED)); |
| 404 |
| 405 const GURL kExistingURL2("http://bee"); |
| 406 controller().LoadURL(kExistingURL2, GURL(), PageTransition::TYPED); |
| 407 rvh()->SendNavigate(1, kExistingURL2); |
| 408 EXPECT_TRUE(notifications.Check1AndReset( |
| 409 NotificationType::NAV_ENTRY_COMMITTED)); |
| 410 |
| 411 // Now make a pending new navigation. |
| 412 const GURL kNewURL("http://see"); |
| 413 controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED); |
| 414 EXPECT_EQ(0U, notifications.size()); |
| 415 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 416 EXPECT_EQ(1, controller().last_committed_entry_index()); |
| 417 |
| 418 // Before that commits, a back navigation from the renderer commits. |
| 419 rvh()->SendNavigate(0, kExistingURL1); |
| 420 |
| 421 // There should no longer be any pending entry, and the back navigation we |
| 422 // just made should be committed. |
| 423 EXPECT_TRUE(notifications.Check1AndReset( |
| 424 NotificationType::NAV_ENTRY_COMMITTED)); |
| 425 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 426 EXPECT_EQ(0, controller().last_committed_entry_index()); |
| 427 EXPECT_EQ(kExistingURL1, controller().GetActiveEntry()->url()); |
| 428 } |
| 429 |
391 TEST_F(NavigationControllerTest, Reload) { | 430 TEST_F(NavigationControllerTest, Reload) { |
392 TestNotificationTracker notifications; | 431 TestNotificationTracker notifications; |
393 RegisterForAllNavNotifications(¬ifications, &controller()); | 432 RegisterForAllNavNotifications(¬ifications, &controller()); |
394 | 433 |
395 const GURL url1("http://foo1"); | 434 const GURL url1("http://foo1"); |
396 | 435 |
397 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 436 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
398 EXPECT_EQ(0U, notifications.size()); | 437 EXPECT_EQ(0U, notifications.size()); |
399 rvh()->SendNavigate(0, url1); | 438 rvh()->SendNavigate(0, url1); |
400 EXPECT_TRUE(notifications.Check1AndReset( | 439 EXPECT_TRUE(notifications.Check1AndReset( |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 TabNavigation nav(0, url0, GURL(), string16(), | 2160 TabNavigation nav(0, url0, GURL(), string16(), |
2122 webkit_glue::CreateHistoryStateForURL(url0), | 2161 webkit_glue::CreateHistoryStateForURL(url0), |
2123 PageTransition::LINK); | 2162 PageTransition::LINK); |
2124 session_helper_.AssertNavigationEquals(nav, | 2163 session_helper_.AssertNavigationEquals(nav, |
2125 windows_[0]->tabs[0]->navigations[0]); | 2164 windows_[0]->tabs[0]->navigations[0]); |
2126 nav.set_url(url2); | 2165 nav.set_url(url2); |
2127 session_helper_.AssertNavigationEquals(nav, | 2166 session_helper_.AssertNavigationEquals(nav, |
2128 windows_[0]->tabs[0]->navigations[1]); | 2167 windows_[0]->tabs[0]->navigations[1]); |
2129 } | 2168 } |
2130 */ | 2169 */ |
OLD | NEW |