| Index: chrome/browser/ui/search/instant_extended_browsertest.cc
|
| diff --git a/chrome/browser/ui/search/instant_extended_browsertest.cc b/chrome/browser/ui/search/instant_extended_browsertest.cc
|
| index 981ce6a0f8bb5ae7dca867f80b7098ae1311a202..da6da5681bdb32371c757759ee05fdb0bb901cc0 100644
|
| --- a/chrome/browser/ui/search/instant_extended_browsertest.cc
|
| +++ b/chrome/browser/ui/search/instant_extended_browsertest.cc
|
| @@ -118,6 +118,16 @@ class InstantExtendedTest : public InProcessBrowserTest,
|
| &on_change_calls_);
|
| }
|
|
|
| + // A convenience function to explicitly blur the omnibox and focus |contents|.
|
| + // TODO(msw|jered|sreeram): Fix test focus issues; see http://crbug.com/226189
|
| + void BlurOmniboxAndFocusContents(content::WebContents* contents) {
|
| + omnibox()->model()->OnWillKillFocus(contents->GetView()->GetNativeView());
|
| + omnibox()->model()->OnKillFocus();
|
| + contents->GetView()->Focus();
|
| + EXPECT_FALSE(omnibox()->model()->has_focus());
|
| + EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
|
| + }
|
| +
|
| int on_most_visited_change_calls_;
|
| int most_visited_items_count_;
|
| int first_most_visited_item_id_;
|
| @@ -171,12 +181,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) {
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
|
|
| - // Explicitly unfocus the omnibox.
|
| + // Blur the omnibox and focus the active web contents.
|
| EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
|
| - ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
|
| -
|
| - EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
|
| - EXPECT_FALSE(omnibox()->model()->has_focus());
|
| + BlurOmniboxAndFocusContents(
|
| + browser()->tab_strip_model()->GetActiveWebContents());
|
|
|
| // Delete any existing overlay.
|
| instant()->overlay_.reset();
|
| @@ -202,9 +210,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
|
| EXPECT_EQ(overlay, instant()->GetOverlayContents());
|
|
|
| // Unfocusing and refocusing the omnibox should also preserve the overlay.
|
| - ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
|
| - EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
|
| -
|
| + BlurOmniboxAndFocusContents(
|
| + browser()->tab_strip_model()->GetActiveWebContents());
|
| FocusOmnibox();
|
| EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
|
| EXPECT_EQ(overlay, instant()->GetOverlayContents());
|
| @@ -367,15 +374,13 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| browser()->window()->GetLocationBar()->AcceptInput();
|
| observer.Wait();
|
|
|
| - // With a committed results page, do a search by unfocusing the omnibox and
|
| - // focusing the contents.
|
| + // With a committed results page, do a search by blurring the omnibox and
|
| + // focusing the contents. Call handleOnChange before focusing the contents.
|
| SetOmniboxText("hello");
|
| - // Calling handleOnChange manually to make sure it is called before the
|
| - // Focus() call below.
|
| EXPECT_TRUE(content::ExecuteScript(instant()->instant_tab()->contents(),
|
| "suggestion = 'hello kitty';"
|
| "handleOnChange();"));
|
| - instant()->instant_tab()->contents()->GetView()->Focus();
|
| + BlurOmniboxAndFocusContents(instant()->instant_tab()->contents());
|
|
|
| // Search term extraction should kick in with the autocompleted text.
|
| EXPECT_EQ(ASCIIToUTF16("hello kitty"), omnibox()->GetText());
|
| @@ -412,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| EXPECT_TRUE(ExecuteScript("suggestion = 'exams are great';"
|
| "behavior = 2;"
|
| "handleOnChange();"));
|
| - instant()->overlay()->contents()->GetView()->Focus();
|
| + BlurOmniboxAndFocusContents(instant()->overlay()->contents());
|
| EXPECT_EQ(ASCIIToUTF16("exams are great"), omnibox()->GetText());
|
|
|
| // TODO(jered): Remove this after fixing OnBlur().
|
| @@ -645,10 +650,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| FocusOmniboxAndWaitForInstantExtendedSupport();
|
|
|
| - // Explicitly unfocus the omnibox.
|
| + // Explicitly blur the omnibox.
|
| EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
|
| - ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
|
| - EXPECT_FALSE(omnibox()->model()->has_focus());
|
| + BlurOmniboxAndFocusContents(
|
| + browser()->tab_strip_model()->GetActiveWebContents());
|
|
|
| // Open new tab. Preloaded NTP contents should have been used.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
|
|