| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 782 |
| 783 // Make a pending entry to somewhere new. | 783 // Make a pending entry to somewhere new. |
| 784 const GURL kExistingURL2("http://bee"); | 784 const GURL kExistingURL2("http://bee"); |
| 785 controller.LoadURL( | 785 controller.LoadURL( |
| 786 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 786 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 787 EXPECT_EQ(0U, notifications.size()); | 787 EXPECT_EQ(0U, notifications.size()); |
| 788 | 788 |
| 789 // After the beforeunload but before it commits, do a new navigation. | 789 // After the beforeunload but before it commits, do a new navigation. |
| 790 main_test_rfh()->PrepareForCommit(); | 790 main_test_rfh()->PrepareForCommit(); |
| 791 const GURL kNewURL("http://see"); | 791 const GURL kNewURL("http://see"); |
| 792 main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true); |
| 792 main_test_rfh()->PrepareForCommit(); | 793 main_test_rfh()->PrepareForCommit(); |
| 793 contents()->GetMainFrame()->SendNavigate(3, kNewURL); | 794 contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
| 794 | 795 |
| 795 // There should no longer be any pending entry, and the third navigation we | 796 // There should no longer be any pending entry, and the third navigation we |
| 796 // just made should be committed. | 797 // just made should be committed. |
| 797 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 798 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 798 navigation_entry_committed_counter_ = 0; | 799 navigation_entry_committed_counter_ = 0; |
| 799 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 800 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 800 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 801 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 801 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 802 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1002 |
| 1002 // Set a WebContentsDelegate to listen for state changes. | 1003 // Set a WebContentsDelegate to listen for state changes. |
| 1003 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 1004 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
| 1004 EXPECT_FALSE(contents()->GetDelegate()); | 1005 EXPECT_FALSE(contents()->GetDelegate()); |
| 1005 contents()->SetDelegate(delegate.get()); | 1006 contents()->SetDelegate(delegate.get()); |
| 1006 | 1007 |
| 1007 // Start with a pending new navigation. | 1008 // Start with a pending new navigation. |
| 1008 const GURL kNewURL("http://eh"); | 1009 const GURL kNewURL("http://eh"); |
| 1009 controller.LoadURL( | 1010 controller.LoadURL( |
| 1010 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1011 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1012 main_test_rfh()->PrepareForCommit(); |
| 1011 EXPECT_EQ(0U, notifications.size()); | 1013 EXPECT_EQ(0U, notifications.size()); |
| 1012 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1014 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 1013 EXPECT_TRUE(controller.GetPendingEntry()); | 1015 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1014 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 1016 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 1015 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 1017 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
| 1016 | 1018 |
| 1017 // It may abort before committing, if it's a download or due to a stop or | 1019 // It may abort before committing, if it's a download or due to a stop or |
| 1018 // a new navigation from the user. | 1020 // a new navigation from the user. |
| 1019 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 1021 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 1020 params.error_code = net::ERR_ABORTED; | 1022 params.error_code = net::ERR_ABORTED; |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 | 1629 |
| 1628 // Tests what happens when we navigate forward successfully. | 1630 // Tests what happens when we navigate forward successfully. |
| 1629 TEST_F(NavigationControllerTest, Forward) { | 1631 TEST_F(NavigationControllerTest, Forward) { |
| 1630 NavigationControllerImpl& controller = controller_impl(); | 1632 NavigationControllerImpl& controller = controller_impl(); |
| 1631 TestNotificationTracker notifications; | 1633 TestNotificationTracker notifications; |
| 1632 RegisterForAllNavNotifications(¬ifications, &controller); | 1634 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1633 | 1635 |
| 1634 const GURL url1("http://foo1"); | 1636 const GURL url1("http://foo1"); |
| 1635 const GURL url2("http://foo2"); | 1637 const GURL url2("http://foo2"); |
| 1636 | 1638 |
| 1639 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true); |
| 1637 main_test_rfh()->PrepareForCommit(); | 1640 main_test_rfh()->PrepareForCommit(); |
| 1638 main_test_rfh()->SendNavigate(0, url1); | 1641 main_test_rfh()->SendNavigate(0, url1); |
| 1639 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1642 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1640 navigation_entry_committed_counter_ = 0; | 1643 navigation_entry_committed_counter_ = 0; |
| 1641 | 1644 |
| 1645 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true); |
| 1642 main_test_rfh()->PrepareForCommit(); | 1646 main_test_rfh()->PrepareForCommit(); |
| 1643 main_test_rfh()->SendNavigate(1, url2); | 1647 main_test_rfh()->SendNavigate(1, url2); |
| 1644 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1648 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1645 navigation_entry_committed_counter_ = 0; | 1649 navigation_entry_committed_counter_ = 0; |
| 1646 | 1650 |
| 1647 controller.GoBack(); | 1651 controller.GoBack(); |
| 1648 main_test_rfh()->PrepareForCommit(); | 1652 main_test_rfh()->PrepareForCommit(); |
| 1649 main_test_rfh()->SendNavigate(0, url1); | 1653 main_test_rfh()->SendNavigate(0, url1); |
| 1650 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1654 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1651 navigation_entry_committed_counter_ = 0; | 1655 navigation_entry_committed_counter_ = 0; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 // Tests what happens when a forward navigation produces a new page. | 1700 // Tests what happens when a forward navigation produces a new page. |
| 1697 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { | 1701 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
| 1698 NavigationControllerImpl& controller = controller_impl(); | 1702 NavigationControllerImpl& controller = controller_impl(); |
| 1699 TestNotificationTracker notifications; | 1703 TestNotificationTracker notifications; |
| 1700 RegisterForAllNavNotifications(¬ifications, &controller); | 1704 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1701 | 1705 |
| 1702 const GURL url1("http://foo1"); | 1706 const GURL url1("http://foo1"); |
| 1703 const GURL url2("http://foo2"); | 1707 const GURL url2("http://foo2"); |
| 1704 const GURL url3("http://foo3"); | 1708 const GURL url3("http://foo3"); |
| 1705 | 1709 |
| 1710 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true); |
| 1706 main_test_rfh()->PrepareForCommit(); | 1711 main_test_rfh()->PrepareForCommit(); |
| 1707 main_test_rfh()->SendNavigate(0, url1); | 1712 main_test_rfh()->SendNavigate(0, url1); |
| 1708 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1713 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1709 navigation_entry_committed_counter_ = 0; | 1714 navigation_entry_committed_counter_ = 0; |
| 1715 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true); |
| 1710 main_test_rfh()->PrepareForCommit(); | 1716 main_test_rfh()->PrepareForCommit(); |
| 1711 main_test_rfh()->SendNavigate(1, url2); | 1717 main_test_rfh()->SendNavigate(1, url2); |
| 1712 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1718 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1713 navigation_entry_committed_counter_ = 0; | 1719 navigation_entry_committed_counter_ = 0; |
| 1714 | 1720 |
| 1715 controller.GoBack(); | 1721 controller.GoBack(); |
| 1716 main_test_rfh()->PrepareForCommit(); | 1722 main_test_rfh()->PrepareForCommit(); |
| 1717 main_test_rfh()->SendNavigate(0, url1); | 1723 main_test_rfh()->SendNavigate(0, url1); |
| 1718 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1724 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1719 navigation_entry_committed_counter_ = 0; | 1725 navigation_entry_committed_counter_ = 0; |
| (...skipping 2815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4535 { | 4541 { |
| 4536 LoadCommittedDetails details; | 4542 LoadCommittedDetails details; |
| 4537 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 4543 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); |
| 4538 EXPECT_EQ(PAGE_TYPE_ERROR, | 4544 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 4539 controller_impl().GetLastCommittedEntry()->GetPageType()); | 4545 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 4540 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); | 4546 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); |
| 4541 } | 4547 } |
| 4542 } | 4548 } |
| 4543 | 4549 |
| 4544 } // namespace content | 4550 } // namespace content |
| OLD | NEW |