OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/profile_manager.h" | 8 #include "chrome/browser/profile_manager.h" |
9 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
10 #include "chrome/browser/renderer_host/test_render_view_host.h" | 10 #include "chrome/browser/renderer_host/test_render_view_host.h" |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 // everything is updated properly. This can be tricky since there is no | 1056 // everything is updated properly. This can be tricky since there is no |
1057 // SiteInstance for the entries created initially. | 1057 // SiteInstance for the entries created initially. |
1058 TEST_F(NavigationControllerTest, RestoreNavigate) { | 1058 TEST_F(NavigationControllerTest, RestoreNavigate) { |
1059 // Create a NavigationController with a restored set of tabs. | 1059 // Create a NavigationController with a restored set of tabs. |
1060 GURL url("http://foo"); | 1060 GURL url("http://foo"); |
1061 std::vector<TabNavigation> navigations; | 1061 std::vector<TabNavigation> navigations; |
1062 navigations.push_back(TabNavigation(0, url, GURL(), | 1062 navigations.push_back(TabNavigation(0, url, GURL(), |
1063 ASCIIToUTF16("Title"), "state", | 1063 ASCIIToUTF16("Title"), "state", |
1064 PageTransition::LINK)); | 1064 PageTransition::LINK)); |
1065 NavigationController* our_controller = | 1065 NavigationController* our_controller = |
1066 new NavigationController(profile(), navigations, 0, &rvh_factory_); | 1066 new NavigationController(profile(), navigations, 0); |
1067 our_controller->GoToIndex(0); | 1067 our_controller->GoToIndex(0); |
1068 | 1068 |
1069 // We should now have one entry, and it should be "pending". | 1069 // We should now have one entry, and it should be "pending". |
1070 EXPECT_EQ(1, our_controller->GetEntryCount()); | 1070 EXPECT_EQ(1, our_controller->GetEntryCount()); |
1071 EXPECT_EQ(our_controller->GetEntryAtIndex(0), | 1071 EXPECT_EQ(our_controller->GetEntryAtIndex(0), |
1072 our_controller->GetPendingEntry()); | 1072 our_controller->GetPendingEntry()); |
1073 EXPECT_EQ(0, our_controller->GetEntryAtIndex(0)->page_id()); | 1073 EXPECT_EQ(0, our_controller->GetEntryAtIndex(0)->page_id()); |
1074 | 1074 |
1075 // Say we navigated to that entry. | 1075 // Say we navigated to that entry. |
1076 ViewHostMsg_FrameNavigate_Params params; | 1076 ViewHostMsg_FrameNavigate_Params params; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 params.gesture = NavigationGestureAuto; | 1348 params.gesture = NavigationGestureAuto; |
1349 params.is_post = false; | 1349 params.is_post = false; |
1350 NavigationController::LoadCommittedDetails details; | 1350 NavigationController::LoadCommittedDetails details; |
1351 EXPECT_FALSE(controller()->RendererDidNavigate(params, &details)); | 1351 EXPECT_FALSE(controller()->RendererDidNavigate(params, &details)); |
1352 | 1352 |
1353 // Nothing should have changed. | 1353 // Nothing should have changed. |
1354 EXPECT_EQ(controller()->GetEntryCount(), 1); | 1354 EXPECT_EQ(controller()->GetEntryCount(), 1); |
1355 EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); | 1355 EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); |
1356 } | 1356 } |
1357 | 1357 |
1358 /* TODO(brettw) These test pass on my local machine but fail on the buildbot | |
1359 cleaning up the directory after they run. This should be fixed. | |
1360 | |
1361 // A basic test case. Navigates to a single url, and make sure the history | 1358 // A basic test case. Navigates to a single url, and make sure the history |
1362 // db matches. | 1359 // db matches. |
1363 TEST_F(NavigationControllerHistoryTest, Basic) { | 1360 TEST_F(NavigationControllerHistoryTest, Basic) { |
1364 controller()->LoadURL(url0, GURL(), PageTransition::LINK); | 1361 controller()->LoadURL(url0, GURL(), PageTransition::LINK); |
1365 rvh()->SendNavigate(0, url0); | 1362 rvh()->SendNavigate(0, url0); |
1366 | 1363 |
1367 GetLastSession(); | 1364 GetLastSession(); |
1368 | 1365 |
1369 session_helper_.AssertSingleWindowWithSingleTab(windows_, 1); | 1366 session_helper_.AssertSingleWindowWithSingleTab(windows_, 1); |
1370 session_helper_.AssertTabEquals(0, 0, 1, *(windows_[0]->tabs[0])); | 1367 session_helper_.AssertTabEquals(0, 0, 1, *(windows_[0]->tabs[0])); |
1371 TabNavigation nav1(0, url0, GURL(), string16(), | 1368 TabNavigation nav1(0, url0, GURL(), string16(), |
1372 webkit_glue::CreateHistoryStateForURL(url0), | 1369 webkit_glue::CreateHistoryStateForURL(url0), |
1373 PageTransition::LINK); | 1370 PageTransition::LINK); |
1374 session_helper_.AssertNavigationEquals(nav1, windows_[0]->tabs[0]->navigations
[0]); | 1371 session_helper_.AssertNavigationEquals(nav1, windows_[0]->tabs[0]->navigations
[0]); |
1375 } | 1372 } |
1376 | 1373 |
| 1374 /* TODO(brettw) These test pass on my local machine but fail on the buildbot |
| 1375 cleaning up the directory after they run. This should be fixed. |
| 1376 |
1377 // Navigates to three urls, then goes back and make sure the history database | 1377 // Navigates to three urls, then goes back and make sure the history database |
1378 // is in sync. | 1378 // is in sync. |
1379 TEST_F(NavigationControllerHistoryTest, NavigationThenBack) { | 1379 TEST_F(NavigationControllerHistoryTest, NavigationThenBack) { |
1380 rvh()->SendNavigate(0, url0); | 1380 rvh()->SendNavigate(0, url0); |
1381 rvh()->SendNavigate(1, url1); | 1381 rvh()->SendNavigate(1, url1); |
1382 rvh()->SendNavigate(2, url2); | 1382 rvh()->SendNavigate(2, url2); |
1383 | 1383 |
1384 controller()->GoBack(); | 1384 controller()->GoBack(); |
1385 rvh()->SendNavigate(1, url1); | 1385 rvh()->SendNavigate(1, url1); |
1386 | 1386 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 TabNavigation nav(0, url0, GURL(), string16(), | 1426 TabNavigation nav(0, url0, GURL(), string16(), |
1427 webkit_glue::CreateHistoryStateForURL(url0), | 1427 webkit_glue::CreateHistoryStateForURL(url0), |
1428 PageTransition::LINK); | 1428 PageTransition::LINK); |
1429 session_helper_.AssertNavigationEquals(nav, | 1429 session_helper_.AssertNavigationEquals(nav, |
1430 windows_[0]->tabs[0]->navigations[0]); | 1430 windows_[0]->tabs[0]->navigations[0]); |
1431 nav.set_url(url2); | 1431 nav.set_url(url2); |
1432 session_helper_.AssertNavigationEquals(nav, | 1432 session_helper_.AssertNavigationEquals(nav, |
1433 windows_[0]->tabs[0]->navigations[1]); | 1433 windows_[0]->tabs[0]->navigations[1]); |
1434 } | 1434 } |
1435 */ | 1435 */ |
OLD | NEW |