Chromium Code Reviews| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 #elif defined(OS_MACOSX) | 373 #elif defined(OS_MACOSX) |
| 374 // On Mac, the newly created window always gets the focus. | 374 // On Mac, the newly created window always gets the focus. |
| 375 focused_browser = browser2; | 375 focused_browser = browser2; |
| 376 unfocused_browser = browser(); | 376 unfocused_browser = browser(); |
| 377 #endif | 377 #endif |
| 378 | 378 |
| 379 const GURL steal_focus_url = embedded_test_server()->GetURL(kStealFocusPage); | 379 const GURL steal_focus_url = embedded_test_server()->GetURL(kStealFocusPage); |
| 380 ui_test_utils::NavigateToURL(unfocused_browser, steal_focus_url); | 380 ui_test_utils::NavigateToURL(unfocused_browser, steal_focus_url); |
| 381 | 381 |
| 382 // Activate the first browser. | 382 // Activate the first browser. |
| 383 focused_browser->window()->Activate(); | 383 focused_browser->window()->Activate(false /* user_gesture */); |
| 384 | 384 |
| 385 ASSERT_TRUE(content::ExecuteScript( | 385 ASSERT_TRUE(content::ExecuteScript( |
| 386 unfocused_browser->tab_strip_model()->GetActiveWebContents(), | 386 unfocused_browser->tab_strip_model()->GetActiveWebContents(), |
| 387 "stealFocus();")); | 387 "stealFocus();")); |
| 388 | 388 |
| 389 // Make sure the first browser is still active. | 389 // Make sure the first browser is still active. |
| 390 EXPECT_TRUE(focused_browser->window()->IsActive()); | 390 EXPECT_TRUE(focused_browser->window()->IsActive()); |
| 391 } | 391 } |
| 392 | 392 |
| 393 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 393 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 653 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 654 | 654 |
| 655 // Go back to the first tab. The focus should not be in the omnibox. | 655 // Go back to the first tab. The focus should not be in the omnibox. |
| 656 chrome::SelectPreviousTab(browser()); | 656 chrome::SelectPreviousTab(browser()); |
| 657 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 657 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 658 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 658 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 659 } | 659 } |
| 660 | 660 |
| 661 // This functionality is currently broken. http://crbug.com/304865. | 661 // This functionality is currently broken. http://crbug.com/304865. |
| 662 // | 662 // |
| 663 //#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 663 // #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
| 664 //// TODO(erg): http://crbug.com/163931 | 664 // // TODO(erg): http://crbug.com/163931 |
| 665 //#define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate | 665 // #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate |
| 666 //#else | 666 // #else |
| 667 //#define MAYBE_FocusOnNavigate FocusOnNavigate | 667 // #define MAYBE_FocusOnNavigate FocusOnNavigate |
| 668 //#endif | 668 // #endif |
|
Avi (use Gerrit)
2015/05/22 21:27:25
Don't touch this code; your patch is big enough :)
| |
| 669 | 669 |
| 670 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) { | 670 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) { |
| 671 // Needed on Mac. | 671 // Needed on Mac. |
| 672 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 672 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 673 // Load the NTP. | 673 // Load the NTP. |
| 674 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 674 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 675 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 675 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 676 | 676 |
| 677 // Navigate to another page. | 677 // Navigate to another page. |
| 678 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); | 678 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 700 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 700 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 701 content::NotificationService::AllSources()); | 701 content::NotificationService::AllSources()); |
| 702 chrome::GoForward(browser(), CURRENT_TAB); | 702 chrome::GoForward(browser(), CURRENT_TAB); |
| 703 forward_nav_observer.Wait(); | 703 forward_nav_observer.Wait(); |
| 704 } | 704 } |
| 705 | 705 |
| 706 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 706 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace | 709 } // namespace |
| OLD | NEW |