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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 945 |
946 // The tab contents should have the focus in the second tab. | 946 // The tab contents should have the focus in the second tab. |
947 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 947 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
948 | 948 |
949 // Go back to the first tab. The focus should not be in the omnibox. | 949 // Go back to the first tab. The focus should not be in the omnibox. |
950 chrome::SelectPreviousTab(browser()); | 950 chrome::SelectPreviousTab(browser()); |
951 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 951 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
952 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 952 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
953 } | 953 } |
954 | 954 |
| 955 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) { |
| 956 // Needed on Mac. |
| 957 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 958 // Load the NTP. |
| 959 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 960 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 961 |
| 962 // Navigate to another page. |
| 963 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); |
| 964 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath( |
| 965 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); |
| 966 ui_test_utils::NavigateToURL(browser(), file_url); |
| 967 |
| 968 ClickOnView(VIEW_ID_TAB_CONTAINER); |
| 969 |
| 970 // Navigate back. Should focus the location bar. |
| 971 { |
| 972 content::WindowedNotificationObserver back_nav_observer( |
| 973 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 974 content::NotificationService::AllSources()); |
| 975 chrome::GoBack(browser(), CURRENT_TAB); |
| 976 back_nav_observer.Wait(); |
| 977 } |
| 978 |
| 979 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 980 |
| 981 // Navigate forward. Shouldn't focus the location bar. |
| 982 ClickOnView(VIEW_ID_TAB_CONTAINER); |
| 983 { |
| 984 content::WindowedNotificationObserver forward_nav_observer( |
| 985 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 986 content::NotificationService::AllSources()); |
| 987 chrome::GoForward(browser(), CURRENT_TAB); |
| 988 forward_nav_observer.Wait(); |
| 989 } |
| 990 |
| 991 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 992 } |
| 993 |
955 } // namespace | 994 } // namespace |
OLD | NEW |