Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3878)

Unified Diff: chrome/browser/ui/browser_focus_uitest.cc

Issue 11414223: Move the test functions that deal with focus to interactive_ui_tets_utils.h and into the interactiv… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698