| Index: chrome/browser/ui/browser_focus_uitest.cc
|
| ===================================================================
|
| --- chrome/browser/ui/browser_focus_uitest.cc (revision 170118)
|
| +++ chrome/browser/ui/browser_focus_uitest.cc (working copy)
|
| @@ -17,12 +17,17 @@
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/chrome_pages.h"
|
| +#include "chrome/browser/ui/omnibox/location_bar.h"
|
| +#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
|
| +#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
|
| +#include "chrome/browser/ui/omnibox/omnibox_view.h"
|
| #include "chrome/browser/ui/tab_contents/tab_contents.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/browser/ui/view_ids.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "chrome/test/base/interactive_test_utils.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "content/public/browser/interstitial_page.h"
|
| @@ -922,4 +927,41 @@
|
| ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
|
| }
|
|
|
| +// Tests that when a new tab is opened from the omnibox, the focus is moved from
|
| +// the omnibox for the current tab.
|
| +IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
|
| + NavigateFromOmniboxIntoNewTab) {
|
| + GURL url("http://www.google.com/");
|
| + GURL url2("http://maps.google.com/");
|
| +
|
| + // Navigate to url.
|
| + chrome::NavigateParams p(browser(), url, content::PAGE_TRANSITION_LINK);
|
| + p.window_action = chrome::NavigateParams::SHOW_WINDOW;
|
| + p.disposition = CURRENT_TAB;
|
| + chrome::Navigate(&p);
|
| +
|
| + // Focus the omnibox.
|
| + chrome::FocusLocationBar(browser());
|
| +
|
| + OmniboxEditController* controller =
|
| + browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
|
| + controller();
|
| +
|
| + // Simulate an alt-enter.
|
| + controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB,
|
| + content::PAGE_TRANSITION_TYPED, GURL());
|
| +
|
| + // Make sure the second tab is selected.
|
| + EXPECT_EQ(1, browser()->active_index());
|
| +
|
| + // The tab contents should have the focus in the second tab.
|
| + EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
|
| +
|
| + // Go back to the first tab. The focus should not be in the omnibox.
|
| + chrome::SelectPreviousTab(browser());
|
| + EXPECT_EQ(0, browser()->active_index());
|
| + EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
|
| + VIEW_ID_LOCATION_BAR));
|
| +}
|
| +
|
| } // namespace
|
|
|