| Index: chrome/browser/ui/browser_focus_uitest.cc
|
| diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
|
| index 0c053f96df2615c7c032ca0060ef374fc47691dd..3e0d748857b4540d2f18ea217fe95d3f0d7b2083 100644
|
| --- a/chrome/browser/ui/browser_focus_uitest.cc
|
| +++ b/chrome/browser/ui/browser_focus_uitest.cc
|
| @@ -39,13 +39,10 @@
|
| #include "content/public/test/browser_test_utils.h"
|
| #include "net/test/test_server.h"
|
|
|
| -#if defined(TOOLKIT_VIEWS) || defined(OS_WIN)
|
| -#include "ui/views/focus/focus_manager.h"
|
| -#include "ui/views/view.h"
|
| -#endif
|
| -
|
| #if defined(TOOLKIT_VIEWS)
|
| #include "chrome/browser/ui/views/frame/browser_view.h"
|
| +#include "ui/views/focus/focus_manager.h"
|
| +#include "ui/views/view.h"
|
| #endif
|
|
|
| #if defined(OS_WIN)
|
| @@ -154,14 +151,6 @@ void CheckFocus(Browser* browser, ViewID id, const base::Time& timeout) {
|
|
|
| class BrowserFocusTest : public InProcessBrowserTest {
|
| public:
|
| - BrowserFocusTest() :
|
| -#if defined(USE_AURA)
|
| - location_bar_focus_view_id_(VIEW_ID_OMNIBOX)
|
| -#else
|
| - location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR)
|
| -#endif
|
| - {}
|
| -
|
| bool IsViewFocused(ViewID vid) {
|
| return ui_test_utils::IsViewFocused(browser(), vid);
|
| }
|
| @@ -180,8 +169,6 @@ class BrowserFocusTest : public InProcessBrowserTest {
|
| content::RunMessageLoop();
|
| return IsViewFocused(vid);
|
| }
|
| -
|
| - ViewID location_bar_focus_view_id_;
|
| };
|
|
|
| class TestInterstitialPage : public content::InterstitialPageDelegate {
|
| @@ -238,13 +225,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_ClickingMovesFocus) {
|
| content::RunMessageLoop();
|
| #endif // defined(OS_POSIX)
|
|
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| ClickOnView(VIEW_ID_TAB_CONTAINER);
|
| ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
|
|
|
| - ClickOnView(VIEW_ID_LOCATION_BAR);
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ClickOnView(VIEW_ID_OMNIBOX);
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| }
|
|
|
| // Flaky, http://crbug.com/69034.
|
| @@ -266,11 +253,11 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
|
| ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
|
|
|
| chrome::FocusLocationBar(browser());
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| // Hide the window, show it again, the focus should not have changed.
|
| ui_test_utils::HideNativeWindow(window);
|
| ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // The rest of this test does not make sense on Linux because the behavior
|
| // of Activate() is not well defined and can vary by window manager.
|
| @@ -299,7 +286,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
|
| // Switch to the 1st browser window, focus should still be on the location
|
| // bar and the second browser should have nothing focused.
|
| browser()->window()->Activate();
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| EXPECT_EQ(NULL, focus_manager2->GetFocusedView());
|
|
|
| // Switch back to the second browser, focus should still be on the page.
|
| @@ -356,8 +343,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) {
|
| // Activate the tab.
|
| browser()->tab_strip_model()->ActivateTabAt(j, true);
|
|
|
| - ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER :
|
| - location_bar_focus_view_id_;
|
| + ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER : VIEW_ID_OMNIBOX;
|
| ASSERT_TRUE(IsViewFocused(vid));
|
| }
|
|
|
| @@ -366,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) {
|
| // this has regressed in the past. Loop through several times to be sure.
|
| for (int j = 0; j < 15; j++) {
|
| ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
|
| - location_bar_focus_view_id_;
|
| + VIEW_ID_OMNIBOX;
|
| ASSERT_TRUE(IsViewFocused(vid));
|
|
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -377,7 +363,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) {
|
| browser()->tab_strip_model()->ActivateTabAt(4, true);
|
| for (int j = 14; j >= 0; --j) {
|
| ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
|
| - location_bar_focus_view_id_;
|
| + VIEW_ID_OMNIBOX;
|
| ASSERT_TRUE(IsViewFocused(vid));
|
|
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -413,7 +399,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
|
| // Select 1st tab, focus should still be on the location-bar.
|
| // (bug http://crbug.com/23296)
|
| browser()->tab_strip_model()->ActivateTabAt(0, true);
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Now open the find box again, switch to another tab and come back, the focus
|
| // should return to the find box.
|
| @@ -493,7 +479,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
|
| "stealFocus();"));
|
|
|
| // Make sure the location bar is still focused.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| }
|
|
|
| // Focus traversal on a regular page.
|
| @@ -523,7 +509,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
|
| for (int i = 0; i < 3; ++i) {
|
| SCOPED_TRACE(base::StringPrintf("outer loop: %d", i));
|
| // Location bar should be focused.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Move the caret to the end, otherwise the next Tab key may not move focus.
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -573,7 +559,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
|
| for (int i = 0; i < 3; ++i) {
|
| SCOPED_TRACE(base::StringPrintf("outer loop: %d", i));
|
| // Location bar should be focused.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Move the caret to the end, otherwise the next Tab key may not move focus.
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -656,7 +642,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
|
| // Test forward focus traversal.
|
| for (int i = 0; i < 2; ++i) {
|
| // Location bar should be focused.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Move the caret to the end, otherwise the next Tab key may not move focus.
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -699,7 +685,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
|
| // Now let's try reverse focus traversal.
|
| for (int i = 0; i < 2; ++i) {
|
| // Location bar should be focused.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Move the caret to the end, otherwise the next Tab key may not move focus.
|
| ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
|
| @@ -801,7 +787,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FindFocusTest) {
|
| ASSERT_TRUE(WaitForFocusChange(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
|
|
|
| chrome::FocusLocationBar(browser());
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Now press Ctrl+F again and focus should move to the Find box.
|
| #if defined(OS_MACOSX)
|
| @@ -845,7 +831,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) {
|
| chrome::NewTab(browser());
|
| ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
|
| browser()->tab_strip_model()->GetActiveWebContents()));
|
| - EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Open the download tab, focus should be on the tab contents.
|
| chrome::ShowDownloads(browser());
|
| @@ -858,7 +844,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) {
|
| content::PAGE_TRANSITION_LINK);
|
| ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
|
| browser()->tab_strip_model()->GetActiveWebContents()));
|
| - EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| }
|
|
|
| // Tests that focus goes where expected when using reload.
|
| @@ -886,12 +872,12 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
|
| observer.Wait();
|
| }
|
| // Focus should stay on the location bar.
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
|
|
| // Open a regular page, focus the location bar, reload.
|
| ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
|
| chrome::FocusLocationBar(browser());
|
| - ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
|
| + ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
|
| {
|
| content::WindowedNotificationObserver observer(
|
| content::NOTIFICATION_LOAD_STOP,
|
| @@ -963,8 +949,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
|
| // Go back to the first tab. The focus should not be in the omnibox.
|
| chrome::SelectPreviousTab(browser());
|
| EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
|
| - EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
|
| - VIEW_ID_LOCATION_BAR));
|
| + EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
|
| }
|
|
|
| } // namespace
|
|
|