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