OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/url_constants.h" | 5 #include "chrome/common/url_constants.h" |
6 #include "chrome/test/testing_profile.h" | 6 #include "chrome/test/testing_profile.h" |
7 #include "content/browser/browser_thread.h" | 7 #include "content/browser/browser_thread.h" |
8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance.h" |
10 #include "content/browser/tab_contents/navigation_controller.h" | 10 #include "content/browser/tab_contents/navigation_controller.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 // Load the NTP. | 171 // Load the NTP. |
172 GURL new_tab_url(chrome::kChromeUINewTabURL); | 172 GURL new_tab_url(chrome::kChromeUINewTabURL); |
173 controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK); | 173 controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK); |
174 rvh()->SendNavigate(page_id, new_tab_url); | 174 rvh()->SendNavigate(page_id, new_tab_url); |
175 | 175 |
176 // Navigate to another page. | 176 // Navigate to another page. |
177 GURL next_url("http://google.com/"); | 177 GURL next_url("http://google.com/"); |
178 int next_page_id = page_id + 1; | 178 int next_page_id = page_id + 1; |
179 controller().LoadURL(next_url, GURL(), PageTransition::LINK); | 179 controller().LoadURL(next_url, GURL(), PageTransition::LINK); |
| 180 TestRenderViewHost* old_rvh = rvh(); |
| 181 old_rvh->SendShouldCloseACK(true); |
180 pending_rvh()->SendNavigate(next_page_id, next_url); | 182 pending_rvh()->SendNavigate(next_page_id, next_url); |
| 183 old_rvh->OnSwapOutACK(); |
181 | 184 |
182 // Navigate back. Should focus the location bar. | 185 // Navigate back. Should focus the location bar. |
183 int focus_called = tc->focus_called(); | 186 int focus_called = tc->focus_called(); |
184 ASSERT_TRUE(controller().CanGoBack()); | 187 ASSERT_TRUE(controller().CanGoBack()); |
185 controller().GoBack(); | 188 controller().GoBack(); |
| 189 old_rvh = rvh(); |
| 190 old_rvh->SendShouldCloseACK(true); |
186 pending_rvh()->SendNavigate(page_id, new_tab_url); | 191 pending_rvh()->SendNavigate(page_id, new_tab_url); |
| 192 old_rvh->OnSwapOutACK(); |
187 EXPECT_LT(focus_called, tc->focus_called()); | 193 EXPECT_LT(focus_called, tc->focus_called()); |
188 | 194 |
189 // Navigate forward. Shouldn't focus the location bar. | 195 // Navigate forward. Shouldn't focus the location bar. |
190 focus_called = tc->focus_called(); | 196 focus_called = tc->focus_called(); |
191 ASSERT_TRUE(controller().CanGoForward()); | 197 ASSERT_TRUE(controller().CanGoForward()); |
192 controller().GoForward(); | 198 controller().GoForward(); |
| 199 old_rvh = rvh(); |
| 200 old_rvh->SendShouldCloseACK(true); |
193 pending_rvh()->SendNavigate(next_page_id, next_url); | 201 pending_rvh()->SendNavigate(next_page_id, next_url); |
| 202 old_rvh->OnSwapOutACK(); |
194 EXPECT_EQ(focus_called, tc->focus_called()); | 203 EXPECT_EQ(focus_called, tc->focus_called()); |
195 } | 204 } |
OLD | NEW |