OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/profile_manager.h" | 9 #include "chrome/browser/profile_manager.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 EXPECT_EQ(controller().last_committed_entry_index(), 0); | 760 EXPECT_EQ(controller().last_committed_entry_index(), 0); |
761 EXPECT_TRUE(controller().GetLastCommittedEntry()); | 761 EXPECT_TRUE(controller().GetLastCommittedEntry()); |
762 EXPECT_EQ(controller().pending_entry_index(), -1); | 762 EXPECT_EQ(controller().pending_entry_index(), -1); |
763 EXPECT_FALSE(controller().pending_entry()); | 763 EXPECT_FALSE(controller().pending_entry()); |
764 EXPECT_EQ(url2, controller().GetActiveEntry()->url()); | 764 EXPECT_EQ(url2, controller().GetActiveEntry()->url()); |
765 | 765 |
766 EXPECT_FALSE(controller().CanGoBack()); | 766 EXPECT_FALSE(controller().CanGoBack()); |
767 EXPECT_FALSE(controller().CanGoForward()); | 767 EXPECT_FALSE(controller().CanGoForward()); |
768 } | 768 } |
769 | 769 |
| 770 // A redirect right off the bat should be a NEW_PAGE. |
| 771 TEST_F(NavigationControllerTest, ImmediateRedirect) { |
| 772 TestNotificationTracker notifications; |
| 773 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 774 |
| 775 const GURL url1("http://foo1"); |
| 776 const GURL url2("http://foo2"); // Redirection target |
| 777 |
| 778 // First request |
| 779 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| 780 |
| 781 EXPECT_TRUE(controller().pending_entry()); |
| 782 EXPECT_EQ(controller().pending_entry_index(), -1); |
| 783 EXPECT_EQ(url1, controller().GetActiveEntry()->url()); |
| 784 |
| 785 ViewHostMsg_FrameNavigate_Params params = {0}; |
| 786 params.page_id = 0; |
| 787 params.url = url2; |
| 788 params.transition = PageTransition::SERVER_REDIRECT; |
| 789 params.redirects.push_back(GURL("http://foo1")); |
| 790 params.redirects.push_back(GURL("http://foo2")); |
| 791 params.should_update_history = false; |
| 792 params.gesture = NavigationGestureAuto; |
| 793 params.is_post = false; |
| 794 |
| 795 NavigationController::LoadCommittedDetails details; |
| 796 |
| 797 EXPECT_EQ(0U, notifications.size()); |
| 798 EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); |
| 799 EXPECT_TRUE(notifications.Check1AndReset( |
| 800 NotificationType::NAV_ENTRY_COMMITTED)); |
| 801 |
| 802 EXPECT_TRUE(details.type == NavigationType::NEW_PAGE); |
| 803 EXPECT_EQ(controller().entry_count(), 1); |
| 804 EXPECT_EQ(controller().last_committed_entry_index(), 0); |
| 805 EXPECT_TRUE(controller().GetLastCommittedEntry()); |
| 806 EXPECT_EQ(controller().pending_entry_index(), -1); |
| 807 EXPECT_FALSE(controller().pending_entry()); |
| 808 EXPECT_EQ(url2, controller().GetActiveEntry()->url()); |
| 809 |
| 810 EXPECT_FALSE(controller().CanGoBack()); |
| 811 EXPECT_FALSE(controller().CanGoForward()); |
| 812 } |
| 813 |
770 // Tests navigation via link click within a subframe. A new navigation entry | 814 // Tests navigation via link click within a subframe. A new navigation entry |
771 // should be created. | 815 // should be created. |
772 TEST_F(NavigationControllerTest, NewSubframe) { | 816 TEST_F(NavigationControllerTest, NewSubframe) { |
773 TestNotificationTracker notifications; | 817 TestNotificationTracker notifications; |
774 RegisterForAllNavNotifications(¬ifications, &controller()); | 818 RegisterForAllNavNotifications(¬ifications, &controller()); |
775 | 819 |
776 const GURL url1("http://foo1"); | 820 const GURL url1("http://foo1"); |
777 rvh()->SendNavigate(0, url1); | 821 rvh()->SendNavigate(0, url1); |
778 EXPECT_TRUE(notifications.Check1AndReset( | 822 EXPECT_TRUE(notifications.Check1AndReset( |
779 NotificationType::NAV_ENTRY_COMMITTED)); | 823 NotificationType::NAV_ENTRY_COMMITTED)); |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 TabNavigation nav(0, url0, GURL(), string16(), | 1512 TabNavigation nav(0, url0, GURL(), string16(), |
1469 webkit_glue::CreateHistoryStateForURL(url0), | 1513 webkit_glue::CreateHistoryStateForURL(url0), |
1470 PageTransition::LINK); | 1514 PageTransition::LINK); |
1471 session_helper_.AssertNavigationEquals(nav, | 1515 session_helper_.AssertNavigationEquals(nav, |
1472 windows_[0]->tabs[0]->navigations[0]); | 1516 windows_[0]->tabs[0]->navigations[0]); |
1473 nav.set_url(url2); | 1517 nav.set_url(url2); |
1474 session_helper_.AssertNavigationEquals(nav, | 1518 session_helper_.AssertNavigationEquals(nav, |
1475 windows_[0]->tabs[0]->navigations[1]); | 1519 windows_[0]->tabs[0]->navigations[1]); |
1476 } | 1520 } |
1477 */ | 1521 */ |
OLD | NEW |