OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.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 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 // First two entries should have the same SiteInstance. | 2076 // First two entries should have the same SiteInstance. |
2077 SiteInstance* instance1 = | 2077 SiteInstance* instance1 = |
2078 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)); | 2078 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)); |
2079 SiteInstance* instance2 = | 2079 SiteInstance* instance2 = |
2080 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); | 2080 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); |
2081 EXPECT_EQ(instance1, instance2); | 2081 EXPECT_EQ(instance1, instance2); |
2082 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); | 2082 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); |
2083 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); | 2083 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); |
2084 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); | 2084 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); |
2085 | 2085 |
2086 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 2086 scoped_ptr<TestTabContents> other_contents( |
| 2087 static_cast<TestTabContents*>(CreateTestWebContents())); |
2087 NavigationControllerImpl& other_controller = | 2088 NavigationControllerImpl& other_controller = |
2088 other_contents->GetControllerImpl(); | 2089 other_contents->GetControllerImpl(); |
2089 other_contents->NavigateAndCommit(url3); | 2090 other_contents->NavigateAndCommit(url3); |
2090 other_contents->ExpectSetHistoryLengthAndPrune( | 2091 other_contents->ExpectSetHistoryLengthAndPrune( |
2091 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | 2092 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, |
2092 other_controller.GetEntryAtIndex(0)->GetPageID()); | 2093 other_controller.GetEntryAtIndex(0)->GetPageID()); |
2093 other_controller.CopyStateFromAndPrune(&controller); | 2094 other_controller.CopyStateFromAndPrune(&controller); |
2094 | 2095 |
2095 // other_controller should now contain the 3 urls: url1, url2 and url3. | 2096 // other_controller should now contain the 3 urls: url1, url2 and url3. |
2096 | 2097 |
(...skipping 24 matching lines...) Expand all Loading... |
2121 TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) { | 2122 TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) { |
2122 NavigationControllerImpl& controller = controller_impl(); | 2123 NavigationControllerImpl& controller = controller_impl(); |
2123 const GURL url1("http://foo1"); | 2124 const GURL url1("http://foo1"); |
2124 const GURL url2("http://foo2"); | 2125 const GURL url2("http://foo2"); |
2125 const GURL url3("http://foo3"); | 2126 const GURL url3("http://foo3"); |
2126 | 2127 |
2127 NavigateAndCommit(url1); | 2128 NavigateAndCommit(url1); |
2128 NavigateAndCommit(url2); | 2129 NavigateAndCommit(url2); |
2129 controller.GoBack(); | 2130 controller.GoBack(); |
2130 | 2131 |
2131 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 2132 scoped_ptr<TestTabContents> other_contents( |
| 2133 static_cast<TestTabContents*>(CreateTestWebContents())); |
2132 NavigationControllerImpl& other_controller = | 2134 NavigationControllerImpl& other_controller = |
2133 other_contents->GetControllerImpl(); | 2135 other_contents->GetControllerImpl(); |
2134 other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1); | 2136 other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1); |
2135 other_controller.CopyStateFromAndPrune(&controller); | 2137 other_controller.CopyStateFromAndPrune(&controller); |
2136 | 2138 |
2137 // other_controller should now contain the 1 url: url1. | 2139 // other_controller should now contain the 1 url: url1. |
2138 | 2140 |
2139 ASSERT_EQ(1, other_controller.GetEntryCount()); | 2141 ASSERT_EQ(1, other_controller.GetEntryCount()); |
2140 | 2142 |
2141 ASSERT_EQ(0, other_controller.GetCurrentEntryIndex()); | 2143 ASSERT_EQ(0, other_controller.GetCurrentEntryIndex()); |
(...skipping 13 matching lines...) Expand all Loading... |
2155 TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) { | 2157 TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) { |
2156 NavigationControllerImpl& controller = controller_impl(); | 2158 NavigationControllerImpl& controller = controller_impl(); |
2157 const GURL url1("http://foo1"); | 2159 const GURL url1("http://foo1"); |
2158 const GURL url2("http://foo2"); | 2160 const GURL url2("http://foo2"); |
2159 const GURL url3("http://foo3"); | 2161 const GURL url3("http://foo3"); |
2160 | 2162 |
2161 NavigateAndCommit(url1); | 2163 NavigateAndCommit(url1); |
2162 NavigateAndCommit(url2); | 2164 NavigateAndCommit(url2); |
2163 controller.GoBack(); | 2165 controller.GoBack(); |
2164 | 2166 |
2165 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 2167 scoped_ptr<TestTabContents> other_contents( |
| 2168 static_cast<TestTabContents*>(CreateTestWebContents())); |
2166 NavigationControllerImpl& other_controller = | 2169 NavigationControllerImpl& other_controller = |
2167 other_contents->GetControllerImpl(); | 2170 other_contents->GetControllerImpl(); |
2168 other_controller.LoadURL( | 2171 other_controller.LoadURL( |
2169 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 2172 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
2170 other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1); | 2173 other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1); |
2171 other_controller.CopyStateFromAndPrune(&controller); | 2174 other_controller.CopyStateFromAndPrune(&controller); |
2172 | 2175 |
2173 // other_controller should now contain 1 entry for url1, and a pending entry | 2176 // other_controller should now contain 1 entry for url1, and a pending entry |
2174 // for url3. | 2177 // for url3. |
2175 | 2178 |
(...skipping 29 matching lines...) Expand all Loading... |
2205 const GURL url3("http://foo/3"); | 2208 const GURL url3("http://foo/3"); |
2206 const GURL url4("http://foo/4"); | 2209 const GURL url4("http://foo/4"); |
2207 | 2210 |
2208 // Create a PrunedListener to observe prune notifications. | 2211 // Create a PrunedListener to observe prune notifications. |
2209 PrunedListener listener(&controller); | 2212 PrunedListener listener(&controller); |
2210 | 2213 |
2211 NavigateAndCommit(url1); | 2214 NavigateAndCommit(url1); |
2212 NavigateAndCommit(url2); | 2215 NavigateAndCommit(url2); |
2213 NavigateAndCommit(url3); | 2216 NavigateAndCommit(url3); |
2214 | 2217 |
2215 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 2218 scoped_ptr<TestTabContents> other_contents( |
| 2219 static_cast<TestTabContents*>(CreateTestWebContents())); |
2216 NavigationControllerImpl& other_controller = | 2220 NavigationControllerImpl& other_controller = |
2217 other_contents->GetControllerImpl(); | 2221 other_contents->GetControllerImpl(); |
2218 other_contents->NavigateAndCommit(url4); | 2222 other_contents->NavigateAndCommit(url4); |
2219 other_contents->ExpectSetHistoryLengthAndPrune( | 2223 other_contents->ExpectSetHistoryLengthAndPrune( |
2220 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | 2224 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, |
2221 other_controller.GetEntryAtIndex(0)->GetPageID()); | 2225 other_controller.GetEntryAtIndex(0)->GetPageID()); |
2222 other_controller.CopyStateFromAndPrune(&controller); | 2226 other_controller.CopyStateFromAndPrune(&controller); |
2223 | 2227 |
2224 // We should have received a pruned notification. | 2228 // We should have received a pruned notification. |
2225 EXPECT_EQ(1, listener.notification_count_); | 2229 EXPECT_EQ(1, listener.notification_count_); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 TabNavigation nav(0, url0, GURL(), string16(), | 2582 TabNavigation nav(0, url0, GURL(), string16(), |
2579 webkit_glue::CreateHistoryStateForURL(url0), | 2583 webkit_glue::CreateHistoryStateForURL(url0), |
2580 content::PAGE_TRANSITION_LINK); | 2584 content::PAGE_TRANSITION_LINK); |
2581 session_helper_.AssertNavigationEquals(nav, | 2585 session_helper_.AssertNavigationEquals(nav, |
2582 windows_[0]->tabs[0]->navigations[0]); | 2586 windows_[0]->tabs[0]->navigations[0]); |
2583 nav.set_url(url2); | 2587 nav.set_url(url2); |
2584 session_helper_.AssertNavigationEquals(nav, | 2588 session_helper_.AssertNavigationEquals(nav, |
2585 windows_[0]->tabs[0]->navigations[1]); | 2589 windows_[0]->tabs[0]->navigations[1]); |
2586 } | 2590 } |
2587 */ | 2591 */ |
OLD | NEW |