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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 // SiteInstance for the entries created initially. | 1139 // SiteInstance for the entries created initially. |
1140 TEST_F(NavigationControllerTest, RestoreNavigate) { | 1140 TEST_F(NavigationControllerTest, RestoreNavigate) { |
1141 // Create a NavigationController with a restored set of tabs. | 1141 // Create a NavigationController with a restored set of tabs. |
1142 GURL url("http://foo"); | 1142 GURL url("http://foo"); |
1143 std::vector<TabNavigation> navigations; | 1143 std::vector<TabNavigation> navigations; |
1144 navigations.push_back(TabNavigation(0, url, GURL(), | 1144 navigations.push_back(TabNavigation(0, url, GURL(), |
1145 ASCIIToUTF16("Title"), "state", | 1145 ASCIIToUTF16("Title"), "state", |
1146 PageTransition::LINK)); | 1146 PageTransition::LINK)); |
1147 TabContents our_contents(profile(), NULL, MSG_ROUTING_NONE, NULL); | 1147 TabContents our_contents(profile(), NULL, MSG_ROUTING_NONE, NULL); |
1148 NavigationController& our_controller = our_contents.controller(); | 1148 NavigationController& our_controller = our_contents.controller(); |
1149 our_controller.RestoreFromState(navigations, 0); | 1149 our_controller.RestoreFromState(navigations, 0, true); |
1150 our_controller.GoToIndex(0); | 1150 our_controller.GoToIndex(0); |
1151 | 1151 |
1152 // We should now have one entry, and it should be "pending". | 1152 // We should now have one entry, and it should be "pending". |
1153 EXPECT_EQ(1, our_controller.entry_count()); | 1153 EXPECT_EQ(1, our_controller.entry_count()); |
1154 EXPECT_EQ(our_controller.GetEntryAtIndex(0), | 1154 EXPECT_EQ(our_controller.GetEntryAtIndex(0), |
1155 our_controller.pending_entry()); | 1155 our_controller.pending_entry()); |
1156 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->page_id()); | 1156 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->page_id()); |
| 1157 EXPECT_EQ(NavigationEntry::RESTORE_LAST_SESSION, |
| 1158 our_controller.GetEntryAtIndex(0)->restore_type()); |
1157 | 1159 |
1158 // Say we navigated to that entry. | 1160 // Say we navigated to that entry. |
1159 ViewHostMsg_FrameNavigate_Params params = {0}; | 1161 ViewHostMsg_FrameNavigate_Params params = {0}; |
1160 params.page_id = 0; | 1162 params.page_id = 0; |
1161 params.url = url; | 1163 params.url = url; |
1162 params.transition = PageTransition::LINK; | 1164 params.transition = PageTransition::LINK; |
1163 params.should_update_history = false; | 1165 params.should_update_history = false; |
1164 params.gesture = NavigationGestureUser; | 1166 params.gesture = NavigationGestureUser; |
1165 params.is_post = false; | 1167 params.is_post = false; |
1166 NavigationController::LoadCommittedDetails details; | 1168 NavigationController::LoadCommittedDetails details; |
1167 our_controller.RendererDidNavigate(params, 0, &details); | 1169 our_controller.RendererDidNavigate(params, 0, &details); |
1168 | 1170 |
1169 // There should be no longer any pending entry and one committed one. This | 1171 // There should be no longer any pending entry and one committed one. This |
1170 // means that we were able to locate the entry, assign its site instance, and | 1172 // means that we were able to locate the entry, assign its site instance, and |
1171 // commit it properly. | 1173 // commit it properly. |
1172 EXPECT_EQ(1, our_controller.entry_count()); | 1174 EXPECT_EQ(1, our_controller.entry_count()); |
1173 EXPECT_EQ(0, our_controller.last_committed_entry_index()); | 1175 EXPECT_EQ(0, our_controller.last_committed_entry_index()); |
1174 EXPECT_FALSE(our_controller.pending_entry()); | 1176 EXPECT_FALSE(our_controller.pending_entry()); |
1175 EXPECT_EQ(url, | 1177 EXPECT_EQ(url, |
1176 our_controller.GetLastCommittedEntry()->site_instance()->site()); | 1178 our_controller.GetLastCommittedEntry()->site_instance()->site()); |
| 1179 EXPECT_EQ(NavigationEntry::RESTORE_NONE, |
| 1180 our_controller.GetEntryAtIndex(0)->restore_type()); |
1177 } | 1181 } |
1178 | 1182 |
1179 // Make sure that the page type and stuff is correct after an interstitial. | 1183 // Make sure that the page type and stuff is correct after an interstitial. |
1180 TEST_F(NavigationControllerTest, Interstitial) { | 1184 TEST_F(NavigationControllerTest, Interstitial) { |
1181 // First navigate somewhere normal. | 1185 // First navigate somewhere normal. |
1182 const GURL url1("http://foo"); | 1186 const GURL url1("http://foo"); |
1183 controller().LoadURL(url1, GURL(), PageTransition::TYPED); | 1187 controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
1184 rvh()->SendNavigate(0, url1); | 1188 rvh()->SendNavigate(0, url1); |
1185 | 1189 |
1186 // Now navigate somewhere with an interstitial. | 1190 // Now navigate somewhere with an interstitial. |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 TabNavigation nav(0, url0, GURL(), string16(), | 1512 TabNavigation nav(0, url0, GURL(), string16(), |
1509 webkit_glue::CreateHistoryStateForURL(url0), | 1513 webkit_glue::CreateHistoryStateForURL(url0), |
1510 PageTransition::LINK); | 1514 PageTransition::LINK); |
1511 session_helper_.AssertNavigationEquals(nav, | 1515 session_helper_.AssertNavigationEquals(nav, |
1512 windows_[0]->tabs[0]->navigations[0]); | 1516 windows_[0]->tabs[0]->navigations[0]); |
1513 nav.set_url(url2); | 1517 nav.set_url(url2); |
1514 session_helper_.AssertNavigationEquals(nav, | 1518 session_helper_.AssertNavigationEquals(nav, |
1515 windows_[0]->tabs[0]->navigations[1]); | 1519 windows_[0]->tabs[0]->navigations[1]); |
1516 } | 1520 } |
1517 */ | 1521 */ |
OLD | NEW |