| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 | 1733 |
| 1734 ASSERT_EQ(3, other_controller.entry_count()); | 1734 ASSERT_EQ(3, other_controller.entry_count()); |
| 1735 | 1735 |
| 1736 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 1736 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
| 1737 | 1737 |
| 1738 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); | 1738 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); |
| 1739 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->url()); | 1739 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->url()); |
| 1740 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->url()); | 1740 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->url()); |
| 1741 | 1741 |
| 1742 // The session id of the new tab should be that of the old, and the old should | 1742 // The session id of the new tab should be that of the old, and the old should |
| 1743 // be set to 0. | 1743 // get a new id. |
| 1744 EXPECT_EQ(id.id(), other_controller.session_id().id()); | 1744 EXPECT_EQ(id.id(), other_controller.session_id().id()); |
| 1745 EXPECT_EQ(0, controller().session_id().id()); | 1745 EXPECT_NE(id.id(), controller().session_id().id()); |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 // Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in | 1748 // Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in |
| 1749 // the target. | 1749 // the target. |
| 1750 TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) { | 1750 TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) { |
| 1751 SessionID id(controller().session_id()); | 1751 SessionID id(controller().session_id()); |
| 1752 const GURL url1("http://foo1"); | 1752 const GURL url1("http://foo1"); |
| 1753 const GURL url2("http://foo2"); | 1753 const GURL url2("http://foo2"); |
| 1754 const GURL url3("http://foo3"); | 1754 const GURL url3("http://foo3"); |
| 1755 | 1755 |
| 1756 NavigateAndCommit(url1); | 1756 NavigateAndCommit(url1); |
| 1757 NavigateAndCommit(url2); | 1757 NavigateAndCommit(url2); |
| 1758 controller().GoBack(); | 1758 controller().GoBack(); |
| 1759 | 1759 |
| 1760 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 1760 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); |
| 1761 NavigationController& other_controller = other_contents->controller(); | 1761 NavigationController& other_controller = other_contents->controller(); |
| 1762 other_controller.CopyStateFromAndPrune(&controller()); | 1762 other_controller.CopyStateFromAndPrune(&controller()); |
| 1763 | 1763 |
| 1764 // other_controller should now contain the 1 url: url1. | 1764 // other_controller should now contain the 1 url: url1. |
| 1765 | 1765 |
| 1766 ASSERT_EQ(1, other_controller.entry_count()); | 1766 ASSERT_EQ(1, other_controller.entry_count()); |
| 1767 | 1767 |
| 1768 ASSERT_EQ(0, other_controller.GetCurrentEntryIndex()); | 1768 ASSERT_EQ(0, other_controller.GetCurrentEntryIndex()); |
| 1769 | 1769 |
| 1770 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); | 1770 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); |
| 1771 | 1771 |
| 1772 // The session id of the new tab should be that of the old, and the old should | 1772 // The session id of the new tab should be that of the old, and the old should |
| 1773 // be set to 0. | 1773 // get a new id. |
| 1774 EXPECT_EQ(id.id(), other_controller.session_id().id()); | 1774 EXPECT_EQ(id.id(), other_controller.session_id().id()); |
| 1775 EXPECT_EQ(0, controller().session_id().id()); | 1775 EXPECT_NE(id.id(), controller().session_id().id()); |
| 1776 } | 1776 } |
| 1777 | 1777 |
| 1778 // Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in | 1778 // Test CopyStateFromAndPrune with 2 urls, the first selected and nothing in |
| 1779 // the target. | 1779 // the target. |
| 1780 TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) { | 1780 TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) { |
| 1781 SessionID id(controller().session_id()); | 1781 SessionID id(controller().session_id()); |
| 1782 const GURL url1("http://foo1"); | 1782 const GURL url1("http://foo1"); |
| 1783 const GURL url2("http://foo2"); | 1783 const GURL url2("http://foo2"); |
| 1784 const GURL url3("http://foo3"); | 1784 const GURL url3("http://foo3"); |
| 1785 | 1785 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1800 EXPECT_EQ(0, other_controller.GetCurrentEntryIndex()); | 1800 EXPECT_EQ(0, other_controller.GetCurrentEntryIndex()); |
| 1801 | 1801 |
| 1802 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); | 1802 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->url()); |
| 1803 | 1803 |
| 1804 // And there should be a pending entry for url3. | 1804 // And there should be a pending entry for url3. |
| 1805 ASSERT_TRUE(other_controller.pending_entry()); | 1805 ASSERT_TRUE(other_controller.pending_entry()); |
| 1806 | 1806 |
| 1807 EXPECT_EQ(url3, other_controller.pending_entry()->url()); | 1807 EXPECT_EQ(url3, other_controller.pending_entry()->url()); |
| 1808 | 1808 |
| 1809 // The session id of the new tab should be that of the old, and the old should | 1809 // The session id of the new tab should be that of the old, and the old should |
| 1810 // be set to 0. | 1810 // be get a new id. |
| 1811 EXPECT_EQ(id.id(), other_controller.session_id().id()); | 1811 EXPECT_EQ(id.id(), other_controller.session_id().id()); |
| 1812 EXPECT_EQ(0, controller().session_id().id()); | 1812 EXPECT_NE(id.id(), controller().session_id().id()); |
| 1813 } | 1813 } |
| 1814 | 1814 |
| 1815 // Tests that navigations initiated from the page (with the history object) | 1815 // Tests that navigations initiated from the page (with the history object) |
| 1816 // work as expected without navigation entries. | 1816 // work as expected without navigation entries. |
| 1817 TEST_F(NavigationControllerTest, HistoryNavigate) { | 1817 TEST_F(NavigationControllerTest, HistoryNavigate) { |
| 1818 const GURL url1("http://foo1"); | 1818 const GURL url1("http://foo1"); |
| 1819 const GURL url2("http://foo2"); | 1819 const GURL url2("http://foo2"); |
| 1820 const GURL url3("http://foo3"); | 1820 const GURL url3("http://foo3"); |
| 1821 | 1821 |
| 1822 NavigateAndCommit(url1); | 1822 NavigateAndCommit(url1); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 PageTransition::LINK); | 1940 PageTransition::LINK); |
| 1941 session_helper_.AssertNavigationEquals(nav, | 1941 session_helper_.AssertNavigationEquals(nav, |
| 1942 windows_[0]->tabs[0]->navigations[0]); | 1942 windows_[0]->tabs[0]->navigations[0]); |
| 1943 nav.set_url(url2); | 1943 nav.set_url(url2); |
| 1944 session_helper_.AssertNavigationEquals(nav, | 1944 session_helper_.AssertNavigationEquals(nav, |
| 1945 windows_[0]->tabs[0]->navigations[1]); | 1945 windows_[0]->tabs[0]->navigations[1]); |
| 1946 } | 1946 } |
| 1947 */ | 1947 */ |
| 1948 | 1948 |
| 1949 } // namespace | 1949 } // namespace |
| OLD | NEW |