| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 671 |
| 672 // The tab contents should have the focus in the second tab. | 672 // The tab contents should have the focus in the second tab. |
| 673 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 673 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 674 | 674 |
| 675 // Go back to the first tab. The focus should not be in the omnibox. | 675 // Go back to the first tab. The focus should not be in the omnibox. |
| 676 chrome::SelectPreviousTab(browser()); | 676 chrome::SelectPreviousTab(browser()); |
| 677 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 677 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 678 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 678 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 679 } | 679 } |
| 680 | 680 |
| 681 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) { | 681 // Flaky on Windows (http://crbug.com/665296). |
| 682 #if defined(OS_WIN) |
| 683 #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate |
| 684 #else |
| 685 #define MAYBE_FocusOnNavigate FocusOnNavigate |
| 686 #endif |
| 687 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnNavigate) { |
| 682 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 688 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 683 ui_test_utils::BrowserActivationWaiter waiter(browser()); | 689 ui_test_utils::BrowserActivationWaiter waiter(browser()); |
| 684 waiter.WaitForActivation(); | 690 waiter.WaitForActivation(); |
| 685 | 691 |
| 686 // Load the NTP. | 692 // Load the NTP. |
| 687 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 693 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 688 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 694 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 689 | 695 |
| 690 // Navigate to another page. | 696 // Navigate to another page. |
| 691 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); | 697 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); | 744 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); |
| 739 EXPECT_EQ(url1, web_contents->GetVisibleURL()); | 745 EXPECT_EQ(url1, web_contents->GetVisibleURL()); |
| 740 // After running the spoof code, |GetActiveWebContents| returns the new tab, | 746 // After running the spoof code, |GetActiveWebContents| returns the new tab, |
| 741 // not the same as |web_contents|. | 747 // not the same as |web_contents|. |
| 742 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( | 748 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( |
| 743 browser()->tab_strip_model()->GetActiveWebContents())); | 749 browser()->tab_strip_model()->GetActiveWebContents())); |
| 744 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 750 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 745 } | 751 } |
| 746 | 752 |
| 747 } // namespace | 753 } // namespace |
| OLD | NEW |