Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 101573003: Add the navigation redirect-chain to Sync sessions proto for offline analysis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from creis on patch set 43. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/file_util.h" 7 #include "base/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 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 std::vector<GURL> redirects; 1306 std::vector<GURL> redirects;
1307 redirects.push_back(GURL("http://foo2")); 1307 redirects.push_back(GURL("http://foo2"));
1308 1308
1309 // Set non-persisted values on the pending entry. 1309 // Set non-persisted values on the pending entry.
1310 NavigationEntryImpl* pending_entry = 1310 NavigationEntryImpl* pending_entry =
1311 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry()); 1311 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry());
1312 pending_entry->SetBrowserInitiatedPostData(post_data.get()); 1312 pending_entry->SetBrowserInitiatedPostData(post_data.get());
1313 pending_entry->set_is_renderer_initiated(true); 1313 pending_entry->set_is_renderer_initiated(true);
1314 pending_entry->set_transferred_global_request_id(transfer_id); 1314 pending_entry->set_transferred_global_request_id(transfer_id);
1315 pending_entry->set_should_replace_entry(true); 1315 pending_entry->set_should_replace_entry(true);
1316 pending_entry->set_redirect_chain(redirects); 1316 pending_entry->SetRedirectChain(redirects);
1317 pending_entry->set_should_clear_history_list(true); 1317 pending_entry->set_should_clear_history_list(true);
1318 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData()); 1318 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData());
1319 EXPECT_TRUE(pending_entry->is_renderer_initiated()); 1319 EXPECT_TRUE(pending_entry->is_renderer_initiated());
1320 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id()); 1320 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id());
1321 EXPECT_TRUE(pending_entry->should_replace_entry()); 1321 EXPECT_TRUE(pending_entry->should_replace_entry());
1322 EXPECT_EQ(1U, pending_entry->redirect_chain().size()); 1322 EXPECT_EQ(1U, pending_entry->GetRedirectChain().size());
1323 EXPECT_TRUE(pending_entry->should_clear_history_list()); 1323 EXPECT_TRUE(pending_entry->should_clear_history_list());
1324 1324
1325 main_test_rfh()->SendNavigate(0, url1); 1325 main_test_rfh()->SendNavigate(0, url1);
1326 1326
1327 // Certain values that are only used for pending entries get reset after 1327 // Certain values that are only used for pending entries get reset after
1328 // commit. 1328 // commit.
1329 NavigationEntryImpl* committed_entry = 1329 NavigationEntryImpl* committed_entry =
1330 NavigationEntryImpl::FromNavigationEntry( 1330 NavigationEntryImpl::FromNavigationEntry(
1331 controller.GetLastCommittedEntry()); 1331 controller.GetLastCommittedEntry());
1332 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData()); 1332 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData());
1333 EXPECT_FALSE(committed_entry->is_renderer_initiated()); 1333 EXPECT_FALSE(committed_entry->is_renderer_initiated());
1334 EXPECT_EQ(GlobalRequestID(-1, -1), 1334 EXPECT_EQ(GlobalRequestID(-1, -1),
1335 committed_entry->transferred_global_request_id()); 1335 committed_entry->transferred_global_request_id());
1336 EXPECT_FALSE(committed_entry->should_replace_entry()); 1336 EXPECT_FALSE(committed_entry->should_replace_entry());
1337 EXPECT_EQ(0U, committed_entry->redirect_chain().size()); 1337 EXPECT_EQ(0U, committed_entry->GetRedirectChain().size());
1338 EXPECT_FALSE(committed_entry->should_clear_history_list()); 1338 EXPECT_FALSE(committed_entry->should_clear_history_list());
1339
1340 // If the navigate parameters include redirects, they will be preserved
1341 // in the committed entry.
1342 main_test_rfh()->SendNavigateWithRedirects(0, url1, redirects);
Charlie Reis 2014/04/05 00:09:10 This sounds like it should be in a test of its own
Donn Denman 2014/04/09 21:09:21 Done.
1343 NavigationEntryImpl* committed_entry_with_redirects =
1344 NavigationEntryImpl::FromNavigationEntry(
1345 controller.GetLastCommittedEntry());
1346 ASSERT_EQ(1U, committed_entry_with_redirects->GetRedirectChain().size());
1347 EXPECT_EQ(GURL("http://foo2"),
1348 committed_entry_with_redirects->GetRedirectChain()[0]);
1339 } 1349 }
1340 1350
1341 // Tests what happens when we navigate back successfully 1351 // Tests what happens when we navigate back successfully
1342 TEST_F(NavigationControllerTest, Back) { 1352 TEST_F(NavigationControllerTest, Back) {
1343 NavigationControllerImpl& controller = controller_impl(); 1353 NavigationControllerImpl& controller = controller_impl();
1344 TestNotificationTracker notifications; 1354 TestNotificationTracker notifications;
1345 RegisterForAllNavNotifications(&notifications, &controller); 1355 RegisterForAllNavNotifications(&notifications, &controller);
1346 1356
1347 const GURL url1("http://foo1"); 1357 const GURL url1("http://foo1");
1348 main_test_rfh()->SendNavigate(0, url1); 1358 main_test_rfh()->SendNavigate(0, url1);
(...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after
4017 EXPECT_EQ(1, controller.GetEntryCount()); 4027 EXPECT_EQ(1, controller.GetEntryCount());
4018 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4028 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4019 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4029 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4020 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4030 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4021 EXPECT_FALSE(controller.CanGoBack()); 4031 EXPECT_FALSE(controller.CanGoBack());
4022 EXPECT_FALSE(controller.CanGoForward()); 4032 EXPECT_FALSE(controller.CanGoForward());
4023 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4033 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4024 } 4034 }
4025 4035
4026 } // namespace content 4036 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698