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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // Tabs remember focus. | 241 // Tabs remember focus. |
242 // Disabled, http://crbug.com/62542. | 242 // Disabled, http://crbug.com/62542. |
243 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { | 243 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { |
244 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 244 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
245 const GURL url = embedded_test_server()->GetURL(kSimplePage); | 245 const GURL url = embedded_test_server()->GetURL(kSimplePage); |
246 ui_test_utils::NavigateToURL(browser(), url); | 246 ui_test_utils::NavigateToURL(browser(), url); |
247 | 247 |
248 // Create several tabs. | 248 // Create several tabs. |
249 for (int i = 0; i < 4; ++i) { | 249 for (int i = 0; i < 4; ++i) { |
250 chrome::AddSelectedTabWithURL(browser(), url, | 250 chrome::AddSelectedTabWithURL(browser(), url, |
251 content::PAGE_TRANSITION_TYPED); | 251 ui::PAGE_TRANSITION_TYPED); |
252 } | 252 } |
253 | 253 |
254 // Alternate focus for the tab. | 254 // Alternate focus for the tab. |
255 const bool kFocusPage[3][5] = { | 255 const bool kFocusPage[3][5] = { |
256 { true, true, true, true, false }, | 256 { true, true, true, true, false }, |
257 { false, false, false, false, false }, | 257 { false, false, false, false, false }, |
258 { false, true, false, true, false } | 258 { false, true, false, true, false } |
259 }; | 259 }; |
260 | 260 |
261 for (int i = 1; i < 3; i++) { | 261 for (int i = 1; i < 3; i++) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 chrome::Find(browser()); | 314 chrome::Find(browser()); |
315 ui_test_utils::FindInPage( | 315 ui_test_utils::FindInPage( |
316 browser()->tab_strip_model()->GetActiveWebContents(), | 316 browser()->tab_strip_model()->GetActiveWebContents(), |
317 base::ASCIIToUTF16("a"), true, false, NULL, NULL); | 317 base::ASCIIToUTF16("a"), true, false, NULL, NULL); |
318 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 318 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
319 | 319 |
320 // Focus the location bar. | 320 // Focus the location bar. |
321 chrome::FocusLocationBar(browser()); | 321 chrome::FocusLocationBar(browser()); |
322 | 322 |
323 // Create a 2nd tab. | 323 // Create a 2nd tab. |
324 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED); | 324 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); |
325 | 325 |
326 // Focus should be on the recently opened tab page. | 326 // Focus should be on the recently opened tab page. |
327 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 327 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
328 | 328 |
329 // Select 1st tab, focus should still be on the location-bar. | 329 // Select 1st tab, focus should still be on the location-bar. |
330 // (bug http://crbug.com/23296) | 330 // (bug http://crbug.com/23296) |
331 browser()->tab_strip_model()->ActivateTabAt(0, true); | 331 browser()->tab_strip_model()->ActivateTabAt(0, true); |
332 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 332 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
333 | 333 |
334 // Now open the find box again, switch to another tab and come back, the focus | 334 // Now open the find box again, switch to another tab and come back, the focus |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 518 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
519 | 519 |
520 // Open the download tab, focus should be on the tab contents. | 520 // Open the download tab, focus should be on the tab contents. |
521 chrome::ShowDownloads(browser()); | 521 chrome::ShowDownloads(browser()); |
522 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( | 522 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( |
523 browser()->tab_strip_model()->GetActiveWebContents())); | 523 browser()->tab_strip_model()->GetActiveWebContents())); |
524 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 524 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
525 | 525 |
526 // Open about:blank, focus should be on the location bar. | 526 // Open about:blank, focus should be on the location bar. |
527 chrome::AddSelectedTabWithURL( | 527 chrome::AddSelectedTabWithURL( |
528 browser(), GURL(url::kAboutBlankURL), content::PAGE_TRANSITION_LINK); | 528 browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); |
529 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( | 529 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( |
530 browser()->tab_strip_model()->GetActiveWebContents())); | 530 browser()->tab_strip_model()->GetActiveWebContents())); |
531 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 531 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
532 } | 532 } |
533 | 533 |
534 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 534 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
535 // TODO(erg): http://crbug.com/163931 | 535 // TODO(erg): http://crbug.com/163931 |
536 #define MAYBE_FocusOnReload DISABLED_FocusOnReload | 536 #define MAYBE_FocusOnReload DISABLED_FocusOnReload |
537 #else | 537 #else |
538 #define MAYBE_FocusOnReload FocusOnReload | 538 #define MAYBE_FocusOnReload FocusOnReload |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 619 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
620 } | 620 } |
621 | 621 |
622 // Tests that when a new tab is opened from the omnibox, the focus is moved from | 622 // Tests that when a new tab is opened from the omnibox, the focus is moved from |
623 // the omnibox for the current tab. | 623 // the omnibox for the current tab. |
624 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NavigateFromOmniboxIntoNewTab) { | 624 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NavigateFromOmniboxIntoNewTab) { |
625 GURL url("http://www.google.com/"); | 625 GURL url("http://www.google.com/"); |
626 GURL url2("http://maps.google.com/"); | 626 GURL url2("http://maps.google.com/"); |
627 | 627 |
628 // Navigate to url. | 628 // Navigate to url. |
629 chrome::NavigateParams p(browser(), url, content::PAGE_TRANSITION_LINK); | 629 chrome::NavigateParams p(browser(), url, ui::PAGE_TRANSITION_LINK); |
630 p.window_action = chrome::NavigateParams::SHOW_WINDOW; | 630 p.window_action = chrome::NavigateParams::SHOW_WINDOW; |
631 p.disposition = CURRENT_TAB; | 631 p.disposition = CURRENT_TAB; |
632 chrome::Navigate(&p); | 632 chrome::Navigate(&p); |
633 | 633 |
634 // Focus the omnibox. | 634 // Focus the omnibox. |
635 chrome::FocusLocationBar(browser()); | 635 chrome::FocusLocationBar(browser()); |
636 | 636 |
637 OmniboxEditController* controller = browser()->window()->GetLocationBar()-> | 637 OmniboxEditController* controller = browser()->window()->GetLocationBar()-> |
638 GetOmniboxView()->model()->controller(); | 638 GetOmniboxView()->model()->controller(); |
639 | 639 |
640 // Simulate an alt-enter. | 640 // Simulate an alt-enter. |
641 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, | 641 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, |
642 content::PAGE_TRANSITION_TYPED); | 642 ui::PAGE_TRANSITION_TYPED); |
643 | 643 |
644 // Make sure the second tab is selected. | 644 // Make sure the second tab is selected. |
645 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 645 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
646 | 646 |
647 // The tab contents should have the focus in the second tab. | 647 // The tab contents should have the focus in the second tab. |
648 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 648 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
649 | 649 |
650 // Go back to the first tab. The focus should not be in the omnibox. | 650 // Go back to the first tab. The focus should not be in the omnibox. |
651 chrome::SelectPreviousTab(browser()); | 651 chrome::SelectPreviousTab(browser()); |
652 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 652 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 695 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
696 content::NotificationService::AllSources()); | 696 content::NotificationService::AllSources()); |
697 chrome::GoForward(browser(), CURRENT_TAB); | 697 chrome::GoForward(browser(), CURRENT_TAB); |
698 forward_nav_observer.Wait(); | 698 forward_nav_observer.Wait(); |
699 } | 699 } |
700 | 700 |
701 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 701 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
702 } | 702 } |
703 | 703 |
704 } // namespace | 704 } // namespace |
OLD | NEW |