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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Tabs remember focus. | 210 // Tabs remember focus. |
211 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { | 211 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { |
212 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 212 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
213 ASSERT_TRUE(test_server()->Start()); | 213 ASSERT_TRUE(test_server()->Start()); |
214 | 214 |
215 // First we navigate to our test page. | 215 // First we navigate to our test page. |
216 GURL url = test_server()->GetURL(kSimplePage); | 216 GURL url = test_server()->GetURL(kSimplePage); |
217 ui_test_utils::NavigateToURL(browser(), url); | 217 ui_test_utils::NavigateToURL(browser(), url); |
218 | 218 |
219 // Create several tabs. | 219 // Create several tabs. |
220 for (int i = 0; i < 4; ++i) { | 220 for (int i = 0; i < 4; ++i) |
221 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); | 221 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
222 browser()->AddTabWithURL(¶ms); | |
223 EXPECT_EQ(browser(), params.target); | |
224 } | |
225 | 222 |
226 // Alternate focus for the tab. | 223 // Alternate focus for the tab. |
227 const bool kFocusPage[3][5] = { | 224 const bool kFocusPage[3][5] = { |
228 { true, true, true, true, false }, | 225 { true, true, true, true, false }, |
229 { false, false, false, false, false }, | 226 { false, false, false, false, false }, |
230 { false, true, false, true, false } | 227 { false, true, false, true, false } |
231 }; | 228 }; |
232 | 229 |
233 for (int i = 1; i < 3; i++) { | 230 for (int i = 1; i < 3; i++) { |
234 for (int j = 0; j < 5; j++) { | 231 for (int j = 0; j < 5; j++) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 286 |
290 browser()->Find(); | 287 browser()->Find(); |
291 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), | 288 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
292 ASCIIToUTF16("a"), true, false, NULL); | 289 ASCIIToUTF16("a"), true, false, NULL); |
293 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 290 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
294 | 291 |
295 // Focus the location bar. | 292 // Focus the location bar. |
296 browser()->FocusLocationBar(); | 293 browser()->FocusLocationBar(); |
297 | 294 |
298 // Create a 2nd tab. | 295 // Create a 2nd tab. |
299 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); | 296 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
300 browser()->AddTabWithURL(¶ms); | |
301 EXPECT_EQ(browser(), params.target); | |
302 | 297 |
303 // Focus should be on the recently opened tab page. | 298 // Focus should be on the recently opened tab page. |
304 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 299 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
305 | 300 |
306 // Select 1st tab, focus should still be on the location-bar. | 301 // Select 1st tab, focus should still be on the location-bar. |
307 // (bug http://crbug.com/23296) | 302 // (bug http://crbug.com/23296) |
308 browser()->SelectTabContentsAt(0, true); | 303 browser()->SelectTabContentsAt(0, true); |
309 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 304 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
310 | 305 |
311 // Now open the find box again, switch to another tab and come back, the focus | 306 // Now open the find box again, switch to another tab and come back, the focus |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 765 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
771 browser()->Reload(CURRENT_TAB); | 766 browser()->Reload(CURRENT_TAB); |
772 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 767 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
773 | 768 |
774 // Focus should now be on the tab contents. | 769 // Focus should now be on the tab contents. |
775 browser()->ShowDownloadsTab(); | 770 browser()->ShowDownloadsTab(); |
776 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 771 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
777 } | 772 } |
778 | 773 |
779 } // namespace | 774 } // namespace |
OLD | NEW |