| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_EQ(controller().entry_count(), 1); | 146 EXPECT_EQ(controller().entry_count(), 1); |
| 147 EXPECT_EQ(controller().last_committed_entry_index(), 0); | 147 EXPECT_EQ(controller().last_committed_entry_index(), 0); |
| 148 EXPECT_EQ(controller().pending_entry_index(), -1); | 148 EXPECT_EQ(controller().pending_entry_index(), -1); |
| 149 EXPECT_TRUE(controller().GetLastCommittedEntry()); | 149 EXPECT_TRUE(controller().GetLastCommittedEntry()); |
| 150 EXPECT_TRUE(controller().pending_entry()); | 150 EXPECT_TRUE(controller().pending_entry()); |
| 151 // TODO(darin): maybe this should really be true? | 151 // TODO(darin): maybe this should really be true? |
| 152 EXPECT_FALSE(controller().CanGoBack()); | 152 EXPECT_FALSE(controller().CanGoBack()); |
| 153 EXPECT_FALSE(controller().CanGoForward()); | 153 EXPECT_FALSE(controller().CanGoForward()); |
| 154 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 154 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
| 155 | 155 |
| 156 rvh()->SendNavigate(1, url2); | 156 // Simulate the beforeunload ack for the cross-site transition, and then the |
| 157 // commit. |
| 158 rvh()->SendShouldCloseACK(true); |
| 159 contents()->pending_rvh()->SendNavigate(1, url2); |
| 157 EXPECT_TRUE(notifications.Check1AndReset( | 160 EXPECT_TRUE(notifications.Check1AndReset( |
| 158 NotificationType::NAV_ENTRY_COMMITTED)); | 161 NotificationType::NAV_ENTRY_COMMITTED)); |
| 159 | 162 |
| 160 // The load should now be committed. | 163 // The load should now be committed. |
| 161 EXPECT_EQ(controller().entry_count(), 2); | 164 EXPECT_EQ(controller().entry_count(), 2); |
| 162 EXPECT_EQ(controller().last_committed_entry_index(), 1); | 165 EXPECT_EQ(controller().last_committed_entry_index(), 1); |
| 163 EXPECT_EQ(controller().pending_entry_index(), -1); | 166 EXPECT_EQ(controller().pending_entry_index(), -1); |
| 164 EXPECT_TRUE(controller().GetLastCommittedEntry()); | 167 EXPECT_TRUE(controller().GetLastCommittedEntry()); |
| 165 EXPECT_FALSE(controller().pending_entry()); | 168 EXPECT_FALSE(controller().pending_entry()); |
| 166 EXPECT_TRUE(controller().CanGoBack()); | 169 EXPECT_TRUE(controller().CanGoBack()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 rvh()->SendNavigate(0, kExistingURL1); | 273 rvh()->SendNavigate(0, kExistingURL1); |
| 271 EXPECT_TRUE(notifications.Check1AndReset( | 274 EXPECT_TRUE(notifications.Check1AndReset( |
| 272 NotificationType::NAV_ENTRY_COMMITTED)); | 275 NotificationType::NAV_ENTRY_COMMITTED)); |
| 273 | 276 |
| 274 // Make a pending entry to somewhere new. | 277 // Make a pending entry to somewhere new. |
| 275 const GURL kExistingURL2("http://bee"); | 278 const GURL kExistingURL2("http://bee"); |
| 276 controller().LoadURL(kExistingURL2, GURL(), | 279 controller().LoadURL(kExistingURL2, GURL(), |
| 277 PageTransition::TYPED); | 280 PageTransition::TYPED); |
| 278 EXPECT_EQ(0U, notifications.size()); | 281 EXPECT_EQ(0U, notifications.size()); |
| 279 | 282 |
| 280 // Before that commits, do a new navigation. | 283 // After the beforeunload but before it commits, do a new navigation. |
| 284 rvh()->SendShouldCloseACK(true); |
| 281 const GURL kNewURL("http://see"); | 285 const GURL kNewURL("http://see"); |
| 282 rvh()->SendNavigate(3, kNewURL); | 286 contents()->pending_rvh()->SendNavigate(3, kNewURL); |
| 283 | 287 |
| 284 // There should no longer be any pending entry, and the third navigation we | 288 // There should no longer be any pending entry, and the third navigation we |
| 285 // just made should be committed. | 289 // just made should be committed. |
| 286 EXPECT_TRUE(notifications.Check1AndReset( | 290 EXPECT_TRUE(notifications.Check1AndReset( |
| 287 NotificationType::NAV_ENTRY_COMMITTED)); | 291 NotificationType::NAV_ENTRY_COMMITTED)); |
| 288 EXPECT_EQ(-1, controller().pending_entry_index()); | 292 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 289 EXPECT_EQ(1, controller().last_committed_entry_index()); | 293 EXPECT_EQ(1, controller().last_committed_entry_index()); |
| 290 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); | 294 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); |
| 291 } | 295 } |
| 292 | 296 |
| 293 // Tests navigating to a new URL when there is a pending back/forward | 297 // Tests navigating to a new URL when there is a pending back/forward |
| 294 // navigation. This will happen if the user hits back, but before that commits, | 298 // navigation. This will happen if the user hits back, but before that commits, |
| 295 // they navigate somewhere new. | 299 // they navigate somewhere new. |
| 296 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { | 300 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
| 297 TestNotificationTracker notifications; | 301 TestNotificationTracker notifications; |
| 298 RegisterForAllNavNotifications(¬ifications, &controller()); | 302 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 299 | 303 |
| 300 // First make some history. | 304 // First make some history. |
| 301 const GURL kExistingURL1("http://eh"); | 305 const GURL kExistingURL1("http://foo/eh"); |
| 302 controller().LoadURL(kExistingURL1, GURL(), | 306 controller().LoadURL(kExistingURL1, GURL(), |
| 303 PageTransition::TYPED); | 307 PageTransition::TYPED); |
| 304 rvh()->SendNavigate(0, kExistingURL1); | 308 rvh()->SendNavigate(0, kExistingURL1); |
| 305 EXPECT_TRUE(notifications.Check1AndReset( | 309 EXPECT_TRUE(notifications.Check1AndReset( |
| 306 NotificationType::NAV_ENTRY_COMMITTED)); | 310 NotificationType::NAV_ENTRY_COMMITTED)); |
| 307 | 311 |
| 308 const GURL kExistingURL2("http://bee"); | 312 const GURL kExistingURL2("http://foo/bee"); |
| 309 controller().LoadURL(kExistingURL2, GURL(), | 313 controller().LoadURL(kExistingURL2, GURL(), |
| 310 PageTransition::TYPED); | 314 PageTransition::TYPED); |
| 311 rvh()->SendNavigate(1, kExistingURL2); | 315 rvh()->SendNavigate(1, kExistingURL2); |
| 312 EXPECT_TRUE(notifications.Check1AndReset( | 316 EXPECT_TRUE(notifications.Check1AndReset( |
| 313 NotificationType::NAV_ENTRY_COMMITTED)); | 317 NotificationType::NAV_ENTRY_COMMITTED)); |
| 314 | 318 |
| 315 // Now make a pending back/forward navigation. The zeroth entry should be | 319 // Now make a pending back/forward navigation. The zeroth entry should be |
| 316 // pending. | 320 // pending. |
| 317 controller().GoBack(); | 321 controller().GoBack(); |
| 318 EXPECT_EQ(0U, notifications.size()); | 322 EXPECT_EQ(0U, notifications.size()); |
| 319 EXPECT_EQ(0, controller().pending_entry_index()); | 323 EXPECT_EQ(0, controller().pending_entry_index()); |
| 320 EXPECT_EQ(1, controller().last_committed_entry_index()); | 324 EXPECT_EQ(1, controller().last_committed_entry_index()); |
| 321 | 325 |
| 322 // Before that commits, do a new navigation. | 326 // Before that commits, do a new navigation. |
| 323 const GURL kNewURL("http://see"); | 327 const GURL kNewURL("http://foo/see"); |
| 324 content::LoadCommittedDetails details; | 328 content::LoadCommittedDetails details; |
| 325 rvh()->SendNavigate(3, kNewURL); | 329 rvh()->SendNavigate(3, kNewURL); |
| 326 | 330 |
| 327 // There should no longer be any pending entry, and the third navigation we | 331 // There should no longer be any pending entry, and the third navigation we |
| 328 // just made should be committed. | 332 // just made should be committed. |
| 329 EXPECT_TRUE(notifications.Check1AndReset( | 333 EXPECT_TRUE(notifications.Check1AndReset( |
| 330 NotificationType::NAV_ENTRY_COMMITTED)); | 334 NotificationType::NAV_ENTRY_COMMITTED)); |
| 331 EXPECT_EQ(-1, controller().pending_entry_index()); | 335 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 332 EXPECT_EQ(2, controller().last_committed_entry_index()); | 336 EXPECT_EQ(2, controller().last_committed_entry_index()); |
| 333 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); | 337 EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url()); |
| 334 } | 338 } |
| 335 | 339 |
| 336 // Tests navigating to an existing URL when there is a pending new navigation. | 340 // Tests navigating to an existing URL when there is a pending new navigation. |
| 337 // This will happen if the user enters a URL, but before that commits, the | 341 // This will happen if the user enters a URL, but before that commits, the |
| 338 // current page fires history.back(). | 342 // current page fires history.back(). |
| 339 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { | 343 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| 340 TestNotificationTracker notifications; | 344 TestNotificationTracker notifications; |
| 341 RegisterForAllNavNotifications(¬ifications, &controller()); | 345 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 342 | 346 |
| 343 // First make some history. | 347 // First make some history. |
| 344 const GURL kExistingURL1("http://eh"); | 348 const GURL kExistingURL1("http://foo/eh"); |
| 345 controller().LoadURL(kExistingURL1, GURL(), PageTransition::TYPED); | 349 controller().LoadURL(kExistingURL1, GURL(), PageTransition::TYPED); |
| 346 rvh()->SendNavigate(0, kExistingURL1); | 350 rvh()->SendNavigate(0, kExistingURL1); |
| 347 EXPECT_TRUE(notifications.Check1AndReset( | 351 EXPECT_TRUE(notifications.Check1AndReset( |
| 348 NotificationType::NAV_ENTRY_COMMITTED)); | 352 NotificationType::NAV_ENTRY_COMMITTED)); |
| 349 | 353 |
| 350 const GURL kExistingURL2("http://bee"); | 354 const GURL kExistingURL2("http://foo/bee"); |
| 351 controller().LoadURL(kExistingURL2, GURL(), PageTransition::TYPED); | 355 controller().LoadURL(kExistingURL2, GURL(), PageTransition::TYPED); |
| 352 rvh()->SendNavigate(1, kExistingURL2); | 356 rvh()->SendNavigate(1, kExistingURL2); |
| 353 EXPECT_TRUE(notifications.Check1AndReset( | 357 EXPECT_TRUE(notifications.Check1AndReset( |
| 354 NotificationType::NAV_ENTRY_COMMITTED)); | 358 NotificationType::NAV_ENTRY_COMMITTED)); |
| 355 | 359 |
| 356 // Now make a pending new navigation. | 360 // Now make a pending new navigation. |
| 357 const GURL kNewURL("http://see"); | 361 const GURL kNewURL("http://foo/see"); |
| 358 controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED); | 362 controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED); |
| 359 EXPECT_EQ(0U, notifications.size()); | 363 EXPECT_EQ(0U, notifications.size()); |
| 360 EXPECT_EQ(-1, controller().pending_entry_index()); | 364 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 361 EXPECT_EQ(1, controller().last_committed_entry_index()); | 365 EXPECT_EQ(1, controller().last_committed_entry_index()); |
| 362 | 366 |
| 363 // Before that commits, a back navigation from the renderer commits. | 367 // Before that commits, a back navigation from the renderer commits. |
| 364 rvh()->SendNavigate(0, kExistingURL1); | 368 rvh()->SendNavigate(0, kExistingURL1); |
| 365 | 369 |
| 366 // There should no longer be any pending entry, and the back navigation we | 370 // There should no longer be any pending entry, and the back navigation we |
| 367 // just made should be committed. | 371 // just made should be committed. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 EXPECT_FALSE(controller().pending_entry()); | 521 EXPECT_FALSE(controller().pending_entry()); |
| 518 EXPECT_FALSE(controller().CanGoBack()); | 522 EXPECT_FALSE(controller().CanGoBack()); |
| 519 EXPECT_TRUE(controller().CanGoForward()); | 523 EXPECT_TRUE(controller().CanGoForward()); |
| 520 } | 524 } |
| 521 | 525 |
| 522 // Tests what happens when a back navigation produces a new page. | 526 // Tests what happens when a back navigation produces a new page. |
| 523 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { | 527 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
| 524 TestNotificationTracker notifications; | 528 TestNotificationTracker notifications; |
| 525 RegisterForAllNavNotifications(¬ifications, &controller()); | 529 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 526 | 530 |
| 527 const GURL url1("http://foo1"); | 531 const GURL url1("http://foo/1"); |
| 528 const GURL url2("http://foo2"); | 532 const GURL url2("http://foo/2"); |
| 529 const GURL url3("http://foo3"); | 533 const GURL url3("http://foo/3"); |
| 530 | 534 |
| 531 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 535 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| 532 rvh()->SendNavigate(0, url1); | 536 rvh()->SendNavigate(0, url1); |
| 533 EXPECT_TRUE(notifications.Check1AndReset( | 537 EXPECT_TRUE(notifications.Check1AndReset( |
| 534 NotificationType::NAV_ENTRY_COMMITTED)); | 538 NotificationType::NAV_ENTRY_COMMITTED)); |
| 535 | 539 |
| 536 controller().LoadURL(url2, GURL(), PageTransition::TYPED); | 540 controller().LoadURL(url2, GURL(), PageTransition::TYPED); |
| 537 rvh()->SendNavigate(1, url2); | 541 rvh()->SendNavigate(1, url2); |
| 538 EXPECT_TRUE(notifications.Check1AndReset( | 542 EXPECT_TRUE(notifications.Check1AndReset( |
| 539 NotificationType::NAV_ENTRY_COMMITTED)); | 543 NotificationType::NAV_ENTRY_COMMITTED)); |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 // At this point the interstitial will be displayed and the load will still | 1414 // At this point the interstitial will be displayed and the load will still |
| 1411 // be pending. If the user continues, the load will commit. | 1415 // be pending. If the user continues, the load will commit. |
| 1412 rvh()->SendNavigate(1, url2); | 1416 rvh()->SendNavigate(1, url2); |
| 1413 | 1417 |
| 1414 // The page should be a normal page again. | 1418 // The page should be a normal page again. |
| 1415 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->url()); | 1419 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->url()); |
| 1416 EXPECT_EQ(NORMAL_PAGE, controller().GetLastCommittedEntry()->page_type()); | 1420 EXPECT_EQ(NORMAL_PAGE, controller().GetLastCommittedEntry()->page_type()); |
| 1417 } | 1421 } |
| 1418 | 1422 |
| 1419 TEST_F(NavigationControllerTest, RemoveEntry) { | 1423 TEST_F(NavigationControllerTest, RemoveEntry) { |
| 1420 const GURL url1("http://foo1"); | 1424 const GURL url1("http://foo/1"); |
| 1421 const GURL url2("http://foo2"); | 1425 const GURL url2("http://foo/2"); |
| 1422 const GURL url3("http://foo3"); | 1426 const GURL url3("http://foo/3"); |
| 1423 const GURL url4("http://foo4"); | 1427 const GURL url4("http://foo/4"); |
| 1424 const GURL url5("http://foo5"); | 1428 const GURL url5("http://foo/5"); |
| 1425 const GURL pending_url("http://pending"); | 1429 const GURL pending_url("http://foo/pending"); |
| 1426 const GURL default_url("http://default"); | 1430 const GURL default_url("http://foo/default"); |
| 1427 | 1431 |
| 1428 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 1432 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| 1429 rvh()->SendNavigate(0, url1); | 1433 rvh()->SendNavigate(0, url1); |
| 1430 controller().LoadURL(url2, GURL(), PageTransition::TYPED); | 1434 controller().LoadURL(url2, GURL(), PageTransition::TYPED); |
| 1431 rvh()->SendNavigate(1, url2); | 1435 rvh()->SendNavigate(1, url2); |
| 1432 controller().LoadURL(url3, GURL(), PageTransition::TYPED); | 1436 controller().LoadURL(url3, GURL(), PageTransition::TYPED); |
| 1433 rvh()->SendNavigate(2, url3); | 1437 rvh()->SendNavigate(2, url3); |
| 1434 controller().LoadURL(url4, GURL(), PageTransition::TYPED); | 1438 controller().LoadURL(url4, GURL(), PageTransition::TYPED); |
| 1435 rvh()->SendNavigate(3, url4); | 1439 rvh()->SendNavigate(3, url4); |
| 1436 controller().LoadURL(url5, GURL(), PageTransition::TYPED); | 1440 controller().LoadURL(url5, GURL(), PageTransition::TYPED); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 EXPECT_EQ(-1, controller().last_committed_entry_index()); | 1477 EXPECT_EQ(-1, controller().last_committed_entry_index()); |
| 1474 pending_entry = controller().pending_entry(); | 1478 pending_entry = controller().pending_entry(); |
| 1475 EXPECT_TRUE(pending_entry && pending_entry->url() == default_url); | 1479 EXPECT_TRUE(pending_entry && pending_entry->url() == default_url); |
| 1476 } | 1480 } |
| 1477 | 1481 |
| 1478 // Tests the transient entry, making sure it goes away with all navigations. | 1482 // Tests the transient entry, making sure it goes away with all navigations. |
| 1479 TEST_F(NavigationControllerTest, TransientEntry) { | 1483 TEST_F(NavigationControllerTest, TransientEntry) { |
| 1480 TestNotificationTracker notifications; | 1484 TestNotificationTracker notifications; |
| 1481 RegisterForAllNavNotifications(¬ifications, &controller()); | 1485 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 1482 | 1486 |
| 1483 const GURL url0("http://foo0"); | 1487 const GURL url0("http://foo/0"); |
| 1484 const GURL url1("http://foo1"); | 1488 const GURL url1("http://foo/1"); |
| 1485 const GURL url2("http://foo2"); | 1489 const GURL url2("http://foo/2"); |
| 1486 const GURL url3("http://foo3"); | 1490 const GURL url3("http://foo/3"); |
| 1487 const GURL url4("http://foo4"); | 1491 const GURL url4("http://foo/4"); |
| 1488 const GURL transient_url("http://transient"); | 1492 const GURL transient_url("http://foo/transient"); |
| 1489 | 1493 |
| 1490 controller().LoadURL(url0, GURL(), PageTransition::TYPED); | 1494 controller().LoadURL(url0, GURL(), PageTransition::TYPED); |
| 1491 rvh()->SendNavigate(0, url0); | 1495 rvh()->SendNavigate(0, url0); |
| 1492 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 1496 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| 1493 rvh()->SendNavigate(1, url1); | 1497 rvh()->SendNavigate(1, url1); |
| 1494 | 1498 |
| 1495 notifications.Reset(); | 1499 notifications.Reset(); |
| 1496 | 1500 |
| 1497 // Adding a transient with no pending entry. | 1501 // Adding a transient with no pending entry. |
| 1498 NavigationEntry* transient_entry = new NavigationEntry; | 1502 NavigationEntry* transient_entry = new NavigationEntry; |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 EXPECT_EQ(url3, other_controller.pending_entry()->url()); | 1936 EXPECT_EQ(url3, other_controller.pending_entry()->url()); |
| 1933 | 1937 |
| 1934 // Make sure session ids didn't change. | 1938 // Make sure session ids didn't change. |
| 1935 EXPECT_EQ(id.id(), controller().session_id().id()); | 1939 EXPECT_EQ(id.id(), controller().session_id().id()); |
| 1936 EXPECT_EQ(other_id.id(), other_controller.session_id().id()); | 1940 EXPECT_EQ(other_id.id(), other_controller.session_id().id()); |
| 1937 } | 1941 } |
| 1938 | 1942 |
| 1939 // Tests that navigations initiated from the page (with the history object) | 1943 // Tests that navigations initiated from the page (with the history object) |
| 1940 // work as expected without navigation entries. | 1944 // work as expected without navigation entries. |
| 1941 TEST_F(NavigationControllerTest, HistoryNavigate) { | 1945 TEST_F(NavigationControllerTest, HistoryNavigate) { |
| 1942 const GURL url1("http://foo1"); | 1946 const GURL url1("http://foo/1"); |
| 1943 const GURL url2("http://foo2"); | 1947 const GURL url2("http://foo/2"); |
| 1944 const GURL url3("http://foo3"); | 1948 const GURL url3("http://foo/3"); |
| 1945 | 1949 |
| 1946 NavigateAndCommit(url1); | 1950 NavigateAndCommit(url1); |
| 1947 NavigateAndCommit(url2); | 1951 NavigateAndCommit(url2); |
| 1948 NavigateAndCommit(url3); | 1952 NavigateAndCommit(url3); |
| 1949 controller().GoBack(); | 1953 controller().GoBack(); |
| 1950 contents()->CommitPendingNavigation(); | 1954 contents()->CommitPendingNavigation(); |
| 1951 | 1955 |
| 1952 // Simulate the page calling history.back(), it should not create a pending | 1956 // Simulate the page calling history.back(), it should not create a pending |
| 1953 // entry. | 1957 // entry. |
| 1954 contents()->OnGoToEntryAtOffset(-1); | 1958 contents()->OnGoToEntryAtOffset(-1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 const GURL url1("http://foo1"); | 1993 const GURL url1("http://foo1"); |
| 1990 NavigateAndCommit(url1); | 1994 NavigateAndCommit(url1); |
| 1991 controller().PruneAllButActive(); | 1995 controller().PruneAllButActive(); |
| 1992 | 1996 |
| 1993 EXPECT_EQ(-1, controller().pending_entry_index()); | 1997 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 1994 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); | 1998 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); |
| 1995 } | 1999 } |
| 1996 | 2000 |
| 1997 // Test call to PruneAllButActive for last entry. | 2001 // Test call to PruneAllButActive for last entry. |
| 1998 TEST_F(NavigationControllerTest, PruneAllButActiveForLast) { | 2002 TEST_F(NavigationControllerTest, PruneAllButActiveForLast) { |
| 1999 const GURL url1("http://foo1"); | 2003 const GURL url1("http://foo/1"); |
| 2000 const GURL url2("http://foo2"); | 2004 const GURL url2("http://foo/2"); |
| 2001 const GURL url3("http://foo3"); | 2005 const GURL url3("http://foo/3"); |
| 2002 | 2006 |
| 2003 NavigateAndCommit(url1); | 2007 NavigateAndCommit(url1); |
| 2004 NavigateAndCommit(url2); | 2008 NavigateAndCommit(url2); |
| 2005 NavigateAndCommit(url3); | 2009 NavigateAndCommit(url3); |
| 2006 controller().GoBack(); | 2010 controller().GoBack(); |
| 2007 controller().GoBack(); | 2011 controller().GoBack(); |
| 2008 contents()->CommitPendingNavigation(); | 2012 contents()->CommitPendingNavigation(); |
| 2009 | 2013 |
| 2010 controller().PruneAllButActive(); | 2014 controller().PruneAllButActive(); |
| 2011 | 2015 |
| 2012 EXPECT_EQ(-1, controller().pending_entry_index()); | 2016 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 2013 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); | 2017 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); |
| 2014 } | 2018 } |
| 2015 | 2019 |
| 2016 // Test call to PruneAllButActive for intermediate entry. | 2020 // Test call to PruneAllButActive for intermediate entry. |
| 2017 TEST_F(NavigationControllerTest, PruneAllButActiveForIntermediate) { | 2021 TEST_F(NavigationControllerTest, PruneAllButActiveForIntermediate) { |
| 2018 const GURL url1("http://foo1"); | 2022 const GURL url1("http://foo/1"); |
| 2019 const GURL url2("http://foo2"); | 2023 const GURL url2("http://foo/2"); |
| 2020 const GURL url3("http://foo3"); | 2024 const GURL url3("http://foo/3"); |
| 2021 | 2025 |
| 2022 NavigateAndCommit(url1); | 2026 NavigateAndCommit(url1); |
| 2023 NavigateAndCommit(url2); | 2027 NavigateAndCommit(url2); |
| 2024 NavigateAndCommit(url3); | 2028 NavigateAndCommit(url3); |
| 2025 controller().GoBack(); | 2029 controller().GoBack(); |
| 2026 contents()->CommitPendingNavigation(); | 2030 contents()->CommitPendingNavigation(); |
| 2027 | 2031 |
| 2028 controller().PruneAllButActive(); | 2032 controller().PruneAllButActive(); |
| 2029 | 2033 |
| 2030 EXPECT_EQ(-1, controller().pending_entry_index()); | 2034 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 2031 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url2); | 2035 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url2); |
| 2032 } | 2036 } |
| 2033 | 2037 |
| 2034 // Test call to PruneAllButActive for intermediate entry. | 2038 // Test call to PruneAllButActive for intermediate entry. |
| 2035 TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { | 2039 TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { |
| 2036 const GURL url1("http://foo1"); | 2040 const GURL url1("http://foo/1"); |
| 2037 const GURL url2("http://foo2"); | 2041 const GURL url2("http://foo/2"); |
| 2038 const GURL url3("http://foo3"); | 2042 const GURL url3("http://foo/3"); |
| 2039 | 2043 |
| 2040 NavigateAndCommit(url1); | 2044 NavigateAndCommit(url1); |
| 2041 NavigateAndCommit(url2); | 2045 NavigateAndCommit(url2); |
| 2042 NavigateAndCommit(url3); | 2046 NavigateAndCommit(url3); |
| 2043 controller().GoBack(); | 2047 controller().GoBack(); |
| 2044 | 2048 |
| 2045 controller().PruneAllButActive(); | 2049 controller().PruneAllButActive(); |
| 2046 | 2050 |
| 2047 EXPECT_EQ(0, controller().pending_entry_index()); | 2051 EXPECT_EQ(0, controller().pending_entry_index()); |
| 2048 } | 2052 } |
| 2049 | 2053 |
| 2050 // Test call to PruneAllButActive for transient entry. | 2054 // Test call to PruneAllButActive for transient entry. |
| 2051 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { | 2055 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { |
| 2052 const GURL url0("http://foo0"); | 2056 const GURL url0("http://foo/0"); |
| 2053 const GURL url1("http://foo1"); | 2057 const GURL url1("http://foo/1"); |
| 2054 const GURL transient_url("http://transient"); | 2058 const GURL transient_url("http://foo/transient"); |
| 2055 | 2059 |
| 2056 controller().LoadURL(url0, GURL(), PageTransition::TYPED); | 2060 controller().LoadURL(url0, GURL(), PageTransition::TYPED); |
| 2057 rvh()->SendNavigate(0, url0); | 2061 rvh()->SendNavigate(0, url0); |
| 2058 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 2062 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| 2059 rvh()->SendNavigate(1, url1); | 2063 rvh()->SendNavigate(1, url1); |
| 2060 | 2064 |
| 2061 // Adding a transient with no pending entry. | 2065 // Adding a transient with no pending entry. |
| 2062 NavigationEntry* transient_entry = new NavigationEntry; | 2066 NavigationEntry* transient_entry = new NavigationEntry; |
| 2063 transient_entry->set_url(transient_url); | 2067 transient_entry->set_url(transient_url); |
| 2064 controller().AddTransientEntry(transient_entry); | 2068 controller().AddTransientEntry(transient_entry); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2237 TabNavigation nav(0, url0, GURL(), string16(), | 2241 TabNavigation nav(0, url0, GURL(), string16(), |
| 2238 webkit_glue::CreateHistoryStateForURL(url0), | 2242 webkit_glue::CreateHistoryStateForURL(url0), |
| 2239 PageTransition::LINK); | 2243 PageTransition::LINK); |
| 2240 session_helper_.AssertNavigationEquals(nav, | 2244 session_helper_.AssertNavigationEquals(nav, |
| 2241 windows_[0]->tabs[0]->navigations[0]); | 2245 windows_[0]->tabs[0]->navigations[0]); |
| 2242 nav.set_url(url2); | 2246 nav.set_url(url2); |
| 2243 session_helper_.AssertNavigationEquals(nav, | 2247 session_helper_.AssertNavigationEquals(nav, |
| 2244 windows_[0]->tabs[0]->navigations[1]); | 2248 windows_[0]->tabs[0]->navigations[1]); |
| 2245 } | 2249 } |
| 2246 */ | 2250 */ |
| OLD | NEW |