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

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

Issue 181113009: Revert 253010 "Revert 251563 "Move browser initiated navigation ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 3602 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 3613
3614 // Simulate the page calling history.back(), it should not create a pending 3614 // Simulate the page calling history.back(), it should not create a pending
3615 // entry. 3615 // entry.
3616 contents()->OnGoToEntryAtOffset(-1); 3616 contents()->OnGoToEntryAtOffset(-1);
3617 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 3617 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
3618 // The actual cross-navigation is suspended until the current RVH tells us 3618 // The actual cross-navigation is suspended until the current RVH tells us
3619 // it unloaded, simulate that. 3619 // it unloaded, simulate that.
3620 contents()->ProceedWithCrossSiteNavigation(); 3620 contents()->ProceedWithCrossSiteNavigation();
3621 // Also make sure we told the page to navigate. 3621 // Also make sure we told the page to navigate.
3622 const IPC::Message* message = 3622 const IPC::Message* message =
3623 process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); 3623 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3624 ASSERT_TRUE(message != NULL); 3624 ASSERT_TRUE(message != NULL);
3625 Tuple1<ViewMsg_Navigate_Params> nav_params; 3625 Tuple1<FrameMsg_Navigate_Params> nav_params;
3626 ViewMsg_Navigate::Read(message, &nav_params); 3626 FrameMsg_Navigate::Read(message, &nav_params);
3627 EXPECT_EQ(url1, nav_params.a.url); 3627 EXPECT_EQ(url1, nav_params.a.url);
3628 process()->sink().ClearMessages(); 3628 process()->sink().ClearMessages();
3629 3629
3630 // Now test history.forward() 3630 // Now test history.forward()
3631 contents()->OnGoToEntryAtOffset(1); 3631 contents()->OnGoToEntryAtOffset(1);
3632 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 3632 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
3633 // The actual cross-navigation is suspended until the current RVH tells us 3633 // The actual cross-navigation is suspended until the current RVH tells us
3634 // it unloaded, simulate that. 3634 // it unloaded, simulate that.
3635 contents()->ProceedWithCrossSiteNavigation(); 3635 contents()->ProceedWithCrossSiteNavigation();
3636 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); 3636 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3637 ASSERT_TRUE(message != NULL); 3637 ASSERT_TRUE(message != NULL);
3638 ViewMsg_Navigate::Read(message, &nav_params); 3638 FrameMsg_Navigate::Read(message, &nav_params);
3639 EXPECT_EQ(url3, nav_params.a.url); 3639 EXPECT_EQ(url3, nav_params.a.url);
3640 process()->sink().ClearMessages(); 3640 process()->sink().ClearMessages();
3641 3641
3642 // Make sure an extravagant history.go() doesn't break. 3642 // Make sure an extravagant history.go() doesn't break.
3643 contents()->OnGoToEntryAtOffset(120); // Out of bounds. 3643 contents()->OnGoToEntryAtOffset(120); // Out of bounds.
3644 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 3644 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
3645 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); 3645 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3646 EXPECT_TRUE(message == NULL); 3646 EXPECT_TRUE(message == NULL);
3647 } 3647 }
3648 3648
3649 // Test call to PruneAllButLastCommitted for the only entry. 3649 // Test call to PruneAllButLastCommitted for the only entry.
3650 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { 3650 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) {
3651 NavigationControllerImpl& controller = controller_impl(); 3651 NavigationControllerImpl& controller = controller_impl();
3652 const GURL url1("http://foo1"); 3652 const GURL url1("http://foo1");
3653 NavigateAndCommit(url1); 3653 NavigateAndCommit(url1);
3654 3654
3655 contents()->ExpectSetHistoryLengthAndPrune( 3655 contents()->ExpectSetHistoryLengthAndPrune(
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 EXPECT_EQ(1, controller.GetEntryCount()); 4014 EXPECT_EQ(1, controller.GetEntryCount());
4015 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4015 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4016 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4016 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4017 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4017 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4018 EXPECT_FALSE(controller.CanGoBack()); 4018 EXPECT_FALSE(controller.CanGoBack());
4019 EXPECT_FALSE(controller.CanGoForward()); 4019 EXPECT_FALSE(controller.CanGoForward());
4020 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4020 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4021 } 4021 }
4022 4022
4023 } // namespace content 4023 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698