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