OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_util.h" | 7 #include "base/files/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 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 | 2604 |
2605 // Remove the 2 remaining entries. | 2605 // Remove the 2 remaining entries. |
2606 controller.RemoveEntryAtIndex(1); | 2606 controller.RemoveEntryAtIndex(1); |
2607 controller.RemoveEntryAtIndex(0); | 2607 controller.RemoveEntryAtIndex(0); |
2608 | 2608 |
2609 // This should leave us with only the last committed entry. | 2609 // This should leave us with only the last committed entry. |
2610 EXPECT_EQ(1, controller.GetEntryCount()); | 2610 EXPECT_EQ(1, controller.GetEntryCount()); |
2611 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 2611 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
2612 } | 2612 } |
2613 | 2613 |
| 2614 TEST_F(NavigationControllerTest, RemoveEntryWithPending) { |
| 2615 NavigationControllerImpl& controller = controller_impl(); |
| 2616 const GURL url1("http://foo/1"); |
| 2617 const GURL url2("http://foo/2"); |
| 2618 const GURL url3("http://foo/3"); |
| 2619 const GURL default_url("http://foo/default"); |
| 2620 |
| 2621 controller.LoadURL( |
| 2622 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2623 main_test_rfh()->SendNavigate(0, url1); |
| 2624 controller.LoadURL( |
| 2625 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2626 main_test_rfh()->SendNavigate(1, url2); |
| 2627 controller.LoadURL( |
| 2628 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2629 main_test_rfh()->SendNavigate(2, url3); |
| 2630 |
| 2631 // Go back, but don't commit yet. Check that we can't delete the current |
| 2632 // and pending entries. |
| 2633 controller.GoBack(); |
| 2634 EXPECT_FALSE(controller.RemoveEntryAtIndex(2)); |
| 2635 EXPECT_FALSE(controller.RemoveEntryAtIndex(1)); |
| 2636 |
| 2637 // Remove the first entry, while there is a pending entry. This is expected |
| 2638 // to discard the pending entry. |
| 2639 EXPECT_TRUE(controller.RemoveEntryAtIndex(0)); |
| 2640 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2641 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 2642 |
| 2643 // We should update the last committed entry index. |
| 2644 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 2645 |
| 2646 // Now commit and ensure we land on the right entry. |
| 2647 main_test_rfh()->SendNavigate(1, url2); |
| 2648 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2649 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 2650 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2651 } |
| 2652 |
2614 // Tests the transient entry, making sure it goes away with all navigations. | 2653 // Tests the transient entry, making sure it goes away with all navigations. |
2615 TEST_F(NavigationControllerTest, TransientEntry) { | 2654 TEST_F(NavigationControllerTest, TransientEntry) { |
2616 NavigationControllerImpl& controller = controller_impl(); | 2655 NavigationControllerImpl& controller = controller_impl(); |
2617 TestNotificationTracker notifications; | 2656 TestNotificationTracker notifications; |
2618 RegisterForAllNavNotifications(¬ifications, &controller); | 2657 RegisterForAllNavNotifications(¬ifications, &controller); |
2619 | 2658 |
2620 const GURL url0("http://foo/0"); | 2659 const GURL url0("http://foo/0"); |
2621 const GURL url1("http://foo/1"); | 2660 const GURL url1("http://foo/1"); |
2622 const GURL url2("http://foo/2"); | 2661 const GURL url2("http://foo/2"); |
2623 const GURL url3("http://foo/3"); | 2662 const GURL url3("http://foo/3"); |
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4354 params.post_id = -1; | 4393 params.post_id = -1; |
4355 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 4394 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
4356 | 4395 |
4357 // Now reload. replaceState overrides the POST, so we should not show a | 4396 // Now reload. replaceState overrides the POST, so we should not show a |
4358 // repost warning dialog. | 4397 // repost warning dialog. |
4359 controller_impl().Reload(true); | 4398 controller_impl().Reload(true); |
4360 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4399 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4361 } | 4400 } |
4362 | 4401 |
4363 } // namespace content | 4402 } // namespace content |
OLD | NEW |