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 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
25 #include "chrome/common/render_messages_params.h" | 25 #include "chrome/common/render_messages_params.h" |
26 #include "chrome/test/test_notification_tracker.h" | 26 #include "chrome/test/test_notification_tracker.h" |
27 #include "chrome/test/testing_profile.h" | 27 #include "chrome/test/testing_profile.h" |
28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "webkit/glue/webkit_glue.h" | 30 #include "webkit/glue/webkit_glue.h" |
31 | 31 |
32 using base::Time; | 32 using base::Time; |
33 | 33 |
34 namespace { | |
35 | |
36 // NavigationControllerTest ---------------------------------------------------- | 34 // NavigationControllerTest ---------------------------------------------------- |
37 | 35 |
38 class NavigationControllerTest : public RenderViewHostTestHarness { | 36 class NavigationControllerTest : public RenderViewHostTestHarness { |
39 public: | 37 public: |
40 NavigationControllerTest() {} | 38 NavigationControllerTest() {} |
41 }; | 39 }; |
42 | 40 |
43 // NavigationControllerHistoryTest --------------------------------------------- | 41 // NavigationControllerHistoryTest --------------------------------------------- |
44 | 42 |
45 class NavigationControllerHistoryTest : public NavigationControllerTest { | 43 class NavigationControllerHistoryTest : public NavigationControllerTest { |
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 const GURL url1("http://foo1"); | 1815 const GURL url1("http://foo1"); |
1818 const GURL url2("http://foo2"); | 1816 const GURL url2("http://foo2"); |
1819 const GURL url3("http://foo3"); | 1817 const GURL url3("http://foo3"); |
1820 | 1818 |
1821 NavigateAndCommit(url1); | 1819 NavigateAndCommit(url1); |
1822 NavigateAndCommit(url2); | 1820 NavigateAndCommit(url2); |
1823 NavigateAndCommit(url3); | 1821 NavigateAndCommit(url3); |
1824 controller().GoBack(); | 1822 controller().GoBack(); |
1825 contents()->CommitPendingNavigation(); | 1823 contents()->CommitPendingNavigation(); |
1826 | 1824 |
1827 // Casts the TabContents to a RenderViewHostDelegate::BrowserIntegration so we | |
1828 // can call GoToEntryAtOffset which is private. | |
1829 RenderViewHostDelegate::BrowserIntegration* rvh_delegate = | |
1830 static_cast<RenderViewHostDelegate::BrowserIntegration*>(contents()); | |
1831 | |
1832 // Simulate the page calling history.back(), it should not create a pending | 1825 // Simulate the page calling history.back(), it should not create a pending |
1833 // entry. | 1826 // entry. |
1834 rvh_delegate->GoToEntryAtOffset(-1); | 1827 contents()->OnGoToEntryAtOffset(-1); |
1835 EXPECT_EQ(-1, controller().pending_entry_index()); | 1828 EXPECT_EQ(-1, controller().pending_entry_index()); |
1836 // The actual cross-navigation is suspended until the current RVH tells us | 1829 // The actual cross-navigation is suspended until the current RVH tells us |
1837 // it unloaded, simulate that. | 1830 // it unloaded, simulate that. |
1838 contents()->ProceedWithCrossSiteNavigation(); | 1831 contents()->ProceedWithCrossSiteNavigation(); |
1839 // Also make sure we told the page to navigate. | 1832 // Also make sure we told the page to navigate. |
1840 const IPC::Message* message = | 1833 const IPC::Message* message = |
1841 process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); | 1834 process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); |
1842 ASSERT_TRUE(message != NULL); | 1835 ASSERT_TRUE(message != NULL); |
1843 Tuple1<ViewMsg_Navigate_Params> nav_params; | 1836 Tuple1<ViewMsg_Navigate_Params> nav_params; |
1844 ViewMsg_Navigate::Read(message, &nav_params); | 1837 ViewMsg_Navigate::Read(message, &nav_params); |
1845 EXPECT_EQ(url1, nav_params.a.url); | 1838 EXPECT_EQ(url1, nav_params.a.url); |
1846 process()->sink().ClearMessages(); | 1839 process()->sink().ClearMessages(); |
1847 | 1840 |
1848 // Now test history.forward() | 1841 // Now test history.forward() |
1849 rvh_delegate->GoToEntryAtOffset(1); | 1842 contents()->OnGoToEntryAtOffset(1); |
1850 EXPECT_EQ(-1, controller().pending_entry_index()); | 1843 EXPECT_EQ(-1, controller().pending_entry_index()); |
1851 // The actual cross-navigation is suspended until the current RVH tells us | 1844 // The actual cross-navigation is suspended until the current RVH tells us |
1852 // it unloaded, simulate that. | 1845 // it unloaded, simulate that. |
1853 contents()->ProceedWithCrossSiteNavigation(); | 1846 contents()->ProceedWithCrossSiteNavigation(); |
1854 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); | 1847 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); |
1855 ASSERT_TRUE(message != NULL); | 1848 ASSERT_TRUE(message != NULL); |
1856 ViewMsg_Navigate::Read(message, &nav_params); | 1849 ViewMsg_Navigate::Read(message, &nav_params); |
1857 EXPECT_EQ(url3, nav_params.a.url); | 1850 EXPECT_EQ(url3, nav_params.a.url); |
1858 process()->sink().ClearMessages(); | 1851 process()->sink().ClearMessages(); |
1859 | 1852 |
1860 // Make sure an extravagant history.go() doesn't break. | 1853 // Make sure an extravagant history.go() doesn't break. |
1861 rvh_delegate->GoToEntryAtOffset(120); // Out of bounds. | 1854 contents()->OnGoToEntryAtOffset(120); // Out of bounds. |
1862 EXPECT_EQ(-1, controller().pending_entry_index()); | 1855 EXPECT_EQ(-1, controller().pending_entry_index()); |
1863 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); | 1856 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); |
1864 EXPECT_TRUE(message == NULL); | 1857 EXPECT_TRUE(message == NULL); |
1865 } | 1858 } |
1866 | 1859 |
1867 // Test call to PruneAllButActive for the only entry. | 1860 // Test call to PruneAllButActive for the only entry. |
1868 TEST_F(NavigationControllerTest, PruneAllButActiveForSingle) { | 1861 TEST_F(NavigationControllerTest, PruneAllButActiveForSingle) { |
1869 const GURL url1("http://foo1"); | 1862 const GURL url1("http://foo1"); |
1870 NavigateAndCommit(url1); | 1863 NavigateAndCommit(url1); |
1871 controller().PruneAllButActive(); | 1864 controller().PruneAllButActive(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 TabNavigation nav(0, url0, GURL(), string16(), | 2016 TabNavigation nav(0, url0, GURL(), string16(), |
2024 webkit_glue::CreateHistoryStateForURL(url0), | 2017 webkit_glue::CreateHistoryStateForURL(url0), |
2025 PageTransition::LINK); | 2018 PageTransition::LINK); |
2026 session_helper_.AssertNavigationEquals(nav, | 2019 session_helper_.AssertNavigationEquals(nav, |
2027 windows_[0]->tabs[0]->navigations[0]); | 2020 windows_[0]->tabs[0]->navigations[0]); |
2028 nav.set_url(url2); | 2021 nav.set_url(url2); |
2029 session_helper_.AssertNavigationEquals(nav, | 2022 session_helper_.AssertNavigationEquals(nav, |
2030 windows_[0]->tabs[0]->navigations[1]); | 2023 windows_[0]->tabs[0]->navigations[1]); |
2031 } | 2024 } |
2032 */ | 2025 */ |
2033 | |
2034 } // namespace | |
OLD | NEW |